5 ms·
cmd/ directories are normal. Hosting all the business logic for the whole package under cmd/ seems less normal. You kind of need cmd/, because you can only hav
by tptacek 7y ago
cmd/ directories are normal. Hosting all the business logic for the whole package under cmd/ seems less normal.
You kind of need cmd/, because you can only have one main() in a package, and a package with a main() can't easily be imported into another package. That's why the directory exists, not (as I understand it) because there is some merit to burying code 3 directory levels deep.
- herval 7y agomy response was to your comment that "having a directory tree that goes like "projectname/cmd/projectlibrary" seems super weird and non-idiomatic to me"
- PhilippGille 7y agoI'm on mobile and didn't check all your examples, but grafana has pkg/cmd and traefik has cmd next to pkg. That's not having the business logic below cmd. Whereas cmd/pkg is.