packageonly

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReportViolations

func ReportViolations(pass *analysis.Pass, violations []PackageOnlyViolation)

ReportViolations reports packageonly violations using the new pretty formatter NOTE: violations should already be filtered by @ignore directives in CheckPackageOnly

Types

type PackageOnlyViolation

type PackageOnlyViolation struct {
	Pos             token.Pos
	ItemName        string   // Name of the @packageonly object being used
	ItemPkgPath     string   // Package path where the item is defined
	CurrentPkgPath  string   // Current package path where the violation occurred
	AllowedPackages []string // Allowed packages for this item
	ReceiverType    string   // Receiver type for methods (empty for types/functions)
	Code            string   // Error code for this violation
}

PackageOnlyViolation represents a violation of @packageonly usage @immutable implements reporting.Violation

func CheckPackageOnly

func CheckPackageOnly(
	cfg *config.Config,
	pass *analysis.Pass,
	packageAnnotations *annotations.PackageAnnotations,
	ignoreSet *util.IgnoreSet,
) []PackageOnlyViolation

CheckPackageOnly checks that @packageonly annotated items are only used in allowed packages

func (PackageOnlyViolation) GetCode

func (v PackageOnlyViolation) GetCode() string

GetCode returns the error code for this violation

func (PackageOnlyViolation) GetMessage

func (v PackageOnlyViolation) GetMessage() string

GetMessage returns the main error message without formatting

func (PackageOnlyViolation) GetPos

func (v PackageOnlyViolation) GetPos() token.Pos

GetPos returns the position of the violation

Jump to

Keyboard shortcuts

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