change you project structure too:
src/
foo/
bar/
v1/ (go code in package bar)
x.go
v2/
x.go
quux/
v1/ (go code in package main)
y.go
this is the only possible way to handle different version of your libs.
with this you also solve the problem jnml described, now each lib would have its own dependencies and versions to other libs.
update due to comments:
according to workspace documentation described here:
http://golang.org/doc/code.html#Workspaces
your structure will looke like
src/
foo/
bar/
v1/ (go code in package bar)
x.go
v2/
x.go
quux/
v1/ (go code in package main)
y.go
meier/
v1/ (go code in package main)
w.go
v2/ (go code in package main)
w.go
now in your bar lib (x.go) you need functions from lib *quux (y.go)
to import this you will write :
import "foo/quux/v1/"
just as note you can also do the version before package in your structure so instead of foo/quux/v1 your structure could look like /foo/v1/quux, then you dont need to name the imports.
now lib quux uses lib meier in version 1
so import will be:
import "foo/meier/v1"
and regarding to jnml,
now you lib bar also needs lib meier but in version 2
so import will look like:
import "foo/meier/v2"
now when you call: bar -> quux -> meier
you will see that you can't assign /pass the return value in bar to something from meier
because: meier/v1 != meier/v2
and this will fail already during compilation.
if you need to work with result from quux which is coming from meier v1 you need to also import meier/v1 in bar