Debian Codegraph @

gopls/doc/advanced.md

raw symbols SCIP
1 ---
2 title: "Gopls: Advanced topics"
3 ---
4
5 This documentation is for advanced `gopls` users, who may want to test
6 unreleased versions or try out special features.
7
8 ## Installing unreleased versions
9
10 To get a specific version of `gopls` (for example, to test a prerelease
11 version), run:
12
13 ```sh
14 $ go install golang.org/x/tools/[email protected]
15 ```
16
17 Where `vX.Y.Z` is the desired version.
18
19 ### Unstable versions
20
21 To update `gopls` to the latest **unstable** version, use the following
22 commands.
23
24 ```sh
25 # Create an empty go.mod file, only for tracking requirements.
26 cd $(mktemp -d)
27 go mod init gopls-unstable
28
29 # Use 'go get' to add requirements and to ensure they work together.
30 go get -d golang.org/x/tools/gopls@master golang.org/x/tools@master
31
32 go install golang.org/x/tools/gopls
33 ```
34
35 ## Working on the Go source distribution
36
37 If you are working on the [Go project] itself, the `go` command that `gopls`
38 invokes will have to correspond to the version of the source you are working
39 on. That is, if you have checked out the Go project to `$HOME/go-tip`, your
40 `go` command should be the `$HOME/go-tip/bin/go` executable that you built
41 with `make.bash` or equivalent.
42
43 You can achieve this by adding the right version of `go` to your `PATH`
44 (`export PATH=$HOME/go-tip/bin:$PATH` on Unix systems) or by configuring your
45 editor.
46
47 To work on both `std` and `cmd` simultaneously, add a `go.work` file to
48 `GOROOT/src`:
49
50 ```
51 cd $(go env GOROOT)/src
52 go work init . cmd
53 ```
54
55 Note that you must work inside the `GOROOT/src` subdirectory, as the `go`
56 command does not recognize `go.work` files in a parent of `GOROOT/src`
57 (https://go.dev/issue/59429).
58
59 [Go project]: https://go.googlesource.com/go