Go Clean Architecture

GoDoc Build Status Build status codecov Go Report Card

Linter for enforcing clean architecture principles in Go. The linter reports violations of clean architecture dependency rules by checking go imports within packages against user defined dependency rules.

For more information on ‘The Clean Architecture Principle’ see Clean Architecture by Uncle Bob. The article Applying The Clean Architecture To Go Applications by Manual Kiessling is useful understand how clean architecture can be applied to Go applications.

Installation

Install go-clean-arch with the following command:

go get -u github.com/bvwells/go-clean-arch

Usage

To invoke go-clean arch use the command:

go-clean-arch [flags] [path]

where the flags are defined as:

-c  Config file containing list of clean architecture layers with hierarchy
    index from inner layers to outer layers.

Example

The go-clean-arch linter can be run on the Git repo https://github.com/ManuelKiessling/go-cleanarchitecture by cloning the repo using the command;

git clone https://github.com/ManuelKiessling/go-cleanarchitecture

Run the linter with the command:

go-clean-arch -c layers.json path-to-repo\go-cleanarchitecture\src

where the layers config file contains the clean architecture layers:

{
    "domain": 1,
    "usecases": 2,
    "interfaces": 3,
    "infrastructure": 4
}

Go Versions Supported

The most recent major version of Go is supported. You can see which versions are currently supported by looking at the lines following go: in .travis.yml.