Skip to content

Characters Disappearing after saving the file in VS Code #2987

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

Closed
sauntheninja2 opened this issue Sep 21, 2023 · 1 comment
Closed

Characters Disappearing after saving the file in VS Code #2987

sauntheninja2 opened this issue Sep 21, 2023 · 1 comment

Comments

@sauntheninja2
Copy link

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.
    • go1.20.5 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • Not Installed
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.82.0
  • 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.
    • set GO111MODULE=
      set GOARCH=amd64
      set GOBIN=
      set GOCACHE=C:\Users\Sujay\AppData\Local\go-build
      set GOENV=C:\Users\Sujay\AppData\Roaming\go\env
      set GOEXE=.exe
      set GOEXPERIMENT=
      set GOFLAGS=
      set GOHOSTARCH=amd64
      set GOHOSTOS=windows
      set GOINSECURE=
      set GOMODCACHE=C:\Users\Sujay\go\pkg\mod
      set GONOPROXY=
      set GONOSUMDB=
      set GOOS=windows
      set GOPATH=C:\Users\Sujay\go
      set GOPRIVATE=
      set GOPROXY=https://proxy.golang.org,direct
      set GOROOT=C:\Program Files\Go
      set GOSUMDB=sum.golang.org
      set GOTMPDIR=
      set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
      set GOVCS=
      set GOVERSION=go1.20.5
      set GCCGO=gccgo
      set GOAMD64=v1
      set AR=ar
      set CC=gcc
      set CXX=g++
      set CGO_ENABLED=0
      set GOMOD=c:\Users\Sujay\Desktop\Dev\Golang\PG\go.mod
      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 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\Sujay\AppData\Local\Temp\go-build278249291=/tmp/go-build -gno-record-gcc-switches

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

Describe the bug

When I am typing golang code in VS Code and after writing a few characters like "log" if I save the file using ctrl s or using the gui to save the file the typed characters disappear.

Steps to reproduce the behavior:

  1. Type some valid GO code
  2. Save the unsaved go file and the characters disappear

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

Characters_Dissapearing_After_Saving.mp4
@gopherbot gopherbot added this to the Untriaged milestone Sep 21, 2023
@findleyr
Copy link
Member

Hi, this is currently how goimports work: since it is a build error to have unused imports, goimports deletes them.

One can get used to this behavior: instead of typing out the import, just start using fmt, save, and goimports will add the missing import. But you are not the first person to have run into this and been confused, and we're going to add an option to change this behavior: https://go.dev/issue/54362.

Closing this in favor of golang/go#54362.

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2023
@golang golang locked and limited conversation to collaborators Sep 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants