Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Allowed ¶
Allowed is a list of modules and module domains that are allowed to be used.
func (*Allowed) IsAllowedModule ¶
IsAllowedModule returns true if the given module name is in the allowed modules list.
func (*Allowed) IsAllowedModuleDomain ¶
IsAllowedModuleDomain returns true if the given modules domain is in the allowed module domains list.
type Blocked ¶
type Blocked struct { Modules BlockedModules `yaml:"modules"` Versions BlockedVersions `yaml:"versions"` LocalReplaceDirectives bool `yaml:"local_replace_directives"` }
Blocked is a list of modules that are blocked and not to be used.
type BlockedModule ¶
type BlockedModule struct { Recommendations []string `yaml:"recommendations"` Reason string `yaml:"reason"` }
BlockedModule has alternative modules to use and a reason why the module is blocked.
func (*BlockedModule) HasRecommendations ¶ added in v1.1.0
func (r *BlockedModule) HasRecommendations() bool
HasRecommendations returns true if the blocked package has recommended modules.
func (*BlockedModule) IsCurrentModuleARecommendation ¶ added in v1.2.0
func (r *BlockedModule) IsCurrentModuleARecommendation(currentModuleName string) bool
IsCurrentModuleARecommendation returns true if the current module is in the Recommendations list.
If the current go.mod file being linted is a recommended module of a blocked module and it imports that blocked module, do not set as blocked. This could mean that the linted module is a wrapper for that blocked module.
func (*BlockedModule) Message ¶ added in v1.1.0
func (r *BlockedModule) Message() string
Message returns the reason why the module is blocked and a list of recommended modules if provided.
type BlockedModules ¶
type BlockedModules []map[string]BlockedModule
BlockedModules a list of blocked modules.
func (BlockedModules) Get ¶
func (b BlockedModules) Get() []string
Get returns the module names that are blocked.
func (BlockedModules) GetBlockReason ¶ added in v1.1.0
func (b BlockedModules) GetBlockReason(lintedModuleName string) *BlockedModule
GetBlockReason returns a block module if one is set for the provided linted module name.
type BlockedVersion ¶ added in v1.1.0
BlockedVersion has a version constraint a reason why the module version is blocked.
func (*BlockedVersion) IsLintedModuleVersionBlocked ¶ added in v1.2.0
func (r *BlockedVersion) IsLintedModuleVersionBlocked(lintedModuleVersion string) (bool, error)
IsLintedModuleVersionBlocked returns true if a version constraint is specified and the linted module version matches the constraint.
func (*BlockedVersion) Message ¶ added in v1.1.0
func (r *BlockedVersion) Message(lintedModuleVersion string) string
Message returns the reason why the module version is blocked.
type BlockedVersions ¶ added in v1.1.0
type BlockedVersions []map[string]BlockedVersion
BlockedVersions a list of blocked modules by a version constraint.
func (BlockedVersions) Get ¶ added in v1.1.0
func (b BlockedVersions) Get() []string
Get returns the module names that are blocked.
func (BlockedVersions) GetBlockReason ¶ added in v1.1.0
func (b BlockedVersions) GetBlockReason(lintedModuleName string) *BlockedVersion
GetBlockReason returns a block version if one is set for the provided linted module name.
type Configuration ¶
Configuration of gomodguard allow and block lists.
type Processor ¶
type Processor struct { Config *Configuration Modfile *modfile.File // contains filtered or unexported fields }
Processor processes Go files.
func NewProcessor ¶
func NewProcessor(config *Configuration) (*Processor, error)
NewProcessor will create a Processor to lint blocked packages.
func (*Processor) ProcessFiles ¶
ProcessFiles takes a string slice with file names (full paths) and lints them.
func (*Processor) SetBlockedModules ¶ added in v1.2.0
func (p *Processor) SetBlockedModules()
SetBlockedModules determines and sets which modules are blocked by reading the go.mod file of the module that is being linted.
It works by iterating over the dependant modules specified in the require directive, checking if the module domain or full name is in the allowed list.