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: diagnostics from modules outside go.work stick around #48929

Closed
hyangah opened this issue Oct 12, 2021 · 3 comments
Closed

x/tools/gopls: diagnostics from modules outside go.work stick around #48929

hyangah opened this issue Oct 12, 2021 · 3 comments
Assignees
Labels
gopls Tools
Milestone

Comments

@hyangah
Copy link
Contributor

@hyangah hyangah commented Oct 12, 2021

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

$ go version
go version devel go1.18-577bb7dba1 Mon Oct 11 17:02:03 2021 +0000 darwin/amd64

$ go version -m gopls
/Users/hakim/go/bin/gopls: devel go1.18-577bb7dba1 Mon Oct 11 17:02:03 2021 +0000
        path    golang.org/x/tools/gopls
        mod     golang.org/x/tools/gopls        v0.7.2  h1:kRKKdvA8GOzra8rhSFDClOR7hV/x8v0J0Vm4C/gWq8s=
        dep     github.com/BurntSushi/toml      v0.4.1  h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
        dep     github.com/google/go-cmp        v0.5.6  h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
        dep     github.com/sergi/go-diff        v1.1.0  h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
        dep     golang.org/x/mod        v0.4.2  h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
        dep     golang.org/x/sync       v0.0.0-20210220032951-036812b2e83c      h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
        dep     golang.org/x/sys        v0.0.0-20210809222454-d867a43fc93e      h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
        dep     golang.org/x/tools      v0.1.6-0.20210908190839-cf92b39a962c    h1:C0nyHiBU2m0cR6hDiUORWqQIt3h37wsp1255QBSSXqY=
        dep     golang.org/x/xerrors    v0.0.0-20200804184101-5ec99f83aff1      h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
        dep     honnef.co/go/tools      v0.2.0  h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
        dep     mvdan.cc/gofumpt        v0.1.1  h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
        dep     mvdan.cc/xurls/v2       v2.3.0  h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=

gopls settings: default

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

go env Output
$ 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/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/hakim/sdk/gotip/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.18-577bb7dba1 Mon Oct 11 17:02:03 2021 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/go-build4178452320=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

--- go.work ---
go 1.18

directory (
        ./b
)
--- a/go.mod ---
module a

go 1.17
--- a/main.go ---
package main

func main() {
   var V string
}
--- b/go.mod ---
module b

go 1.17
--- b/main.go ---
package b

import (
        _ "fmt"
)

Note that go.work includes only b module, and a/main.go has an error (V unused).
Open the editor from the top directory.

Then, open a/main.go, observe gopls finds the error, and later close a/main.go.

What did you expect to see?

Diagnostics that appear in a/main.go (single file mode?) disappear when I close a/main.go.

What did you see instead?

The diagnostics remain forever until I restart gopls.

[Trace - 16:40:40.955 PM] Sending request 'initialize - (0)'.
Params: {"processId":26087,"clientInfo":{"name":"Visual Studio Code","version":"1.61.0"},"locale":"en-us","rootPath":"/Users/hakim/report","rootUri":"file:///Users/hakim/report","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true,"semanticTokens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"didRename":true,"didDelete":true,"willCreate":true,"willRename":true,"willDelete":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertTextModeSupport":{"valueSet":[1,2]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]},"labelSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"disabledSupport":true,"dataSupport":true,"resolveSupport":{"properties":["edit"]},"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"honorsChangeAnnotations":false},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1,"honorsChangeAnnotations":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats":["relative"],"requests":{"range":true,"full":{"delta":true}},"multilineTokenSupport":false,"overlappingTokenSupport":false},"linkedEditingRange":{"dynamicRegistration":true}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"showDocument":{"support":true},"workDoneProgress":true},"general":{"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"markdown":{"parser":"marked","version":"1.1.0"}}},"initializationOptions":{},"trace":"off","workspaceFolders":[{"uri":"file:///Users/hakim/report","name":"report"}]}

[Trace - 16:40:40.958 PM] Received response 'initialize - (0)' in 3ms.
Result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."],"completionItem":{}},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor.extract","refactor.rewrite","source.fixAll","source.organizeImports"]},"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":{"prepareProvider":true},"foldingRangeProvider":true,"executeCommandProvider":{"commands":["gopls.add_dependency","gopls.add_import","gopls.apply_fix","gopls.check_upgrades","gopls.gc_details","gopls.generate","gopls.generate_gopls_mod","gopls.go_get_package","gopls.list_known_packages","gopls.regenerate_cgo","gopls.remove_dependency","gopls.run_tests","gopls.start_debugging","gopls.test","gopls.tidy","gopls.toggle_gc_details","gopls.update_go_sum","gopls.upgrade_dependency","gopls.vendor","gopls.workspace_metadata"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"{"path":"golang.org/x/tools/gopls","version":"v0.7.2","sum":"h1:kRKKdvA8GOzra8rhSFDClOR7hV/x8v0J0Vm4C/gWq8s=","deps":[{"path":"github.com/BurntSushi/toml","version":"v0.4.1","sum":"h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw="},{"path":"github.com/google/go-cmp","version":"v0.5.6","sum":"h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ="},{"path":"github.com/sergi/go-diff","version":"v1.1.0","sum":"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0="},{"path":"golang.org/x/mod","version":"v0.4.2","sum":"h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo="},{"path":"golang.org/x/sync","version":"v0.0.0-20210220032951-036812b2e83c","sum":"h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ="},{"path":"golang.org/x/sys","version":"v0.0.0-20210809222454-d867a43fc93e","sum":"h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA="},{"path":"golang.org/x/tools","version":"v0.1.6-0.20210908190839-cf92b39a962c","sum":"h1:C0nyHiBU2m0cR6hDiUORWqQIt3h37wsp1255QBSSXqY="},{"path":"golang.org/x/xerrors","version":"v0.0.0-20200804184101-5ec99f83aff1","sum":"h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE="},{"path":"honnef.co/go/tools","version":"v0.2.0","sum":"h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE="},{"path":"mvdan.cc/gofumpt","version":"v0.1.1","sum":"h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA="},{"path":"mvdan.cc/xurls/v2","version":"v2.3.0","sum":"h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I="}]}"}}

[Trace - 16:40:40.988 PM] Sending notification 'initialized'.
Params: {}

[Trace - 16:40:40.988 PM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}

[Trace - 16:40:40.990 PM] Sending response 'window/workDoneProgress/create - (1)' in 2ms.
Result:

[Trace - 16:40:40.990 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}

[Trace - 16:40:40.991 PM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///Users/hakim/report","section":"gopls"}]}

[Trace - 16:40:40.998 PM] Sending response 'workspace/configuration - (2)' in 7ms.
Result: [{}]

[Trace - 16:40:41.051 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/12 16:40:41 go env for /Users/hakim/report\n(root /Users/hakim/report)\n(go version go version devel go1.18-577bb7dba1 Mon Oct 11 17:02:03 2021 +0000 darwin/amd64)\n(valid build configuration = false)\n(build flags: [])\nGOSUMDB=sum.golang.org\nGOINSECURE=\nGOPATH=/Users/hakim/go\nGO111MODULE=\nGOMOD=/dev/null\nGOMODCACHE=/Users/hakim/go/pkg/mod\nGOROOT=/Users/hakim/sdk/gotip\nGOFLAGS=\nGOPRIVATE=\nGOPROXY=https://proxy.golang.org,direct\nGONOSUMDB=\nGOCACHE=/Users/hakim/Library/Caches/go-build\nGONOPROXY=\n\n"}

[Info - 4:40:41 PM] 2021/10/12 16:40:41 go env for /Users/hakim/report
(root /Users/hakim/report)
(go version go version devel go1.18-577bb7dba1 Mon Oct 11 17:02:03 2021 +0000 darwin/amd64)
(valid build configuration = false)
(build flags: [])
GOSUMDB=sum.golang.org
GOINSECURE=
GOPATH=/Users/hakim/go
GO111MODULE=
GOMOD=/dev/null
GOMODCACHE=/Users/hakim/go/pkg/mod
GOROOT=/Users/hakim/sdk/gotip
GOFLAGS=
GOPRIVATE=
GOPROXY=https://proxy.golang.org,direct
GONOSUMDB=
GOCACHE=/Users/hakim/Library/Caches/go-build
GONOPROXY=

[Trace - 16:40:41.067 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/12 16:40:41 go/packages.Load\n\tsnapshot=0\n\tdirectory=/Users/hakim/report\n\tquery=[./ builtin]\n\tpackages=2\n"}

[Trace - 16:40:41.067 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"end","message":"Finished loading packages."}}

[Trace - 16:40:41.068 PM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/*.*tmpl","kind":7},{"globPattern":"/*.{go,mod,sum,work,tmpl}","kind":7}]}}]}

[Trace - 16:40:41.113 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/12 16:40:41 go/packages.Load\n\tsnapshot=0\n\tdirectory=/Users/hakim/report\n\tquery=[./]\n\tpackages=1\n"}

[Info - 4:40:41 PM] 2021/10/12 16:40:41 go/packages.Load
snapshot=0
directory=/Users/hakim/report
query=[./ builtin]
packages=2

[Trace - 16:40:41.159 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/12 16:40:41 go/packages.Load\n\tsnapshot=0\n\tdirectory=/Users/hakim/report\n\tquery=[./]\n\tpackages=1\n"}

[Info - 4:40:41 PM] 2021/10/12 16:40:41 go/packages.Load
snapshot=0
directory=/Users/hakim/report
query=[./]
packages=1

[Info - 4:40:41 PM] 2021/10/12 16:40:41 go/packages.Load
snapshot=0
directory=/Users/hakim/report
query=[./]
packages=1

[Trace - 16:40:41.165 PM] Sending response 'client/registerCapability - (3)' in 96ms.
Result:

[Trace - 16:40:41.166 PM] Received request 'client/registerCapability - (4)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]}

[Trace - 16:40:41.175 PM] Sending response 'client/registerCapability - (4)' in 9ms.
Result:

[Trace - 16:40:41.196 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/12 16:40:41 go/packages.Load\n\tsnapshot=0\n\tdirectory=/Users/hakim/report\n\tquery=[./]\n\tpackages=1\n"}

[Info - 4:40:41 PM] 2021/10/12 16:40:41 go/packages.Load
snapshot=0
directory=/Users/hakim/report
query=[./]
packages=1

[Trace - 16:40:49.120 PM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go","languageId":"go","version":1,"text":"package main\n\nfunc main() {\n var V string\n}\n"}}

[Trace - 16:40:49.122 PM] Sending request 'textDocument/documentLink - (1)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go"}}

[Trace - 16:40:49.156 PM] Sending request 'textDocument/codeAction - (2)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"context":{"diagnostics":[]}}

[Trace - 16:40:49.160 PM] Sending notification '$/cancelRequest'.
Params: {"id":2}

[Trace - 16:40:49.160 PM] Sending request 'textDocument/codeAction - (3)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"context":{"diagnostics":[]}}

[Trace - 16:40:49.162 PM] Sending request 'textDocument/documentSymbol - (4)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go"}}

[Trace - 16:40:49.296 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/12 16:40:49 go/packages.Load\n\tsnapshot=1\n\tpackage="command-line-arguments"\n\tfiles=[/Users/hakim/report/a/main.go]\n"}

[Trace - 16:40:49.296 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/12 16:40:49 go/packages.Load\n\tsnapshot=1\n\tdirectory=/Users/hakim/report\n\tquery=[file=/Users/hakim/report/a/main.go]\n\tpackages=1\n"}

[Trace - 16:40:49.296 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/12 16:40:49 go/packages.Load\n\tsnapshot=1\n\tdirectory=/Users/hakim/report\n\tquery=[file=/Users/hakim/report/a/main.go]\n\tpackages=1\n"}

[Trace - 16:40:49.296 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/10/12 16:40:49 go/packages.Load\n\tsnapshot=1\n\tpackage="command-line-arguments"\n\tfiles=[/Users/hakim/report/a/main.go]\n"}

[Trace - 16:40:49.296 PM] Received response 'textDocument/documentLink - (1)' in 174ms.
Result: null

[Error - Received] 16:40:49.296 PM #2 JSON RPC cancelled

[Info - 4:40:49 PM] 2021/10/12 16:40:49 go/packages.Load
snapshot=1
package="command-line-arguments"
files=[/Users/hakim/report/a/main.go]

[Trace - 16:40:49.297 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/report/a/main.go","version":1,"diagnostics":[{"range":{"start":{"line":3,"character":7},"end":{"line":3,"character":8}},"severity":1,"code":"UnusedVar","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal?utm_source=gopls#UnusedVar"},"source":"compiler","message":"V declared but not used"}]}

[Trace - 16:40:49.297 PM] Received response 'textDocument/documentSymbol - (4)' in 135ms.
Result: [{"name":"main","detail":"()","kind":12,"range":{"start":{"line":2,"character":0},"end":{"line":4,"character":1}},"selectionRange":{"start":{"line":2,"character":5},"end":{"line":2,"character":9}}}]

[Trace - 16:40:49.298 PM] Received response 'textDocument/codeAction - (3)' in 137ms.
Result: null

[Info - 4:40:49 PM] 2021/10/12 16:40:49 go/packages.Load
snapshot=1
directory=/Users/hakim/report
query=[file=/Users/hakim/report/a/main.go]
packages=1

[Info - 4:40:49 PM] 2021/10/12 16:40:49 go/packages.Load
snapshot=1
directory=/Users/hakim/report
query=[file=/Users/hakim/report/a/main.go]
packages=1

[Info - 4:40:49 PM] 2021/10/12 16:40:49 go/packages.Load
snapshot=1
package="command-line-arguments"
files=[/Users/hakim/report/a/main.go]

[Trace - 16:40:49.350 PM] Sending request 'textDocument/foldingRange - (5)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go"}}

[Trace - 16:40:49.350 PM] Received response 'textDocument/foldingRange - (5)' in 0ms.
Result: [{"startLine":2,"startCharacter":13,"endLine":3,"endCharacter":15}]

[Trace - 16:40:49.370 PM] Sending request 'textDocument/codeLens - (6)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go"}}

[Trace - 16:40:49.371 PM] Received response 'textDocument/codeLens - (6)' in 0ms.
Result: null

[Trace - 16:40:49.550 PM] Received request 'window/workDoneProgress/create - (5)'.
Params: {"token":"8674665223082153551"}

[Trace - 16:40:49.550 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/10/12 16:40:49 errors loading workspace: gopls requires a module at the root of your workspace.\nYou can work with multiple modules by opening each one as a workspace folder.\nImprovements to this workflow will be coming soon, and you can learn more here:\nhttps://github.com/golang/tools/blob/master/gopls/doc/workspace.md.\n\tsnapshot=1\n\tdirectory=file:///Users/hakim/report\n"}

[Error - 4:40:49 PM] 2021/10/12 16:40:49 errors loading workspace: gopls requires a module at the root of your workspace.
You can work with multiple modules by opening each one as a workspace folder.
Improvements to this workflow will be coming soon, and you can learn more here:
https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.
snapshot=1
directory=file:///Users/hakim/report

[Trace - 16:40:49.550 PM] Sending response 'window/workDoneProgress/create - (5)' in 0ms.
Result:

[Trace - 16:40:49.551 PM] Received notification '$/progress'.
Params: {"token":"8674665223082153551","value":{"kind":"begin","title":"Error loading workspace","message":"gopls requires a module at the root of your workspace. You can work with multiple modules by opening each one as a workspace folder. Improvements to this workflow will be coming soon, and you can learn more here: https://github.com/golang/tools/blob/master/gopls/doc/workspace.md."}}

[Trace - 16:40:49.551 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/report/a/main.go","version":1,"diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":12}},"severity":1,"source":"go list","message":"gopls requires a module at the root of your workspace.\nYou can work with multiple modules by opening each one as a workspace folder.\nImprovements to this workflow will be coming soon, and you can learn more here:\nhttps://github.com/golang/tools/blob/master/gopls/doc/workspace.md."},{"range":{"start":{"line":3,"character":7},"end":{"line":3,"character":8}},"severity":1,"code":"UnusedVar","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal?utm_source=gopls#UnusedVar"},"source":"compiler","message":"V declared but not used"}]}

[Trace - 16:40:49.572 PM] Sending request 'textDocument/foldingRange - (7)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go"}}

[Trace - 16:40:49.572 PM] Received response 'textDocument/foldingRange - (7)' in 0ms.
Result: [{"startLine":2,"startCharacter":13,"endLine":3,"endCharacter":15}]

[Trace - 16:40:53.581 PM] Sending request 'textDocument/documentSymbol - (8)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go"}}

[Trace - 16:40:53.583 PM] Sending notification 'textDocument/didClose'.
Params: {"textDocument":{"uri":"file:///Users/hakim/report/a/main.go"}}

[Trace - 16:40:53.583 PM] Sending notification '$/cancelRequest'.
Params: {"id":8}

[Error - Received] 16:40:53.586 PM #8 JSON RPC cancelled

[Trace - 16:40:53.841 PM] Received notification '$/progress'.
Params: {"token":"8674665223082153551","value":{"kind":"report","message":"gopls requires a module at the root of your workspace. You can work with multiple modules by opening each one as a workspace folder. Improvements to this workflow will be coming soon, and you can learn more here: https://github.com/golang/tools/blob/master/gopls/doc/workspace.md."}}

[Trace - 16:40:53.842 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///Users/hakim/report/a/main.go","diagnostics":[{"range":{"start":{"line":3,"character":7},"end":{"line":3,"character":8}},"severity":1,"code":"UnusedVar","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal?utm_source=gopls#UnusedVar"},"source":"compiler","message":"V declared but not used"}]}

[Trace - 16:40:53.842 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/10/12 16:40:53 errors loading workspace: gopls requires a module at the root of your workspace.\nYou can work with multiple modules by opening each one as a workspace folder.\nImprovements to this workflow will be coming soon, and you can learn more here:\nhttps://github.com/golang/tools/blob/master/gopls/doc/workspace.md.\n\tsnapshot=2\n\tdirectory=file:///Users/hakim/report\n"}

[Error - 4:40:53 PM] 2021/10/12 16:40:53 errors loading workspace: gopls requires a module at the root of your workspace.
You can work with multiple modules by opening each one as a workspace folder.
Improvements to this workflow will be coming soon, and you can learn more here:
https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.
snapshot=2
directory=file:///Users/hakim/report

@gopherbot gopherbot added Tools gopls labels Oct 12, 2021
@gopherbot gopherbot added this to the Unreleased milestone Oct 12, 2021
@stamblerre stamblerre removed this from the Unreleased milestone Oct 12, 2021
@stamblerre stamblerre added this to the gopls/on-deck milestone Oct 12, 2021
@stamblerre stamblerre self-assigned this Oct 12, 2021
@stamblerre stamblerre removed their assignment Oct 19, 2021
@findleyr findleyr removed this from the gopls/on-deck milestone Jan 4, 2022
@findleyr findleyr added this to the gopls/v0.8.0 milestone Jan 4, 2022
@findleyr findleyr self-assigned this Jan 27, 2022
@findleyr
Copy link
Contributor

@findleyr findleyr commented Feb 28, 2022

I didn't get a chance to look into this for gopls@v0.8.0, unfortunately. Moving to v0.8.1.

@findleyr findleyr removed this from the gopls/v0.8.0 milestone Feb 28, 2022
@findleyr findleyr added this to the gopls/v0.8.1 milestone Feb 28, 2022
@findleyr findleyr removed this from the gopls/v0.8.1 milestone Mar 15, 2022
@findleyr findleyr added this to the gopls/v0.8.2 milestone Mar 15, 2022
@findleyr findleyr removed this from the gopls/v0.8.2 milestone Mar 31, 2022
@findleyr findleyr added this to the gopls/v0.8.3 milestone Mar 31, 2022
@findleyr findleyr removed this from the gopls/v0.8.3 milestone Apr 5, 2022
@findleyr findleyr added this to the gopls/v0.8.4 milestone Apr 5, 2022
@gopherbot
Copy link

@gopherbot gopherbot commented Apr 18, 2022

Change https://go.dev/cl/400822 mentions this issue: internal/lsp/cache: honor the go.work for computing workspace packages

@findleyr findleyr removed this from the gopls/v0.8.4 milestone May 18, 2022
@findleyr findleyr added this to the gopls/v0.9.0 milestone May 18, 2022
gopherbot pushed a commit to golang/tools that referenced this issue Jun 22, 2022
When using Go workspaces, the go.work file should be used to determine
which packages are workspace packages.

For golang/go#48929

Change-Id: I1a8753ab7887daf193e093fca5070b4cc250a245
Reviewed-on: https://go-review.googlesource.com/c/tools/+/400822
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
@findleyr
Copy link
Contributor

@findleyr findleyr commented Jun 24, 2022

This should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Tools
Projects
None yet
Development

No branches or pull requests

4 participants