pkgboundaries

package module
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 6 Imported by: 0

README

status PkgGoDev

pkgboundaries

pkgboundaries find layering violations.

Synopsis

go install github.com/aereal/pkgboundaries@latest
go vet -vettool=$(which pkgboundaries) -pkgboundaries.config=path/to/pkgboundaries.json ./...

See testdata/config.json.

License

See LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLayersSet

func NewLayersSet(layers ...*Layer) *sets.OrderedSet[*Layer]

func NewPackagesSet

func NewPackagesSet(pkgNames ...string) *sets.OrderedSet[Package]

Types

type Config

type Config struct {
	// Layers is a set of layer definitions.
	Layers *sets.OrderedSet[*Layer]

	// Rules is a set of rules.
	Rules []*Rule
}

Config is pkgboundaries' configuration.

func (*Config) CanDepend

func (c *Config) CanDepend(dependantLayerName string, dependency Package) Decision

type Decision

type Decision int
const (
	DecisionDeny Decision = iota
	DecisionAllow
)

func (Decision) And

func (d Decision) And(other Decision) Decision

func (Decision) String

func (e Decision) String() string

type Layer

type Layer struct {
	Name                string
	PackageNames        *sets.OrderedSet[Package]
	PackageNamePatterns *PackagePatternSet
}

Layer is a named set of packages.

func (*Layer) GoString

func (l *Layer) GoString() string

func (*Layer) Key

func (l *Layer) Key() string

type LayersSet

type LayersSet sets.OrderedSet[*Layer]

LayersSet is an ordered set of layers.

func (*LayersSet) FindByPackagePath

func (s *LayersSet) FindByPackagePath(pkgPath string) *Layer

FindByPackagePath returns a layer that the pkgPath belongs to.

type Package

type Package string

func (Package) Key

func (p Package) Key() string

type PackagePattern

type PackagePattern string

PackagePattern is a regular expression that matches packages.

func (PackagePattern) Key

func (p PackagePattern) Key() string

type PackagePatternSet

type PackagePatternSet struct {
	// contains filtered or unexported fields
}

func NewPackagePatternSet

func NewPackagePatternSet(patterns ...PackagePattern) *PackagePatternSet

func (*PackagePatternSet) MarshalJSON

func (ps *PackagePatternSet) MarshalJSON() ([]byte, error)

func (*PackagePatternSet) UnmarshalJSON

func (ps *PackagePatternSet) UnmarshalJSON(b []byte) error

type Rule

type Rule struct {
	// Layer is a layer name applies the rule.
	Layer string

	// Allowed is layer names list that can be appeared in dependency list.
	Allowed []string

	// Denied is layer names list that can NOT be appeared in dependency list.
	Denied []string
}

Rule is a pair of Layer and allowed/denied layers list.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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