rdev-go-ddgen: Automating Domain Directory Boilerplate for Go Applications

rdev-go-ddgen: Automating Domain Directory Boilerplate for Go Applications

2 7
calendar_todayschedule1 min read
— Originally published at dev.to

When building robust backend APIs in Go, maintaining a consistent, clean architectural pattern across domain directories is essential for scalability. However, manually creating repetitive domain structures for every new resource introduces subtle human error.

The Why: Why Manual Boilerplate Fails Copy-pasting existing files to scaffold a new domain (e.g., adding an orders domain next to a users domain) is a common but fragile practice. It is incredibly easy to overlook an import statement, miss a file, or forget to update a variable definition. As an API grows to dozens of domains, this manual approach becomes a major bottleneck that risks introducing compilation errors or silent bugs into your application.

The What: What is rdev-go-ddgen? rdev-go-ddgen (Domain Directory Generator) is a lightweight, open-source Command Line Interface (CLI) tool designed to eliminate manual boilerplate creation for Go applications. It targets developers looking to instantly spin up predictable, structured domain directories without the risk of copy-paste mistakes.

While built out of a personal need while developing high-conformance Go APIs using Gin and Bun ORM, rdev-go-ddgen is completely engine-agnostic and serves as a universal foundational bootstrapper.

The How: Rapid Deployment You can install rdev-go-ddgen globally and immediately integrate it into your development workflow with a single command:

go install github.com/XaiPhyr/rdev-go-ddgen@latest

To Initialize folder structure

rdev-go-ddgen init

To scaffold a completely new, structured domain directory, simply initialize the tool and use the domain flag (-d):

rdev-go-ddgen -d orders

This single command instantly generates a pristine directory containing five core architectural layers, fully stubbed with basic functions and type declarations:

handler.go – API routing and transport logic. service.go – Core business logic boundaries. repository.go – Database abstraction and data access. types.go – Domain-specific data models and structs. _test.go – Unit and integration test placeholders.

P.S. I hope this tool saves you some development time! rdev-go-ddgen is my first official contribution to the Go community, it’s a small step, but I’m incredibly excited to finally share something back with the ecosystem.

1 Comment

1 vote
🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

Merancang Backend Bisnis ISP: API Pelanggan, Paket Internet, Invoice, dan Tiket Support

Masbadar - Mar 13

Go-Gin & Bun ORM API Scaffolder

xaiphyr - Jun 17

Optimizing Bulk Product Uploads: Handling Embedded Images and Partial Success in Go

xaiphyr - Jun 12

Refactoring Go API Unit Tests: Breaking Down the Testing Monolith

xaiphyr - Jun 12

Optimizing the Clinical Interface: Data Management for Efficient Medical Outcomes

Huifer - Jan 26
chevron_left
199 Points9 Badges
Philippinesgithub.com/XaiPhyr
4Posts
0Comments
3Connections
Here’s my philosophy: If you know it, show it. If you learn it, earn it by teaching it.

I’m a firm... Show more

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!