Skip to content

x/tools/gopls: defining the workspace root #36899

@stamblerre

Description

@stamblerre

gopls supports both module and GOPATH modes. However, we need to define a scope in which language features like references, rename, and implementation should operate. The following is subject to, and will likely, change.

For now, we have the following cases:

Module mode

Supported

  • Open workspace at the module root (directory containing the go.mod file). The scope is the entire module.
  • Open a subdirectory of a module. The scope is the subdirectory that has been opened.

Unsupported

  • Open a directory that contains a module in a subdirectory. gopls will not work in this case.

GOPATH mode

Supported

  • Open a directory inside of your GOPATH. The scope is the open directory.

At your own risk

  • Open your entire GOPATH. The workspace scope will be your entire GOPATH. Note that this will cause gopls to load your entire GOPATH. If your GOPATH is large, this will take a long time and cause gopls to be very slow.

To work around this case, you can create a new GOPATH that contains only the packages you want to work on.

Unsupported

  • Open a directory containing your GOPATH. Similar to the case above, this will cause gopls to treat your entire GOPATH as the workspace scope. It will be very slow to start because it will try to find all of the Go files in the directory you have opened. It will then load all of the files it has found.

We are working on addressing all of these cases and improving the behavior of gopls in the unsupported cases. All of these cases will be supported once gopls reaches v1.0.0.

We understand it may be inconvenient to change your typical workflow to accommodate frequent changes in gopls. In this case, it may be easier to stick with a version of gopls that works for you (gopls/v0.2.2, for instance), or if you are using GOPATH, gopls may not be the best tool to use until it reaches v1.0.0.

If you have additional use cases that are not mentioned above, please comment below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions