profile
viewpoint

Ask questionsx/tools/gopls: format feature doesn't follow `goimports`

For example, here is what imports block looks like in VS Code after pressing Alt-Shift-F (formatting) with enabled gopls: изображение

And here is what it looks like after pressing Ctrl-S (forcefully save file): изображение

For p.2, these options are enabled for gopls:

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

I'd like to have an ability to configure gopls to follow goimports style when formatting the file or to have this behavior as default.

Related: If I remove fmt dependency from code, but leave it in imports section, formatting will not remove fmt: изображение

golang/go

Answer questions inliquid

Maybe let others say their word instead of just closing all my issues? I believe you are very wrong with that approach. At least it's non-professional.

There was a setting both in Sourcegraph's go-langserver and in bingo. There is setting in VS Code which allows to select gofmt or goimports for formatting. Most of the gophers I know use goimports-like for formatting in VS Code and Goland (last one is on a cosmic distance in all that, which makes use of gopls ridiculous).

useful!

Related questions

cmd/link: segmentation fault during mach-o linking hot 3
cmd/go: needs a better error than "missing dot in first path element" when GOROOT is set incorrectly hot 2
x/xerrors: fails to compile on tip hot 1
vendor/golang.org/x/xerrors/adaptor_go1_13.go:16:14: undefined: errors.Frame ... hot 1
cmd/go: `go clean <package>` downloads modules hot 1
cmd/cgo error: runtime: unknown pc 0x7fff5c805b86 hot 1
runtime: crash with "invalid pc-encoded table" hot 1
cmd/vet: potential false positive in the "suspect or" check hot 1
cmd/link: showing many ld warnings of "building for macOS, but linking in object file" hot 1
cmd/go: major version without preceding tag must be v0, not v1 - breaks build of github.com/go-check hot 1
runtime: macOS Sierra builders spinning hot 1
cmd/go: Problem using go modules hot 1
cmd/go: "unrecognized import path" for local packages after updating to go1.13 hot 1
cmd/go: "found, but does not contain package" error refers to replaced version instead of its replacement hot 1
cmd/go: 'go get repo@<commit>' succeeds when <commit> is the full hash of an unpublished commit hot 1
Github User Rank List