From 4d205d81b5a0f7cb051584b8964b7a0fd6d502c2 Mon Sep 17 00:00:00 2001 From: Rob Findley Date: Tue, 4 Apr 2023 12:00:29 -0400 Subject: [PATCH] gopls/doc: add instructions for using go.work with the Go distribution 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 Reviewed-by: Alan Donovan TryBot-Result: Gopher Robot Run-TryBot: Robert Findley --- gopls/doc/advanced.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gopls/doc/advanced.md b/gopls/doc/advanced.md index 9f9267c1c58..1f70143a7b3 100644 --- a/gopls/doc/advanced.md +++ b/gopls/doc/advanced.md @@ -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 @@ -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