go-clean-arch

command module
v0.0.0-...-b73b426 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 11 Imported by: 0

README

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.

Documentation

Overview

Go-clean-arch is a 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.

Usage

go-clean-arch [flags] [path]

The flags are:

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

Examples

To check go source code folder containing clean architecture layers:

go-clean-arch -c config.json path

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL