Skip to content

x/tools/gopls: add a regression test for adding a new function to a replace target #40712

Open
@segevfiner

Description

@segevfiner

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

$ go version
go version go1.14.7 darwin/amd64
# gopls version
golang.org/x/tools/gopls 0.4.4
    golang.org/x/tools/gopls@v0.4.4 h1:8djGYsaZ0ByP0vaXg4T+mnyfDcHpWKSZ+tpQSGv9ahk=

VS Code version v1.47.3
vscode-go v0.16.1

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/segev/Library/Caches/go-build"
GOENV="/Users/segev/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/segev/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.7/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/b_/c6yh0ksn63d1yy192x2p9f4c0000gn/T/go-build425202633=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Create two new packages using Go modules:
    mkdir foo && cd foo
    go mod init github.com/segevfiner/foo
    cd ..
    mkdir bar && cd bar
    go mod init github.com/segevfiner/bar
    cd ..
  2. Open VS Code with vscode-go installed and gopls enabled: code foo bar
  3. Add replace github.com/segevfiner/bar => ../bar to module foo's go.mod.
  4. Add to module foo as main.go:
    package main
    
    func main() {
    
    }
  5. Add to module bar as bar1.go:
    package bar
    
    func Bar1() {
    
    }
  6. Try to add foo.Bar1() to foo's main.go, it would work and also auto complete it. (Might need to manually add the import statement)
  7. Add to module bar as bar2.go:
    package bar
    
    func Bar2() {
    
    }
  8. Try to add foo.Bar2() to foo's main.go, it would not autocomplete and will fail to compile until you restart the language server.

What did you expect to see?

Adding new files to replaced packages should work seamlessly, auto-completing, compiling correctly, without requiring a restart of the language server.

What did you see instead?

It fails to auto-complete, compile etc. (While working correctly with go build) until you restart the language server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TestingAn issue that has been verified to require only test changes, not just a test failure.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/workspaceIssues related to support for modules or multi-module workspaces.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions