Skip to content

Commit

Permalink
gopls/doc: add instructions for using go.work with the Go distribution
Browse files Browse the repository at this point in the history
Following the discovery of golang/go#59429, we should have more detailed
instructions for how to use a `go.work` file with the Go distribution.

Change-Id: I9aab204832cfc08016f4f3c53cbe7195e23cf21c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/482016
gopls-CI: kokoro <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Robert Findley <[email protected]>
  • Loading branch information
findleyr committed Apr 4, 2023
1 parent d5076cc commit 4d205d8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion gopls/doc/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ You can achieve this by adding the right version of `go` to your `PATH`
(`export PATH=$HOME/go/bin:$PATH` on Unix systems) or by configuring your
editor.

To work on both `std` and `cmd` simultaneously, add a `go.work` file to
`GOROOT/src`:

```
cd $(go env GOROOT)/src
go work init . cmd
```

Note that you must work inside the `GOROOT/src` subdirectory, as the `go`
command does not recognize `go.work` files in a parent of `GOROOT/src`
(https://go.dev/issue/59429).

## Working with generic code

Gopls has support for editing generic Go code. To enable this support, you need
Expand All @@ -55,7 +67,6 @@ $ go install golang.org/x/tools/gopls@latest

It is strongly recommended that you install the latest version of `gopls`, or
the latest **unstable** version as [described above](#installing-unreleased-versions).
We're still working on improving our generics support.

The `gopls` built with these instructions understands generic code. See the
[generics tutorial](https://go.dev/doc/tutorial/generics) for more information
Expand Down

0 comments on commit 4d205d8

Please sign in to comment.