Use go modules.

In the top directory:
go mod init github.com/username/project-name

This creates go.mod in the top directory.

Put additional packages in their own subdirectories.  But *don't* run "go 
mod init" for these.  They all share the top one.

Example: foo/bar.go contains 
package xyz
func Doit() {
    ...
}

Your users can then import it like this:

import "github.com/username/project-name/foo"
xyz.Doit()

The packages in other subdirectories of your module can refer to each other 
in the same way.  They should *not* use relative imports.  Forget that 
relative imports ever existed, and it will all work.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f7a03a8e-9fb8-4c51-a601-922f78a5ed4fo%40googlegroups.com.

Reply via email to