Skip to content

x/tools/gopls: some properties/defaults from gopls api-json are invalid #41964

@hyangah

Description

@hyangah
$ gopls -v version
Build info
----------
golang.org/x/tools/gopls master
    golang.org/x/tools/[email protected] h1:WOieoYgx8c4Yz9/oW7VgjvzIsjTN0++21yoFC15q+RY=
    github.com/BurntSushi/[email protected] h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/[email protected] h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
    github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/[email protected] h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
    golang.org/x/[email protected] h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
    golang.org/x/[email protected] h1:2ntEwh02rqo2jSsrYmp4yKHHjh0CbXP3ZtSUetSB+q8=
    golang.org/x/[email protected] h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/[email protected] h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=
    mvdan.cc/[email protected] h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=
    mvdan.cc/xurls/[email protected] h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=

But reproducible with the latest stable version of gopls (gopls settings-json).

Configure the vscode gopls section with the default values listed in settings.md@64a9e34

  "gopls": {
    "env": [],
    "semanticTokens": false,
    "experimentalPackageCacheKey": false,
    "completionBudget": 100000000,
    "literalCompletions": true,
  }

See gopls complaining about the default values and triggering multiple notification popups.


[Trace - 23:17:01.044 PM] Sending response 'workspace/configuration - (2)' in 4ms.
Result: [{"env":[],"semanticTokens":false,"experimentalPackageCacheKey":false,"completionBudget":100000000,"literalCompletions":true},null]

[Trace - 23:17:01.044 PM] Received notification 'window/showMessage'.
Params: {"type":1,"message":"invalid config gopls.env type []interface {}"}

[Trace - 23:17:01.044 PM] Received notification 'window/showMessage'.
Params: {"type":1,"message":"unexpected gopls setting \"semanticTokens\""}

[Trace - 23:17:01.044 PM] Received notification 'window/showMessage'.
Params: {"type":1,"message":"unexpected gopls setting \"experimentalPackageCacheKey\""}

[Trace - 23:17:01.044 PM] Received notification 'window/showMessage'.
Params: {"type":1,"message":"Invalid type float64 for string option \"completionBudget\""}

[Trace - 23:17:01.045 PM] Received notification 'window/showMessage'.
Params: {"type":1,"message":"unexpected gopls setting \"literalCompletions\""}

Issues:

  • semanticTokens, experimentalPackageCacheKey, literalCompletions were unexpected
  • completionBudget is time.Duration type. The default value 100000000 is interpreted as float64. I tried to supply "100000000" (string type) which still fails due to parsing error ( Params: {"type":1,"message":"failed to parse duration \"100000000\": time: missing unit in duration \"100000000\""})
    Note: the error message does not include the property name which needs to be addressed too.
  • env section is defined as []string following source.UserOptions.Env
    In VS Code, environment variable collection is often map[string]string type, so string array type is unusual.
    And, gopls doesn't accept default [] but accepts {}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions