golang/go

x/tools/cmd/goimports: lost line between package and import statements in output

Open

#26,921 opened on Aug 10, 2018

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
NeedsFixToolshelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10.3 linux/amd64

Does this issue reproduce with the latest release?

Yes with go1.10.3 and the following commits:

golang.org/x/tools/imports: 8cb83b71b42ccf5fe279fa8a24a6a8f65507dc9c
golang.org/x/tools/cmd/goimports: 059bec968c61383b574810040ba9410712de36c5

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/legers/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/legers/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build017712154=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Very similar to issue #26290, but no initial import statement.

$ cat x.go
package p // comment

// T does something useful.
func T() {
    var _ = fmt.Printf
}

$ goimports x.go
package p // comment

import "fmt" // T does something useful.
func T() {
	var _ = fmt.Printf
}

A blank line should have been inserted after the new import statement.

Contributor guide