Skip to content

go test -cover outputs build errors with incorrect line numbers #22414

Closed
@leighmcculloch

Description

@leighmcculloch

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

go version go1.8 linux/amd64

Does this issue reproduce with the latest release?

Yes, I tried the same commands with go1.9 and the exact same output resulted.

go version go1.9 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/leighmcculloch/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build083996345=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
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?

$ git clone https://github.com/leighmcculloch/go-strrev.git
$ git checkout broken # ba1a9a9962908c303407878762304821fd764c4a
$ go test -cover

What did you expect to see?

I expected to see the same build error output as when I run go test.

$ go test
# 4d63.com/strrev
./strrev.go:17: undefined: bytes
./strrev.go:19: undefined: s
FAIL    4d63.com/strrev [build failed]

What did you see instead?

Different build error output, which displayed different line numbers and different locations for the files.

$ go test -cover  
# 4d63.com/strrev
/tmp/go-build636495490/4d63.com/strrev/_test/_obj_test/strrev.go:16: undefined: bytes
/tmp/go-build636495490/4d63.com/strrev/_test/_obj_test/strrev.go:19: undefined: s
FAIL    4d63.com/strrev [build failed]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions