This is really similar to what Robert Engels said, and may be the same
thing. Anyway, this definitely works in VSCode to have the editor leave
your file along when you save to disk.
Ha! Problem solved. (And I am so embarrassed)In the documentation for
the extension, they document exactly how to disable the reformatting on
save.
Formatting and organizing imports are enabled by default. You can choose to
disable them by configuring the following settings."[go]": {
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.organizeImports": false
}
}
I tried it, and it works.
On Wednesday, November 19, 2025 at 3:34:49 AM UTC-6 Stephen Illingworth
wrote:
> Having an unused import is a compilation error so it's generally good that
> editors do this (by calling goimports or using the gopls code action).
> Using the underscore notation is a good tip though.
>
> On Wednesday, 19 November 2025 at 09:18:31 UTC Brian Candler wrote:
>
>> I don't know anything about fancy editors, but I note that go.dev/play/
>> does the same (maybe for same underlying reason).
>>
>> You can prevent it by writing:
>>
>> import _ "github.com/zalando/go-keyring"
>>
>> (although you then have to remove the underscore later when you actually
>> want to use the module)
>>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/golang-nuts/889d5ed4-16d2-4b35-84c4-c8b9fc6b9138n%40googlegroups.com.