4 ms·
pkg/cmd or just /cmd are rather popular in a lot of projects (https://github.com/grafana/grafana/tree/master/pkg/cmd https://github.com/grafana/grafana/tree/mas
by herval 7y ago
pkg/cmd or just /cmd are rather popular in a lot of projects (https://github.com/grafana/grafana/tree/master/pkg/cmd https://github.com/grafana/grafana/tree/master/pkg/cmd / https://github.com/prometheus/prometheus/tree/master/cmd https://github.com/prometheus/prometheus/tree/master/cmd / https://github.com/istio/istio/tree/c3e1824c5e3f3e51ceb4a80b46aee9876be07131/istioctl/cmd https://github.com/istio/istio/tree/c3e1824c5e3f3e51ceb4a80b... / https://github.com/containous/traefik/tree/master/cmd https://github.com/containous/traefik/tree/master/cmd / etc)
- tptacek 7y agocmd/ 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.