29 lines
1.5 KiB
Markdown
29 lines
1.5 KiB
Markdown
Scaffold a new internal domain package named `$ARGUMENTS`.
|
|
|
|
## Steps
|
|
|
|
1. 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)
|
|
|
|
2. 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.Run` and helpers from `gitea.djmil.dev/go/template/pkg/testutil`
|
|
- Use `logger.NewNop()` from `gitea.djmil.dev/go/template/pkg/logger` if logging is needed
|
|
|
|
## 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 return `result.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`.
|