data

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2022 License: MIT Imports: 4 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DocMatchStringIndex added in v0.9.7

func DocMatchStringIndex(pkg string, links PatternList) (idx int)

DocMatchStringIndex matches pkg in links and returns its index. Only full matches are returned. If pkg doesn't match, pkg+"/" is tried. -1 is returned for no match.

func RegexpForPattern added in v0.9.7

func RegexpForPattern(pattern string, allowDollar EnumDollar, maxDollar int,
) (*regexp.Regexp, int, []int, error)

RegexpForPattern converts the given pattern including wildcards and variables into a proper regular expression that can be used for matching.

func TypeFormat

func TypeFormat(t PkgType) string

TypeFormat returns the formatting string associated with package type t ("", "_", "`" or "**").

func TypeLetter

func TypeLetter(t PkgType) rune

TypeLetter returns the type letter associated with package type t ('S', 'T', 'D' or 'G').

Types

type EnumDollar added in v0.9.7

type EnumDollar int

EnumDollar is an enumeration type for how to hanlde dollars ('$') in patterns.

const (
	EnumDollarNone  EnumDollar = iota // '$' isn't allowed at all
	EnumDollarStar                    // '$' has to be followed by one or two '*'
	EnumDollarDigit                   // '$' has to be followed by a single digit (1-9)
)

internal enum for '$' handling in patterns

type Pattern added in v0.9.7

type Pattern struct {
	Pattern    string
	Regexp     *regexp.Regexp
	DollarIdxs []int
}

Pattern combines the original pattern string with a compiled regular expression ready for efficient evaluation.

type PatternGroup added in v0.9.8

type PatternGroup struct {
	Left  Pattern
	Right PatternList
}

type PatternList added in v0.9.7

type PatternList []Pattern

PatternList is a slice of the Pattern type.

func NewSimplePatternList added in v0.9.7

func NewSimplePatternList(patterns []string, key string) (PatternList, error)

NewSimplePatternList returns a PatternList initialized from the given patterns. An error is returned if a pattern isn't valid.

func (PatternList) MatchString added in v0.9.7

func (pl PatternList) MatchString(s string, dollars []string) (atAll, full bool)

MatchString returns true if any of the patterns in the pattern list matches the given string including its dollars and false otherwise. If the full string is matched full will be true and false otherwise.

func (PatternList) MatchStringIndex added in v0.9.7

func (pl PatternList) MatchStringIndex(s string, dollars []string) (idx int, full bool)

MatchStringIndex returns the index of the pattern in the list that matches the given string and an indicator if it was a full match.

func (PatternList) String added in v0.9.7

func (pl PatternList) String() string

String implements Stringer and returns the list of patterns, or "..." if no patterns have been added.

type PatternMap added in v0.9.8

type PatternMap map[string]PatternGroup

PatternMap is a map from a single pattern to a list of patterns.

func (*PatternMap) HasKeyValue added in v0.9.8

func (pm *PatternMap) HasKeyValue(key, strictKey, value, strictValue string) (hasKey, hasValue bool)

HasKeyValue checks if this pattern map contains the given key value pair. The strict versions are checked first (1. strictKey+strictValue, 2. strictKey+value, 3. key+strictValue, 4. key+value).

func (*PatternMap) String added in v0.9.8

func (pm *PatternMap) String() string

String implements Stringer and returns the map of patterns, or "....." if it is empty. The stringer methods are tested in the config package: TestParseAndStringers

type PkgType

type PkgType int

PkgType can be one of: Standard, Tool, DB or God

const (
	TypeStandard PkgType = iota
	TypeTool
	TypeDB
	TypeGod
)

Enum of package types: Standard, Tool, DB and God

Jump to

Keyboard shortcuts

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