Skip to content

x/tools/gopls: organize imports formats the package statement #63153

Open
@70sh1

Description

@70sh1

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.21.1 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • gopls v0.13.2
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.82.1 x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.39.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
GOBIN: undefined
toolsGopath: 
gopath: C:\Users\redacted\go
GOROOT: C:\Users\redacted\scoop\apps\go\current
PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\WireGuard\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\PowerShell\7\;C:\Program Files\dotnet\;C:\Users\redacted\go\bin;C:\Users\redacted\scoop\apps\python\current\Scripts;C:\Users\redacted\scoop\apps\python\current;C:\Users\redacted\scoop\apps\vscode\current\bin;C:\Users\redacted\scoop\apps\gcc\current\bin;C:\Users\redacted\scoop\apps\rustup\current\.cargo\bin;C:\Users\redacted\scoop\shims;C:\Users\redacted\AppData\Local\Microsoft\WindowsApps;C:\Users\redacted\Apps\poetry\bin;C:\Users\redacted\dev\Inno Setup 6;c:\users\redacted\.local\bin

    go: C:\Users\redacted\scoop\shims\go.exe: go version go1.21.1 windows/amd64

    gotests:    not installed
    gomodifytags:   not installed
    impl:   not installed
    goplay: not installed
    dlv:    C:\Users\redacted\go\bin\dlv.exe   (version: v1.21.0 built with go: go1.21.1)
    staticcheck:    C:\Users\redacted\go\bin\staticcheck.exe   (version: v0.4.6 built with go: go1.21.1)
    gopls:  C:\Users\redacted\go\bin\gopls.exe (version: v0.13.2 built with go: go1.21.1)

go env
Workspace Folder (playground): c:\Users\redacted\dev\go_projects\playground
    set GO111MODULE=
    set GOARCH=amd64
    set GOBIN=
    set GOCACHE=C:\Users\redacted\AppData\Local\go-build
    set GOENV=C:\Users\redacted\AppData\Roaming\go\env
    set GOEXE=.exe
    set GOEXPERIMENT=
    set GOFLAGS=
    set GOHOSTARCH=amd64
    set GOHOSTOS=windows
    set GOINSECURE=
    set GOMODCACHE=C:\Users\redacted\go\pkg\mod
    set GONOPROXY=
    set GONOSUMDB=
    set GOOS=windows
    set GOPATH=C:\Users\redacted\go
    set GOPRIVATE=
    set GOPROXY=https://proxy.golang.org,direct
    set GOROOT=C:\Users\redacted\scoop\apps\go\current
    set GOSUMDB=sum.golang.org
    set GOTMPDIR=
    set GOTOOLCHAIN=auto
    set GOTOOLDIR=C:\Users\redacted\scoop\apps\go\current\pkg\tool\windows_amd64
    set GOVCS=
    set GOVERSION=go1.21.1
    set GCCGO=gccgo
    set GOAMD64=v1
    set AR=ar
    set CC=gcc
    set CXX=g++
    set CGO_ENABLED=1
    set GOMOD=NUL
    set GOWORK=
    set CGO_CFLAGS=-O2 -g
    set CGO_CPPFLAGS=
    set CGO_CXXFLAGS=-O2 -g
    set CGO_FFLAGS=-O2 -g
    set CGO_LDFLAGS=-O2 -g
    set PKG_CONFIG=pkg-config
    set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\redacted\AppData\Local\Temp\go-build1818320928=/tmp/go-build -gno-record-gcc-switches

Share the Go related settings you have added/edited

"[go]": {
   "editor.formatOnSave": false,
   "editor.defaultFormatter": "golang.go"
 },

Describe the bug

Disabling format on save is not possible without disabling gopls altogether.

Steps to reproduce the behavior:

  1. Install Go extension
  2. Create new Go file
  3. Type anything with the wrong formatting e. g. package main
  4. Save the file

Metadata

Metadata

Assignees

No one assigned

    Labels

    goplsIssues related to the Go language server, gopls.gopls/imports

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions