The variant with relative paths can be used, BUT it works only if you compile the file directly, for example go build asd.go
If you compile the entire package, the relative paths do not work and you need to prescribe the full path from $ GOPATH / src
for example if there are packages
github.com/rekby/tmp github.com/rekby/tmp/asd.go, export Func1 github.com/rekby/tmp/sub1 github.com/rekby/tmp/sub1/sub2 github.com/rekby/tmp/sub1/sub2/asd.go, export Func2
That (so that the code is always compiled regardless of the form of the call) in sub1 / main.go you need to write
package main import ( "fmt" "github.com/rekby/tmp" "github.com/rekby/tmp/sub1/sub2" ) func main(){ fmt.Println(tmp.Func1(), sub2.Func2()) }
If you write
import ( "fmt" tmp ".." "../sub1/sub2" ) func main(){ fmt.Println(tmp.Func1(), sub2.Func2()) }
then the code will be compiled only by calling "go build main.go", but NOT "go build" from the project folder or "go build github.com/rekby/tmp/sub1" or "go get github.com/rekby/tmp/sub1 "