Skip to content

Commit 4d4ee95

Browse files
committed
[gopls-release-branch.0.6] all: merge master into gopls-release-branch.0.6
9b8df07 internal/lsp: enable -mod=readonly in workspace module mode f1f686b internal/lsp: re-enable upgrades for individual dependencies d8a2a07 go/packages: improve go invocation errors 19db92e internal/lsp/cache: remove mod upgrade code 0cef57b internal/lsp/protocol: use a pointer for code action's disabled field db4c57d gopls/internal/regtest: split regtests up into multiple packages f871472 internal/lsp/cache: lock in snapshot.knownFilesInDir c2bea79 internal/lsp/source: make it an error to rename embedded fields 514964b gopls/internal/hooks: improve license file test 68bf78a internal/lsp/cmd: improve help output of gopls subcommands 4922717 go/analysis/passes/fieldalignment: delete doc style comments in fix 917f61d gopls/internal/regtest: automate counting of editor notifications to await 2972602 internal/lsp: correct links provided in critical error pop-ups e13398c internal/lsp: display current diagnostics in the debug server cf1022a gopls: factor out advanced documentation from the README 87bc10f gopls: mention workspaces and build systems in the README ce34e26 internal/lsp: don't show context cancellation in the progress bar bec622c gopls: merge README and user.md 7e51fbd gopls/internal/regtest: re-enable android builder Change-Id: I0e262f49306c7b44d89d994dfa89659fe04b6724
2 parents 84af7dd + 9b8df07 commit 4d4ee95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1193
-1013
lines changed

