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: gopls doesn't format my codes while saving or changing #41926

Closed
tigeran2020 opened this issue Oct 12, 2020 · 10 comments
Closed
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@tigeran2020
Copy link

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

$ go version

go version go1.14 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY="git.code.oa.com"
GONOSUMDB="git.code.oa.com"
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE="git.code.oa.com"
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/src/gotest/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build557597222=/tmp/go-build -gno-record-gcc-switches"

go env Output
$ go env

What did you do?

opened vscode, installed latest gopls, toggled use go language server setting,
opened folder ~/src/gotest/, executed go mod init hello at directory ~/src/gotest/,
created a new file main.go, and write codes as below:

package main

import "fmt"

func main() {
	fmt.Println( "hello"        )
}

and saved it.

What did you expect to see?

codes formated as below:

package main

import "fmt"

func main() {
	fmt.Println("hello")
}

What did you see instead?

codes not changed.

more information

I used command gopls main.go dirrectly, it formated my codes correctly.

@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 Oct 12, 2020
@gopherbot gopherbot added this to the Unreleased milestone Oct 12, 2020
@stamblerre
Copy link
Contributor

@tigeran2020: Can you please share collect gopls logs from when you see this issue? Information on how to do so can be found here: https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v1.0.0 Oct 12, 2020
@tigeran2020
Copy link
Author

tigeran2020 commented Oct 13, 2020

@stamblerre
sure, here is:

[Trace - 12:34:00.835 PM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go","version":3},"contentChanges":[{"range":{"start":{"line":5,"character":24},"end":{"line":5,"character":25}},"rangeLength":1,"text":""}]}


[Trace - 12:34:01.030 PM] Sending request 'textDocument/foldingRange - (12)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}


[Trace - 12:34:01.031 PM] Received response 'textDocument/foldingRange - (12)' in 0ms.
Result: [{"startLine":4,"startCharacter":13,"endLine":5,"endCharacter":28}]


[Trace - 12:34:01.079 PM] Sending request 'textDocument/codeLens - (13)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}


[Trace - 12:34:01.079 PM] Received response 'textDocument/codeLens - (13)' in 0ms.
Result: null


[Trace - 12:34:01.180 PM] Sending request 'textDocument/documentSymbol - (14)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}


[Trace - 12:34:01.181 PM] Received response 'textDocument/documentSymbol - (14)' in 0ms.
Result: [{"name":"main","detail":"()","kind":12,"range":{"start":{"line":4,"character":0},"end":{"line":7,"character":0}},"selectionRange":{"start":{"line":4,"character":5},"end":{"line":4,"character":9}}}]


[Trace - 12:34:01.425 PM] Sending request 'textDocument/codeAction - (15)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":6,"character":1}},"context":{"diagnostics":[],"only":["source.organizeImports"]}}


[Trace - 12:34:01.426 PM] Received response 'textDocument/codeAction - (15)' in 0ms.
Result: null


[Trace - 12:34:01.492 PM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go","version":3}}


[Trace - 12:34:01.776 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///root/src/gotest/main.go","type":2},{"uri":"file:///root/src/gotest/main.go","type":2}]}


[Trace - 12:34:01.827 PM] Sending request 'textDocument/documentLink - (16)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}


[Trace - 12:34:01.827 PM] Received response 'textDocument/documentLink - (16)' in 0ms.
Result: [{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":11}},"target":"https://pkg.go.dev/fmt"}]



@stamblerre
Copy link
Contributor

This looks like a partial log--do you mind sharing the complete log?

@tigeran2020
Copy link
Author

tigeran2020 commented Oct 13, 2020

hear is:
[Trace - 15:25:48.228 PM] Sending request 'shutdown - (26)'.
Params:

[Trace - 15:25:48.229 PM] Received response 'shutdown - (26)' in 0ms.
Result: null

[Trace - 15:25:48.229 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/13 15:25:48 Shutdown session\n\tshutdown_session=1\n"}

[Trace - 15:25:48.229 PM] Sending notification 'exit'.
Params:

[Trace - 15:25:48.280 PM] Sending request 'initialize - (0)'.
Params: {"processId":15776,"clientInfo":{"name":"vscode","version":"1.49.3"},"rootPath":"/root/src/gotest","rootUri":"file:///root/src/gotest","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"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]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]}},"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]}},"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}},"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},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":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}},"window":{"workDoneProgress":true}},"initializationOptions":{},"trace":"off","workspaceFolders":[{"uri":"file:///root/src/gotest","name":"gotest"}]}

[Trace - 15:25:48.281 PM] Received response 'initialize - (0)' in 1ms.
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,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":{"prepareProvider":true},"foldingRangeProvider":true,"executeCommandProvider":{"commands":["generate","fill_struct","regenerate_cgo","test","tidy","undeclared_name","upgrade_dependency","vendor","extract_variable","extract_function","gc_details","generate_gopls_mod"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"Build info\n----------\ngolang.org/x/tools/gopls v0.5.1\n golang.org/x/tools/gopls@v0.5.1 h1:AF3Uh7HF08SZpKFfgJO6zfF3bbxyDXWqdkK4kMXiQ1o=\n github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=\n github.com/google/go-cmp@v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=\n github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=\n golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=\n golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=\n golang.org/x/tools@v0.0.0-20200930165741-f1523d29dbb9 h1:1R38tQp22dcHpTKJPjgVa16FhlDy/kHEaCM/ndi/FIc=\n golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=\n honnef.co/go/tools@v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=\n mvdan.cc/gofumpt@v0.0.0-20200802201014-ab5a8192947d h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=\n mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=\n"}}

[Trace - 15:25:48.281 PM] Sending notification 'initialized'.
Params: {}

[Trace - 15:25:48.282 PM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}

[Trace - 15:25:48.282 PM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go","languageId":"go","version":4,"text":"package main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println( "hello" )\n}"}}

[Trace - 15:25:48.284 PM] Sending response 'window/workDoneProgress/create - (1)' in 2ms.
Result:

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

[Trace - 15:25:48.284 PM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///root/src/gotest","section":"gopls"},{"scopeUri":"file:///root/src/gotest","section":"gopls-gotest"}]}

[Trace - 15:25:48.287 PM] Sending response 'workspace/configuration - (2)' in 2ms.
Result: [null,null]

[Trace - 15:25:48.299 PM] Sending request 'textDocument/documentSymbol - (1)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 15:25:48.300 PM] Sending request 'textDocument/codeAction - (2)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"},"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":1}},"context":{"diagnostics":[]}}

[Trace - 15:25:48.300 PM] Sending request 'textDocument/documentLink - (3)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 15:25:48.330 PM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/*.{go,mod,sum}","kind":7},{"globPattern":"/root/src/gotest//*.{go,mod,sum}","kind":7}]}}]}

[Trace - 15:25:48.330 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/13 15:25:48 go env for /root/src/gotest\n(root /root/src/gotest)\n(go version go version go1.14 linux/amd64\n)\n(valid build configuration = true)\n(build flags: [])\nGOROOT=/usr/lib/golang\nGOCACHE=/root/.cache/go-build\nGOINSECURE=\nGOPROXY=https://goproxy.cn,direct\nGOPATH=/root/go\nGOPRIVATE=git.code.oa.com\nGONOSUMDB=git.code.oa.com\nGOSUMDB=off\nGOFLAGS=\nGO111MODULE=\nGOMOD=/root/src/gotest/go.mod\nGOMODCACHE=\nGONOPROXY=git.code.oa.com\n\n"}

[Info - 3:25:48 PM] 2020/10/13 15:25:48 go env for /root/src/gotest
(root /root/src/gotest)
(go version go version go1.14 linux/amd64
)
(valid build configuration = true)
(build flags: [])
GOROOT=/usr/lib/golang
GOCACHE=/root/.cache/go-build
GOINSECURE=
GOPROXY=https://goproxy.cn,direct
GOPATH=/root/go
GOPRIVATE=git.code.oa.com
GONOSUMDB=git.code.oa.com
GOSUMDB=off
GOFLAGS=
GO111MODULE=
GOMOD=/root/src/gotest/go.mod
GOMODCACHE=
GONOPROXY=git.code.oa.com

[Trace - 15:25:48.330 PM] Sending response 'client/registerCapability - (3)' in 0ms.
Result:

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

[Trace - 15:25:48.330 PM] Sending response 'client/registerCapability - (4)' in 0ms.
Result:

[Trace - 15:25:48.377 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/13 15:25:48 go/packages.Load\n\tsnapshot=0\n\tdirectory=/root/src/gotest\n\tquery=[./... builtin]\n\tpackages=2\n"}

[Info - 3:25:48 PM] 2020/10/13 15:25:48 go/packages.Load
snapshot=0
directory=/root/src/gotest
query=[./... builtin]
packages=2

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

[Trace - 15:25:48.477 PM] Received response 'textDocument/documentSymbol - (1)' in 177ms.
Result: [{"name":"main","detail":"()","kind":12,"range":{"start":{"line":4,"character":0},"end":{"line":7,"character":0}},"selectionRange":{"start":{"line":4,"character":5},"end":{"line":4,"character":9}}}]

[Trace - 15:25:48.477 PM] Received response 'textDocument/codeAction - (2)' in 177ms.
Result: null

[Trace - 15:25:48.477 PM] Received response 'textDocument/documentLink - (3)' in 177ms.
Result: [{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":11}},"target":"https://pkg.go.dev/fmt"}]

[Trace - 15:25:48.502 PM] Sending request 'textDocument/foldingRange - (4)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 15:25:48.503 PM] Received response 'textDocument/foldingRange - (4)' in 0ms.
Result: [{"startLine":4,"startCharacter":13,"endLine":5,"endCharacter":27}]

[Trace - 15:25:48.549 PM] Sending request 'textDocument/codeLens - (5)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 15:25:48.549 PM] Received response 'textDocument/codeLens - (5)' in 0ms.
Result: null

[Trace - 15:25:52.939 PM] Sending request 'textDocument/hover - (6)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"},"position":{"line":5,"character":22}}

[Trace - 15:25:52.940 PM] Received response 'textDocument/hover - (6)' in 0ms.
Result: null

[Trace - 15:25:53.277 PM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go","version":5},"contentChanges":[{"range":{"start":{"line":5,"character":23},"end":{"line":5,"character":23}},"rangeLength":0,"text":" "}]}

[Trace - 15:25:53.476 PM] Sending request 'textDocument/foldingRange - (7)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 15:25:53.477 PM] Received response 'textDocument/foldingRange - (7)' in 0ms.
Result: [{"startLine":4,"startCharacter":13,"endLine":5,"endCharacter":28}]

[Trace - 15:25:53.531 PM] Sending request 'textDocument/codeLens - (8)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 15:25:53.531 PM] Received response 'textDocument/codeLens - (8)' in 0ms.
Result: null

[Trace - 15:25:53.615 PM] Sending request 'textDocument/documentSymbol - (9)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 15:25:53.616 PM] Received response 'textDocument/documentSymbol - (9)' in 0ms.
Result: [{"name":"main","detail":"()","kind":12,"range":{"start":{"line":4,"character":0},"end":{"line":7,"character":0}},"selectionRange":{"start":{"line":4,"character":5},"end":{"line":4,"character":9}}}]

[Trace - 15:25:53.741 PM] Sending request 'textDocument/codeAction - (10)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":6,"character":1}},"context":{"diagnostics":[],"only":["source.organizeImports"]}}

[Trace - 15:25:53.741 PM] Received response 'textDocument/codeAction - (10)' in 0ms.
Result: null

[Trace - 15:25:54.266 PM] Sending request 'textDocument/documentLink - (11)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 15:25:54.266 PM] Received response 'textDocument/documentLink - (11)' in 0ms.
Result: [{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":11}},"target":"https://pkg.go.dev/fmt"}]

[Trace - 15:25:54.286 PM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go","version":5}}

[Trace - 15:25:54.495 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///root/src/gotest/main.go","type":2},{"uri":"file:///root/src/gotest/main.go","type":2}]}

[Trace - 15:26:18.477 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/13 15:26:18 background imports cache refresh starting\n"}

[Info - 3:26:18 PM] 2020/10/13 15:26:18 background imports cache refresh starting

[Trace - 15:26:18.560 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/13 15:26:18 background refresh finished after 82.603936ms\n"}

[Info - 3:26:18 PM] 2020/10/13 15:26:18 background refresh finished after 82.603936ms

@stamblerre
Copy link
Contributor

stamblerre commented Oct 13, 2020

Your log doesn't seem to have errors, but you're right that I'm not seeing any formatting requests. Do you have the following in your VS Code settings?

"[go]": {
	"editor.codeActionsOnSave": {
		"source.organizeImports": true,
	},		
	"editor.formatOnSave": true,
}

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 13, 2020
@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.5.2 Oct 13, 2020
@tigeran2020
Copy link
Author

@stamblerre I hadn't. But it still doesn't work after I have add these settings.

@tigeran2020
Copy link
Author

[Trace - 10:17:27.663 AM] Sending request 'initialize - (0)'.
Params: {"processId":16936,"clientInfo":{"name":"vscode","version":"1.49.3"},"rootPath":"/root/src/gotest","rootUri":"file:///root/src/gotest","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"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]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]}},"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]}},"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}},"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},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":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}},"window":{"workDoneProgress":true}},"initializationOptions":{},"trace":"off","workspaceFolders":[{"uri":"file:///root/src/gotest","name":"gotest"}]}

[Trace - 10:17:27.665 AM] Received response 'initialize - (0)' in 1ms.
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,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":{"prepareProvider":true},"foldingRangeProvider":true,"executeCommandProvider":{"commands":["generate","fill_struct","regenerate_cgo","test","tidy","undeclared_name","upgrade_dependency","vendor","extract_variable","extract_function","gc_details","generate_gopls_mod"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"Build info\n----------\ngolang.org/x/tools/gopls v0.5.1\n golang.org/x/tools/gopls@v0.5.1 h1:AF3Uh7HF08SZpKFfgJO6zfF3bbxyDXWqdkK4kMXiQ1o=\n github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=\n github.com/google/go-cmp@v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=\n github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=\n golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=\n golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=\n golang.org/x/tools@v0.0.0-20200930165741-f1523d29dbb9 h1:1R38tQp22dcHpTKJPjgVa16FhlDy/kHEaCM/ndi/FIc=\n golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=\n honnef.co/go/tools@v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=\n mvdan.cc/gofumpt@v0.0.0-20200802201014-ab5a8192947d h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=\n mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=\n"}}

[Trace - 10:17:27.683 AM] Sending notification 'initialized'.
Params: {}

[Trace - 10:17:27.683 AM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}

[Trace - 10:17:27.684 AM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go","languageId":"go","version":1,"text":"package main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println( "hello" )\n}"}}

[Trace - 10:17:27.695 AM] Sending response 'window/workDoneProgress/create - (1)' in 12ms.
Result:

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

[Trace - 10:17:27.696 AM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///root/src/gotest","section":"gopls"},{"scopeUri":"file:///root/src/gotest","section":"gopls-gotest"}]}

[Trace - 10:17:27.713 AM] Sending response 'workspace/configuration - (2)' in 17ms.
Result: [null,null]

[Trace - 10:17:27.715 AM] Sending request 'textDocument/documentSymbol - (1)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 10:17:27.716 AM] Sending request 'textDocument/codeAction - (2)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"},"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":1}},"context":{"diagnostics":[]}}

[Trace - 10:17:27.717 AM] Sending request 'textDocument/documentLink - (3)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 10:17:27.757 AM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"/*.{go,mod,sum}","kind":7},{"globPattern":"/root/src/gotest//*.{go,mod,sum}","kind":7}]}}]}

[Trace - 10:17:27.757 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/15 10:17:27 go env for /root/src/gotest\n(root /root/src/gotest)\n(go version go version go1.14 linux/amd64\n)\n(valid build configuration = true)\n(build flags: [])\nGOMOD=/root/src/gotest/go.mod\nGOSUMDB=off\nGO111MODULE=\nGOMODCACHE=\nGOINSECURE=\nGONOSUMDB=git.code.oa.com\nGOPRIVATE=git.code.oa.com\nGOROOT=/usr/lib/golang\nGOFLAGS=\nGOPATH=/root/go\nGOPROXY=https://goproxy.cn,direct\nGOCACHE=/root/.cache/go-build\nGONOPROXY=git.code.oa.com\n\n"}

[Info - 10:17:27 AM] 2020/10/15 10:17:27 go env for /root/src/gotest
(root /root/src/gotest)
(go version go version go1.14 linux/amd64
)
(valid build configuration = true)
(build flags: [])
GOMOD=/root/src/gotest/go.mod
GOSUMDB=off
GO111MODULE=
GOMODCACHE=
GOINSECURE=
GONOSUMDB=git.code.oa.com
GOPRIVATE=git.code.oa.com
GOROOT=/usr/lib/golang
GOFLAGS=
GOPATH=/root/go
GOPROXY=https://goproxy.cn,direct
GOCACHE=/root/.cache/go-build
GONOPROXY=git.code.oa.com

[Trace - 10:17:27.760 AM] Sending response 'client/registerCapability - (3)' in 2ms.
Result:

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

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

[Trace - 10:17:27.804 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/15 10:17:27 go/packages.Load\n\tsnapshot=0\n\tdirectory=/root/src/gotest\n\tquery=[./... builtin]\n\tpackages=2\n"}

[Info - 10:17:27 AM] 2020/10/15 10:17:27 go/packages.Load
snapshot=0
directory=/root/src/gotest
query=[./... builtin]
packages=2

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

[Trace - 10:17:27.908 AM] Sending request 'textDocument/foldingRange - (4)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 10:17:27.912 AM] Received response 'textDocument/documentSymbol - (1)' in 196ms.
Result: [{"name":"main","detail":"()","kind":12,"range":{"start":{"line":4,"character":0},"end":{"line":7,"character":0}},"selectionRange":{"start":{"line":4,"character":5},"end":{"line":4,"character":9}}}]

[Trace - 10:17:27.912 AM] Received response 'textDocument/codeAction - (2)' in 196ms.
Result: null

[Trace - 10:17:27.913 AM] Received response 'textDocument/documentLink - (3)' in 195ms.
Result: [{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":11}},"target":"https://pkg.go.dev/fmt"}]

[Trace - 10:17:27.913 AM] Received response 'textDocument/foldingRange - (4)' in 5ms.
Result: [{"startLine":4,"startCharacter":13,"endLine":5,"endCharacter":28}]

[Trace - 10:17:27.964 AM] Sending request 'textDocument/codeLens - (5)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"}}

[Trace - 10:17:27.964 AM] Received response 'textDocument/codeLens - (5)' in 0ms.
Result: null

[Trace - 10:17:28.678 AM] Sending request 'textDocument/codeAction - (6)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"},"range":{"start":{"line":6,"character":1},"end":{"line":6,"character":1}},"context":{"diagnostics":[]}}

[Trace - 10:17:28.679 AM] Received response 'textDocument/codeAction - (6)' in 0ms.
Result: null

[Trace - 10:17:28.714 AM] Sending request 'textDocument/codeAction - (7)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":6,"character":1}},"context":{"diagnostics":[],"only":["source.organizeImports"]}}

[Trace - 10:17:28.715 AM] Received response 'textDocument/codeAction - (7)' in 0ms.
Result: null

[Trace - 10:17:29.067 AM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go","version":1}}

[Trace - 10:17:29.349 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///root/src/gotest/main.go","type":2},{"uri":"file:///root/src/gotest/main.go","type":2}]}

[Trace - 10:17:29.804 AM] Sending request 'textDocument/codeAction - (8)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":6,"character":1}},"context":{"diagnostics":[],"only":["source.organizeImports"]}}

[Trace - 10:17:29.804 AM] Received response 'textDocument/codeAction - (8)' in 0ms.
Result: null

[Trace - 10:17:29.896 AM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go","version":1}}

[Trace - 10:17:30.130 AM] Sending request 'textDocument/codeAction - (9)'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":6,"character":1}},"context":{"diagnostics":[],"only":["source.organizeImports"]}}

[Trace - 10:17:30.131 AM] Received response 'textDocument/codeAction - (9)' in 0ms.
Result: null

[Trace - 10:17:30.189 AM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"uri":"file:///root/src/gotest/main.go","version":1}}

[Trace - 10:17:30.189 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///root/src/gotest/main.go","type":2},{"uri":"file:///root/src/gotest/main.go","type":2}]}

[Trace - 10:17:30.471 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///root/src/gotest/main.go","type":2},{"uri":"file:///root/src/gotest/main.go","type":2}]}

[Trace - 10:17:57.913 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/15 10:17:57 background imports cache refresh starting\n"}

[Info - 10:17:57 AM] 2020/10/15 10:17:57 background imports cache refresh starting

[Trace - 10:18:02.272 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/15 10:18:02 background refresh finished after 4.35913356s\n"}

[Info - 10:18:02 AM] 2020/10/15 10:18:02 background refresh finished after 4.35913356s

[Trace - 10:18:23.515 AM] Sending notification '$/setTraceNotification'.
Params: {"value":"off"}

[Trace - 10:18:23.522 AM] Sending request 'shutdown - (10)'.
Params:

[Trace - 10:18:23.522 AM] Received response 'shutdown - (10)' in 0ms.
Result: null

[Trace - 10:18:23.522 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/10/15 10:18:23 Shutdown session\n\tshutdown_session=1\n"}

[Trace - 10:18:23.526 AM] Sending notification 'exit'.
Params:

[Info - 10:18:23 AM] 2020/10/15 10:18:23 go env for /root/src/gotest
(root /root/src/gotest)
(go version go version go1.14 linux/amd64
)
(valid build configuration = true)
(build flags: [])
GOFLAGS=
GOPROXY=https://goproxy.cn,direct
GOMODCACHE=
GOPRIVATE=git.code.oa.com
GOROOT=/usr/lib/golang
GOCACHE=/root/.cache/go-build
GONOSUMDB=git.code.oa.com
GOPATH=/root/go
GO111MODULE=
GOINSECURE=
GOMOD=/root/src/gotest/go.mod
GOSUMDB=off
GONOPROXY=git.code.oa.com

[Info - 10:18:23 AM] 2020/10/15 10:18:23 go/packages.Load
snapshot=0
directory=/root/src/gotest
query=[./... builtin]
packages=2

[Info - 10:19:04 AM] 2020/10/15 10:19:04 background imports cache refresh starting

[Info - 10:19:04 AM] 2020/10/15 10:19:04 background refresh finished after 79.147271ms

[Info - 10:19:38 AM] 2020/10/15 10:19:38 background imports cache refresh starting

[Info - 10:19:38 AM] 2020/10/15 10:19:38 background refresh finished after 19.247537ms

@tigeran2020
Copy link
Author

this is my setting:

{
    "editor.formatOnSave": true,
    "go.formatTool": "gofmt",
    "go.useLanguageServer": true,
    "go.languageServerFlags": [
        "serve",
        "-rpc.trace",
        "--debug=localhost:6060"
    ],
    "[go]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
        },		
        "editor.formatOnSave": true,
    }
}

@stamblerre
Copy link
Contributor

Please make sure to restart the editor after you update those settings (just in case). I see the didSaves in your log, but there is still no formatting request.

@stamblerre stamblerre added this to Needs Triage in vscode-go: gopls by default Nov 10, 2020
@stamblerre stamblerre moved this from Needs Triage to In progress in vscode-go: gopls by default Nov 10, 2020
@stamblerre stamblerre moved this from In progress to Waiting for Info in vscode-go: gopls by default Nov 18, 2020
@stamblerre
Copy link
Contributor

Closing, as there hasn't been any activity on this issue for over a month.

vscode-go: gopls by default automation moved this from Waiting for Info to Done Nov 22, 2020
@stamblerre stamblerre removed this from the gopls/vscode-go milestone Nov 22, 2020
@golang golang locked and limited conversation to collaborators Nov 22, 2021
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. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
No open projects
Development

No branches or pull requests

3 participants