Skip to content

Commit 2e739cc

Browse files
committed
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 #2486 Change-Id: I7c30904f59e7ab9694be3fc3b8e4f894138d3fa3 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/443155 TryBot-Result: kokoro <[email protected]> Reviewed-by: Robert Findley <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
1 parent 2a6a178 commit 2e739cc

File tree

4 files changed

+98
-36
lines changed

4 files changed

+98
-36
lines changed

docs/settings.md

+44-7
Original file line numberDiff line numberDiff line change
@@ -612,16 +612,20 @@ relative to the workspace folder. They are evaluated in order, and
612612
the last filter that applies to a path controls whether it is included.
613613
The path prefix can be empty, so an initial `-` excludes everything.
614614

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

617-
Exclude node_modules: `-node_modules`
619+
Exclude node_modules at current depth: `-node_modules`
620+
621+
Exclude node_modules at any depth: `-**/node_modules`
618622

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

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

623627

624-
Default: `["-node_modules"]`
628+
Default: `["-**/node_modules"]`
625629
### `build.env`
626630

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

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

659665

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

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

667676
Default: `false`
668677
### `build.memoryMode`
@@ -681,6 +690,29 @@ References and Rename will miss results in such packages.
681690

682691

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

686718
templateExtensions gives the extensions of file names that are treateed
@@ -768,8 +800,8 @@ Default: `false`
768800

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

774806
Example Usage:
775807

@@ -802,7 +834,7 @@ Example Usage:
802834
| `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` |
803835
| `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` |
804836
| `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` |
805-
| `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` |
837+
| `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` |
806838
| `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` |
807839
| `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` |
808840
| `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 @@ file system notifications.
863895

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

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

867902
Default: `"0s"`
868903
### `ui.diagnostic.staticcheck`
869904

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

872909

873910
Default: `false`

package.json

+16-8
Original file line numberDiff line numberDiff line change
@@ -2075,9 +2075,9 @@
20752075
},
20762076
"build.directoryFilters": {
20772077
"type": "array",
2078-
"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",
2078+
"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",
20792079
"default": [
2080-
"-node_modules"
2080+
"-**/node_modules"
20812081
],
20822082
"scope": "resource"
20832083
},
@@ -2100,13 +2100,13 @@
21002100
},
21012101
"build.experimentalUseInvalidMetadata": {
21022102
"type": "boolean",
2103-
"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",
2103+
"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",
21042104
"default": false,
21052105
"scope": "resource"
21062106
},
21072107
"build.experimentalWorkspaceModule": {
21082108
"type": "boolean",
2109-
"markdownDescription": "(Experimental) experimentalWorkspaceModule opts a user into the experimental support\nfor multi-module workspaces.\n",
2109+
"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",
21102110
"default": false,
21112111
"scope": "resource"
21122112
},
@@ -2124,6 +2124,14 @@
21242124
"default": "Normal",
21252125
"scope": "resource"
21262126
},
2127+
"build.standaloneTags": {
2128+
"type": "array",
2129+
"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",
2130+
"default": [
2131+
"ignore"
2132+
],
2133+
"scope": "resource"
2134+
},
21272135
"build.templateExtensions": {
21282136
"type": "array",
21292137
"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 @@
22252233
},
22262234
"ui.diagnostic.analyses": {
22272235
"type": "object",
2228-
"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",
2236+
"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",
22292237
"scope": "resource",
22302238
"properties": {
22312239
"asmdecl": {
@@ -2320,7 +2328,7 @@
23202328
},
23212329
"loopclosure": {
23222330
"type": "boolean",
2323-
"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",
2331+
"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",
23242332
"default": true
23252333
},
23262334
"lostcancel": {
@@ -2500,13 +2508,13 @@
25002508
},
25012509
"ui.diagnostic.experimentalWatchedFileDelay": {
25022510
"type": "string",
2503-
"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",
2511+
"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",
25042512
"default": "0s",
25052513
"scope": "resource"
25062514
},
25072515
"ui.diagnostic.staticcheck": {
25082516
"type": "boolean",
2509-
"markdownDescription": "(Experimental) staticcheck enables additional analyses from staticcheck.io.\n",
2517+
"markdownDescription": "(Experimental) staticcheck enables additional analyses from staticcheck.io.\nThese analyses are documented on\n[Staticcheck's website](https://staticcheck.io/docs/checks/).\n",
25102518
"default": false,
25112519
"scope": "resource"
25122520
},

0 commit comments

Comments
 (0)