Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference

archrules

A Go library for enforcing architectural rules in your Go codebase.


Caution

go-archrules is still in active development and may face breaking changes on the road to stabilization.

Why?

I originally made a proposal for a custom lintier on an open source api at my school, I felt like many students who wanted to try their hands at backend would not recognize concepts like dependency injections and such, so hence the proposal of a custom linter to enforce these rules (like not importing db models in handlers, etc...). I figured it might be a fun idea to turn it into a bigger library with more options and for others to use! Whether it be for enforcing rules like mentioned above, or making coding challanges!

How do I use it?

Simply run

go get github.com/GaballaGit/go-archrules@latest

Here is an example in action

package main

import (
	"fmt"
	"github.com/GaballaGit/go-archrules"
)

func main() {
	test := &archrules.Rule{
		NecessaryImports:     []string{"fmt", "time"},
		OnlyNecessaryImports: true,
	}

	fmt.Println("Running archrules!")
	err := archrules.Run(".", test)
	if err != nil {
		fmt.Println(err, "\n", "Whats the time again?")
	}
}

Output

Running archrules!
Missing necessary imports: "time" in main.go 
 Whats the time again?

To-Do

  • Skip directory
  • Necessary and Forbidden Functions
  • Necessary and Forbidden Operators
  • Necessary and Forbidden Methods

About

A Go library for enforcing architectural rules in your Go codebase.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages