ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - roblaszczak/go-cleanarch: Clean architecture validator for go, like a The Dependency Rule and interaction between packages in your Go projects.
Clean architecture validator for go, like a The Dependency Rule and interaction between packages in your Go projects. - roblaszczak/go-cleanarch
Visit Site

GitHub - roblaszczak/go-cleanarch: Clean architecture validator for go, like a The Dependency Rule and interaction between packages in your Go projects.

GitHub - roblaszczak/go-cleanarch: Clean architecture validator for go, like a The Dependency Rule and interaction between packages in your Go projects.

Clean Architecture checker for Golang

Go Report Card

go-cleanarch was created to keep Clean Architecture rules, like a The Dependency Rule and interaction between modules in your Go projects. For more information you should read our article about Clean Architecture.

Some benefits of using Clean Architecture:

  1. Independent of Frameworks. The architecture does not depend on the existence of some library of feature laden software. This allows you to use such frameworks as tools, rather than having to cram your system into their limited constraints.
  2. Testable. The business rules can be tested without the UI, Database, Web Server, or any other external element.
  3. Independent of UI. The UI can change easily, without changing the rest of the system. A Web UI could be replaced with a console UI, for example, without changing the business rules.
  4. Independent of Database. You can swap out Oracle or SQL Server, for Mongo, BigTable, CouchDB, or something else. Your business rules are not bound to the database.
  5. Independent of any external agency. In fact your business rules simply don’t know anything at all about the outside world.

Source: The Clean Architecture

Clean Architecture

Project schema requirements

go-cleanarch assumes this files structure:

[GOPATH]/[PACKAGE_NAME]/[LAYER_NAME]

or

[GOPATH]/[PACKAGE_NAME]/[MODULE_NAME]/[LAYER_NAME]

For example

  • go/src/github.com/roblaszczak/awesome-app
    • auth
      • domain
      • application
      • interfaces
    • content
      • domain
        • submodule1
        • submodule2
        • etc.
      • application
      • interfaces
    • frontend
      • domain
      • application
      • interfaces

Allowed LAYER_NAME:

The default layer names are as followed. It is possible to set different names by command line parameters see -domain/-application/-interfaces/-infrastructure bellow.

var LayersAliases = map[string]Layer{
    // Domain
    "domain":   LayerDomain,
    "entities": LayerDomain,

    // Application
    "app":         LayerApplication,
    "application": LayerApplication,
    "usecases":    LayerApplication,
    "usecase":     LayerApplication,
    "use_cases":   LayerApplication,

    // Interfaces
    "interfaces": LayerInterfaces,
    "interface":  LayerInterfaces,
    "adapters":   LayerInterfaces,
    "adapter":    LayerInterfaces,

    // Infrastructure
    "infrastructure": LayerInfrastructure,
    "infra":          LayerInfrastructure,
}

For examples please go to examples directory, with contains examples of valid and invalid architectures.

For more information you should read our article about Clean Architecture.

Installing

go install github.com/roblaszczak/go-cleanarch@latest

go-cleanarch was only tested on Linux and also should work on OS X. Probably it doesn't work well on Windows.

Running

To run in the current directory:

go-cleanarch

To run in provided directory

go-cleanarch go/src/github.com/roblaszczak/awesome-cms

Process will exit with code 1 if architecture is not valid, otherwise it will exit with 0.

-ignore-tests

If you need to ignore *_test.go files in go-cleanarch check you can pass -ignore-tests

go-cleanarch -ignore-tests

It is useful when you have memory implementation in infrastructure layer and you need to test application service which depends of it.

-ignore-package

If for some reason you need to allow to make forbidden import, for example

github.com/roblaszczak/go-cleanarch/examples/ignore-package/app to github.com/roblaszczak/go-cleanarch/examples/ignore-package/domain.

you can use

go-cleanarch -ignore-package=github.com/roblaszczak/go-cleanarch/examples/ignore-package/app 

Layer names

The layer names can be set to a specific value with the following parameters. Each parameter stands for on layer.

go-cleanarch -domain dom -application appli -interfaces int -infrastructure outer

This would only allow the domain name to be dom, application hast to be appli, interafces must be int and infrastructure must be outer.

Running the tests

make test

And coding style tests

make qa

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Credits

Made without love by Robert Laszczak </3

License

This project is licensed under the MIT License.

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory