Closed
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
go version devel +6b3e343408 Tue Jun 12 03:42:37 2018 +0000 linux/amd64
Does this issue reproduce with the latest release?
No; this is only available in tip.
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/tmp/tmp.4mkm9vJCVB"
GORACE=""
GOROOT="/home/myitcv/gos"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="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-build091981204=/tmp/go-build -gno-record-gcc-switches"
What did you do?
cd `mktemp -d`
export GOPATH=$PWD
mkdir -p src/example.com
cd src/example.com
mkdir p1
cat <<EOD > p1/p1.go
package p1
const Name = "p1"
EOD
mkdir p2
cat <<EOD > p2/main.go
package main
import "fmt"
import "example.com/p1"
func main() {
fmt.Println(p1.Name == 5)
}
EOD
go list
behaves as expected (there are no syntax errors but there is a compile error):
$ go list ./...
example.com/p1
example.com/p2
But if we add the -export
and -e
flags we see:
$ go list -e -export ./...
p2/main.go:7:29: cannot convert p1.Name (type untyped string) to type int
p2/main.go:7:29: invalid operation: p1.Name == 5 (mismatched types string and int)
example.com/p1
example.com/p2
$ echo $?
2
I wonder whether my expectations about -e
are correct in the context of -export
?
The -e flag changes the handling of erroneous packages, those that cannot be found or are malformed.
What did you expect to see?
$ go list -e -export ./...
example.com/p1
example.com/p2
$ echo $?
0
What did you see instead?
Per the repro steps:
$ go list -e -export ./...
p2/main.go:7:29: cannot convert p1.Name (type untyped string) to type int
p2/main.go:7:29: invalid operation: p1.Name == 5 (mismatched types string and int)
example.com/p1
example.com/p2
$ echo $?
2
/cc @rsc