Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.13 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=REDACTED set GOENV=REDACTED set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=REDACTED set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=c:\go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=c:\go\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Tools\Cygwin\tmp\go-build079254262=/tmp/go-build -gno-record-gcc-switches
What did you do?
- gitlab.com/firelizzard/golang-issue-34300
- a
- go.mod
- b
- main.go - just
println("hello world")
- main.go - just
- c
- go.mod
- d
- main.go -
println("hello world")
and a package import
- main.go -
- a
-
Issues with
-trimpath
- Build from the parent directory - builds
go build -trimpath -o a.exe ./a/b
- Build from the module directory - builds
cd ./a && go build -trimpath -o ../b.exe ./b
- Build from the parent directory, forcing modules - fails with "cannot find main module"
GO111MODULE=on go build -trimpath -o am.exe ./a/b
- Build from the parent directory - builds
-
Issues with imports
- Build from the parent directory - fails with "cannot find package"
go build ./c/d
- Build from the module directory - builds
cd ./c && go build ./d
- Build from the parent directory, forcing modules - fails with "cannot find main module"
GO111MODULE=on go build ./c/d
- Build from the parent directory - fails with "cannot find package"
I used this script, sym.go
to dump the paths stored in the executables.
What did you expect to see?
I expected builds to work from both directories, and I expected -trimpath
to... trim paths.
What did you see instead?
Weird paths for the main package (results for b.exe
are what I expected for both):
% go run $GOROOT/src/cmd/objtest/sym.go a.exe
main.main => _/C_/Source/test/a/b/main.go:3
% go run $GOROOT/src/cmd/objtest/sym.go b.exe
main.main => test@/b/main.go:3
Errors when building:
c\d\main.go:3:8: cannot find package "github.com/etcd-io/bbolt" in any of:
GOROOT\src\github.com\etcd-io\bbolt (from $GOROOT)
GOPATH\src\github.com\etcd-io\bbolt (from $GOPATH)
go: cannot find main module, but found .git/config in C:\Source\test
to create a module there, run:
go mod init