Architecture testing for Go

ArchUnitGo

Write the sentence your team already says aloud and let go test show where the code disagrees. ArchUnitGo covers files, layers, slices, metrics, and dependency graphs with structured violations and no special runner.

Main-branch previewGo 1.26+Repository terms

Go module

go get github.com/LukasNiessen/ArchUnitGo
architecture_test.go
package architecture_test

import (
    "testing"
    archunit "github.com/LukasNiessen/ArchUnitGo"
)

func TestApiDoesNotTouchDatabase(t *testing.T) {
    rule := archunit.ProjectFiles(nil).
        InFolder("internal/api/**").
        ShouldNot().DependOnFiles().
        InFolder("internal/db/**")

    archunit.AssertPasses(t, rule, nil)
}

Capabilities

What ArchUnitGo brings to the test suite.

The family shares a recognizable architecture vocabulary while each implementation stays honest about its language, toolchain, and maturity.

01

Go module and workspace discovery

02

File, named-layer, and slice rules

03

Counting and dependency metrics

04

Structured violations with test helpers

05

Graph snapshots and HTML reports

06

Glob, regex, and exclusion semantics

Current maturity

Main-branch preview

Functional on main with no tagged release yet; installation resolves to a pseudo-version and APIs may move.

LanguageGo
ReleaseUntagged preview
RuntimeGo 1.26+
LicenseRepository terms

Where it fits

Put boundaries next to the code they protect.

Common starting points for ArchUnitGo include the following project shapes.

Go servicesModular monolithsCLI applicationsPlatform tooling

Make the first boundary executable.

Add one meaningful rule, run it with the existing tests, and grow the architecture suite as the system reveals where it needs protection.

Start with ArchUnitGo ↗