Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go build inconsistent directory structure #11001

Closed
james-lawrence opened this issue May 30, 2015 · 3 comments
Closed

cmd/go: go build inconsistent directory structure #11001

james-lawrence opened this issue May 30, 2015 · 3 comments
Milestone

Comments

@james-lawrence
Copy link
Contributor

currently when crosscompiling gobuild will place the binary files for the non-native
os/architectures in a subdirectory in GOBIN, but for native os/arch they are placed at the root of GOBIN.

would be nice to have an option that specifies (or forces) the subdirectory within GOBIN so native builds can be packaged with the same code as crosscompilations.

e.g)

GOOS=linux GOARCH=amd64 go build --subdirectory=$GOOS\_$GOARCH {package}
tar -cf {name}-$GOOS-$GOARCH.tar.gz --directory $GOBIN/$GOOS\_$GOARCH .
GOOS=linux GOARCH=386 go build --subdirectory=$GOOS\_$GOARCH {package}
tar -cf {name}-$GOOS-$GOARCH.tar.gz --directory $GOBIN/$GOOS\_$GOARCH .

instead I need to do some checking to determine current goos/arch and treat that one dfferently.

@minux minux changed the title gobuild inconsistent directory structure. cmd/go: go build inconsistent directory structure May 30, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 3, 2015
@rsc
Copy link
Contributor

rsc commented Nov 23, 2015

It's not obvious to me we want more options. It might be that instead we should have an output line in "go env" that says where the binaries will be written. Then a script could look at that value to find out where to read them from.

@davecheney
Copy link
Contributor

@rsc, sgtm. We do the same in gb and that let's people integrating gb into larger scripts tune their behaviour appropriately.

@rsc
Copy link
Contributor

rsc commented Dec 17, 2015

I looked into adding something to 'go env' but the result depends on which package we're talking about. So it can't be printed from 'go env'. It can be printed from 'go list', which can be told what package to use, and in fact it already is:

$ go list -f '{{.Target}}' cmd/go rsc.io/toolstash golang.org/x/tools/cmd/godoc
/Users/rsc/go/bin/go
/Users/rsc/bin/toolstash
/Users/rsc/go/bin/godoc
$ GOOS=linux go list -f '{{.Target}}' cmd/go rsc.io/toolstash golang.org/x/tools/cmd/godoc
/Users/rsc/go/bin/linux_amd64/go
/Users/rsc/bin/linux_amd64/toolstash
/Users/rsc/go/bin/linux_amd64/godoc
$ 

So I think there's nothing to add here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants