pkgutil

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pkgutil provides useful functions for working with packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

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 Intersect

func Intersect(ps1, ps2 pacman.Packages) pacman.Packages

Intersect returns the intersection between two sets of pacman.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 MapBool

func MapBool(pkgs pacman.AnyPackages, f MapFunc) map[string]bool

func MapPkg

func MapPkg(pkgs pacman.AnyPackages, f MapFunc) map[string]*pacman.Package

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

func Subtract

func Subtract(ps1, ps2 pacman.Packages) pacman.Packages

Subtract returns ps1 minus all packages that are found in ps2.

func Union

func Union(ps1, ps2 pacman.Packages) pacman.Packages

Union returns the union of two sets of pacman.Packages.

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

type Set

type Set map[string]pacman.Packages

func NewSet

func NewSet() Set

func (Set) All

func (s Set) All() pacman.Packages

func (Set) Contains

func (s Set) Contains(p *pacman.Package) bool

func (Set) Insert

func (s Set) Insert(p *pacman.Package)

func (Set) InsertAll

func (s Set) InsertAll(pkgs pacman.Packages)

func (Set) Remove

func (s Set) Remove(p *pacman.Package)

Jump to

Keyboard shortcuts

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