This article was originally published on bmf-tech.com.
Overview
A note on how to perform static analysis of Clean Architecture layers in Go.
Using go-cleanarch
While I could have created a custom static analysis tool, I found an easy-to-use tool and decided to try it out.
I introduced it to my custom CMS, gobel-api.
cf. PR
Install it with go install github.com/roblaszczak/go-cleanarch@latest.
Since the layer naming differs from the default, run the check with options.
go-cleanarch -application usecase
If there is a violation of layer dependencies, the check will catch it and result in an error.
If an error occurs, you'll be told, Uncle Bob is not happy.
Thoughts
I plan to create my own tool eventually, but for now, I want to rely on this tool.
I believe that static analysis tools like this should be introduced early to maintain the design and structure of applications.
Since Go makes it easy to implement static analysis tools, it seems beneficial to actively create such tools if you want to maintain the structure of specific layers, not limited to Clean Architecture.
Top comments (0)