I'm new to go modules, and am taking them for a spin in a new project which I'm trying to model after the structure described here
Here is an example of my directory structure:
.
├── cmd
│ └── app_name
│ └── main.go
├── go.mod
├── go.sum
├── internal
│ └── bot
│ └── bot.go
└── pkg
├── website_name
│ ├── client.go
│ ├── client.options.go
│ ├── server.go
│ └── server.options.go
└── lib
└── lib.go
- Is this idiomatically correct? I know there's not a whole lot of consensus out there, but I'd like to follow best practices.
- When I run
go build
I get 'unexpected module path "github.com/ragurney/app_name/cmd/app_name"', but when I rungo build ./...
it works. Why?
When I move main.go
to the top level everything works as expected. Should I just not use the /cmd
pattern with modules?