3 This document describes the LSP-level commands supported by `gopls`. They cannot be invoked directly by users, and all the details are subject to change, so nobody should rely on this information.
5 <!-- BEGIN Commands: DO NOT MANUALLY EDIT THIS SECTION -->
7 Identifier: `gopls.add_dependency`
9 Adds a dependency to the go.mod file for a module.
15 // The go.mod file URI.
17 // Additional args to pass to the go command.
18 "GoCmdArgs": []string,
19 // Whether to add a require directive.
25 Identifier: `gopls.add_import`
39 Identifier: `gopls.apply_fix`
41 Applies a fix to a region of source code.
49 // The file URI for the document to fix.
51 // The document range to scan for fixes.
65 ### **Check for upgrades**
66 Identifier: `gopls.check_upgrades`
68 Checks for module upgrades.
74 // The go.mod file URI.
76 // The modules to check.
81 ### **Toggle gc_details**
82 Identifier: `gopls.gc_details`
84 Toggle the calculation of gc annotations.
92 ### **Run go generate**
93 Identifier: `gopls.generate`
95 Runs `go generate` for a given directory.
101 // URI for the directory to generate.
103 // Whether to generate recursively (go generate ./...)
108 ### **Generate gopls.mod**
109 Identifier: `gopls.generate_gopls_mod`
111 (Re)generate the gopls.mod file for a workspace.
122 ### **go get package**
123 Identifier: `gopls.go_get_package`
125 Runs `go get` to fetch a package.
131 // Any document URI within the relevant module.
133 // The package to go get.
140 Identifier: `gopls.list_known_packages`
153 ### **Regenerate cgo**
154 Identifier: `gopls.regenerate_cgo`
156 Regenerates cgo definitions.
167 ### **Remove dependency**
168 Identifier: `gopls.remove_dependency`
170 Removes a dependency from the go.mod file of a module.
176 // The go.mod file URI.
178 // The module path to remove.
179 "ModulePath": string,
180 "OnlyDiagnostic": bool,
185 Identifier: `gopls.run_tests`
187 Runs `go test` for a specific set of test or benchmark functions.
193 // The test file containing the tests to run.
195 // Specific test names to run, e.g. TestFoo.
197 // Specific benchmarks to run, e.g. BenchmarkFoo.
198 "Benchmarks": []string,
202 ### **Run test(s) (legacy)**
203 Identifier: `gopls.test`
205 Runs `go test` for a specific set of test or benchmark functions.
215 ### **Run go mod tidy**
216 Identifier: `gopls.tidy`
218 Runs `go mod tidy` for a module.
229 ### **Toggle gc_details**
230 Identifier: `gopls.toggle_gc_details`
232 Toggle the calculation of gc annotations.
243 ### **Update go.sum**
244 Identifier: `gopls.update_go_sum`
246 Updates the go.sum file for a module.
257 ### **Upgrade dependency**
258 Identifier: `gopls.upgrade_dependency`
260 Upgrades a dependency in the go.mod file for a module.
266 // The go.mod file URI.
268 // Additional args to pass to the go command.
269 "GoCmdArgs": []string,
270 // Whether to add a require directive.
275 ### **Run go mod vendor**
276 Identifier: `gopls.vendor`
278 Runs `go mod vendor` for a module.
289 <!-- END Commands: DO NOT MANUALLY EDIT THIS SECTION -->