ntaps
Scaffold Go service boilerplate the fast way: usecases, handlers (Echo), repositories (Postgres/sqlc), and outbound adapters β all wired into your DI.
- Generates clean, formatted Go code (runs
goimports under the hood).
- Idempotent: re-runs safely append to interfaces/impls and avoid dupes.
- Interactive mode for user-friendly prompts (or use flags if you prefer).
π Install
Requires Go 1.20+
go install github.com/AndreeJait/ntaps@latest
# make sure $(go env GOPATH)/bin is on your PATH
π Project Layout
ntaps expects a hexagonal service layout. It auto-detects the module path from the first line of go.mod.
Expected directories (auto-created if missing):
internal/
usecase/
adapters/
inbound/
http/
outbound/
db/
postgres/
<other outbound packagesβ¦>
infrastructure/
di/
handler.go
repository.go
config/
db/
π Start from the template repo:
go-template-hexagonal
π Global Conventions
π Commands
1) create-usecase
Scaffolds/extends a usecase.
ntaps create-usecase --pkg=send --method=SubmitCashToCash --withParam --withResponse
Generates:
internal/usecase/<pkg>/port.go
internal/usecase/<pkg>/dto.go
internal/usecase/<pkg>/usecase.go
- DI wiring in
internal/usecase/di.go + internal/infrastructure/di/usecase.go
β
Idempotent: re-runs append safely.
2) create-handler (Echo)
Interactive (default):
ntaps create-handler
# prompts: pkg, ucPkg, endpointType, endpoint, verb, etc.
With flags:
ntaps create-handler \
--pkg=send \
--ucPkg=send \
--endpointType=private \
--endpoint=/submit/cash-to-cash \
--withParamUc \
--withResponseUc \
--ucMethodName=SubmitCashToCash \
--method=submitCashToCash \
--tag=Send \
--verb=POST
3) create-repository (Postgres/sqlc)
ntaps create-repository \
--type=postgres \
--pkg=user \
--method=UpdateUserStatus \
--withParamRepo \
--withResponseRepo \
--withTx \
--addToUC=send
Generates:
internal/adapters/outbound/db/postgres/<pkg>/impl.go
internal/adapters/outbound/db/postgres/<pkg>/dto.go
- DI wiring in
internal/adapters/outbound/db/postgres/di.go
internal/infrastructure/di/repository.go
Optionally wires repo β usecase if --addToUC is given.
4) create-outbound (generic outbound adapter)
Interactive:
ntaps create-outbound
With flags:
ntaps create-outbound --pkg=email --method=SendEmailActivation --withParam --withResp
Generates:
internal/adapters/outbound/<pkg>/port.go
internal/adapters/outbound/<pkg>/impl.go
internal/adapters/outbound/<pkg>/dto.go
π‘ Interactive Mode Tips
π Versioning & Release Workflow
This repo includes GitHub Actions for version tagging:
The workflow:
- Creates an annotated tag & pushes it
- Moves
latest tag to same commit
- Creates a GitHub Release
Install a version:
go install github.com/AndreeJait/ntaps@v.0.1.0
Install the latest:
go install github.com/AndreeJait/ntaps@latest
π Troubleshooting
βinitUseCase/initRepository/handlers slice not foundβ
β Ensure DI files exist with expected names:
internal/infrastructure/di/usecase.go β func (s wire) initUseCase(...)
internal/infrastructure/di/repository.go β func (s wire) initRepository(...)
internal/infrastructure/di/handler.go β var handlers = []http.Handler{...}
Module path looks wrong
β Check first line of go.mod: module <path>
Imports/formatting
β Run manually:
gofmt -w . && goimports -w .
π¦ Template Use
Best to start from:
go-template-hexagonal
π License
MIT Β© AndreeJait