Documentation ¶
Overview ¶
Package pkgutil provides useful functions for working with packages.
Index ¶
- func Filter(pkgs pacman.AnyPackages, f FilterFunc) pacman.AnyPackages
- func FilterAll(pkgs pacman.AnyPackages, fs ...FilterFunc) pacman.AnyPackages
- func FilterAny(pkgs pacman.AnyPackages, fs ...FilterFunc) pacman.AnyPackages
- func FilterNewest(pkgs pacman.AnyPackages) pacman.AnyPackages
- func Intersect(ps1, ps2 pacman.Packages) pacman.Packages
- func Map(pkgs pacman.AnyPackages, f MapFunc) []string
- func MapAny(pkgs pacman.AnyPackages, f MapFunc) map[string]pacman.AnyPackage
- func MapBool(pkgs pacman.AnyPackages, f MapFunc) map[string]bool
- func MapPkg(pkgs pacman.AnyPackages, f MapFunc) map[string]*pacman.Package
- func PkgBase(ap pacman.AnyPackage) string
- func PkgBasename(ap pacman.AnyPackage) string
- func PkgFilename(ap pacman.AnyPackage) string
- func PkgFilter(ap pacman.AnyPackage) string
- func PkgName(ap pacman.AnyPackage) string
- func Subtract(ps1, ps2 pacman.Packages) pacman.Packages
- func Union(ps1, ps2 pacman.Packages) pacman.Packages
- type FilterFunc
- func GlobFltr(glob string, mf MapFunc) FilterFunc
- func MissingFltr() FilterFunc
- func MustRegexFltr(regex string, mf MapFunc) FilterFunc
- func NameFltr(names []string) FilterFunc
- func NewerFltr(pkgs pacman.AnyPackages) FilterFunc
- func NewestFltr(pkgs pacman.AnyPackages) FilterFunc
- func RegexFltr(regex string, mf MapFunc) (FilterFunc, error)
- func WordFltr(word string, mf MapFunc) FilterFunc
- type MapFunc
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
func Filter(pkgs pacman.AnyPackages, f FilterFunc) pacman.AnyPackages
Filter filters a set of packages with some filter functions.
The idea is that you can do this:
pkgs := pkgutil.FilterAll(pkgs, func(ap AnyPackage) bool { p := ap.(*meta.Package) p :=
func FilterAll ¶
func FilterAll(pkgs pacman.AnyPackages, fs ...FilterFunc) pacman.AnyPackages
FilterAll filters the packages through all of the filter functions.
func FilterAny ¶
func FilterAny(pkgs pacman.AnyPackages, fs ...FilterFunc) pacman.AnyPackages
FilterAny filters the packages through the filters in fs, where at least one must return true for it to be included.
func FilterNewest ¶
func FilterNewest(pkgs pacman.AnyPackages) pacman.AnyPackages
FilterNewest returns the newest of the given packages.
func Map ¶
func Map(pkgs pacman.AnyPackages, f MapFunc) []string
Map maps pacman.Packages to some string characteristic of a pacman.Package.
For example:
files := pkgutil.Map(ps, pkgutil.PkgFilename)
func MapAny ¶
func MapAny(pkgs pacman.AnyPackages, f MapFunc) map[string]pacman.AnyPackage
func PkgBase ¶
func PkgBase(ap pacman.AnyPackage) string
func PkgBasename ¶
func PkgBasename(ap pacman.AnyPackage) string
func PkgFilename ¶
func PkgFilename(ap pacman.AnyPackage) string
PkgFilename gets the filename of the package. There is no normalization done here. Comparing two pacman.Packages that refer to the same file might not have the same filename internally.
If you need that, check out PkgBasename!
func PkgFilter ¶
func PkgFilter(ap pacman.AnyPackage) string
PkgFilter returns a combination of many fields, separated by a space.
func PkgName ¶
func PkgName(ap pacman.AnyPackage) string
Types ¶
type FilterFunc ¶
type FilterFunc func(pacman.AnyPackage) bool
FilterFunc is a function that given a package, returns true if the package is ok, and false if it should not be included (filtered out).
It is used with the various Filter* functions to turn one set of pacman.Packages into another.
FilterFuncs can be combined and negated. The idea is that you implement your own filter functions.
func GlobFltr ¶
func GlobFltr(glob string, mf MapFunc) FilterFunc
GlobFltr passes all packages through that match the glob pattern.
func MissingFltr ¶
func MissingFltr() FilterFunc
MissingFltr passes all packages through that do not exist in the filesystem.
func MustRegexFltr ¶
func MustRegexFltr(regex string, mf MapFunc) FilterFunc
MustRegexFltr is the same as RegexFltr, except that it quits the program if regular expression is invalid.
func NameFltr ¶
func NameFltr(names []string) FilterFunc
NameFltr passes all packages through that have one of the names.
func NewerFltr ¶
func NewerFltr(pkgs pacman.AnyPackages) FilterFunc
NewerFltr passes all packages through that are really newer than the packages given.
func NewestFltr ¶
func NewestFltr(pkgs pacman.AnyPackages) FilterFunc
NewestFltr passes all packages through that are at least as new as the packages given; this is a superset of NewerFltr.
func RegexFltr ¶
func RegexFltr(regex string, mf MapFunc) (FilterFunc, error)
RegexFltr passes all packages through that match the regular expression.
func WordFltr ¶
func WordFltr(word string, mf MapFunc) FilterFunc
WordFltr passes all packages through that contain the given word.
func (FilterFunc) And ¶
func (f FilterFunc) And(fs ...FilterFunc) FilterFunc
And performs a logical AND of f and fs. True is returned only iff all the filter functions in fs and f return true.
func (FilterFunc) Not ¶
func (f FilterFunc) Not() FilterFunc
Not negates the effect of the filter. Therefore true becomes false and false becomes true.
func (FilterFunc) Or ¶
func (f FilterFunc) Or(fs ...FilterFunc) FilterFunc
Or performs a logical OR of f and fs. True is returned as soon as any of the filter functions in fs and f return true.
type MapFunc ¶
type MapFunc func(pacman.AnyPackage) string