Skip to content

Commit 6d3e439

Browse files
committed
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>
1 parent 4c651fc commit 6d3e439

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

gopls/doc/advanced.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,32 @@ You can achieve this by adding the right version of `go` to your `PATH`
3434
(`export PATH=$HOME/go/bin:$PATH` on Unix systems) or by configuring your
3535
editor.
3636

37+
## Working with generic code
38+
39+
Gopls has experimental support for generic Go, as defined by the type
40+
parameters proposal ([golang/go#43651](https://golang.org/issues/43651)) and
41+
type set addendum ([golang/go#45346](https://golang.org/issues/45346)).
42+
43+
To enable this support, you need to build gopls with a version of Go that
44+
supports type parameters: the
45+
[dev.typeparams branch](https://github.com/golang/go/tree/dev.typeparams). This
46+
can be done by checking out this branch in the Go repository, or by using
47+
`golang.org/dl/gotip`:
48+
49+
```
50+
$ go get golang.org/dl/gotip
51+
$ gotip download dev.typeparams
52+
```
53+
54+
For building gopls with type parameter support, it is recommended that you
55+
build gopls at tip. External APIs are under active development on the
56+
`dev.typeparams` branch, so building gopls at tip minimizes the chances of
57+
a build failure (though it is still possible). To get enhanced gopls features
58+
for generic code, build gopls with the `typeparams` build constraint (though
59+
this increases your chances of a build failure).
60+
61+
```
62+
$ GO111MODULE=on gotip get -tags=typeparams golang.org/x/tools/gopls@master golang.org/x/tools@master
63+
```
64+
3765
[Go project]: https://go.googlesource.com/go

0 commit comments

Comments
 (0)