Skip to content
Back to skills

Golang Architecture

ASecurity

A practical Clean Architecture layout for a Go microservice is: - `cmd/<service>/` - App entrypoint only. - Parse config, build logger/DB/HTTP server, wire dependencies, start the app. - Keep business logic out of `main.go`. - `internal/` - Private application code for this service. - Organize by domain or capability, not by generic layer buckets. - Example: - `internal/orders/` - Entities, use cases, service orchestration, domain interfaces owned by callers. - `internal/customers/` - `intern...

  • 584 stars
  • 0 votes
  • 4 copies
  • 14 views
  • Added September 5, 2026
developmentgosqlapidatabase

Works with

  • api

Security analysis

A100/100

Pro scans all 11 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill golang-architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Golang Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Golang Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-golang-architecture-agent-skills-standard/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-golang-architecture-agent-skills-standard)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
A practical Clean Architecture layout for a Go microservice is:

- `cmd/<service>/`
  - App entrypoint only.
  - Parse config, build logger/DB/HTTP server, wire dependencies, start the app.
  - Keep business logic out of `main.go`.

- `internal/`
  - Private application code for this service.
  - Organize by domain or capability, not by generic layer buckets.
  - Example:
    - `internal/orders/`
      - Entities, use cases, service orchestration, domain interfaces owned by callers.
    - `internal/customers/`
    - `internal/billing/`

- `internal/<domain>/transport/` or `internal/http/`
  - Delivery layer: HTTP handlers, request/response DTOs, routing, middleware.
  - Should call business use cases, not contain business rules.

- `internal/<domain>/storage/` or `internal/repository/`
  - Persistence adapters: SQL, Redis, external APIs.
  - Implements interfaces needed by use cases.
  - Accept `context.Context` on I/O paths.

- `internal/platform/` or narrower infrastructure packages
  - Shared infra with clear ownership, like:
    - `internal/platform/config`
    - `internal/platform/logging`
    - `internal/platform/database`
  - Use sparingly; avoid turning this into a dumping ground.

- `pkg/` (optional)
  - Only for code intentionally reusable by other modules/services.
  - If it is not a stable public package, keep it in `internal/`.

- `api/` (optional)
  - OpenAPI specs, protobuf files, generated contract definitions.

- `configs/` (optional)
  - Static config templates or example env files.

- `scripts/` (optional)
  - Dev and ops scripts: local bootstrap, codegen, release helpers.

- `test/` (optional)
  - Black-box integration or end-to-end tests if you want them outside package-local `_test.go` files.

Good rule of thumb:

- `cmd/` = startup and wiring
- `internal/<domain>/` = business capability
- transport/storage = adapters around the domain
- `pkg/` = truly reusable public code only

Example:

```text
myservice/
├── cmd/myservice/
│   └── main.go
├── internal/
│   ├── orders/
│   │   ├── entity.go
│   │   ├── service.go
│   │   ├── ports.go
│   │   ├── transport/http/
│   │   │   └── handler.go
│   │   └── storage/postgres/
│   │       └── repository.go
│   └── platform/
│       ├── config/
│       ├── database/
│       └── logging/
├── api/
├── configs/
├── scripts/
└── go.mod
```

The key is to keep dependencies explicit: wire concrete implementations in `cmd/<service>/main.go`, keep interfaces small and near the consumers, and avoid global singletons or generic `shared/utils` package sprawl.

Files in this skill

  • eval-1.baseline.md3 KB
  • eval-1.with-skill.md2.7 KB
  • eval-2.baseline.md364 B
  • eval-2.with-skill.md871 B
  • eval-3.baseline.md783 B
  • eval-3.with-skill.md1.1 KB
  • trigger-1.md229 B
  • trigger-2.md121 B
  • trigger-3.md184 B
  • trigger-4.md154 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.