[Solved] Private Go projects and GOPATH beyond go 1.13 [duplicate]


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:

  1. Project foo is under GOPATH/src/foo/
  2. Project, our lib, greeting is under GOPATH/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]