Skip to content
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

x/tools/gopls: autoimport doesn't work properly in VS Code when using CRLF line endings #47200

Closed
preslavmihaylov opened this issue Jul 14, 2021 · 4 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@preslavmihaylov
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.16 windows/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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\pmiha\AppData\Local\go-build
set GOENV=C:\Users\pmiha\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\pmiha\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\pmiha\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.16
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\pmiha\Programming\learn-programming-with-go\02_data-types-and-variables\examples\15_shorthand_operations\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\pmiha\AppData\Local\Temp\go-build4014282860=/tmp/go-build -gno-record-gcc-switches

What did you do?

go mod init example
touch main.go

Write this via Visual Studio Code:

package main

import "fmt"

func main() {
	math.Sqrt(9)
	fmt.Println("hello")
}

Save

What did you expect to see?

package main

import (
	"fmt"
	"math"
)

func main() {
	math.Sqrt(9)
	fmt.Println("hello")
}

What did you see instead?

package main

import (
	"fmt"	"math"
)

func main() {
	math.Sqrt(9)
	fmt.Println("hello")
}
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jul 14, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jul 14, 2021
@preslavmihaylov preslavmihaylov changed the title x/tools/gopls: Autoimport doesn't work properly in VS Code x/tools/gopls: Autoimport doesn't work properly in VS Code on Windows Jul 14, 2021
@hyangah
Copy link
Contributor

hyangah commented Jul 14, 2021

@preslavmihaylov Thanks for filing the issue. We need more info here:

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 14, 2021
@preslavmihaylov
Copy link
Author

preslavmihaylov commented Jul 15, 2021

gopls version output:

gopls version output ``` Build info ---------- golang.org/x/tools/gopls v0.7.0 golang.org/x/tools/[email protected] h1:JQBHW81Gsyim6iDjUwGoPeSpXrSqwen3isPJLfDfaYU= github.com/BurntSushi/[email protected] h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/google/[email protected] h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= golang.org/x/[email protected] h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/[email protected] h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/[email protected] h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/[email protected] h1:Pv9gNyJFYVdpUAVZYJ1BDSU4eGgXQ+0f3DIGAdolO5s= golang.org/x/[email protected] h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= honnef.co/go/[email protected] h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE= mvdan.cc/[email protected] h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA= mvdan.cc/xurls/[email protected] h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A= ```

The file type was indeed CRLF, when I changed it to LF, the problem stopped occuring. Should I still keep this issue open under the title Autoimport doesn't work on CRLF files?

@preslavmihaylov preslavmihaylov changed the title x/tools/gopls: Autoimport doesn't work properly in VS Code on Windows x/tools/gopls: Autoimport doesn't work properly in VS Code when using CRLF line endings Jul 15, 2021
@stamblerre stamblerre changed the title x/tools/gopls: Autoimport doesn't work properly in VS Code when using CRLF line endings x/tools/gopls: autoimport doesn't work properly in VS Code when using CRLF line endings Jul 15, 2021
@stamblerre stamblerre self-assigned this Jul 15, 2021
@stamblerre stamblerre removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 15, 2021
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/334890 mentions this issue: internal/lsp: handle incorrect import with CRLF line endings

@hyangah hyangah modified the milestones: Unreleased, gopls/v0.7.1 Jul 15, 2021
@hyangah
Copy link
Contributor

hyangah commented Jul 16, 2021

Duplicate of #46791

@hyangah hyangah marked this as a duplicate of #46791 Jul 16, 2021
@hyangah hyangah closed this as completed Jul 16, 2021
gopherbot pushed a commit to golang/tools that referenced this issue Jul 22, 2021
Going from an import line to an import block with CRLF endings did not
previously work.

Fixes golang/go#47200

Change-Id: I51334587ad51b828bd0828217ba39fb745d7e835
Reviewed-on: https://go-review.googlesource.com/c/tools/+/334890
Trust: Rebecca Stambler <[email protected]>
Run-TryBot: Rebecca Stambler <[email protected]>
gopls-CI: kokoro <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants