Go
Possible, and the smallest change of the four. A context is one package tree inside one Go module. The compiler guards its inside.
The files
Explorer
- go.modone module for the whole app
- main.goapi, worker, migrate
- orders_gen.gogeneratedone file per context, committed
- context.yaml
- register.gothe one function
- public
- Go will not let another context import this
- policies.yaml
- flags.yaml
What the tools allow
| Question | Answer | Tag |
|---|---|---|
| Tests inside the folder | yes; coverage needs -coverpkg | MEASURED |
| A planted failing test | fails | MEASURED |
| Tests or docs in the binary | 0 found | MEASURED |
A src/ folder | no: internal/ must sit at the context's root | MEASURED |
| One Go module per context | no: go.work would be edited by every new context | MEASURED |
Another context's inside does not compile
billing imports the inside of orders (real output)
$go build ./...
package bc1/gobase/contexts/billing/internal/domain
contexts/billing/internal/domain/zz_breach.go:3:8: use of internal package bc1/gobase/contexts/orders/internal/domain not allowed
$
What changes in the template
| Change | Count | Tag |
|---|---|---|
| Files moved | 4 of 248 | MEASURED |
| Config files edited | 10 | MEASURED |
| Project files per context | 0 | MEASURED |
| Generated files per context | 1 | MEASURED |
What does not work cleanly
- Two new libraries on neighbouring lines conflict in
go.modandgo.sum.go mod tidyfixes it. MEASURED - The lint tool cannot match a context by wildcard, so our generator checks the layers. MEASURED
- No real Go app exists to try it on. NOT TESTED