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: Spurious newlines #21101

Closed
romeovs opened this issue Jul 20, 2017 · 4 comments
Closed

x/tools/cmd/goimports: Spurious newlines #21101

romeovs opened this issue Jul 20, 2017 · 4 comments

Comments

@romeovs
Copy link

romeovs commented Jul 20, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8.3 darwin/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/romeo/code/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.8.3/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.8.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ts/5_6bnlvn0lb8g4lnmvh7l9140000gn/T/go-build999961078=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

Using x/tools/goimports does not have a consistent way of grouping imports when newlines are there. For instance, both of these files will not be changed by goimports:

// A.go
package main

import (
	"os"
	"strings"
)

func main() {
	_ := os.Args
	_ := strings.NewReplacer
}
// B.go
package main

import (
	"os"

	"strings"
)

func main() {
	_ := os.Args
	_ := strings.NewReplacer
}

What did you expect to see?

I would expect the second one to be formatted like the first one.

@gopherbot gopherbot added this to the Unreleased milestone Jul 20, 2017
@fraenkel
Copy link
Contributor

This seems like a dupe of #20818

@mvdan
Copy link
Member

mvdan commented Jul 20, 2017

Indeed a duplicate.

@mvdan mvdan closed this as completed Jul 20, 2017
@bradfitz
Copy link
Contributor

@fraenkel, agreed.
Duplicate of #20818

@bradfitz bradfitz marked this as a duplicate of #20818 Jul 20, 2017
@romeovs
Copy link
Author

romeovs commented Jul 20, 2017

Weird it did not show up in the GitHub search!
I'll continue the discussion there.

@golang golang locked and limited conversation to collaborators Jul 20, 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

5 participants