You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
03af3d4 package.json: sync gopls settings @ v0.8.0
1274335 package.json: fix spelling for generateTestForPackage
b6187d8 package.json: add go.toolsManagement.go
6399238 codereview.cfg: declare issue repo
09c4936 src/goEnv.ts: pass uri to getGoConfig
0f849d1 src/config: add ExtensionInfo to replace isInPreview/isInCloudIDE
0bd09b6 src/goMain: install tools for suggested updates if autoUpdate is on
2434bfa src/utils: add utils/README.md and move test_events.md to goTest
acbe503 src/goImport,goOutline: check registered gopls commands
4aa4554 src/goLanguageServer: skip buildLanguageClient if it's disabled
073b8fc src/goLanguageServer: include go version in the gopls crash report
e6dc469 src/goLanguageServer: sample half of gopls opt-out users for survey
4b6318c src/goLanguageServer: clean unused `surveyOnly` param
5494d35 src/goLanguageServer.ts: don't let config change trigger opt-out survey
2222461 src/goOutline.ts: use regexp to find package decl
7bc14ec src/goStatus: add go.work to status bar quickpick
16eadfa src/goMain: suggest tool updates if tools were compiled with old go
934911a src/goLanguageServer: cache language server info
28136c8 src/goOutline: use language server to get document symbols
af9afa3 src/goMain.ts: remove warning about dlv-dap in alternateTools
bdcd7a6 src/goMain.ts: remove prompt for nightly extension users
b3048fc src/goLanguageServer: use 1.42+ workspace.getConfiguration API
9156fb4 src/goMain: use inspectGoToolVersion instead of runGoVersionM
3e9fb0e src/util: remove vendoring support check
4435e8e src/util: fix vendor support check
37ffd3c test: update switch goroutine test
e04eb10 build: log shm size & increase shm size to 8G
e50cf23 src/goPackages: make goListPkgs async and run go list with -e
5b290fa CHANGELOG.md: list changes for v0.31.1
fb8ba52 vscode-go: remove references to gopkgs
68fae93 tools: remove gopkgs from all tools information
037e8a3 src/goTest: avoid a name conflicting with the proposed quickpick api
3ad379c src/goEnvironmentStatus: use installTool for golang.org/dl/* install
9d0ec81 .github/workflows: replace go1.18-beta1 with go1.18-beta2
c01699e docs/features.md: discuss default formatting behavior and template support
c5ebe02 docs/advanced.md: use go1.18beta2 in the instruction
d5403b9 src/goToolsInformation: require go1.13+ for gopls
0a9d740 .github/workflows: partially revert go.dev/cl/380175
59d4c16 test/integration: skip 'disconnect with multiple disconnectRequests' test
92797b2 package.json: bump dev version to 0.32.0
6264294 docs/advanced.md: fix broken link and add more links
debf84a docs/advanced.md: add go1.18 instruction
2735f15 src/goTest: remove '#' in subtest name parsing cutset
c42b3cd src/goTest: detect Fuzz tests and list them in test explorer UI
6a37048 workflows: replace repository dispatch with workflow dispatch
b5b4835 CHANGELOG.md: Update changelog for release continued
6135b6e src/goPackages.ts: replace use of gopkgs with go list
1b607ad tests/testdata: fix package name in importTest
6fb2a2a package.json: update [email protected]e4e5dfa test: remove flaky step out test
59db2c8 tools/license.sh: only include production dependencies in LICENSE
Change-Id: Ia9e1dab191444b17f968ba64c9e95556ac5483ee
*[Toggle between code and tests](#toggle-between-code-and-tests)
18
+
*[Syntax Highlighting](#syntax-highlighting)
18
19
*[Code Editing](#code-editing)
19
20
*[Snippets](#snippets)
20
21
*[Format and organize imports](#format-and-organize-imports)
@@ -103,6 +104,19 @@ Quickly toggle between a file and its corresponding test file by using the [`Go:
103
104
104
105
<divstyle="text-align: center;"><imgsrc="images/toggletestfile.gif"alt="Toggle between reverse.go and reverse_test.go"style="width: 75%"> </div>
105
106
107
+
108
+
## Syntax Highlighting
109
+
110
+
The default syntax highlighting for Go files is implemented in Visual Studio Code using TextMate grammar, not by this extension.
111
+
112
+
If you are using `gopls`, you can enable [Semantic Highlighting](https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide) for more accurate syntax highlighting based on semantic tokenization using `"gopls": { "ui.semanticTokens": true }`.
113
+
114
+
### Go template syntax highlighting
115
+
116
+
When `gopls`'s semantic tokens feature is enabled, `gopls` also provides semantic tokens for Go template files (language identifier: `gotmpl`). By default, the extension associates all `*.tmpl` or `*.gotmpl` files in the workspace with `gotmpl` language. Users can override the language mode by using Visual Studio Code's UI or the `"files.associations"` setting. See [Visual Studio Code's doc](https://code.visualstudio.com/docs/languages/overview#_changing-the-language-for-the-selected-file) for more details.
117
+
118
+
<divstyle="text-align: center;"><imgsrc="images/gotmpl.gif"alt="Enable Go template language support by changing the language ID"style="width: 75%"> </div>
@@ -115,13 +129,16 @@ Predefined snippets for quick coding. These snippets will appear as completion s
115
129
116
130
Format code and organize imports, either manually or on save.
117
131
132
+
The extension formats Go code, organizes imports, and removes unused imports by default. For different behavior, please override per-language default settings following [the instruction](https://github.com/golang/vscode-go/blob/master/docs/advanced.md#formatting-code-and-organizing-imports).
133
+
134
+
When organizing imports, the imported packages are grouped in the default `goimports` style. In order to group some packages after 3rd-party packages, use [`"gopls": { "formatting.local": <comma-separated imports prefix>}`](https://github.com/golang/vscode-go/blob/master/docs/settings.md#formattinglocal).
135
+
118
136
#### Add import
119
137
120
-
Manually add a new import to your file through the [`Go: Add Import`](commands.md#go-add-import) command. Available packages are offered from your `GOPATH`and module cache.
138
+
The extension organizes imports automatically and can add missing imports if the package is present in your module cache already. However, you can also manually add a new import to your file through the [`Go: Add Import`](commands.md#go-add-import) command. Available packages are offered from module cache (or from your `GOPATH`in GOPATH mode).
121
139
122
140
<divstyle="text-align: center;"><imgsrc="images/addimport.gif"alt="Add byte import to Go file"style="width: 75%"> </div>
Copy file name to clipboardExpand all lines: docs/settings.md
+10-5Lines changed: 10 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,6 @@ Alternate tools or alternate paths for the same tools used by the Go extension.
54
54
|`dlv`| Alternate tool to use instead of the dlv binary or alternate path to use for the dlv binary. <br/> Default: `"dlv"`|
55
55
|`go`| Alternate tool to use instead of the go binary or alternate path to use for the go binary. <br/> Default: `"go"`|
56
56
|`go-outline`| Alternate tool to use instead of the go-outline binary or alternate path to use for the go-outline binary. <br/> Default: `"go-outline"`|
57
-
|`gopkgs`| Alternate tool to use instead of the gopkgs binary or alternate path to use for the gopkgs binary. <br/> Default: `"gopkgs"`|
58
57
|`gopls`| Alternate tool to use instead of the gopls binary or alternate path to use for the gopls binary. <br/> Default: `"gopls"`|
59
58
### `go.autocompleteUnimportedPackages`
60
59
@@ -175,7 +174,7 @@ Experimental Feature: Enable/Disable entries from the context menu in the editor
175
174
|`fillStruct`| If true, adds command to fill struct literal with default values to the editor context menu <br/> Default: `true`|
176
175
|`generateTestForFile`| If true, adds command to generate unit tests for current file to the editor context menu <br/> Default: `true`|
177
176
|`generateTestForFunction`| If true, adds command to generate unit tests for function under the cursor to the editor context menu <br/> Default: `true`|
178
-
|`generateTestForPackage`| If true, adds command to generate unit tests for currnt package to the editor context menu <br/> Default: `true`|
177
+
|`generateTestForPackage`| If true, adds command to generate unit tests for current package to the editor context menu <br/> Default: `true`|
179
178
|`playground`| If true, adds command to upload the current file or selection to the Go Playground <br/> Default: `true`|
180
179
|`removeTags`| If true, adds command to remove configured tags from struct fields to the editor context menu <br/> Default: `true`|
181
180
|`testAtCursor`| If true, adds command to run the test under the cursor to the editor context menu <br/> Default: `false`|
@@ -455,6 +454,11 @@ Allowed Options:
455
454
456
455
457
456
Default: `"proxy"`
457
+
### `go.toolsManagement.go`
458
+
459
+
The path to the `go` binary used to install the Go tools. If it's empty, the same `go` binary chosen for the project will be used for tool installation.
460
+
461
+
Default: `""`
458
462
### `go.trace.server`
459
463
460
464
Trace the communication between VS Code and the Go language server.<br/>
@@ -731,7 +735,7 @@ Example Usage:
731
735
|`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`|
732
736
|`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`|
733
737
|`nonewvars`| suggested fixes for "no new vars on left side of :=" <br/> This checker provides suggested fixes for type errors of the type "no new vars on left side of :=". For example: <pre>z := 1<br/>z := 2</pre>will turn into <pre>z := 1<br/>z = 2</pre><br/> <br/> Default: `true`|
734
-
|`noresultvalues`| suggested fixes for "no result values expected" <br/> This checker provides suggested fixes for type errors of the type "no result values expected". For example: <pre>func z() { return nil }</pre>will turn into <pre>func z() { return }</pre><br/> <br/> Default: `true`|
738
+
|`noresultvalues`| suggested fixes for unexpected return values <br/> This checker provides suggested fixes for type errors of the type "no result values expected" or "too many return values". For example: <pre>func z() { return nil }</pre>will turn into <pre>func z() { return }</pre><br/> <br/> Default: `true`|
735
739
| `printf` | check consistency of Printf format strings and arguments <br/> The check applies to known functions (for example, those in package fmt) as well as any detected wrappers of known functions. <br/> A function that wants to avail itself of printf checking but is not found by this analyzer's heuristics (for example, due to use of dynamic calls) can insert a bogus call: <br/> <pre>if false {<br/> _ = fmt.Sprintf(format, args...) // enable printf checking<br/>}</pre><br/> The -funcs flag specifies a comma-separated list of names of additional known formatting functions or methods. If the name contains a period, it must denote a specific function using one of the following forms: <br/> <pre>dir/pkg.Function<br/>dir/pkg.Type.Method<br/>(*dir/pkg.Type).Method</pre><br/> Otherwise the name is interpreted as a case-insensitive unqualified identifier such as "errorf". Either way, if a listed name ends in f, the function is assumed to be Printf-like, taking a format string before the argument list. Otherwise it is assumed to be Print-like, taking a list of arguments with no format string. <br/> <br/> Default: `true` |
736
740
|`shadow`| check for possible unintended shadowing of variables <br/> This analyzer check for shadowed variables. A shadowed variable is a variable declared in an inner scope with the same name and type as a variable in an outer scope, and where the outer variable is mentioned after the inner one is declared. <br/> (This definition can be refined; the module generates too many false positives and is not yet enabled by default.) <br/> For example: <br/> <pre>func BadRead(f *os.File, buf []byte) error {<br/> var err error<br/> for {<br/> n, err := f.Read(buf) // shadows the function variable 'err'<br/> if err != nil {<br/> break // causes return of wrong value<br/> }<br/> foo(buf)<br/> }<br/> return err<br/>}</pre><br/> <br/> Default: `false`|
737
741
|`shift`| check for shifts that equal or exceed the width of the integer <br/> Default: `true`|
@@ -742,6 +746,7 @@ Example Usage:
742
746
|`stdmethods`| check signature of methods of well-known interfaces <br/> Sometimes a type may be intended to satisfy an interface but may fail to do so because of a mistake in its method signature. For example, the result of this WriteTo method should be (int64, error), not error, to satisfy io.WriterTo: <br/> <pre>type myWriterTo struct{...}</pre> func (myWriterTo) WriteTo(w io.Writer) error { ... } <br/> This check ensures that each method whose name matches one of several well-known interface methods from the standard library has the correct signature for that interface. <br/> Checked method names include: <pre>Format GobEncode GobDecode MarshalJSON MarshalXML<br/>Peek ReadByte ReadFrom ReadRune Scan Seek<br/>UnmarshalJSON UnreadByte UnreadRune WriteByte<br/>WriteTo</pre><br/> <br/> Default: `true`|
743
747
|`stringintconv`| check for string(int) conversions <br/> This checker flags conversions of the form string(x) where x is an integer (but not byte or rune) type. Such conversions are discouraged because they return the UTF-8 representation of the Unicode code point x, and not a decimal string representation of x as one might expect. Furthermore, if x denotes an invalid code point, the conversion cannot be statically rejected. <br/> For conversions that intend on using the code point, consider replacing them with string(rune(x)). Otherwise, strconv.Itoa and its equivalents return the string representation of the value in the desired base. <br/> <br/> Default: `true`|
744
748
|`structtag`| check that struct field tags conform to reflect.StructTag.Get <br/> Also report certain struct tags (json, xml) used with unexported fields. <br/> Default: `true`|
749
+
|`stubmethods`| stub methods analyzer <br/> This analyzer generates method stubs for concrete types in order to implement a target interface <br/> Default: `true`|
745
750
|`testinggoroutine`| report calls to (*testing.T).Fatal from goroutines started by a test. <br/> Functions that abruptly terminate a test, such as the Fatal, Fatalf, FailNow, and Skip{,f,Now} methods of *testing.T, must be called from the test goroutine itself. This checker detects calls to these functions that occur within a goroutine started by the test. For example: <br/> func TestFoo(t *testing.T) { go func() { t.Fatal("oops") // error: (*T).Fatal called from non-test goroutine }() } <br/> <br/> Default: `true`|
746
751
|`tests`| check for common mistaken usages of tests and examples <br/> The tests checker walks Test, Benchmark and Example functions checking malformed names, wrong signatures and examples documenting non-existent identifiers. <br/> Please see the documentation for package testing in golang.org/pkg/testing for the conventions that are enforced for Tests, Benchmarks, and Examples. <br/> Default: `true`|
747
752
|`undeclaredname`| suggested fixes for "undeclared name: <>" <br/> This checker provides suggested fixes for type errors of the type "undeclared name: <>". It will either insert a new statement, such as: <br/> "<> := " <br/> or a new function declaration, such as: <br/> func <>(inferred parameters) { <pre>panic("implement me!")</pre>} <br/> <br/> Default: `true`|
@@ -751,7 +756,7 @@ Example Usage:
751
756
|`unusedparams`| check for unused parameters of functions <br/> The unusedparams analyzer checks functions to see if there are any parameters that are not being used. <br/> To reduce false positives it ignores: - methods - parameters that do not have a name or are underscored - functions in test files - functions with empty bodies or those with just a return stmt <br/> Default: `false`|
752
757
|`unusedresult`| check for unused results of calls to some functions <br/> Some functions like fmt.Errorf return a result and have no side effects, so it is always a mistake to discard the result. This analyzer reports calls to certain functions in which the result of the call is ignored. <br/> The set of functions may be controlled using flags. <br/> Default: `true`|
753
758
|`unusedwrite`| checks for unused writes <br/> The analyzer reports instances of writes to struct fields and arrays that are never read. Specifically, when a struct object or an array is copied, its elements are copied implicitly by the compiler, and any element write to this copy does nothing with the original object. <br/> For example: <br/> <pre>type T struct { x int }<br/>func f(input []T) {<br/> for i, v := range input { // v is a copy<br/> v.x = i // unused write to field x<br/> }<br/>}</pre><br/> Another example is about non-pointer receiver: <br/> <pre>type T struct { x int }<br/>func (t T) f() { // t is a copy<br/> t.x = i // unused write to field x<br/>}</pre><br/> <br/> Default: `false`|
754
-
|`useany`| check for constraints that could be simplified to "any" <br/> Default: `true`|
759
+
|`useany`| check for constraints that could be simplified to "any" <br/> Default: `false`|
755
760
### `ui.diagnostic.annotations`
756
761
757
762
(Experimental) annotations specifies the various kinds of optimization diagnostics
0 commit comments