Illustration that says, “The Go Layout Software Devs Can’t Resist”
Copyright © 2024 Mike Vincent. All Rights Reserved.

The Go Project Structure That Devs Can’t Resist

Go Projects. Technical or Business Layouts — Time to pick.

Mike Vincent
4 min readOct 21, 2024

--

When you’re building a Go project, how you organize the code matters. It’s not just about keeping it clean — it’s about making everything run faster. How easy it is to add features. How smooth it is for the team to work together. How you avoid bugs and broken code.

You’ve got two main options for structuring Go code: Technical Structure and Business Structure. Both work, but each has its sweet spot. Pick the wrong one, and you’ll feel it later.

The Go Technical Project Layout

The Technical Structure groups code by role. Handlers in one place. Repositories in another. Business logic somewhere else. It’s clear, and it keeps things easy to find. Think of it like a toolbox where every tool has its slot.

Example of a Go Technical Layout for REST APIs

Let’s say you’re working on two REST resources: Users and Orders. Here’s how the Technical Structure lays them out:

└── app/
├── handlers/
│ ├── users_handler.go
│ └── orders_handler.go
├── usecases/
│ ├── users_usecase.go
│ └── orders_usecase.go
├── repos/
│ ├── users_repo.go
│ └── orders_repo.go
└── models/
├── users_model.go
└── orders_model.go

The code is sorted by what it does:

  • Handlers handle incoming requests.
  • Use cases hold business logic.
  • Repositories deal with data.

Why the Go Technical Layout Works for Small Teams

  • Clear separation: Each piece of the system has its place. Handlers here, repos there. No overlap.
  • Easy testing: Each part can be tested alone. Want to test the orders repo? You don’t need to worry about the handler.
  • Familiar feel: If you’ve worked with MVC frameworks before, this setup feels natural.

Drawbacks of the Go Technical Layout

But when your project grows, it gets heavy. Let’s say you’re adding Products. You’ll need to create or update a handler, a use case, and a repository — spread across three different folders. Every change touches multiple spots, which slows you down. Changes get wide. Broad. The risk of breaking something increases.

The Go Business Project Layout

The Business Structure takes a different route. Instead of sorting by role, it groups everything by feature. Everything for Users goes in one folder. Same for Orders. It’s feature-focused, making it easier for teams to work independently on different parts of the app.

Example of a Go Business Layout for REST APIs

Here’s how the Business Structure organizes Users and Orders:

└── app/
├── users/
│ ├── handlers.go
│ ├── usecases.go
│ ├── repos.go
│ └── models.go
├── orders/
│ ├── handlers.go
│ ├── usecases.go
│ ├── repos.go
│ └── models.go

Everything related to Users is bundled together. Handlers, business logic, repos — all in one place. Same for Orders.

Why Devs Love the Go Business Layout for Speed

  • Feature-focused: When you’re adding a new resource — like Products — all your changes stay in the same folder. Clean, contained.
  • Easier teamwork: Devs can work on separate features — Users, Orders, etc. — without stepping on each other’s toes. Teams work on isolated parts of the code, which means fewer conflicts.
  • Narrow changes: Less risk. When you update a feature, the changes stay tight. You’re only touching what you need.

Trade-Offs of the Go Business Layout: Duplication

Duplication. You might end up writing similar code in both the Users and Orders repos. It’s not a deal-breaker, but it’s something to watch out for. The trade-off is worth it for the speed and focus you get in return.

Breadth of Changes in Go Projects: Why Layouts Matter

One of the biggest risks in any project is how wide a change spreads. In a Technical Structure, changes often touch multiple layers — handlers, use cases, repositories — making updates broad. More moving pieces, more chance for something to break.

In a Business Structure, changes stay narrow. When you’re adding a feature or fixing a bug, your changes are focused within a single folder. Less risk of accidentally breaking unrelated code.

Choosing the Right Go Layout for Scalability

The Technical Structure is great for small teams or simple projects. It’s clear, familiar, and keeps things easy to find. But as your project grows, the changes get wider, and managing the code becomes harder.

The Business Structure is perfect for bigger projects, especially when teams are working on different features at the same time. It keeps everything focused, makes teamwork easier, and reduces the risk of conflicts.

So, pick your structure based on your needs. If you’re looking to scale fast with a team, the Business Structure will serve you well. If you’re keeping things tight and simple, the Technical Structure will do just fine.

Fast. Focused. Done.

Next Steps

Whether you’re building your Go project from scratch or refining it for scale, structuring your code the right way is key. If you’re leading a dev team or heading IT and want to streamline your development, let’s talk. I specialize in DevOps, automation, and platform architecture, and I can help you optimize your setup for faster, smoother releases. Reach out to see how I can add value to your team.

About Mike Vincent

Mike Vincent is an American software engineer and leading voice in AI and Machine Learning infrastructure. With a strong track record in building high-performing tech teams and driving strategic initiatives, Mike specializes in cloud computing, containers, and automation. Based in Los Angeles, he holds degrees in Linguistics and Management.

Connect with Mike:

🔗 linkedin.com/in/michael-thomas-vincent

Disclaimer: This material has been prepared for informational purposes only, and is not intended to provide, and should not be relied on for business, tax, legal, or accounting advice.

--

--

Mike Vincent
Mike Vincent

Written by Mike Vincent

Mike Vincent is an American software engineer and writer based in Los Angeles. He writes about tech leadership and holds degrees in Linguistics and Management.

Responses (1)