VSC Vanishing Go Imports

With the Go extension installed in VSC, by default if you have an unused import, when you save, it will disappear.

If you're like me and you may habitually press ctrl+s, this is very frustrating.

After a lot of messing around in VSC's settings. I learned that this "feature" has nothing to do with the settings pertaining to linting or formatting.

It's actually to do with automatic import organisation, which you can configure as follows in VSC's settings.json.

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

This solution comes from this StackOverflow answer.

You can still organise imports with the shortcut shift+alt+o.

Comments

Popular posts from this blog

Fix Controller Input when a Game Doesn't Use Steam Input

En Dash with ComposeKey (Shift+AltGr)