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: duplicates multi-line comment on first function after imports on every save #43000

Closed
kdeconinck opened this issue Dec 4, 2020 · 2 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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@kdeconinck
Copy link

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

$ go version
go version go1.15.5 windows/amd64

gopls version
golang.org/x/tools/gopls v0.5.4
    golang.org/x/tools/gopls@v0.5.4 h1:PkQWDfzw8CxoseHDQniF2GhzmndN8KnQL6gcG2gnF3Y=

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\kdeconinck\AppData\Local\go-build
set GOENV=C:\Users\kdeconinck\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\kdeconinck\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\kdeconinck\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\kdeconinck\DEV\github.com\kdeconinck\GOSudoku\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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\KDECON~1\AppData\Local\Temp\go-build977075402=/tmp/go-build -gno-record-gcc-switches

What did you do?

Create a new Go source file and add a function to the file.
Add a comment to that function which spawns multiple lines.

// Package main implements the main entry point for the application.
package main

// PRIVATE: The method `main` implements the MAIN entry point for the application.
//          This method is executed when the application is started.
func main() {
	// TODO: Implement the 'MAIN' entry point for the application.
}

Next save the document.

What did you expect to see?

The document should be saved the same way as it was written.

What did you see instead?

The lines below the first line of the comment of the method is duplicated.

// Package main implements the main entry point for the application.
package main

// PRIVATE: The method `main` implements the MAIN entry point for the application.
//          This method is executed when the application is started.
//          This method is executed when the application is started.
func main() {
	// TODO: Implement the 'MAIN' entry point for the application.
}

When saving again, there's a duplication again:

// Package main implements the main entry point for the application.
package main

// PRIVATE: The method `main` implements the MAIN entry point for the application.
//          This method is executed when the application is started.
//          This method is executed when the application is started.
//          This method is executed when the application is started.
//          This method is executed when the application is started.
func main() {
	// TODO: Implement the 'MAIN' entry point for the application.
}

Related issues.

#39147

Additional information:

When the first method in the Go source file is a method that does NOT contain a comment or that does contain a comment which does NOT span multiple lines, other methods in this file containing comments which spans multiple lines are NOT duplicated.

// Package main implements the main entry point for the application.
package main

func temp() {}

// PRIVATE: The method `main` implements the MAIN entry point for the application.
//          This method is executed when the application is started.
func main() {
	// TODO: Implement the 'MAIN' entry point for the application.
}
@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 Dec 4, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 4, 2020
@stamblerre
Copy link
Contributor

Thank you for reporting this issue. The fix for this should be in the pre-release for gopls/v0.5.5 (which will be out later today). Can you try it out and confirm that it fixes the issue? You can download it by running GO111MODULE=on go get golang.org/x/tools/gopls@v0.5.5-pre.1.

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 4, 2020
@kdeconinck
Copy link
Author

Thanks for the feedback.
I have installed it locally in my project and the issue seems to be gone.

Ticket can be closed.

@golang golang locked and limited conversation to collaborators Dec 4, 2021
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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants