Go Hexagonal Architecture

Standardize Go projects into hexagonal architecture with domain, service, and storage layers.

4|1|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/egravert/egravert-marketplace --skill go-hexagonal-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Go Hexagonal Architecture
Source: https://github.com/egravert/egravert-marketplace/tree/main/go-hexagonal/skills/go-hexagonal
Command: npx skills add https://github.com/egravert/egravert-marketplace --skill go-hexagonal-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It provides an opinionated blueprint for building Go services using a hexagonal (ports-and-adapters) architecture, helping teams create maintainable, testable, and evolvable codebases by strictly separating domain logic from infrastructure.

Core Features & Use Cases

  • Opinionated project layout for Go services (cmd/, internal/, storage/adapters) with clear separation of domain, service, and infrastructure.
  • Demonstrates translation between domain models and persistence, plus zero-dependency domain entities to enable pure logic testing.
  • Use cases include building new services, refactoring monoliths, and teaching teams a scalable architecture pattern.

Quick Start

Create a new Go service and structure it using a ports-and-adapters layout with clear domain, service, and storage boundaries.

Frequently Asked Questions about Go Hexagonal Architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Go project using hexagonal architecture?

To structure a Go project using hexagonal architecture, you separate code into strict domain, service, and storage boundaries. This opinionated layout uses a ports-and-adapters pattern with dedicated interface layers for CLI, TUI, and Web interactions.

What is the best way to separate domain logic from infrastructure in Go?

The best way to separate domain logic from infrastructure in Go is using a hexagonal architecture. This approach defines zero-dependency domain entities for pure logic testing and introduces translation layers between domain models and persistence.

Can I refactor an existing Go monolith into a ports-and-adapters layout?

Yes, you can refactor an existing Go monolith into a ports-and-adapters layout. The hexagonal architecture blueprint applies to both new service development and refactoring existing codebases that require a clean separation of concerns.

How do you handle translation between domain models and persistence in Go?

Translation between domain models and persistence in Go is handled via dedicated translation layers within the storage boundaries. This ensures the domain remains zero-dependency while allowing infrastructure adapters to manage persistence mapping.

When do I need a hexagonal architecture blueprint for my Go service?

You need a hexagonal architecture blueprint for your Go service when you require a maintainable, testable, and evolvable codebase. It is particularly useful for new services, refactoring monoliths, or teaching teams a scalable architecture pattern.

Does this hexagonal architecture approach support both CLI and Web interfaces in Go?

Yes, this hexagonal architecture approach supports both CLI and Web interfaces in Go. It defines dedicated interface layers for CLI, TUI, and Web, allowing multiple entry points to interact with the same isolated domain and service layers.