--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Since Go is almost always the primary language for such projects of mine, I just make all of the source live in $GOPATH/src/github.com/kylelemons/project. The Go code imports itself as github.com/kylelemons/project/whatever and the rest of the code doesn't really care where it lives.
The symlink approach does work, doesn't it? If it stops working then you'll know about it and can find an alternative.
You can have multiple GOPATHs. Why not just add an entry for the path where your go code in the larger project lives?
--
You can have multiple GOPATHs. Why not just add an entry for the path where your go code in the larger project lives?
go {build,install,fmt,test} proj/a/bwork for me where proj is a symlink in GOPATH to outside of GOPATH.Indeed those packages don't show up in godoc.I may be missing something myself. I have only experimented with one such multi-language project and haven't read the ML discussions you mention.
In the mean time, to work around I've had to do what you call the "obvious" way, but instead of using a symlink I have a small shell script in my project that reassigns the $GOPATH, which I can run before working on the project. Annoying but effective. Perhaps a more ideal solution would be to do the exporting when running a local build tool (e.g. Rake). By exporting the path in such a script it would only be temporary while the build is taking place, but then of course you have to write a bunch of build tasks to route to the go tool.
--
By the way, guys. If you need more flexibility you can always call the tools directly (compiler, linker, etc) instead of using the higher level tool and build your own build script.
I don't understand the issue here. GOPATH is only really needed when
you're doing "go get" or "go install". as long as you have a default
GOPATH for the stuff you "go get", then the rest of your projects can
be wherever you want. use relative imports to build library
hierarchies completely outside the canon, but still use the go tool to
compile them. I have plenty of projects outside GOPATH (including
stuff with relative imports), the go tool manages them just fine*.
Another way is to checkout the full project source (Go and Python) in $GOPATH/src/myproject and import "myproject/go" instead of "myproject". It's perfect and idiomatic from Go's point of view. But from Python's point of view, it's weird to be forced to live in $GOPATH. Go requires the project source to live in a directory src under $GOPATH. Now let's imagine that Python would require the project source to be rooted in a directory lib (for example) under its own $PYPATH. That would make Go's and Python's requirements contradictory and impossible to satisfy at the same time.
It's only impossible if you've really completely ruled out symlinks. If you can't symlink go, why not python? Eg.ln -s $GOPATH/src/myproject/python $PYPATH/lib
Well first you'd have to do some rearranging. Add a gopath like directory with a src/ and pkg/ directory in your repo. github.com/ngrilly/myproject/go/{src,pkg} for instanceThen move the *.go files into a reasonable directory in the src/ directory. .../go/src/myproject/*.go for instance.Then in your build script which you will need anyway since this is a multi language project add e.g. github.com/ngrilly/myproject/go/src/ to your GOPATH so all go builds of myproject/... will work.This will work for all your developers and packagers. It will not work for making the the go code go gettable but this is a multilanguage project where Go is not the primarly language so that is likely not really a goal in the first place.if go gettability *is* a goal then you should probably have the go code in a separate repo instead.
First, let me qualify things by saying I am new to Go, so I am still learning how to do things too. Having said that, do you know about Ruby Gemsets? We'll its basically like that. By changing the $GOPATH to point to each project as I work on it, I have an isolated set of Go installs all geared for use by the project I am working on. Of course the downside it that It creates redundancy, but I can live with it.
Since Go is almost always the primary language for such projects of mine, I just make all of the source live in $GOPATH/src/github.com/kylelemons/project. The Go code imports itself as github.com/kylelemons/project/whatever and the rest of the code doesn't really care where it lives.
that said, the relative import trick is not for everybody, i agree. if
i understand your constraints correctly, what you really are asking
for is to have your Go code live in two places at the same time:
inside GOPATH when convenient, and outside GOPATH the rest of the
time. you can do with some degree of success with union mounts on
unix-y operating systems, or you can even use sshfs to do it. just
mount at the right path and, even though you'll be editing outside
GOPATH the go tool will find your code. that gives you a fine control
over naming libraries as only the last part of the path must agree
with the stated package name. here's an example:
http://play.golang.org/p/twUCNd2UhJ
--
I realize that this is a very late response to this thread, but project layout has been something I’ve continued to struggle with since day one with Go.
I’ve tried capturing the entire gopath in version control, but this is awkward and makes creating go-gettable libraries difficult. I’ve gone back and forth on this and I think the simple answer is if you can reasonably work inside a single gopath, that’s probably the best way of working.
I can’t quite pull that off because of how I do branching, so I’ve been relying on home grown tools to mess around with the gopath. I’ve opensourced them today at:
I still consider this something of an experiment. If you can work inside a single gopath, that’s the way to go, but this is what i’m doing for now.