Organize local code in packages using Go modules
I can not find a way to factor out some code from main.go into a local package when using Go modules (go version >= 1.11) outside of $GOPATH . I am not importing any external dependencies that need to be included into go.mod , I am just trying to organize locally the source code of this Go module. The file main.go : package main // this import does not work import "./stuff" func main() { stuff.PrintBaz() } The file ./stuff/bar.go (pretending to be a local package): package stuff import "log" type Bar struct { Baz int } func PrintBaz() { baz := Bar{42} log.Printf("Bar struct: %v", baz) } The