Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: support multiple local values in the local prefix setting #44027

Open
bravoecho opened this issue Jan 31, 2021 · 1 comment
Open

x/tools/gopls: support multiple local values in the local prefix setting #44027

bravoecho opened this issue Jan 31, 2021 · 1 comment

Comments

@bravoecho
Copy link

@bravoecho bravoecho commented Jan 31, 2021

The goimports tool allows to specify the -local option multiple times. gopls imports has a local option to reproduce that, but it only seems to work for a single prefix (gopls docs)

Everything works as expected when only one prefix is specified.

What version of Go are you using (go version)?

$ go version
go version go1.15.7 darwin/amd64
$ gopls version
golang.org/x/tools/gopls v0.6.4
    golang.org/x/tools/gopls@v0.6.4 h1:PO8rURGmi+QEKZ3pk+ZXJh51EFTVTSXqxzoRzrGSTJM=

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/luca.belmondo/Library/Caches/go-build"
GOENV="/Users/luca.belmondo/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/luca.belmondo/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/luca.belmondo/go"
GOPRIVATE=""
GOPROXY="athens.glintpay.com"
GOROOT="/usr/local/Cellar/go/1.15.7_1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.7_1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/luca.belmondo/projects/svc/adjust-events/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/7l/jq5b64g946n0lxq82d8x32tryf6wnc/T/go-build147895208=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

In Vim, using the vim-go plugin, and setting the following options:

let g:go_fmt_command = 'gopls'
let g:go_imports_mode = 'gopls'
let g:go_gopls_gofumpt = v:true
let g:go_imports_autosave = 1
let g:go_gopls_local = 'acme.com,foobar.org'

What did you expect to see?

After saving any .go file:

import (
  "net"

  "google.golang.org/grpc"

  "acme.com/lib1"
  "acme.com/lib2"
  "foobar.org/lib1"
  "foobar.org/lib2"
)

What did you see instead?

import (
  "net"

  "acme.com/lib1"
  "acme.com/lib2"
  "foobar.org/lib1"
  "foobar.org/lib2"
  "google.golang.org/grpc"
)
@gopherbot gopherbot added this to the Unreleased milestone Jan 31, 2021
@stamblerre stamblerre changed the title x/tools/gopls: Multiple locals for imports x/tools/gopls: support multiple local values in the local prefix setting Feb 2, 2021
@stamblerre stamblerre removed this from the Unreleased milestone Feb 2, 2021
@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Feb 2, 2021
@heschi
Copy link
Contributor

@heschi heschi commented Feb 2, 2021

goimports may allow you to specify the -local flag, but as far as I know, later values override, not add to, earlier values. The value of the flag is a comma separated list in both goimports and gopls. The gopls documentation should be updated.

@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Feb 2, 2021
@stamblerre stamblerre added this to the gopls/v0.6.6 milestone Feb 2, 2021
@stamblerre stamblerre removed this from the gopls/v0.6.6 milestone Feb 17, 2021
@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Feb 17, 2021
@stamblerre stamblerre added this to To Do in gopls on-deck Feb 28, 2021
@stamblerre stamblerre removed this from To Do in gopls on-deck Jun 28, 2021
@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Jun 28, 2021
@stamblerre stamblerre added this to the gopls/unplanned milestone Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants