gopls/doc: add instructions for working with generic code

Change-Id: Ib0e5e16042791d96ed0d71e900b006a2c536032a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/330031
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Rob Findley 2021-06-22 11:01:27 -04:00 committed by Robert Findley
parent 4c651fc1fc
commit 6d3e439322
1 changed files with 28 additions and 0 deletions

View File

@ -34,4 +34,32 @@ 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.
## Working with generic code
Gopls has experimental support for generic Go, as defined by the type
parameters proposal ([golang/go#43651](https://golang.org/issues/43651)) and
type set addendum ([golang/go#45346](https://golang.org/issues/45346)).
To enable this support, you need to build gopls with a version of Go that
supports type parameters: the
[dev.typeparams branch](https://github.com/golang/go/tree/dev.typeparams). This
can be done by checking out this branch in the Go repository, or by using
`golang.org/dl/gotip`:
```
$ go get golang.org/dl/gotip
$ gotip download dev.typeparams
```
For building gopls with type parameter support, it is recommended that you
build gopls at tip. External APIs are under active development on the
`dev.typeparams` branch, so building gopls at tip minimizes the chances of
a build failure (though it is still possible). To get enhanced gopls features
for generic code, build gopls with the `typeparams` build constraint (though
this increases your chances of a build failure).
```
$ GO111MODULE=on gotip get -tags=typeparams golang.org/x/tools/gopls@master golang.org/x/tools@master
```
[Go project]: https://go.googlesource.com/go