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: unnecessary go.sum entries added after viewing Go files #61935

Closed
spencerschrock opened this issue Aug 10, 2023 · 9 comments
Closed
Labels
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.
Milestone

Comments

@spencerschrock
Copy link

What did you do?

  1. Open https://github.com/ossf/scorecard directory root in VSCode with the Go extension.
  2. View any .go file

What did you expect to see?

No changes to my go.sum file, as I haven't changed anything and the file was already go mod tidy'd

What did you see instead?

125 insertions to go.sum that disappear when I run go mod tidy.
Which is inconvenient when I try to change branches, as the uncommitted go.sum changes abort my checkout.

Build info

golang.org/x/tools/gopls v0.13.1
    golang.org/x/tools/gopls@v0.13.1 h1:Q0cfPbEG1WVfgxcRZ9uKTA6/ckIRNXx6Ym7KgT/VFE4=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
    golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/mod@v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
    golang.org/x/sync@v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
    golang.org/x/sys@v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
    golang.org/x/text@v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
    golang.org/x/tools@v0.11.2-0.20230801165449-23c7f589706c h1:YilyjKn3EDn6X+x+kP+4REeEtG3WeM52dJAr7AWzVrQ=
    golang.org/x/vuln@v0.0.0-20230110180137-6ad3e3d07815 h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU=
    honnef.co/go/tools@v0.4.2 h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=
    mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
    mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.21.0

Trace Output

Click to expand
[Trace - 10:00:25.787 AM] Sending request 'initialize - (0)'.
Params: {"processId":1252086,"clientInfo":{"name":"Visual Studio Code","version":"1.81.0"},"locale":"en","rootPath":"/tmp/scorecard","rootUri":"file:///tmp/scorecard","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"configuration":true,"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":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]},"resolveSupport":{"properties":["location.range"]}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"didChangeConfiguration":{"dynamicRegistration":true},"workspaceFolders":true,"semanticTokens":{"refreshSupport":true},"fileOperations":{"dynamicRegistration":true,"didCreate":true,"didRename":true,"didDelete":true,"willCreate":true,"willRename":true,"willDelete":true},"inlineValue":{"refreshSupport":true},"inlayHint":{"refreshSupport":true},"diagnostics":{"refreshSupport":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]},"labelDetailsSupport":true},"insertTextMode":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]},"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode"]}},"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,"foldingRangeKind":{"valueSet":["comment","imports","region"]},"foldingRange":{"collapsedText":false}},"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","decorator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats":["relative"],"requests":{"range":true,"full":{"delta":true}},"multilineTokenSupport":false,"overlappingTokenSupport":false,"serverCancelSupport":true,"augmentsSyntaxTokens":true},"linkedEditingRange":{"dynamicRegistration":true},"typeHierarchy":{"dynamicRegistration":true},"inlineValue":{"dynamicRegistration":true},"inlayHint":{"dynamicRegistration":true,"resolveSupport":{"properties":["tooltip","textEdits","label.tooltip","label.location","label.command"]}},"diagnostic":{"dynamicRegistration":true,"relatedDocumentSupport":false}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"showDocument":{"support":true},"workDoneProgress":true},"general":{"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]},"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"markdown":{"parser":"marked","version":"1.1.0"},"positionEncodings":["utf-16"]},"notebookDocument":{"synchronization":{"dynamicRegistration":true,"executionSummarySupport":true}}},"initializationOptions":{"ui.semanticTokens":true,"ui.inlayhint.hints":{"assignVariableTypes":false,"compositeLiteralFields":false,"compositeLiteralTypes":false,"constantValues":false,"functionTypeParameters":false,"parameterNames":false,"rangeVariableTypes":false},"ui.vulncheck":"Off"},"trace":"off","workspaceFolders":[{"uri":"file:///tmp/scorecard","name":"scorecard"}]}

[Trace - 10:00:25.791 AM] Received response 'initialize - (0)' in 3ms.
Result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."]},"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,"renameProvider":{"prepareProvider":true},"foldingRangeProvider":true,"selectionRangeProvider":true,"executeCommandProvider":{"commands":["gopls.add_dependency","gopls.add_import","gopls.apply_fix","gopls.check_upgrades","gopls.edit_go_directive","gopls.fetch_vulncheck_result","gopls.gc_details","gopls.generate","gopls.go_get_package","gopls.list_imports","gopls.list_known_packages","gopls.mem_stats","gopls.regenerate_cgo","gopls.remove_dependency","gopls.reset_go_mod_diagnostics","gopls.run_go_work_command","gopls.run_govulncheck","gopls.run_tests","gopls.start_debugging","gopls.start_profile","gopls.stop_profile","gopls.test","gopls.tidy","gopls.toggle_gc_details","gopls.update_go_sum","gopls.upgrade_dependency","gopls.vendor","gopls.workspace_stats"]},"callHierarchyProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"]},"range":true,"full":true},"inlayHintProvider":{},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"{"GoVersion":"go1.21.0","Path":"golang.org/x/tools/gopls","Main":{"Path":"golang.org/x/tools/gopls","Version":"v0.13.1","Sum":"h1:Q0cfPbEG1WVfgxcRZ9uKTA6/ckIRNXx6Ym7KgT/VFE4=","Replace":null},"Deps":[{"Path":"github.com/BurntSushi/toml","Version":"v1.2.1","Sum":"h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=","Replace":null},{"Path":"github.com/google/go-cmp","Version":"v0.5.9","Sum":"h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=","Replace":null},{"Path":"github.com/sergi/go-diff","Version":"v1.1.0","Sum":"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=","Replace":null},{"Path":"golang.org/x/exp","Version":"v0.0.0-20220722155223-a9213eeb770e","Sum":"h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=","Replace":null},{"Path":"golang.org/x/exp/typeparams","Version":"v0.0.0-20221212164502-fae10dda9338","Sum":"h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=","Replace":null},{"Path":"golang.org/x/mod","Version":"v0.12.0","Sum":"h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=","Replace":null},{"Path":"golang.org/x/sync","Version":"v0.3.0","Sum":"h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=","Replace":null},{"Path":"golang.org/x/sys","Version":"v0.10.0","Sum":"h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=","Replace":null},{"Path":"golang.org/x/text","Version":"v0.11.0","Sum":"h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=","Replace":null},{"Path":"golang.org/x/tools","Version":"v0.11.2-0.20230801165449-23c7f589706c","Sum":"h1:YilyjKn3EDn6X+x+kP+4REeEtG3WeM52dJAr7AWzVrQ=","Replace":null},{"Path":"golang.org/x/vuln","Version":"v0.0.0-20230110180137-6ad3e3d07815","Sum":"h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU=","Replace":null},{"Path":"honnef.co/go/tools","Version":"v0.4.2","Sum":"h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=","Replace":null},{"Path":"mvdan.cc/gofumpt","Version":"v0.4.0","Sum":"h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=","Replace":null},{"Path":"mvdan.cc/xurls/v2","Version":"v2.4.0","Sum":"h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=","Replace":null}],"Settings":[{"Key":"-buildmode","Value":"exe"},{"Key":"-compiler","Value":"gc"},{"Key":"DefaultGODEBUG","Value":"panicnil=1"},{"Key":"CGO_ENABLED","Value":"1"},{"Key":"CGO_CFLAGS","Value":""},{"Key":"CGO_CPPFLAGS","Value":""},{"Key":"CGO_CXXFLAGS","Value":""},{"Key":"CGO_LDFLAGS","Value":""},{"Key":"GOARCH","Value":"amd64"},{"Key":"GOOS","Value":"linux"},{"Key":"GOAMD64","Value":"v1"}],"Version":"v0.13.1"}"}}

[Trace - 10:00:25.798 AM] Sending notification 'initialized'.
Params: {}

[Trace - 10:00:25.799 AM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"6325380323204672475"}

[Trace - 10:00:25.864 AM] Sending response 'window/workDoneProgress/create - (1)' in 65ms.
Result:

[Trace - 10:00:25.864 AM] Received notification '$/progress'.
Params: {"token":"6325380323204672475","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}

[Trace - 10:00:25.864 AM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///tmp/scorecard","section":"gopls"}]}

[Trace - 10:00:25.869 AM] Sending response 'workspace/configuration - (2)' in 4ms.
Result: [{"ui.semanticTokens":true,"ui.inlayhint.hints":{"assignVariableTypes":false,"compositeLiteralFields":false,"compositeLiteralTypes":false,"constantValues":false,"functionTypeParameters":false,"parameterNames":false,"rangeVariableTypes":false},"ui.vulncheck":"Off"}]

[Trace - 10:00:25.924 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:00:25 go info for /tmp/scorecard\n(go dir /tmp/scorecard)\n(go version go version go1.21.0 linux/amd64)\n(valid build configuration = true)\n(build flags: [])\n(selected go env: [GO111MODULE=on, GOCACHE=/usr/local/google/home/sschrock/.cache/go-build, GOFLAGS=-mod=mod, GOMODCACHE=/usr/local/google/home/sschrock/go/pkg/mod, GOPATH=/usr/local/google/home/sschrock/go, GOPRIVATE=, GOROOT=/usr/local/google/home/sschrock/sdk/go1.21.0, GOWORK=])\n\n"}

[Trace - 10:00:26.767 AM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go","languageId":"go","version":1,"text":"// Copyright 2020 OpenSSF Scorecard Authors\n//\n// Licensed under the Apache License, Version 2.0 (the "License");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an "AS IS" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Package main of OSSF Scoreard.\npackage main\n\nimport (\n\t"log"\n\n\t"github.com/ossf/scorecard/v4/cmd"\n\t"github.com/ossf/scorecard/v4/options"\n)\n\nfunc main() {\n\topts := options.New()\n\tif err := cmd.New(opts).Execute(); err != nil {\n\t\tlog.Fatalf("error during command execution: %v", err)\n\t}\n}\n"}}

[Trace - 10:00:26.768 AM] Sending request 'textDocument/documentSymbol - (1)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"}}

[Trace - 10:00:26.768 AM] Sending request 'textDocument/semanticTokens/full - (2)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"}}

[Trace - 10:00:26.768 AM] Sending request 'textDocument/codeAction - (3)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"context":{"diagnostics":[],"triggerKind":2}}

[Trace - 10:00:26.772 AM] Sending request 'textDocument/documentLink - (4)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"}}

[Trace - 10:00:26.774 AM] Sending request 'textDocument/inlayHint - (5)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":30,"character":0}}}

[Trace - 10:00:26.882 AM] Sending request 'textDocument/semanticTokens/range - (6)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":30,"character":0}}}

[Trace - 10:00:27.016 AM] Sending notification '$/cancelRequest'.
Params: {"id":3}

[Trace - 10:00:27.017 AM] Sending request 'textDocument/codeAction - (7)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"},"range":{"start":{"line":17,"character":8},"end":{"line":17,"character":8}},"context":{"diagnostics":[],"triggerKind":2}}

[Trace - 10:00:27.058 AM] Sending request 'textDocument/foldingRange - (8)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"}}

[Trace - 10:00:27.109 AM] Sending request 'textDocument/codeLens - (9)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"}}

[Trace - 10:00:27.841 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:00:27 go/packages.Load #1\n\tsnapshot=0\n\tdirectory=file:///tmp/scorecard\n\tquery=[/tmp/scorecard/... builtin]\n\tpackages=170\n"}

[Trace - 10:00:27.870 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:00:27 go/packages.Load #1: updating metadata for 1389 packages\n"}

[Trace - 10:00:28.174 AM] Received notification '$/progress'.
Params: {"token":"6325380323204672475","value":{"kind":"end","message":"Finished loading packages."}}

[Trace - 10:00:28.186 AM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/tmp/scorecard/checks/evaluation/permissions","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/webhook","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/data/validate","kind":7},{"globPattern":"/tmp/scorecard/stats","kind":7},{"globPattern":"/tmp/scorecard/checks/evaluation","kind":7},{"globPattern":"/tmp/scorecard/dependencydiff","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/data","kind":7},{"globPattern":"/tmp/scorecard/docs/checks/internal","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/cii","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/shuffle","kind":7},{"globPattern":"/tmp/scorecard/clients/ossfuzz","kind":7},{"globPattern":"/tmp/scorecard/cmd/internal/scdiff/app/runner","kind":7},{"globPattern":"/tmp/scorecard/cron/config","kind":7},{"globPattern":"/tmp/scorecard/cmd/internal/nuget","kind":7},{"globPattern":"/tmp/scorecard/probes","kind":7},{"globPattern":"/tmp/scorecard/clients","kind":7},{"globPattern":"/tmp/scorecard/docs/checks","kind":7},{"globPattern":"/tmp/scorecard/cmd/internal","kind":7},{"globPattern":"/tmp/scorecard/cmd/internal/scdiff","kind":7},{"globPattern":"/tmp/scorecard/cron/internal","kind":7},{"globPattern":"/tmp/scorecard/clients/githubrepo/stats","kind":7},{"globPattern":"/tmp/scorecard/cron","kind":7},{"globPattern":"/tmp/scorecard/clients/localdir","kind":7},{"globPattern":"/tmp/scorecard/probes/internal","kind":7},{"globPattern":"/tmp/scorecard/probes/toolRenovateInstalled","kind":7},{"globPattern":"/tmp/scorecard/docs/checks/internal/validate","kind":7},{"globPattern":"/tmp/scorecard/probes/securityPolicyPresent","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/worker","kind":7},{"globPattern":"/tmp/scorecard/probes/securityPolicyContainsLinks","kind":7},{"globPattern":"/tmp/scorecard/cmd/internal/scdiff/app/format","kind":7},{"globPattern":"/tmp/scorecard/pkg","kind":7},{"globPattern":"/tmp/scorecard/rule","kind":7},{"globPattern":"/tmp/scorecard/clients/githubrepo/roundtripper/tokens/server","kind":7},{"globPattern":"/tmp/scorecard/docs","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/pubsub","kind":7},{"globPattern":"/tmp/scorecard/policy","kind":7},{"globPattern":"/tmp/scorecard/checks/raw","kind":7},{"globPattern":"/tmp/scorecard/cron/data","kind":7},{"globPattern":"/tmp/scorecard/probes/internal/utils","kind":7},{"globPattern":"/tmp/scorecard/attestor","kind":7},{"globPattern":"/tmp/scorecard/clients/mockclients","kind":7},{"globPattern":"/tmp/scorecard/cron/worker","kind":7},{"globPattern":"/tmp/scorecard/e2e","kind":7},{"globPattern":"/tmp/scorecard/clients/githubrepo/roundtripper","kind":7},{"globPattern":"/tmp/scorecard/checks","kind":7},{"globPattern":"/tmp/scorecard/log","kind":7},{"globPattern":"/tmp/scorecard/clients/githubrepo","kind":7},{"globPattern":"/tmp/scorecard/checks/raw/github","kind":7},{"globPattern":"/tmp/scorecard/finding/probe","kind":7},{"globPattern":"/tmp/scorecard/clients/githubrepo/roundtripper/tokens","kind":7},{"globPattern":"/tmp/scorecard/probes/securityPolicyContainsVulnerabilityDisclosure","kind":7},{"globPattern":"/tmp/scorecard/probes/toolPyUpInstalled","kind":7},{"globPattern":"/tmp/scorecard/cmd","kind":7},{"globPattern":"/tmp/scorecard/options","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/data/add","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/bq","kind":7},{"globPattern":"/tmp/scorecard/probes/toolSonatypeLiftInstalled","kind":7},{"globPattern":"/tmp/scorecard/clients/git","kind":7},{"globPattern":"/tmp/scorecard/remediation","kind":7},{"globPattern":"/tmp/scorecard/checks/fileparser","kind":7},{"globPattern":"/tmp/scorecard/attestor/policy","kind":7},{"globPattern":"/tmp/scorecard/cmd/internal/packagemanager","kind":7},{"globPattern":"/tmp/scorecard/attestor/command","kind":7},{"globPattern":"/tmp/scorecard/probes/zrunner","kind":7},{"globPattern":"/tmp/scorecard/docs/checks/internal/generate","kind":7},{"globPattern":"/tmp/scorecard/checker","kind":7},{"globPattern":"**/*.{go,mod,sum,work}","kind":7},{"globPattern":"/tmp/scorecard/cmd/internal/scdiff/app","kind":7},{"globPattern":"/tmp/scorecard/errors","kind":7},{"globPattern":"/tmp/scorecard/cron/monitoring","kind":7},{"globPattern":"/tmp/scorecard/finding","kind":7},{"globPattern":"/tmp/scorecard/probes/securityPolicyContainsText","kind":7},{"globPattern":"/tmp/scorecard/clients/gitlabrepo","kind":7},{"globPattern":"/tmp/scorecard/utests","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/controller","kind":7},{"globPattern":"/tmp/scorecard/probes/toolDependabotInstalled","kind":7},{"globPattern":"/tmp/scorecard/checks/raw/gitlab","kind":7},{"globPattern":"/tmp/scorecard/cron/internal/format","kind":7}]}}]}

[Trace - 10:00:28.193 AM] Sending response 'client/registerCapability - (3)' in 6ms.
Result:

[Trace - 10:00:28.193 AM] Received request 'client/registerCapability - (4)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"}]}

[Trace - 10:00:28.194 AM] Sending response 'client/registerCapability - (4)' in 0ms.
Result:

[Trace - 10:00:28.229 AM] Received response 'textDocument/documentSymbol - (1)' in 1461ms.
Result: [{"name":"main","detail":"func()","kind":12,"range":{"start":{"line":24,"character":0},"end":{"line":29,"character":1}},"selectionRange":{"start":{"line":24,"character":5},"end":{"line":24,"character":9}}}]

[Trace - 10:00:28.230 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///tmp/scorecard/main.go","diagnostics":[]}

[Trace - 10:00:28.617 AM] Received response 'textDocument/semanticTokens/full - (2)' in 1849ms.
Result: {"resultId":"2023-08-10 10:00:28.617664628 -0700 PDT m=+2.894252057","data":[0,0,43,17,0,1,0,2,17,0,1,0,66,17,0,1,0,67,17,0,1,0,42,17,0,1,0,2,17,0,1,0,50,17,0,1,0,2,17,0,1,0,70,17,0,1,0,68,17,0,1,0,75,17,0,1,0,70,17,0,1,0,33,17,0,2,0,33,17,0,1,0,7,15,0,0,8,4,0,0,2,0,6,15,0,1,2,3,0,0,2,31,3,0,0,1,31,7,0,0,3,0,4,15,0,0,5,4,12,2,1,1,4,8,2,0,5,2,21,0,0,3,7,0,0,0,8,3,12,0,1,1,2,15,0,0,3,3,8,2,0,4,2,21,0,0,3,3,0,0,0,4,3,12,0,0,4,4,8,0,0,6,7,12,0,0,11,3,8,0,0,4,2,21,0,0,3,3,8,516,1,2,3,0,0,0,4,6,12,0,0,7,36,18,0,0,38,3,8,0]}

[Error - Received] 10:00:28.618 AM #3 JSON RPC cancelled

[Trace - 10:00:28.619 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///tmp/scorecard/main.go","version":1,"diagnostics":[]}

[Trace - 10:00:28.623 AM] Received response 'textDocument/documentLink - (4)' in 1850ms.
Result: [{"range":{"start":{"line":18,"character":2},"end":{"line":18,"character":5}},"target":"https://pkg.go.dev/log"},{"range":{"start":{"line":20,"character":2},"end":{"line":20,"character":34}},"target":"https://pkg.go.dev/github.com/ossf/scorecard/v4/cmd"},{"range":{"start":{"line":21,"character":2},"end":{"line":21,"character":38}},"target":"https://pkg.go.dev/github.com/ossf/scorecard/v4/options"},{"range":{"start":{"line":6,"character":8},"end":{"line":6,"character":50}},"target":"http://www.apache.org/licenses/LICENSE-2.0"}]

[Trace - 10:00:28.623 AM] Received response 'textDocument/inlayHint - (5)' in 1849ms.
Result: null

[Trace - 10:00:28.624 AM] Received response 'textDocument/semanticTokens/range - (6)' in 1741ms.
Result: {"resultId":"2023-08-10 10:00:28.62410322 -0700 PDT m=+2.900690651","data":[0,0,43,17,0,1,0,2,17,0,1,0,66,17,0,1,0,67,17,0,1,0,42,17,0,1,0,2,17,0,1,0,50,17,0,1,0,2,17,0,1,0,70,17,0,1,0,68,17,0,1,0,75,17,0,1,0,70,17,0,1,0,33,17,0,2,0,33,17,0,1,0,7,15,0,0,8,4,0,0,2,0,6,15,0,1,2,3,0,0,2,31,3,0,0,1,31,7,0,0,3,0,4,15,0,0,5,4,12,2,1,1,4,8,2,0,5,2,21,0,0,3,7,0,0,0,8,3,12,0,1,1,2,15,0,0,3,3,8,2,0,4,2,21,0,0,3,3,0,0,0,4,3,12,0,0,4,4,8,0,0,6,7,12,0,0,11,3,8,0,0,4,2,21,0,0,3,3,8,516,1,2,3,0,0,0,4,6,12,0,0,7,36,18,0,0,38,3,8,0]}

[Trace - 10:00:29.072 AM] Received response 'textDocument/foldingRange - (8)' in 2013ms.
Result: [{"startLine":0,"startCharacter":43,"endLine":12,"endCharacter":33,"kind":"comment"},{"startLine":17,"startCharacter":8,"endLine":21,"endCharacter":39,"kind":"imports"},{"startLine":24,"startCharacter":13,"endLine":28,"endCharacter":2},{"startLine":26,"startCharacter":48,"endLine":27,"endCharacter":55}]

[Trace - 10:00:29.073 AM] Received response 'textDocument/codeLens - (9)' in 1963ms.
Result: null

[Trace - 10:00:29.073 AM] Received response 'textDocument/codeAction - (7)' in 2056ms.
Result: null

[Trace - 10:00:29.415 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///tmp/scorecard/go.sum","type":2}]}

[Trace - 10:00:32.761 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:00:32 go/packages.Load #2\n\tsnapshot=2\n\tdirectory=file:///tmp/scorecard\n\tquery=[/tmp/scorecard/... builtin]\n\tpackages=170\n"}

[Trace - 10:00:32.804 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:00:32 go/packages.Load #2: updating metadata for 1389 packages\n"}

[Trace - 10:00:33.245 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///tmp/scorecard/go.sum","diagnostics":[]}

[Trace - 10:00:55.874 AM] Sending request 'textDocument/codeLens - (10)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"}}

[Trace - 10:00:55.876 AM] Received response 'textDocument/codeLens - (10)' in 1ms.
Result: null

[Trace - 10:00:56.233 AM] Sending request 'textDocument/hover - (11)'.
Params: {"textDocument":{"uri":"file:///tmp/scorecard/main.go"},"position":{"line":20,"character":16}}

[Trace - 10:00:56.247 AM] Received response 'textDocument/hover - (11)' in 13ms.
Result: {"contents":{"kind":"markdown","value":"Package cmd implements Scorecard commandline.\n"},"range":{"start":{"line":20,"character":1},"end":{"line":20,"character":35}}}

[Trace - 10:00:59.075 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:00:59 background imports cache refresh starting\n"}

[Trace - 10:01:00.457 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:01:00 background refresh finished after 1.381919711s\n"}

[Trace - 10:01:04.002 AM] Sending notification '$/setTrace'.
Params: {"value":"off"}

[Trace - 10:01:04.003 AM] Sending notification 'workspace/didChangeConfiguration'.
Params: {"settings":null}

[Trace - 10:01:04.003 AM] Received request 'workspace/configuration - (5)'.
Params: {"items":[{"section":"gopls"}]}

[Trace - 10:01:04.008 AM] Sending response 'workspace/configuration - (5)' in 4ms.
Result: [{"ui.inlayhint.hints":{"assignVariableTypes":false,"compositeLiteralFields":false,"compositeLiteralTypes":false,"constantValues":false,"functionTypeParameters":false,"parameterNames":false,"rangeVariableTypes":false},"ui.vulncheck":"Off"}]

[Trace - 10:01:04.008 AM] Received request 'workspace/configuration - (6)'.
Params: {"items":[{"scopeUri":"file:///tmp/scorecard","section":"gopls"}]}

[Trace - 10:01:04.009 AM] Sending response 'workspace/configuration - (6)' in 1ms.
Result: [{"ui.inlayhint.hints":{"assignVariableTypes":false,"compositeLiteralFields":false,"compositeLiteralTypes":false,"constantValues":false,"functionTypeParameters":false,"parameterNames":false,"rangeVariableTypes":false},"ui.vulncheck":"Off"}]

[Trace - 10:01:09.706 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///tmp/scorecard/go.sum","type":2}]}

[Trace - 10:01:12.601 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:01:12 go/packages.Load #3\n\tsnapshot=3\n\tdirectory=file:///tmp/scorecard\n\tquery=[/tmp/scorecard/... builtin]\n\tpackages=170\n"}

[Trace - 10:01:12.629 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:01:12 go/packages.Load #3: updating metadata for 1389 packages\n"}

[Trace - 10:01:12.931 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {"uri":"file:///tmp/scorecard/go.sum","diagnostics":[]}

[Trace - 10:01:14.130 AM] Sending request 'shutdown - (12)'.
Params:

[Trace - 10:01:14.132 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2023/08/10 10:01:14 Shutdown session\n\tshutdown_session=1\n"}

[Trace - 10:01:14.132 AM] Received response 'shutdown - (12)' in 2ms.
Result: null

[Trace - 10:01:14.144 AM] Sending notification 'exit'.
Params:

Go/gopls extension settings

Occurs with default VS Code settings for Go and gopls

@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 Aug 10, 2023
@gopherbot gopherbot added this to the Unreleased milestone Aug 10, 2023
@jamalc jamalc added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 10, 2023
@rhcarvalho
Copy link
Contributor

Could it be that gopls is using a different Go version than expected?

I noticed that after upgrading a project to Go 1.21 and then running go mod tidy, new go.sum entries were created. AFAIK there's no guarantee that go mod tidy output is stable between Go releases. OTOH I also don't recall anything in the release notes that could hint at changes in this area.

@rhcarvalho
Copy link
Contributor

@spencerschrock this might be the source of changes to go.sum: https://go.dev/ref/mod#glos-go-mod-file:~:text=The%20go%20command%20is%20more%20careful%20about%20keeping%20checksums%20of%20go.mod%20files%20in%20the%20go.sum%20file.

(emphasis mine)

At go 1.21 or higher:
The go line declares a required minimum version of Go to use with this module.
The go line must be greater than or equal to the go line of all dependencies.
The go command no longer attempts to maintain compatibility with the previous older version of Go.
The go command is more careful about keeping checksums of go.mod files in the go.sum file.

@spencerschrock
Copy link
Author

Could it be that gopls is using a different Go version than expected?

I noticed that after upgrading a project to Go 1.21 and then running go mod tidy, new go.sum entries were created. AFAIK there's no guarantee that go mod tidy output is stable between Go releases. OTOH I also don't recall anything in the release notes that could hint at changes in this area.

I tried (locally) upgrading the project'sgo.mod from 1.19 to 1.21, and go mod tidy produces a different go.sum, which I committed to my test branch. However upon reloading the project and viewing any Go file, entries are inserted again (which are removed after go mod tidy).

If I leave the project at 1.19 and change my Go toolchain to 1.19 instead, the issue goes away. I tried a few more versions and the issue only starts when my Go toolchain is 1.20.5.

@spencerschrock
Copy link
Author

With that info, and the 1.20.5 milestone, I'm guessing it's this issue:
#60748

@findleyr
Copy link
Contributor

Thanks for investigating, @spencerschrock and @rhcarvalho.

Do you think there is anything to be improved here from the gopls side? We'd prefer to keep things simple, given that go.sum requirements will (eventually) stabilize.

@spencerschrock
Copy link
Author

I can follow #60748 for resolution. My only immediate thought is a local workaround, which will probably be me defining an alias for go mod tidy && git checkout. Unless there's any hooks I can configure on the gopls side to run go mod tidy for me.

@findleyr
Copy link
Contributor

Hmm, thinking about this a bit more, I'm not sure why gopls is fighting with you.

The only go commands gopls is running are go list, go version, and go env. I don't think the Go command should be inserting sum lines that are removed on go mod tidy. @bcmills does any of this ring bells? Is the behavior with go1.20.5+ perhaps inconsistent across operations?

@heschi
Copy link
Contributor

heschi commented Aug 11, 2023

FWIW, I'm skeptical that this is gopls at all. Looking at the log, no commands are being run, so go.sum shouldn't be changing regardless of any go command bugs. I suppose gopls could be buggy, but my money is on some linter or script doing it. Especially since I wasn't able to reproduce.

@spencerschrock
Copy link
Author

FWIW, I'm skeptical that this is gopls at all. Looking at the log, no commands are being run, so go.sum shouldn't be changing regardless of any go command bugs. I suppose gopls could be buggy, but my money is on some linter or script doing it.

The behavior went away when I turned off the language server(go.useLanguageServer), or when I uninstalled gopls, so I don't think it was script/linter related.

Especially since I wasn't able to reproduce.

Thanks for the data point. I requested a second cloud VM and was unable to reproduce there.
After cleaning the modcache on my original VM, I was no longer able to reproduce there either. I'm not sure what state the modcache was in originally, but the issue is no longer occurring.

Apologies for the lack of go clean troubleshooting earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
None yet
Development

No branches or pull requests

6 participants