A basic go module called example with additional handlers and data packages, which doesn’t require Git.
The key point is that a Go module that isn’t a source repo can be created, which enables local subfolders to be used as packages. This may be obvious to Go developers (as it is to me too…now), but I had to work it out the first time I created a Go project independent of my GitHub.
/data
- abc.go
/handlers
- xyz.go
go.mod
main.go
go.mod
Run this from the command line to generate.
$ go mod init example
module example
go 1.17
Code language: JavaScript (javascript)
main.go
package main
import example/handlers
...
Code language: JavaScript (javascript)
/handlers/xyz.go
package handlers
import example/data
...
Code language: JavaScript (javascript)