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/cmd/goimports: #22045

Closed
niko-fp opened this issue Sep 26, 2017 · 1 comment
Closed

x/tools/cmd/goimports: #22045

niko-fp opened this issue Sep 26, 2017 · 1 comment

Comments

@niko-fp
Copy link

niko-fp commented Sep 26, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.9 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

What did you do?

run goimports -d .

It seems to not work as expected when there is a line with a comment

What did you expect to see?

Having in test.go

package main

var (
	translationItemResponseChannel chan string
	version                        string
	environment                    string
	countryCode                    string
	// CacheControlMaxAge in minutes
	CacheControlMaxAge int
        anotherVarToFix string
)

goimports should fix it and align the types like this

$ goimports -d test.go
diff -u test.go.orig test.go
--- test.go.orig	2017-09-26 17:02:52.000000000 +0200
+++ test.go	2017-09-26 17:02:52.000000000 +0200
@@ -3,8 +3,8 @@
 var (
 	translationItemResponseChannel chan string
 	version                        string
-	environment         string
+	environment                    string
 	countryCode                    string
 	// CacheControlMaxAge in minutes
-	CacheControlMaxAge int
-	anotherVarToFix string
+	CacheControlMaxAge             int
+	anotherVarToFix                string
 )

What did you see instead?

But if there is a commented line in between, weird things happen

$ goimports -d test.go
diff -u test.go.orig test.go
--- test.go.orig	2017-09-26 17:00:40.000000000 +0200
+++ test.go	2017-09-26 17:00:40.000000000 +0200
@@ -3,9 +3,9 @@
 var (
 	translationItemResponseChannel chan string
 	version                        string
-	environment         string
+	environment                    string
 	countryCode                    string
 	// CacheControlMaxAge in minutes
 	CacheControlMaxAge int
-	anotherVarToFix string
+	anotherVarToFix    string
 )
@gopherbot gopherbot added this to the Unreleased milestone Sep 26, 2017
@dominikh
Copy link
Member

This is working as intended. See for example #5277.

@golang golang locked and limited conversation to collaborators Sep 26, 2018
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