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: .go files starting with "_" can cause error #43517

Closed
martinrode opened this issue Jan 5, 2021 · 4 comments
Closed

x/tools/gopls: .go files starting with "_" can cause error #43517

martinrode opened this issue Jan 5, 2021 · 4 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@martinrode
Copy link

What version of Go, VS Code & VS Code Go extension are you using?

  • go version
 go version go1.15.6 darwin/amd64
  • gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.6.0
    golang.org/x/tools/gopls@v0.6.1 h1:vD171EDBkyUVyp9B45IYXklV/VEfbHgX0FKw0Q0dO30=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
    golang.org/x/sync@v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
    golang.org/x/tools@v0.0.0-20201217163546-c88dec5c6b05 h1:4hzTNH658xirWc4MvAx9HK2/2hY6z42i1+lRK8OzeJE=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.0.1-2020.1.6 h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc=
    mvdan.cc/gofumpt@v0.0.0-20200927160801-5bfeb2e70dd6 h1:z+/YqapuV7VZPvBb3GYmuEJbA88M3PFUxaHilHYVCpQ=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
- Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders
	Version: 1.52.1
Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523
Date: 2020-12-16T16:30:02.420Z
Electron: 9.3.5
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 20.1.0

go env

GO111MODULE="on"
GOARCH="amd64"
GOBIN="/Users/martin/go/bin"
GOCACHE="/Users/martin/Library/Caches/go-build"
GOENV="/Users/martin/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/martin/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/martin/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/martin/go/src/github.com/programmfabrik/fylr/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/4f/l31kb4n521d6g89qxrwcx69h0000gp/T/go-build409113686=/tmp/go-build -gno-record-gcc-switches -fno-common"

Share the Go related settings you have added/edited

    "go.vetOnSave": "off",
    "go.lintOnSave": "off",
    "go.delveConfig": {
        "useApiV1": false,
        "dlvLoadConfig": {
            "followPointers": true,
            "maxVariableRecurse": 3,
            "maxStringLen": 256,
            "maxArrayValues": 256,
            "maxStructFields": -1
        }
    },
    "go.languageServerExperimentalFeatures": {
    

        "diagnostics": true,
        "documentLink": true
    },
    "go.formatTool": "goimports",
    "go.buildOnSave": "workspace",
    "go.useLanguageServer": true

Describe the bug

In my project I have an obsolete "_claims.go" file which is not ignored by gopls, causing bugs:


[Error - 3:06:11 PM] 2021/01/05 15:06:11 no highlight: getting file for Highlight: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- github.com/olivere/elastic/v7 github.com/programmfabrik/fylr/internal/api/acl github.com/programmfabrik/fylr/internal/api/datamodel github.com/programmfabrik/fylr/internal/indexer github.com/programmfabrik/fylr/internal/api/file github.com/programmfabrik/fylr/internal/api/fcontext github.com/programmfabrik/fylr/internal/baseconfig github.com/programmfabrik/fylr/internal/api/facet golang.org/x/xerrors github.com/programmfabrik/fylr/internal/util/iso8601 github.com/programmfabrik/fylr/internal/api/mapping github.com/programmfabrik/fylr/internal/api/transition github.com/programmfabrik/fylr/internal/api/privatetag github.com/dgrijalva/jwt-go github.com/programmfabrik/fylr/internal/api/object/enumerate github.com/programmfabrik/fylr/internal/api/event github.com/programmfabrik/fylr/internal/api/settings]: exit status 1: go: updates to go.sum needed, disabled by -mod=readonly

	URI=file:///Users/martin/go/src/github.com/programmfabrik/fylr/internal/api/_session/_claims.go

[Error - 3:06:11 PM] Request textDocument/formatting failed.
  Message: 82:2: expected statement, found '.'
  Code: 0 
[Error - 3:06:11 PM] 2021/01/05 15:06:11 imports fixes: AllImportsFixes: /Users/martin/go/src/github.com/programmfabrik/fylr/internal/api/_session/_claims.go:82:2: expected statement, found '.'
	file="/Users/martin/go/src/github.com/programmfabrik/fylr/internal/api/_session/_claims.go"

if I comment the package "github.com/dgrijalva/jwt-go" in _claims.go gopls works again.

With this bug, none of the features like "Show all occurrences" work.

"gopls" should ignore all files starting with "_", the same as "go build" does.

@hyangah hyangah changed the title gopls: .go files starting with "_" can cause error x/tools/gopls: .go files starting with "_" can cause error Jan 5, 2021
@hyangah hyangah transferred this issue from golang/vscode-go Jan 5, 2021
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jan 5, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jan 5, 2021
@hyangah
Copy link
Contributor

hyangah commented Jan 5, 2021

@martinrode Thanks for the report.

@stamblerre According to https://tip.golang.org/cmd/go/#hdr-Package_lists_and_patterns, directory and file names beginning with "." or "_" should be ignored by the go tool.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/vscode-go Jan 5, 2021
@stamblerre stamblerre added this to Needs Triage in vscode-go: gopls by default via automation Jan 5, 2021
@stamblerre stamblerre moved this from Needs Triage to Critical in vscode-go: gopls by default Jan 6, 2021
@stamblerre stamblerre removed this from Critical in vscode-go: gopls by default Jan 6, 2021
@stamblerre stamblerre added this to To Do in gopls on-deck Feb 28, 2021
@breml
Copy link
Contributor

breml commented Apr 7, 2021

I hit this as well. I also tried to move my files into a folder testdata, which is ignored by the Go compiler as well, but gopls does still consider the files located in the testdata folder.

@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 9, 2021
@stamblerre
Copy link
Contributor

@breml: Do you mind opening a new issue with your gopls logs attached? Information on how to capture them can be found here.

The original issue is probably outdated, especially since the latest gopls version is v0.6.9.

gopls on-deck automation moved this from To Do to Done Apr 9, 2021
@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Apr 12, 2021
@breml
Copy link
Contributor

breml commented Apr 21, 2021

@stamblerre I was no longer able to reproduce the problem with gopls v0.6.10. I will open an issue, when I observe the problem again. Thanks anyway.

@golang golang locked and limited conversation to collaborators Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
No open projects
Development

No branches or pull requests

5 participants