Skip to content

Unfriendly behavior for new users when adding a module #2930

Closed as not planned
@aathan

Description

@aathan

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.

    • go version go1.19.3 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • 1.80.2
      2ccd690cbff1569e4a83d7c43d45101f817401dc
      x64
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.39.1

Share the Go related settings you have added/edited

Describe the bug

If you want to add a completely new module which has never been used in a project, you must go get... Meanwhile, that command seems to inspect the code to determine what's referenced. If you try and add a reference to the module, you "can't" because every time you add the import and hit save, the reformatter nukes the import because nothing uses it. If you do the go get before you add the import, the module ends up //indirect and in go.sum it's commented out.

I ended up having to break out to emacs, add the import, then go get & go mod tidy/vendor/etc before things started working correctly.

Steps to reproduce the behavior:

See above.

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions