1.5 KiB
1.5 KiB
Scaffold a new internal domain package named $ARGUMENTS.
Steps
-
Create
internal/$ARGUMENTS/$ARGUMENTS.go:- Package declaration
package $ARGUMENTS - One exported concrete type named after the package's responsibility (e.g.
Service,Store,Client,Parser) - Constructor:
func New(...) *<Type>— only accept dependencies the type actually needs; leave the signature empty if none are obvious yet - At least one exported method stub representing the package's primary operation; return
result.Expect[T]if the operation can fail - Doc comment on every exported symbol (the linter enforces this)
- Package declaration
-
Create
internal/$ARGUMENTS/$ARGUMENTS_test.go:- Package:
package $ARGUMENTS_test(black-box) - Declare a minimal interface covering only the methods the test calls
- Write a manual fake struct that satisfies that interface (no code generation)
- One table-driven test using
t.Runand helpers fromgitea.djmil.dev/go/template/pkg/testutil - Use
logger.NewNop()fromgitea.djmil.dev/go/template/pkg/loggerif logging is needed
- Package:
Rules (do not break these)
- Never define an interface inside the package itself — consumers define interfaces
- Never call
.Expect(),.Must(), or.Expectf()inside the package — only returnresult.Expect[T] - No third-party imports
- No hard-coded configuration values
After scaffolding
Run make lint test to verify the files compile and the stub test passes. Report what was created and suggest what the caller should wire in cmd/app/main.go.