Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Vs Code Go extension deleting my code. . . Help! 😥 #2490

Answered by suzmue
Major2000 asked this question in Help
Discussion options

I installed the official go extension in VS Code all the necessary executables are installed, the problem is when I am writing my code their is this weird thing that deletes my code all the time and I cannot stop it....

gopls.mp4

I think its something to do with the settings but I don't know how to set them.... 🥵

You must be logged in to vote

Deleting unused imports is the default behavior to help saved files can compile - In Go, unused imports are compile-time errors.

For different behavior, follow the instruction in "Formatting Code and Organizing Imports".

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

Replies: 1 comment 2 replies

Comment options

Deleting unused imports is the default behavior to help saved files can compile - In Go, unused imports are compile-time errors.

For different behavior, follow the instruction in "Formatting Code and Organizing Imports".

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

You must be logged in to vote
2 replies
Comment options

why it's enabled by default., i really dont get it. like it's not a bug it is a feature. however it only golang extension enforces it

Comment options

Wouldn't it be better to simply comment out the unused imports rather than deleting them?

Answer selected by h9jiang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /