The current code layout grew fast and organically, and doesn't follow any rule / invariant.
We have most Substrate binaries under /cmd//... although each one structures its packages in a different way. We also have api/, pkg/ internal/ etc.
This proposal tries to introduce some rules so we can have:
- Packages that can be imported by downstream projects in a safe way (no breakages).
- Clean separation of production code vs dev tooling.
- A common place for internal shared packages.
- A common place for internal per component packages.
A good starting point could be:
cmd/<component>/main.go for the component main packages / entrypoints.
internal/<component> for component specific specific packages.
internal for internal shared packages (across components).
pkg for the shared public packages.
hack/ dev scripts.
tools/<tool-name>: dev tools (e.g. benchmarking, load testing).
The current code layout grew fast and organically, and doesn't follow any rule / invariant.
We have most Substrate binaries under /cmd//... although each one structures its packages in a different way. We also have api/, pkg/ internal/ etc.
This proposal tries to introduce some rules so we can have:
A good starting point could be:
cmd/<component>/main.gofor the component main packages / entrypoints.internal/<component>for component specific specific packages.internalfor internal shared packages (across components).pkgfor the shared public packages.hack/dev scripts.tools/<tool-name>: dev tools (e.g. benchmarking, load testing).