Description
What version of Go are you using (go version
)?
$ go version go version go1.15.5 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/jwalton/Library/Caches/go-build" GOENV="/Users/jwalton/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/jwalton/.go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/jwalton/.go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/Cellar/go/1.15.5/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.15.5/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/jwalton/solink/solink-cli/go.mod" 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/42/y3h31nrx5c98b7sq_vqskskw0000gn/T/go-build712473597=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
In VSCode, if I type fmt.Prin<tab>
, then VSCode replaces what I typed with fmt.Printf()
and places my cursor between the brackets. There seems to be no option to disable auto-adding the brackets.
In Typescript, if I type console.lo<tab>
, VSCode fills in console.log
, and I have to type the "(". Since I spend 90% of my time in Typescript, I'm kinda hard wired to typing console.lo<tab>(
. In Golang, because I type that extra bracket (and VSCode isn't smart enough to "overtype" the opening bracket) it adds an extra bracket, which I then have to go back and remove. In fact, in golang if I type fmt.Prin<tab>("test")
, then you might expect this to "work out" because I ought to get fmt.Println(("test"))
, and then the code formatter would fix it (assuming I only have one variable at any rate), but if you try it you'll actually get fmt.Println(("test")
because VSCode will "overtype" the closing bracket for you but not the opening bracket, so you end up with a syntax error, even though you typed something perfectly sensible.
@hyangah directed me here, and noted that in order to implement this option in VSCode, support would need to be added to gopls.
I would also reference this issue in the old vscode-go repo, where MS explained they didn't auto-add the ()s because "this is not the standard interaction model for VS Code." I understand why some people might like this behavior, but there should at least be an option to turn it off.
What did you expect to see?
There should be an option to disable auto-brackets.
fmt.Println
What did you see instead?
There is no such option. :(
fmt.Println()