tools: run go fix Change-Id: I30597874e4857d58dc40925c5b54cac3a8012514 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/807640 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/extension/tools/docs2wiki/main.go b/extension/tools/docs2wiki/main.go index f49ffb4..1ec87b8 100644 --- a/extension/tools/docs2wiki/main.go +++ b/extension/tools/docs2wiki/main.go
@@ -3,7 +3,6 @@ // license that can be found in the LICENSE file. //go:build !windows -// +build !windows // Tool docs2wiki rewrites links in ./docs/* to wiki link format. // This program may call the 'diff' tool which may be missing on Windows. @@ -108,11 +107,11 @@ if len(src) == 0 || src[0] != '#' { return src } - index := bytes.Index(src, []byte("\n")) - if index < 0 { + _, after, ok := bytes.Cut(src, []byte("\n")) + if !ok { return src } - return src[index+1:] + return after } // find pattern like '](link.md)' @@ -136,7 +135,7 @@ }) } -func errorf(format string, a ...interface{}) { +func errorf(format string, a ...any) { fmt.Fprintf(os.Stderr, format+"\n", a...) }
diff --git a/extension/tools/docs2wiki/main_test.go b/extension/tools/docs2wiki/main_test.go index eabb016..c4b452a 100644 --- a/extension/tools/docs2wiki/main_test.go +++ b/extension/tools/docs2wiki/main_test.go
@@ -1,5 +1,4 @@ //go:build !windows -// +build !windows // Tool docs2wiki rewrites links in ./docs/* to wiki link format. package main
diff --git a/extension/tools/generate.go b/extension/tools/generate.go index 83c9c51..1b33406 100644 --- a/extension/tools/generate.go +++ b/extension/tools/generate.go
@@ -65,9 +65,9 @@ Commands []Command `json:"commands,omitempty"` Configuration struct { Properties map[string]*Property `json:"properties,omitempty"` - } `json:"configuration,omitempty"` + } `json:"configuration"` Debuggers []Debugger `json:"debuggers,omitempty"` - } `json:"contributes,omitempty"` + } `json:"contributes"` } type Command struct { @@ -82,13 +82,13 @@ // Below are defined in package.json Properties map[string]*Property `json:"properties,omitempty"` AnyOf []Property `json:"anyOf,omitempty"` - Default interface{} `json:"default,omitempty"` + Default any `json:"default,omitempty"` MarkdownDescription string `json:"markdownDescription,omitempty"` Description string `json:"description,omitempty"` MarkdownDeprecationMessage string `json:"markdownDeprecationMessage,omitempty"` DeprecationMessage string `json:"deprecationMessage,omitempty"` - Type interface{} `json:"type,omitempty"` - Enum []interface{} `json:"enum,omitempty"` + Type any `json:"type,omitempty"` + Enum []any `json:"enum,omitempty"` EnumDescriptions []string `json:"enumDescriptions,omitempty"` MarkdownEnumDescriptions []string `json:"markdownEnumDescriptions,omitempty"` Items *Property `json:"items,omitempty"` @@ -100,7 +100,7 @@ ConfigurationAttributes struct { Launch Configuration Attach Configuration - } `json:"configurationAttributes,omitempty"` + } `json:"configurationAttributes"` } type Configuration struct { @@ -341,7 +341,7 @@ b := &bytes.Buffer{} switch p.Type { case "object": - x, ok := p.Default.(map[string]interface{}) + x, ok := p.Default.(map[string]any) if !ok { panic(fmt.Sprintf("unexpected type of object: %v", *p)) } else if len(x) > 0 { @@ -353,7 +353,7 @@ case "boolean", "number": fmt.Fprintf(b, "%v", p.Default) case "array": - x, ok := p.Default.([]interface{}) + x, ok := p.Default.([]any) if !ok { panic(fmt.Sprintf("unexpected type for array: %v", *p)) } else if len(x) > 0 { @@ -372,7 +372,7 @@ return b.String() } -func writeMapObject(b *bytes.Buffer, indent string, obj map[string]interface{}) { +func writeMapObject(b *bytes.Buffer, indent string, obj map[string]any) { keys := []string{} for k := range obj { keys = append(keys, k) @@ -386,7 +386,7 @@ switch v := v.(type) { case string: fmt.Fprintf(b, "%q", v) - case map[string]interface{}: + case map[string]any: writeMapObject(b, indent+"\t", v) default: fmt.Fprintf(b, "%v", v)
diff --git a/extension/tools/installtools/main.go b/extension/tools/installtools/main.go index f954817..8696345 100644 --- a/extension/tools/installtools/main.go +++ b/extension/tools/installtools/main.go
@@ -20,6 +20,7 @@ "path" "path/filepath" "runtime" + "slices" "strings" ) @@ -80,7 +81,7 @@ } } -func exitf(format string, args ...interface{}) { +func exitf(format string, args ...any) { fmt.Fprintf(os.Stderr, format, args...) os.Exit(1) } @@ -101,9 +102,9 @@ } // Split up "[go1.1 go1.15]" tags := strings.Fields(result[1 : len(result)-2]) - for i := len(tags) - 1; i >= 0; i-- { + for _, tag := range slices.Backward(tags) { var version int - if _, err := fmt.Sscanf(tags[i], "go1.%d", &version); err != nil { + if _, err := fmt.Sscanf(tag, "go1.%d", &version); err != nil { continue } return version, nil
diff --git a/internal/vscgo/main.go b/internal/vscgo/main.go index 831cf89..631f4a8 100644 --- a/internal/vscgo/main.go +++ b/internal/vscgo/main.go
@@ -105,7 +105,7 @@ } } -func output(msgs ...interface{}) { +func output(msgs ...any) { fmt.Fprintln(flag.CommandLine.Output(), msgs...) }