go/analysis/passes/fieldalignment/fieldalignment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func fieldalignment(pass *analysis.Pass, node *ast.StructType, typ *types.Struct
7979
// TODO: Preserve comment, for now get rid of them.
8080
// See https://github.com/golang/go/issues/20744
8181
f.Comment = nil
82+
f.Doc = nil
8283
if len(f.Names) <= 1 {
8384
flat = append(flat, f)
8485
continue

go/analysis/passes/fieldalignment/testdata/src/a/a.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,12 @@ type NoNameBad struct { // want "struct of size 20 could be 16"
3535
y int32
3636
z byte
3737
}
38+
39+
type WithComments struct { // want "struct of size 8 could be 4"
40+
// doc style comment
41+
a uint32 // field a comment
42+
b [0]byte // field b comment
43+
// other doc style comment
44+
45+
// and a last comment
46+
}

go/analysis/passes/fieldalignment/testdata/src/a/a.go.golden

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ type NoNameBad struct {
3535
x byte
3636
z byte
3737
}
38+
39+
type WithComments struct {
40+
b [0]byte
41+
a uint32
42+
}

go/packages/golist.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"encoding/json"
1111
"fmt"
1212
"go/types"
13-
exec "golang.org/x/sys/execabs"
1413
"io/ioutil"
1514
"log"
1615
"os"
@@ -23,6 +22,7 @@ import (
2322
"sync"
2423
"unicode"
2524

25+
exec "golang.org/x/sys/execabs"
2626
"golang.org/x/tools/go/internal/packagesdriver"
2727
"golang.org/x/tools/internal/gocommand"
2828
"golang.org/x/xerrors"
@@ -865,7 +865,7 @@ func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer,
865865
if gocmdRunner == nil {
866866
gocmdRunner = &gocommand.Runner{}
867867
}
868-
stdout, stderr, _, err := gocmdRunner.RunRaw(cfg.Context, inv)
868+
stdout, stderr, friendlyErr, err := gocmdRunner.RunRaw(cfg.Context, inv)
869869
if err != nil {
870870
// Check for 'go' executable not being found.
871871
if ee, ok := err.(*exec.Error); ok && ee.Err == exec.ErrNotFound {
@@ -886,7 +886,7 @@ func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer,
886886

887887
// Related to #24854
888888
if len(stderr.String()) > 0 && strings.Contains(stderr.String(), "unexpected directory layout") {
889-
return nil, fmt.Errorf("%s", stderr.String())
889+
return nil, friendlyErr
890890
}
891891

892892
// Is there an error running the C compiler in cgo? This will be reported in the "Error" field
@@ -999,7 +999,7 @@ func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer,
999999
// TODO(matloob): Remove these once we can depend on go list to exit with a zero status with -e even when
10001000
// packages don't exist or a build fails.
10011001
if !usesExportData(cfg) && !containsGoFile(args) {
1002-
return nil, fmt.Errorf("go %v: %s: %s", args, exitErr, stderr)
1002+
return nil, friendlyErr
10031003
}
10041004
}
10051005
return stdout, nil

gopls/README.md

Lines changed: 72 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,99 @@
1-
# gopls documentation
1+
# `gopls`, the Go language server
22

33
[![PkgGoDev](https://pkg.go.dev/badge/golang.org/x/tools/gopls)](https://pkg.go.dev/golang.org/x/tools/gopls)
44

5-
gopls (pronounced: "go please") is the official [language server] for the Go language.
5+
`gopls` (pronounced "Go please") is the official Go [language server] developed
6+
by the Go team. It provides IDE features to any [LSP]-compatible editor.
67

7-
## Status
8+
<!--TODO(rstambler): Add gifs here.-->
89

9-
It is currently in **alpha**, so it is **not stable**.
10+
You should not need to interact with `gopls` directly--it will be automatically
11+
integrated into your editor. The specific features and settings vary slightly
12+
by editor, so we recommend that you proceed to the [documentation for your
13+
editor](#editors) below.
1014

11-
You can see more information about the status of gopls and its supported features [here](doc/status.md).
15+
## Editors
1216

13-
## Roadmap
17+
To get started with `gopls`, install an LSP plugin in your editor of choice.
1418

15-
The current goal is a fully stable build with the existing feature set, aiming
16-
for the first half of 2020, with release candidates earlier in the year.
19+
* [VSCode](https://github.com/golang/vscode-go/blob/master/README.md)
20+
* [Vim / Neovim](doc/vim.md)
21+
* [Emacs](doc/emacs.md)
22+
* [Atom](https://github.com/MordFustang21/ide-gopls)
23+
* [Sublime Text](doc/subl.md)
24+
* [Acme](https://github.com/fhs/acme-lsp)
1725

18-
This will be the first build that we recommend people use, and will be tagged as the 1.0 version.
19-
You can see the set of things being worked on in the [1.0 milestone], in general
20-
we are focused on stability, specifically, making sure we have a reliable service that produces an experience in module mode that is not a retrograde step from the old tools in GOPATH mode.
26+
If you use `gopls` with an editor that is not on this list, please let us know
27+
by [filing an issue](#new-issue) or [modifying this documentation](doc/contributing.md).
2128

22-
There is also considerable effort being put into testing in order to make sure that we both have a stable service and also that we do not regress after launch.
29+
## Installation
2330

24-
While we may continue to accept contributions for new features, they may be turned off behind a configuration flag if they are not yet stable. See the [gopls unplanned] milestone for deprioritized features.
31+
For the most part, you should not need to install or update `gopls`. Your
32+
editor should handle that step for you.
2533

26-
This is just a milestone for gopls itself. We work with editor integrators to make sure they can use the latest builds of gopls, and will help them use the 1.0 version as soon as it is ready, but that does not imply anything about the stability, supported features or version of the plugins.
34+
If you do want to get the latest stable version of `gopls`, change to any
35+
directory that is both outside of your `GOPATH` and outside of a module (a temp
36+
directory is fine), and run:
2737

28-
## Using
38+
```sh
39+
GO111MODULE=on go get golang.org/x/tools/gopls@latest
40+
```
2941

30-
In general you should not need to know anything about gopls, it should be integrated into your editor for you.
42+
**NOTE**: Do not use the `-u` flag, as it will update your dependencies to
43+
incompatible versions.
3144

32-
To install for your specific editor you can follow the following instructions
45+
Learn more in the [advanced installation
46+
instructions](doc/advanced.md#installing-unreleased-versions).
3347

34-
* [VSCode](doc/vscode.md)
35-
* [Vim / Neovim](doc/vim.md)
36-
* [Emacs](doc/emacs.md)
37-
* [Acme](doc/acme.md)
38-
* [Sublime Text](doc/subl.md)
39-
* [Atom](doc/atom.md)
48+
## Setting up your workspace
49+
50+
`gopls` supports both Go module and GOPATH modes, but if you are working with
51+
multiple modules or uncommon project layouts, you will need to specifically
52+
configure your workspace. See the [Workspace document](doc/workspace.md) for
53+
information on supported workspace layouts.
54+
55+
## Configuration
56+
57+
You can configure `gopls` to change your editor experience or view additional
58+
debugging information. Configuration options will be made available by your
59+
editor, so see your [editor's instructions](#editors) for specific details. A
60+
full list of `gopls` settings can be found in the [Settings documentation](doc/settings.md).
4061

41-
See the [user guide](doc/user.md) for more information, including the how to install gopls by hand if you need.
62+
### Environment variables
4263

43-
## Issues
64+
`gopls` inherits your editor's environment, so be aware of any environment
65+
variables you configure. Some editors, such as VS Code, allow users to
66+
selectively override the values of some environment variables.
4467

45-
If you are having issues with gopls, please first check the [known issues](doc/status.md#known-issues) before following the [troubleshooting](doc/troubleshooting.md#steps) guide.
46-
If that does not give you the information you need, reach out to us.
68+
## Troubleshooting
4769

48-
You can chat with us on:
49-
* the golang-tools [mailing list]
50-
* the #gopls [slack channel] on the gophers slack
70+
If you are having issues with `gopls`, please follow the steps described in the
71+
[troubleshooting guide](doc/troubleshooting.md).
5172

52-
If you think you have an issue that needs fixing, or a feature suggestion, then please make sure you follow the steps to [file an issue](doc/troubleshooting.md#file-an-issue) with the right information to allow us to address it.
73+
## Supported Go versions and build systems
5374

54-
If you need to talk to us directly (for instance to file an issue with confidential information in it) you can reach out directly to [@stamblerre] or [@ianthehat].
75+
`gopls` follows the
76+
[Go Release Policy](https://golang.org/doc/devel/release.html#policy),
77+
meaning that it officially supports the last 2 major Go releases. Though we
78+
try not to break older versions, we do not prioritize issues only affecting
79+
legacy Go releases.
5580

56-
## More information
81+
`gopls` currently only supports the `go` command, so if you are using a
82+
different build system, `gopls` will not work well. Bazel support is currently
83+
blocked on
84+
[bazelbuild/rules_go#512](https://github.com/bazelbuild/rules_go/issues/512).
5785

58-
If you want to know more about it, have an unusual use case, or want to contribute, please read the following documents
86+
## Additional information
5987

60-
* [Using gopls](doc/user.md)
61-
* [Troubleshooting and reporting issues](doc/troubleshooting.md)
62-
* [Integrating gopls with an editor](doc/integrating.md)
63-
* [Contributing to gopls](doc/contributing.md)
64-
* [Design requirements and decisions](doc/design.md)
65-
* [Implementation details](doc/implementation.md)
88+
* [Features](doc/features.md)
89+
* [Command-line interface](doc/command-line.md)
90+
* [Advanced topics](doc/advanced.md)
91+
* [Contributing to `gopls`](doc/contributing.md)
92+
* [Integrating `gopls` with an editor](doc/design/integrating.md)
93+
* [Design requirements and decisions](doc/design/design.md)
94+
* [Implementation details](doc/design/implementation.md)
95+
* [Open issues](https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+label%3Agopls)
6696

6797
[language server]: https://langserver.org
68-
[mailing list]: https://groups.google.com/forum/#!forum/golang-tools
69-
[slack channel]: https://gophers.slack.com/messages/CJZH85XCZ
70-
[@stamblerre]: https://github.com/stamblerre "Rebecca Stambler"
71-
[@ianthehat]: https://github.com/ianthehat "Ian Cottrell"
72-
[1.0 milestone]: https://github.com/golang/go/milestone/112
73-
[gopls unplanned]: https://github.com/golang/go/milestone/124
98+
[LSP]: https://microsoft.github.io/language-server-protocol/
99+
[Gophers Slack]: https://gophers.slack.com/

gopls/doc/acme.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

gopls/doc/advanced.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Advanced topics
2+
3+
This documentation is for advanced `gopls` users, who may want to test
4+
unreleased versions or try out special features.
5+
6+
## Installing unreleased versions
7+
8+
To get a specific version of `gopls` (for example, to test a prerelease
9+
version), run:
10+
11+
```sh
12+
GO111MODULE=on go get golang.org/x/tools/[email protected]
13+
```
14+
15+
Where `vX.Y.Z` is the desired version.
16+
17+
### Unstable versions
18+
19+
To update `gopls` to the latest **unstable** version, use:
20+
21+
```sh
22+
GO111MODULE=on go get golang.org/x/tools/gopls@master golang.org/x/tools@master
23+
```
24+
25+
## Working on the Go source distribution
26+
27+
If you are working on the [Go project] itself, the `go` command that `gopls`
28+
invokes will have to correspond to the version of the source you are working
29+
on. That is, if you have checked out the Go project to `$HOME/go`, your `go`
30+
command should be the `$HOME/go/bin/go` executable that you built with
31+
`make.bash` or equivalent.
32+
33+
You can achieve this by adding the right version of `go` to your `PATH`
34+
(`export PATH=$HOME/go/bin:$PATH` on Unix systems) or by configuring your
35+
editor.
36+
37+
[Go project]: https://go.googlesource.com/go

gopls/doc/atom.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

gopls/doc/commands.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ Identifier: `gopls.go_get_package`
5353
go_get_package runs `go get` to fetch a package.
5454

5555

56+
### **Check for upgrades**
57+
Identifier: `gopls.check_upgrades`
58+
59+
check_upgrades checks for module upgrades.
60+
61+
5662
### **Add dependency**
5763
Identifier: `gopls.add_dependency`
5864

gopls/doc/contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Documentation for contributors
22

33
This documentation augments the general documentation for contributing to the
4-
x/tools repository, described at the [repository root](../CONTRIBUTING.md).
4+
x/tools repository, described at the [repository root](../../CONTRIBUTING.md).
55

66
Contributions are welcome, but since development is so active, we request that
77
you file an issue and claim it before starting to work on something. Otherwise,
@@ -96,7 +96,7 @@ Furthermore, an additional "gopls-CI" pass will be run by _Kokoro_, which is a
9696
Jenkins-like Google infrastructure for running Dockerized tests. This allows us
9797
to run gopls tests in various environments that would be difficult to add to
9898
the TryBots. Notably, Kokoro runs tests on
99-
[older Go versions](user.md#supported-go-versions) that are no longer supported
99+
[older Go versions](../README.md#supported-go-versions) that are no longer supported
100100
by the TryBots.
101101

102102
## Debugging

0 commit comments

Comments
 (0)