If you want to go with the $GOPATH way, then this is still working on go1.14.1:
You can put both projects (not using gomodules) inside your GOPATH:
- Project
foois underGOPATH/src/foo/ - Project, our lib,
greetingis underGOPATH/src/myfancycompany/greeting/
Our goal is that foo will import greeting.
Then foo/main.go will look like this:
package main
import "myfancycompany/greeting"
func main() {
println("How to greet?")
greeting.English()
}
And our lib myfancycompany/greeting/greeter.go will look like this:
package greeting
func English() {
println("hi, i am boo")
}
Then go build main.go and run it ./main:
~/go/src/foo$ ./main
How to greet?
hi, i am boo
1
solved Private Go projects and GOPATH beyond go 1.13 [duplicate]