2

I open the vscode language server gopls. And use Format Tool default(because prompts said others are not applicable when language server is enabled).

and config set:

"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
    "source.organizeImports": true
}

but my code imports are:

import (
    "net/http"

    "private.com/error"
    "github.com/gin-gonic/gin"
)

When I save it, it doesn't add blank line between private.com/error and github.com/gin-gonic/gin automatically, even though the vscode prompts it enter image description here

How can I set it, it will organize import automatically ?

xrui
  • 63
  • 2
  • It seems like gopls is not organizing imports as expected. You can try updating gopls to the latest version with the following command:···GO111MODULE=on go get golang.org/x/tools/gopls@latest···Then, restart VSCode and see if the issue is resolved. If the problem persists, you can consider reporting this as an issue on the gopls GitHub repository to seek further assistance. – Richard-zrx Apr 12 '23 at 10:48

1 Answers1

0

seems similar to the issue

try "go.useLanguageServer": false or the suggested config for "[go]":