top | item 9449670

Ask HN: Why do go apps have to live in $GOPATH/src?

3 points| j_mcnally | 11 years ago | reply

I don't get why GO projects need to live in $GOPATH, i know this is at least a requirement of Go deps but it seems dumb.

1 comment

order
[+] bketelsen|11 years ago|reply
They technically don't. The "go" tool is a programmatic wrapper around the compiler and linker - which live in your Go installation under pkg/tool/$platform The compiler for 64bit Linux is named 6g and the linker is named 6l. The "go" tool wraps usage of these two tools into a program that uses the convention of the GOPATH to figure out where dependencies should be found. If you wanted to do everything without a GOPATH you could. Go find your 6l and 6g tools and play with them a bit.

/usr/local/go/pkg/tool/linux_amd64/6g mygofile.go -o mygofile.a /usr/local/go/pkg/tool/linux_amd64/6l mygofile.a mygapp (disclaimer - this is off the top of my head - haven't manually compiled and linked in years because the go tool makes that unnecessary)