Normally Golang projects on Github are consumed by go install
when there is a src
folder at the root of the project. Right now I have a Git repo structured like so:
project/
lang/
typescript/
java/
golang/
src/
pkg/
is there a way to use go install
against this git repo? Something like this:
go install 'github.com/org/project' --dir 'lang/golang'
anybody know if this is possible and how? Perhaps I can use go get
first to get the right directory, and then go install
after that?
Update - perhaps one solution is to use go bundle
to package the library, and then install the go library with a url to the file?
from the go documentation go command
after using
$ go get github.com/google/codesearch/index
$ go get github.com/petar/GoLLRB/llrb
Both of these projects are now downloaded and installed into $HOME/go, which contains the two directories src/github.com/google/codesearch/index/ and src/github.com/petar/GoLLRB/llrb/, along with the compiled packages (in pkg/) for those libraries and their dependencies.
Set GOPATH
environment variable to the project/lang/golang
directory and of your project (probably with a fully qualified path, i.e. one starting with /
on unix-like systems). go get
will install to the correct location. Other commands like go build
/go install
will also work properly.
Information about GOPATH: https://golang.org/doc/code.html#GOPATH
How to set GOPATH: https://github.com/golang/go/wiki/SettingGOPATH
You can also run the go help gopath
command for more documentation.