I start typing the code in .go file using VSCODE Editor as below
package main
import (
"fmt"
"log"
"math/rand"
"net/http"
)
func main() {
fmt.Println("Hello World!")
}
as soon as the above is typed I save the file and then I find that I have lost the statement I have typed in import and the code remains as follows
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World!")
}
though I am aware that the unused imports are automatically removed, I do not know how to resolve this. I need these packages for the remaining part of my source code and only with that understanding I have included these package names even when I began to write the code.
Which setting should I use to resolve this in VSCode Editor
CodePudding user response:
though I am aware that the unused imports are automatically removed, I do not know how to resolve this.
In vscode setting.json set this config
"[go]": {
"editor.codeActionsOnSave": {
"source.organizeImports": false
}
}