You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
The text was updated successfully, but these errors were encountered:
When building in GOPATH mode, you'll need your dependencies fetched first with "go get". go help gopath-get provides useful instructions.
Finally, the trimpath behavior also seems correct when operating outside of your GOPATH in GOPATH mode. I'm not positive, but I think the package name is inferred based on the fully qualified path in that case.
I don't believe there is a bug here, so I am going to close this issue. Please re-open if you disagree.
If you have further questions on why build behaves this way, I suggest checking out one of the places listed on https://golang.org/wiki/Questions, such as golang-nuts.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
println("hello world")
println("hello world")
and a package importIssues with
-trimpath
go build -trimpath -o a.exe ./a/b
cd ./a && go build -trimpath -o ../b.exe ./b
GO111MODULE=on go build -trimpath -o am.exe ./a/b
Issues with imports
go build ./c/d
cd ./c && go build ./d
GO111MODULE=on go build ./c/d
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):Errors when building:
The text was updated successfully, but these errors were encountered: