util

package
v1.0.131 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWritePermissions = 0760

	MaximumNewDirectoryAttempts = 1000
)
View Source
const (
	ALIGN_LEFT   = 0
	ALIGN_CENTER = 1
	ALIGN_RIGHT  = 2
)
View Source
const (
	DefaultSuggestionsMinimumDistance = 2
)

Variables

View Source
var ColorError = color.New(color.FgRed).SprintFunc()
View Source
var ColorInfo = color.New(color.FgGreen).SprintFunc()
View Source
var ColorStatus = color.New(color.FgBlue).SprintFunc()
View Source
var ColorWarning = color.New(color.FgYellow).SprintFunc()

Functions

func AtoInt32 added in v1.0.2

func AtoInt32(text string) (int32, error)

func BinaryLocation added in v1.0.6

func BinaryLocation() (string, error)

func CacheDir added in v1.0.6

func CacheDir() (string, error)

func ConfigDir added in v1.0.6

func ConfigDir() (string, error)

func Contains added in v1.0.29

func Contains(arr []string, str string) bool

func CopyDir added in v1.0.75

func CopyDir(src string, dst string, force bool) (err error)

credit https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04

func CopyFile added in v1.0.75

func CopyFile(src, dst string) (err error)

credit https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04

func CreateUniqueDirectory added in v1.0.2

func CreateUniqueDirectory(dir string, name string, maximumAttempts int) (string, error)

CreateUniqueDirectory creates a new directory but if the combination of dir and name exists then append a number until a unique name is found

func DownloadFile added in v1.0.6

func DownloadFile(filepath string, url string) (err error)

Download a file from the given URL

func EnvironmentsDir added in v1.0.6

func EnvironmentsDir() (string, error)

func FileExists

func FileExists(path string) (bool, error)

func FirstNotEmptyString added in v1.0.26

func FirstNotEmptyString(values ...string) string

FirstNotEmptyString returns the first non empty string or the empty string if none can be found

func GetCommandOutput added in v1.0.14

func GetCommandOutput(dir string, name string, args ...string) (string, error)

GetCommandOutput evaluates the given command and returns the trimmed output

func GetLatestVersionFromGitHub added in v1.0.6

func GetLatestVersionFromGitHub(githubOwner, githubRepo string) (semver.Version, error)

func HomeDir added in v1.0.6

func HomeDir() string

func Int32ToA added in v1.0.2

func Int32ToA(n int32) string

func InvalidArg added in v1.0.2

func InvalidArg(value string, values []string) error

func InvalidArgError added in v1.0.2

func InvalidArgError(value string, err error) error

func InvalidArgf added in v1.0.2

func InvalidArgf(value string, message string, a ...interface{}) error

func InvalidOption added in v1.0.2

func InvalidOption(name string, value string, values []string) error

func InvalidOptionError added in v1.0.2

func InvalidOptionError(option string, value string, err error) error

func InvalidOptionf added in v1.0.2

func InvalidOptionf(option string, value string, message string, a ...interface{}) error

func LoadCacheData added in v1.0.2

func LoadCacheData(fileName string, loader CacheLoader) ([]byte, error)

LoadCacheData loads cached data from the given cache file name and loader

func MissingOption added in v1.0.54

func MissingOption(name string) error

func Pad added in v1.0.123

func Pad(s, pad string, width int, align int) string

func PadCenter added in v1.0.123

func PadCenter(s, pad string, width int) string

func PadLeft added in v1.0.123

func PadLeft(s, pad string, width int) string

func PadRight added in v1.0.123

func PadRight(s, pad string, width int) string

func PickName added in v1.0.10

func PickName(names []string, message string) (string, error)

func PickNameWithDefault added in v1.0.10

func PickNameWithDefault(names []string, message string, defaultValue string) (string, error)

func PickNames added in v1.0.10

func PickNames(names []string, message string) ([]string, error)

func PickValue added in v1.0.112

func PickValue(message string, defaultValue string, required bool) (string, error)

func RegexpSplit

func RegexpSplit(text string, regexSeperator string) []string

RegexpSplit splits a string into an array using the regexSep as a separator

func ReverseStrings added in v1.0.69

func ReverseStrings(a []string)

func SelectNames added in v1.0.119

func SelectNames(names []string, message string, selectAll bool) ([]string, error)

SelectNames select which names from the list should be chosen

func SortedMapKeys added in v1.0.54

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

SortedMapKeys returns the sorted keys of the given map

func StringArrayIndex added in v1.0.2

func StringArrayIndex(array []string, value string) int

func StringIndexes

func StringIndexes(text string, value string) []int

StringIndexes returns all the indices where the value occurs in the given string

func SuggestionsFor added in v1.0.2

func SuggestionsFor(typedName string, values []string, suggestionsMinimumDistance int, explicitSuggestions ...string) []string

func UnTargz added in v1.0.6

func UnTargz(tarball, target string, onlyFiles []string) error

untargz a tarball to a target, from http://blog.ralch.com/tutorial/golang-working-with-tar-and-gzipf

func Unzip added in v1.0.2

func Unzip(src, dest string) error

func UrlJoin

func UrlJoin(paths ...string) string

UrlJoin joins the given paths so that there is only ever one '/' character between the paths

Types

type CacheLoader added in v1.0.2

type CacheLoader func() ([]byte, error)

Jump to

Keyboard shortcuts

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