Do you use linter to enforce layer/architecture boundaries?

Hi all,

Does anyone use a linter that also takes regex as parameters and checks to see if layer/architecture boundaries are not being stepped over ?

For example code in the database layer should not depend on code in the presentation layer directly, but instead only depend on bussiness logic layer ?

Is there such a tool that monitors code dependencies when compiling/linting ?

I’m not aware of such a tool, but you can hack it with go list and grep.

Complain if pkg/db imports pkg/preso:

if ( go list -f '{{range .Imports}}{{.}}{{"\n"}}{{end}}' \
  | grep -q ) ; then
  echo forbidden dependency
  exit 1
exit 0

Totally untested of course, etc

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.