mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-31 14:26:40 -04:00
all: simplify code by using modern Go constructs
Generated using modernize by running:
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...
Change-Id: Ifc7d61cf6735cc53f2bdf890a338961f55075af5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/661975
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
committed by
Gopher Robot
parent
1b2bd6bb49
commit
01aaa8342f
@@ -137,7 +137,7 @@ type filterFn func(codeElem) bool
|
||||
// filter parses and filters Go source code from src, removing top
|
||||
// level declarations using keep as predicate.
|
||||
// For src parameter, please see docs for parser.ParseFile.
|
||||
func filter(src interface{}, keep filterFn) ([]byte, error) {
|
||||
func filter(src any, keep filterFn) ([]byte, error) {
|
||||
// Parse the src into an ast
|
||||
fset := token.NewFileSet()
|
||||
f, err := parser.ParseFile(fset, "", src, parser.ParseComments)
|
||||
@@ -243,7 +243,7 @@ func getCommonSet(files []srcFile) (*codeSet, error) {
|
||||
|
||||
// getCodeSet returns the set of all top-level consts, types, and funcs from src.
|
||||
// src must be string, []byte, or io.Reader (see go/parser.ParseFile docs)
|
||||
func getCodeSet(src interface{}) (*codeSet, error) {
|
||||
func getCodeSet(src any) (*codeSet, error) {
|
||||
set := newCodeSet()
|
||||
|
||||
fset := token.NewFileSet()
|
||||
|
||||
@@ -498,7 +498,7 @@ func diffLines(t *testing.T, got, expected []byte) {
|
||||
func addLineNr(src []byte) []byte {
|
||||
lines := bytes.Split(src, []byte("\n"))
|
||||
for i, line := range lines {
|
||||
lines[i] = []byte(fmt.Sprintf("%d: %s", i+1, line))
|
||||
lines[i] = fmt.Appendf(nil, "%d: %s", i+1, line)
|
||||
}
|
||||
return bytes.Join(lines, []byte("\n"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user