-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.
Milestone
Description
gopls version
$ gopls -v version
Build info
----------
golang.org/x/tools/gopls (devel)
golang.org/x/tools/gopls@(devel)
github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
golang.org/x/mod@v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/sync@v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/telemetry@v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/tools@v0.17.0 => ../
golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
honnef.co/go/tools@v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: devel go1.23-daa58db486 Fri Feb 16 11:59:07 2024 +0000
go env
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/hakim/Library/Caches/go-build'
GOENV='/Users/hakim/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/hakim/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/hakim/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/hakim/go_tip/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN=''
GOTOOLDIR='/Users/hakim/go_tip/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='devel go1.23-b91bad7819 Mon Jan 29 19:39:24 2024 +0000'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/hakim/go_tip/go/src/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64
What did you do?
- Opened VS Code from
src
dir of the Go project. - Opened
src/cmd/go/internal/load/pkg.go
in the Go project. - Change one of the exported field name of
PackagePublic
(but, not update the references). For example,
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
index 1549800afb..f9cc8f599d 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
@@ -63,7 +63,7 @@ type PackagePublic struct {
Dir string `json:",omitempty"` // directory containing package sources
ImportPath string `json:",omitempty"` // import path of package in dir
ImportComment string `json:",omitempty"` // path in import comment on package statement
- Name string `json:",omitempty"` // package name
+ NameX string `json:",omitempty"` // package name
Doc string `json:",omitempty"` // package documentation string
Target string `json:",omitempty"` // installed target for this package (may be executable)
Shlib string `json:",omitempty"` // the shared library that contains this package (only set when -linkshared)
What did you see happen?
Expected gopls to detect build breakage ("has no field or method Name" error), across many packages.
What did you expect to see?
Gopls published diagnostics for some files and then soon empty diagnostics for all those files. This empty diagnostic message makes vscode (client) clears all diagnostics immediately.
Editor and settings
"gopls": {},
"go.languageServerFlags": [ "-rpc.trace" ]
Logs
[Info - 10:07:51 PM] 2024/02/19 22:07:51 go info for /Users/hakim/go_tip/go/src
(view type GoModView)
(root dir /Users/hakim/go_tip/go/src)
(go version go version devel go1.23-b91bad7819 Mon Jan 29 19:39:24 2024 +0000 darwin/amd64)
(build flags: [])
(go env: {GOOS:darwin GOARCH:amd64 GOCACHE:/Users/hakim/Library/Caches/go-build GOMODCACHE:/Users/hakim/go/pkg/mod GOPATH:/Users/hakim/go GOPRIVATE: GOFLAGS: GO111MODULE: GoVersion:23 GoVersionOutput:go version devel go1.23-b91bad7819 Mon Jan 29 19:39:24 2024 +0000 darwin/amd64
GOWORK: GOPACKAGESDRIVER:})
(env overlay: map[])
...
[Trace - 22:08:00.621 PM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"uri":"file:///Users/hakim/go_tip/go/src/cmd/go/internal/load/pkg.go","version":2},"contentChanges":[{"range":{"start":{"line":65,"character":5},"end":{"line":65,"character":5}},"rangeLength":0,"text":"X"}]}
...
[Trace - 22:08:00.676 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/go_tip/go/src/cmd/go/internal/load/godebug.go","diagnostics":[{"range":{"start":{"line":59,"character":6},"end":{"line":59,"character":10}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"}]}
[Trace - 22:08:00.676 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/go_tip/go/src/cmd/go/internal/load/pkg.go","version":2,"diagnostics":[{"range":{"start":{"line":399,"character":3},"end":{"line":399,"character":7}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":817,"character":6},"end":{"line":817,"character":10}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":1693,"character":61},"end":{"line":1693,"character":65}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":1802,"character":16},"end":{"line":1802,"character":20}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":1926,"character":7},"end":{"line":1926,"character":11}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":2034,"character":24},"end":{"line":2034,"character":28}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":2372,"character":7},"end":{"line":2372,"character":11}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":2961,"character":8},"end":{"line":2961,"character":12}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":3093,"character":9},"end":{"line":3093,"character":13}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"pkg.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":3093,"character":32},"end":{"line":3093,"character":36}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"pkg.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":3165,"character":7},"end":{"line":3165,"character":11}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"pkg.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":3167,"character":61},"end":{"line":3167,"character":65}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"pkg.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":3227,"character":8},"end":{"line":3227,"character":12}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"pkg.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":3237,"character":25},"end":{"line":3237,"character":29}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"pkg.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":3379,"character":7},"end":{"line":3379,"character":11}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"d.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":3497,"character":22},"end":{"line":3497,"character":26}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"}]}
[Trace - 22:08:00.676 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/go_tip/go/src/cmd/go/internal/load/test.go","diagnostics":[{"range":{"start":{"line":174,"character":32},"end":{"line":174,"character":36}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":230,"character":4},"end":{"line":230,"character":8}},"severity":1,"code":"MissingLitField","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingLitField"},"source":"compiler","message":"unknown field Name in struct literal of type PackagePublic"},{"range":{"start":{"line":230,"character":18},"end":{"line":230,"character":22}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":273,"character":3},"end":{"line":273,"character":7}},"severity":1,"code":"MissingLitField","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingLitField"},"source":"compiler","message":"unknown field Name in struct literal of type PackagePublic"},{"range":{"start":{"line":500,"character":7},"end":{"line":500,"character":11}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"p.Name undefined (type *Package has no field or method Name)"},{"range":{"start":{"line":684,"character":18},"end":{"line":684,"character":22}},"severity":1,"code":"MissingFieldOrMethod","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MissingFieldOrMethod"},"source":"compiler","message":"t.Package.Name undefined (type *Package has no field or method Name)"}]}
....
[Trace - 22:08:01.659 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/go_tip/go/src/cmd/go/internal/load/pkg.go","version":2,"diagnostics":[]}
[Trace - 22:08:01.659 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/go_tip/go/src/cmd/go/internal/load/godebug.go","diagnostics":[]}
[Trace - 22:08:01.659 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/go_tip/go/src/cmd/go/internal/load/test.go","diagnostics":[]}
And, the session info:
Session 1
From: [Cache 1](http://127.0.0.1:52081/cache/1)
Views
ID: 1
Type: GoModView
Root: file:///Users/hakim/go_tip/go/src
Folder: src:file:///Users/hakim/go_tip/go/src
ID: 2
Type: GoModView
Root: file:///Users/hakim/go_tip/go/src/cmd
Folder: src:file:///Users/hakim/go_tip/go/src
Overlays
[file:///Users/hakim/go_tip/go/src/cmd/go/internal/load/pkg.go](http://127.0.0.1:52081/file/1/099fab280c86b6e134a3bdd7366359e3b3372b5057354446bad0cb2f9c504df2)
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.