New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/gofmt: insert space between : and = when syntax error #27576
Comments
Mh, I can't reproduce this:
What am I missing? Are you sure it's gofmt that is doing this? |
@ALTree I have this exact issue when using Visual Studio Code (Version 1.27.1) with ms-vscode.go extension installed. This extension advertise to be using gomft in the background. However, the issue does not appear when using directly gofmt in the shell (I can run your example and everything is fine), so I suspect something on extension's side. I'll dig deeper. @jingyugao Is that your use case as well ? |
I resolved my issue: it was a conflict between two formatting extensions in Visual Studio Code: ryannaddy.vscode-format and ms-vscode.go. I opened an issue for the first. |
@dav-m85 Thank you for your hint,I got the annswer.I use vscode-format extension. Gofmt is running ok after I remove the vscode-format.Thanks! |
I got why. Because I use vscode-format which ii conflicted with gofmt. Now gofmt is runniing well after I remove vscode-format |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.11 darwin/amd64
Does this issue reproduce with the latest release?
Yes,always.
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/gao/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/gao/go:/Users/gao/xng/xngo"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/9m/_jx550mn55x8mjzz6tgtnjph0000gn/T/go-build384560299=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
format *.go which is like this
Yes,there is an syntax error.
What did you expect to see?
I expect to see gofmt does nothing
What did you see instead?
gofmt insert a space between : and = .Sometimes when i open a big file with a syntax and press save,gofmt will change the code.Then i have to replace : = with := .
The text was updated successfully, but these errors were encountered: