[vscode-go] package.json: update gopls settings to match v0.10.0-pre.1

90 views
Skip to first unread message

Hyang-Ah Hana Kim (Gerrit)

unread,
Oct 14, 2022, 5:18:46 PM10/14/22
to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Robert Findley, kokoro, golang-co...@googlegroups.com

Hyang-Ah Hana Kim submitted this change.

View Change



1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: Hyang-Ah Hana Kim: Run TryBots kokoro: TryBots succeeded Robert Findley: Looks good to me, approved
package.json: update gopls settings to match v0.10.0-pre.1

And change tools/installtools (the script used to install tools
needed for running tests in CI) to query the latest version of gopls
(including prerelease) and install that version. This script change does not affect extension's behavior.


Updates golang/vscode-go#2486

Change-Id: I7c30904f59e7ab9694be3fc3b8e4f894138d3fa3
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/443155
TryBot-Result: kokoro <noreply...@google.com>
Reviewed-by: Robert Findley <rfin...@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hya...@gmail.com>
---
M docs/settings.md
M package.json
M tools/installtools/main.go
M tools/installtools/main_test.go
4 files changed, 118 insertions(+), 36 deletions(-)

diff --git a/docs/settings.md b/docs/settings.md
index c6f9975..a7d68bf 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -612,16 +612,20 @@
the last filter that applies to a path controls whether it is included.
The path prefix can be empty, so an initial `-` excludes everything.

+DirectoryFilters also supports the `**` operator to match 0 or more directories.
+
Examples:

-Exclude node_modules: `-node_modules`
+Exclude node_modules at current depth: `-node_modules`
+
+Exclude node_modules at any depth: `-**/node_modules`

Include only project_a: `-` (exclude everything), `+project_a`

Include only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`


-Default: `["-node_modules"]`
+Default: `["-**/node_modules"]`
### `build.env`

env adds environment variables to external commands run by `gopls`, most notably `go list`.
@@ -653,8 +657,10 @@

(Experimental) experimentalUseInvalidMetadata enables gopls to fall back on outdated
package metadata to provide editor features if the go command fails to
-load packages for some reason (like an invalid go.mod file). This will
-eventually be the default behavior, and this setting will be removed.
+load packages for some reason (like an invalid go.mod file).
+
+Deprecated: this setting is deprecated and will be removed in a future
+version of gopls (https://go.dev/issue/55333).


Default: `false`
@@ -663,6 +669,9 @@
(Experimental) experimentalWorkspaceModule opts a user into the experimental support
for multi-module workspaces.

+Deprecated: this feature is deprecated and will be removed in a future
+version of gopls (https://go.dev/issue/55331).
+

Default: `false`
### `build.memoryMode`
@@ -681,6 +690,29 @@


Default: `"Normal"`
+### `build.standaloneTags`
+
+standaloneTags specifies a set of build constraints that identify
+individual Go source files that make up the entire main package of an
+executable.
+
+A common example of standalone main files is the convention of using the
+directive `//go:build ignore` to denote files that are not intended to be
+included in any package, for example because they are invoked directly by
+the developer using `go run`.
+
+Gopls considers a file to be a standalone main file if and only if it has
+package name "main" and has a build directive of the exact form
+"//go:build tag" or "// +build tag", where tag is among the list of tags
+configured by this setting. Notably, if the build constraint is more
+complicated than a simple tag (such as the composite constraint
+`//go:build tag && go1.18`), the file is not considered to be a standalone
+main file.
+
+This setting is only supported when gopls is built with Go 1.16 or later.
+
+
+Default: `["ignore"]`
### `build.templateExtensions`

templateExtensions gives the extensions of file names that are treateed
@@ -768,8 +800,8 @@

analyses specify analyses that the user would like to enable or disable.
A map of the names of analysis passes that should be enabled/disabled.
-A full list of analyzers that gopls uses can be found
-[here](https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md).
+A full list of analyzers that gopls uses can be found in
+[analyzers.md](https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md).

Example Usage:

@@ -802,7 +834,7 @@
| `httpresponse` | check for mistakes using HTTP responses <br/> A common mistake when using the net/http package is to defer a function call to close the http.Response Body before checking the error that determines whether the response is valid: <br/> <pre>resp, err := http.Head(url)<br/>defer resp.Body.Close()<br/>if err != nil {<br/> log.Fatal(err)<br/>}<br/>// (defer statement belongs here)</pre><br/> This checker helps uncover latent nil dereference bugs by reporting a diagnostic for such mistakes. <br/> Default: `true` |
| `ifaceassert` | detect impossible interface-to-interface type assertions <br/> This checker flags type assertions v.(T) and corresponding type-switch cases in which the static type V of v is an interface that cannot possibly implement the target interface T. This occurs when V and T contain methods with the same name but different signatures. Example: <br/> <pre>var v interface {<br/> Read()<br/>}<br/>_ = v.(io.Reader)</pre><br/> The Read method in v has a different signature than the Read method in io.Reader, so this assertion cannot succeed. <br/> <br/> Default: `true` |
| `infertypeargs` | check for unnecessary type arguments in call expressions <br/> Explicit type arguments may be omitted from call expressions if they can be inferred from function arguments, or from other type arguments: <br/> <pre>func f[T any](T) {}<br/><br/><br/>func _() {<br/> f[string]("foo") // string could be inferred<br/>}</pre><br/> <br/> Default: `true` |
-| `loopclosure` | check references to loop variables from within nested functions <br/> This analyzer checks for references to loop variables from within a function literal inside the loop body. It checks only instances where the function literal is called in a defer or go statement that is the last statement in the loop body, as otherwise we would need whole program analysis. <br/> For example: <br/> <pre>for i, v := range s {<br/> go func() {<br/> println(i, v) // not what you might expect<br/> }()<br/>}</pre><br/> See: https://golang.org/doc/go_faq.html#closures_and_goroutines <br/> Default: `true` |
+| `loopclosure` | check references to loop variables from within nested functions <br/> This analyzer checks for references to loop variables from within a function literal inside the loop body. It checks for patterns where access to a loop variable is known to escape the current loop iteration: 1. a call to go or defer at the end of the loop body 2. a call to golang.org/x/sync/errgroup.Group.Go at the end of the loop body <br/> The analyzer only considers references in the last statement of the loop body as it is not deep enough to understand the effects of subsequent statements which might render the reference benign. <br/> For example: <br/> <pre>for i, v := range s {<br/> go func() {<br/> println(i, v) // not what you might expect<br/> }()<br/>}</pre><br/> See: https://golang.org/doc/go_faq.html#closures_and_goroutines <br/> Default: `true` |
| `lostcancel` | check cancel func returned by context.WithCancel is called <br/> The cancellation function returned by context.WithCancel, WithTimeout, and WithDeadline must be called or the new context will remain live until its parent context is cancelled. (The background context is never cancelled.) <br/> Default: `true` |
| `nilfunc` | check for useless comparisons between functions and nil <br/> A useless comparison is one like f == nil as opposed to f() == nil. <br/> Default: `true` |
| `nilness` | check for redundant or impossible nil comparisons <br/> The nilness checker inspects the control-flow graph of each function in a package and reports nil pointer dereferences, degenerate nil pointers, and panics with nil values. A degenerate comparison is of the form x==nil or x!=nil where x is statically known to be nil or non-nil. These are often a mistake, especially in control flow related to errors. Panics with nil values are checked because they are not detectable by <br/> <pre>if r := recover(); r != nil {</pre><br/> This check reports conditions such as: <br/> <pre>if f == nil { // impossible condition (f is a function)<br/>}</pre><br/> and: <br/> <pre>p := &v<br/>...<br/>if p != nil { // tautological condition<br/>}</pre><br/> and: <br/> <pre>if p == nil {<br/> print(*p) // nil dereference<br/>}</pre><br/> and: <br/> <pre>if p == nil {<br/> panic(p)<br/>}</pre><br/> <br/> Default: `false` |
@@ -863,11 +895,16 @@

This option must be set to a valid duration string, for example `"100ms"`.

+Deprecated: this setting is deprecated and will be removed in a future
+version of gopls (https://go.dev/issue/55332)
+

Default: `"0s"`
### `ui.diagnostic.staticcheck`

(Experimental) staticcheck enables additional analyses from staticcheck.io.
+These analyses are documented on
+[Staticcheck's website](https://staticcheck.io/docs/checks/).


Default: `false`
diff --git a/package.json b/package.json
index 050fee5..3bdf63c 100644
--- a/package.json
+++ b/package.json
@@ -2075,9 +2075,9 @@
},
"build.directoryFilters": {
"type": "array",
- "markdownDescription": "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nExamples:\n\nExclude node_modules: `-node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n",
+ "markdownDescription": "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nDirectoryFilters also supports the `**` operator to match 0 or more directories.\n\nExamples:\n\nExclude node_modules at current depth: `-node_modules`\n\nExclude node_modules at any depth: `-**/node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n",
"default": [
- "-node_modules"
+ "-**/node_modules"
],
"scope": "resource"
},
@@ -2100,13 +2100,13 @@
},
"build.experimentalUseInvalidMetadata": {
"type": "boolean",
- "markdownDescription": "(Experimental) experimentalUseInvalidMetadata enables gopls to fall back on outdated\npackage metadata to provide editor features if the go command fails to\nload packages for some reason (like an invalid go.mod file). This will\neventually be the default behavior, and this setting will be removed.\n",
+ "markdownDescription": "(Experimental) experimentalUseInvalidMetadata enables gopls to fall back on outdated\npackage metadata to provide editor features if the go command fails to\nload packages for some reason (like an invalid go.mod file).\n\nDeprecated: this setting is deprecated and will be removed in a future\nversion of gopls (https://go.dev/issue/55333).\n",
"default": false,
"scope": "resource"
},
"build.experimentalWorkspaceModule": {
"type": "boolean",
- "markdownDescription": "(Experimental) experimentalWorkspaceModule opts a user into the experimental support\nfor multi-module workspaces.\n",
+ "markdownDescription": "(Experimental) experimentalWorkspaceModule opts a user into the experimental support\nfor multi-module workspaces.\n\nDeprecated: this feature is deprecated and will be removed in a future\nversion of gopls (https://go.dev/issue/55331).\n",
"default": false,
"scope": "resource"
},
@@ -2124,6 +2124,14 @@
"default": "Normal",
"scope": "resource"
},
+ "build.standaloneTags": {
+ "type": "array",
+ "markdownDescription": "standaloneTags specifies a set of build constraints that identify\nindividual Go source files that make up the entire main package of an\nexecutable.\n\nA common example of standalone main files is the convention of using the\ndirective `//go:build ignore` to denote files that are not intended to be\nincluded in any package, for example because they are invoked directly by\nthe developer using `go run`.\n\nGopls considers a file to be a standalone main file if and only if it has\npackage name \"main\" and has a build directive of the exact form\n\"//go:build tag\" or \"// +build tag\", where tag is among the list of tags\nconfigured by this setting. Notably, if the build constraint is more\ncomplicated than a simple tag (such as the composite constraint\n`//go:build tag && go1.18`), the file is not considered to be a standalone\nmain file.\n\nThis setting is only supported when gopls is built with Go 1.16 or later.\n",
+ "default": [
+ "ignore"
+ ],
+ "scope": "resource"
+ },
"build.templateExtensions": {
"type": "array",
"markdownDescription": "templateExtensions gives the extensions of file names that are treateed\nas template files. (The extension\nis the part of the file name after the final dot.)\n",
@@ -2225,7 +2233,7 @@
},
"ui.diagnostic.analyses": {
"type": "object",
- "markdownDescription": "analyses specify analyses that the user would like to enable or disable.\nA map of the names of analysis passes that should be enabled/disabled.\nA full list of analyzers that gopls uses can be found\n[here](https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md).\n\nExample Usage:\n\n```json5\n...\n\"analyses\": {\n \"unreachable\": false, // Disable the unreachable analyzer.\n \"unusedparams\": true // Enable the unusedparams analyzer.\n}\n...\n```\n",
+ "markdownDescription": "analyses specify analyses that the user would like to enable or disable.\nA map of the names of analysis passes that should be enabled/disabled.\nA full list of analyzers that gopls uses can be found in\n[analyzers.md](https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md).\n\nExample Usage:\n\n```json5\n...\n\"analyses\": {\n \"unreachable\": false, // Disable the unreachable analyzer.\n \"unusedparams\": true // Enable the unusedparams analyzer.\n}\n...\n```\n",
"scope": "resource",
"properties": {
"asmdecl": {
@@ -2320,7 +2328,7 @@
},
"loopclosure": {
"type": "boolean",
- "markdownDescription": "check references to loop variables from within nested functions\n\nThis analyzer checks for references to loop variables from within a\nfunction literal inside the loop body. It checks only instances where\nthe function literal is called in a defer or go statement that is the\nlast statement in the loop body, as otherwise we would need whole\nprogram analysis.\n\nFor example:\n\n\tfor i, v := range s {\n\t\tgo func() {\n\t\t\tprintln(i, v) // not what you might expect\n\t\t}()\n\t}\n\nSee: https://golang.org/doc/go_faq.html#closures_and_goroutines",
+ "markdownDescription": "check references to loop variables from within nested functions\n\nThis analyzer checks for references to loop variables from within a function\nliteral inside the loop body. It checks for patterns where access to a loop\nvariable is known to escape the current loop iteration:\n 1. a call to go or defer at the end of the loop body\n 2. a call to golang.org/x/sync/errgroup.Group.Go at the end of the loop body\n\nThe analyzer only considers references in the last statement of the loop body\nas it is not deep enough to understand the effects of subsequent statements\nwhich might render the reference benign.\n\nFor example:\n\n\tfor i, v := range s {\n\t\tgo func() {\n\t\t\tprintln(i, v) // not what you might expect\n\t\t}()\n\t}\n\nSee: https://golang.org/doc/go_faq.html#closures_and_goroutines",
"default": true
},
"lostcancel": {
@@ -2500,13 +2508,13 @@
},
"ui.diagnostic.experimentalWatchedFileDelay": {
"type": "string",
- "markdownDescription": "(Experimental) experimentalWatchedFileDelay controls the amount of time that gopls waits\nfor additional workspace/didChangeWatchedFiles notifications to arrive,\nbefore processing all such notifications in a single batch. This is\nintended for use by LSP clients that don't support their own batching of\nfile system notifications.\n\nThis option must be set to a valid duration string, for example `\"100ms\"`.\n",
+ "markdownDescription": "(Experimental) experimentalWatchedFileDelay controls the amount of time that gopls waits\nfor additional workspace/didChangeWatchedFiles notifications to arrive,\nbefore processing all such notifications in a single batch. This is\nintended for use by LSP clients that don't support their own batching of\nfile system notifications.\n\nThis option must be set to a valid duration string, for example `\"100ms\"`.\n\nDeprecated: this setting is deprecated and will be removed in a future\nversion of gopls (https://go.dev/issue/55332)\n",
"default": "0s",
"scope": "resource"
},
"ui.diagnostic.staticcheck": {
"type": "boolean",
- "markdownDescription": "(Experimental) staticcheck enables additional analyses from staticcheck.io.\n",
+ "markdownDescription": "(Experimental) staticcheck enables additional analyses from staticcheck.io.\nThese analyses are documented on\n[Staticcheck's website](https://staticcheck.io/docs/checks/).\n",
"default": false,
"scope": "resource"
},
diff --git a/tools/installtools/main.go b/tools/installtools/main.go
index eaf20a0..ca6d5ba 100644
--- a/tools/installtools/main.go
+++ b/tools/installtools/main.go
@@ -6,6 +6,7 @@
package main

import (
+ "bytes"
"fmt"
"os"
"os/exec"
@@ -23,8 +24,9 @@
}

var tools = []struct {
- path string
- dest string
+ path string
+ dest string
+ preferPreview bool
// versions is a list of supportedVersions sorted by
// goMinorVersion. If we want to pin a tool's version
// add a fake entry with a large goMinorVersion
@@ -33,32 +35,32 @@
versions []finalVersion
}{
// TODO: auto-generate based on allTools.ts.in.
- {"golang.org/x/tools/gopls", "", nil},
- {"github.com/acroca/go-symbols", "", nil},
- {"github.com/cweill/gotests/gotests", "", nil},
- {"github.com/davidrjenni/reftools/cmd/fillstruct", "", nil},
- {"github.com/haya14busa/goplay/cmd/goplay", "", nil},
- {"github.com/stamblerre/gocode", "gocode-gomod", nil},
- {"github.com/mdempsky/gocode", "", nil},
- {"github.com/ramya-rao-a/go-outline", "", nil},
- {"github.com/rogpeppe/godef", "", nil},
- {"github.com/sqs/goreturns", "", nil},
- {"github.com/uudashr/gopkgs/v2/cmd/gopkgs", "", nil},
- {"github.com/zmb3/gogetdoc", "", nil},
- {"honnef.co/go/tools/cmd/staticcheck", "", []finalVersion{{16, "v0.2.2"}}},
- {"golang.org/x/tools/cmd/gorename", "", nil},
- {"github.com/go-delve/delve/cmd/dlv", "", nil},
+ {"golang.org/x/tools/gopls", "", true, nil},
+ {"github.com/acroca/go-symbols", "", false, nil},
+ {"github.com/cweill/gotests/gotests", "", false, nil},
+ {"github.com/davidrjenni/reftools/cmd/fillstruct", "", false, nil},
+ {"github.com/haya14busa/goplay/cmd/goplay", "", false, nil},
+ {"github.com/stamblerre/gocode", "gocode-gomod", false, nil},
+ {"github.com/mdempsky/gocode", "", false, nil},
+ {"github.com/ramya-rao-a/go-outline", "", false, nil},
+ {"github.com/rogpeppe/godef", "", false, nil},
+ {"github.com/sqs/goreturns", "", false, nil},
+ {"github.com/uudashr/gopkgs/v2/cmd/gopkgs", "", false, nil},
+ {"github.com/zmb3/gogetdoc", "", false, nil},
+ {"honnef.co/go/tools/cmd/staticcheck", "", false, []finalVersion{{16, "v0.2.2"}}},
+ {"golang.org/x/tools/cmd/gorename", "", false, nil},
+ {"github.com/go-delve/delve/cmd/dlv", "", false, nil},
}

// pickVersion returns the version to install based on the supported
// version list.
-func pickVersion(goMinorVersion int, versions []finalVersion) string {
+func pickVersion(goMinorVersion int, versions []finalVersion, defaultVersion string) string {
for _, v := range versions {
if goMinorVersion <= v.goMinorVersion {
return v.version
}
}
- return "latest"
+ return defaultVersion
}

func main() {
@@ -137,7 +139,7 @@
}
env := append(os.Environ(), "GO111MODULE=on")
for _, tool := range tools {
- ver := pickVersion(goMinorVersion, tool.versions)
+ ver := pickVersion(goMinorVersion, tool.versions, pickLatest(tool.path, tool.preferPreview))
path := tool.path + "@" + ver
cmd := exec.Command("go", installCmd, path)
cmd.Env = env
@@ -166,3 +168,18 @@
}
return b
}
+
+func pickLatest(toolPath string, preferPreview bool) string {
+ if !preferPreview {
+ return "latest" // should we pick the pinned version in allTools.ts.in?
+ }
+ out, err := exec.Command("go", "list", "-m", "--versions", toolPath).Output()
+ if err != nil {
+ exitf("failed to find a suitable version for %q: %v", toolPath, err)
+ }
+ versions := bytes.Split(out, []byte(" "))
+ if len(versions) == 0 {
+ exitf("failed to find a suitable version for %q: %s", toolPath, out)
+ }
+ return string(bytes.TrimSpace(versions[len(versions)-1]))
+}
diff --git a/tools/installtools/main_test.go b/tools/installtools/main_test.go
index 6175c23..d8b3d8d 100644
--- a/tools/installtools/main_test.go
+++ b/tools/installtools/main_test.go
@@ -37,7 +37,7 @@
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for goMinorVersion, want := range tt.want {
- if got := pickVersion(goMinorVersion, tt.versions); got != want {
+ if got := pickVersion(goMinorVersion, tt.versions, "latest"); got != want {
t.Errorf("pickVersion(go 1.%v) = %v, want %v", goMinorVersion, got, want)
}
}

To view, visit change 443155. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: I7c30904f59e7ab9694be3fc3b8e4f894138d3fa3
Gerrit-Change-Number: 443155
Gerrit-PatchSet: 3
Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
Gerrit-Reviewer: kokoro <noreply...@google.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages