gopls breaking imports?

70 views
Skip to first unread message

John Robinson

unread,
Nov 7, 2024, 1:49:44 PMNov 7
to golan...@googlegroups.com
Hi!

When autocomplete tries to add a missing module for me (using BBEdit on a Mac), the result is a real mess. I’ve seen this consistently across multiple go and gopls releases (currently on 1.23.2 and 0.16.2), multiple codebases, and when adding modules from the standard library or remote sources. But I haven’t found anyone with the same problem in the archives here, gopls issues, or elsewhere. BBEdit support says they just call the language server, and don’t mess with what it does. Does anyone know if this has been seen before?

func main() {
s, err := auto.Up
}

After Autocomplete:

func main() {
s, err := auto.UpsertStackInlineSource
}

With Module Already Listed:
If I add the module to imports before trying autocomplete, it doesn’t mess with the import statement, and the autocompleted function is fully printed:


Verbose gopls Trace:
2024-11-07 12:22:12.872: Server message: 2024/11/07 12:22:12 go/packages.Load #14
view_id="1"
snapshot=44
directory=/Users/john/Documents/Cellscale/code/cellscale/
query=[file=/Users/john/Documents/Cellscale/code/pulumi/cell-factory/main.go]
packages=1
duration=453.669ms

2024-11-07 12:22:13.932: Server message: 2024/11/07 12:22:13 go/packages.Load #15
view_id="3"
snapshot=44
directory=/Users/john/Documents/Cellscale/code/pulumi/quickstart/
query=[cell-factory]
packages=1
duration=536.321333ms

2024-11-07 12:22:14.592: Server message: 2024/11/07 12:22:14 go/packages.Load #16
view_id="4"
snapshot=44
directory=/Users/john/Documents/Cellscale/code/pulumi/cell-factory/
query=[cell-factory]
packages=1
duration=528.763708ms

2024-11-07 12:22:15.227: Server message: 2024/11/07 12:22:15 go/packages.Load #17
view_id="2"
snapshot=44
directory=/Users/john/Documents/Cellscale/code/cellscale/randSeq/
query=[cell-factory]
packages=1
duration=513.960541ms

Thanks,

John Robinson

Robert Findley

unread,
Nov 7, 2024, 4:46:04 PMNov 7
to golang-nuts
Hi John, I'm not able to immediately reproduce with VS Code, but if you file an issue we can investigate.

We'll want the logs with the `-rpc.trace` flag passed to gopls, from a brief session reproducing the problem.

Thanks,
- Rob

Reply all
Reply to author
Forward
0 new messages