util

package
v0.0.0-...-b7948c7 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2017 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package util contains a collection of miscellaneous utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Basename

func Basename(p string) string

Basename is the base of a path string.

func BoolMapTrue

func BoolMapTrue(l []bool) bool

BoolMapTrue returns true if everyone in the list is true.

func BoolMapValues

func BoolMapValues(m map[string]bool) []bool

BoolMapValues returns the sorted list of bool values in a map with string values.

func DirifyFileList

func DirifyFileList(fileList []string, removeDirs bool) []string

DirifyFileList adds trailing slashes to any likely dirs in a package manager fileList if removeDirs is true, otherwise, don't keep the dirs in our output.

func Dirname

func Dirname(p string) string

Dirname is similar to the GNU dirname command.

func FirstToUpper

func FirstToUpper(str string) string

FirstToUpper returns the string with the first character capitalized.

func FlattenListWithSplit

func FlattenListWithSplit(input []string, split []string) []string

FlattenListWithSplit flattens a list of input by splitting each element by any and all of the strings listed in the split array

func HasPathPrefix

func HasPathPrefix(p, prefix string) bool

HasPathPrefix tells us if a path string contain the given path prefix in it.

func PathPrefixDelta

func PathPrefixDelta(p, prefix string) int

PathPrefixDelta returns the delta of the path prefix, which tells you how many path tokens different the prefix is.

func PathSplit

func PathSplit(p string) []string

PathSplit splits a path into an array of tokens excluding any trailing empty tokens.

func PathSplitFullReversed

func PathSplitFullReversed(p string) []string

PathSplitFullReversed returns the full list of "dependency" paths for a given path in reverse order.

func RemoveCommonFilePrefixes

func RemoveCommonFilePrefixes(paths []string) []string

RemoveCommonFilePrefixes removes redundant file path prefixes that are under the tree of other files.

func ReverseStringList

func ReverseStringList(in []string) []string

ReverseStringList reverses a list of strings.

func StrFilterElementsInList

func StrFilterElementsInList(filter []string, list []string) []string

StrFilterElementsInList removes any of the elements in filter, if they exist in the list.

func StrInList

func StrInList(needle string, haystack []string) bool

StrInList returns true if a string exists inside a list, otherwise false.

func StrInPathPrefixList

func StrInPathPrefixList(needle string, haystack []string) bool

StrInPathPrefixList returns true if the needle is a PathPrefix in the haystack.

func StrListIntersection

func StrListIntersection(list1 []string, list2 []string) []string

StrListIntersection removes any of the elements in filter, if they don't exist in the list. This is an in order intersection of two lists.

func StrMapKeys

func StrMapKeys(m map[string]string) []string

StrMapKeys return the sorted list of string keys in a map with string keys. NOTE: i thought it would be nice for this to use: map[string]interface{} but it turns out that's not allowed. I know we don't have generics, but come on!

func StrMapKeysUint64

func StrMapKeysUint64(m map[string]uint64) []string

StrMapKeysUint64 return the sorted list of string keys in a map with string keys but uint64 values.

func StrMapValues

func StrMapValues(m map[string]string) []string

StrMapValues returns the sorted list of string values in a map with string values.

func StrMapValuesUint64

func StrMapValuesUint64(m map[uint64]string) []string

StrMapValuesUint64 return the sorted list of string values in a map with string values.

func StrRemoveDuplicatesInList

func StrRemoveDuplicatesInList(list []string) []string

StrRemoveDuplicatesInList removes any duplicate values in the list. This is a possibly sub-optimal, O(n^2)? implementation.

func SystemBusPrivateUsable

func SystemBusPrivateUsable() (conn *dbus.Conn, err error)

SystemBusPrivateUsable makes using the private bus usable TODO: should be upstream: https://github.com/godbus/dbus/issues/15

func TimeAfterOrBlock

func TimeAfterOrBlock(t int) <-chan time.Time

TimeAfterOrBlock is aspecial version of time.After that blocks when given a negative integer. When used in a case statement, the timer restarts on each select call to it.

func Uint64KeyFromStrInMap

func Uint64KeyFromStrInMap(needle string, haystack map[uint64]string) (uint64, bool)

Uint64KeyFromStrInMap returns true if needle is found in haystack of keys that have uint64 type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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