util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsPath

func AbsPath(fromExec bool, elem ...string) string

AbsPath returns absolute path from current execution path

func ConcatFiles

func ConcatFiles(dest string, append bool, files ...string) error

ConcatFiles concats a set files into a new or existing file

func CreateTempFile

func CreateTempFile(content string) (string, func(), error)

CreateTempFile writes a file in your os temp directory

func DeleteAll

func DeleteAll(basePath string, items ...string) error

DeleteAll deletes all files and directories

func GenerateInt

func GenerateInt(min, max int) int

GenerateInt generates a random integer

func GenerateIntSlice

func GenerateIntSlice(size, min, max int) []Generic

GenerateIntSlice generates an array with random integers

func GenerateString

func GenerateString(minLen, maxLen int) string

GenerateString generates a random string

func GenerateStringSlice

func GenerateStringSlice(size, minLen, maxLen int) []Generic

GenerateStringSlice generates an array with random strings

func IsIntIn

func IsIntIn(n int, list ...int) bool

IsIntIn checks if an integer is in a list of integers

func IsSorted

func IsSorted(items []Generic, compare Compare) bool

IsSorted checks if an array is ascendingly sorted

func IsStringIn

func IsStringIn(s string, list ...string) bool

IsStringIn checks if a string is in a list of strings

func MaxFloat64

func MaxFloat64(nums ...float64) float64

MaxFloat64 returns maximum of float64 numbers

func MaxInt

func MaxInt(nums ...int) int

MaxInt returns maximum of int numbers

func MinFloat64

func MinFloat64(nums ...float64) float64

MinFloat64 returns minimun of float64 numbers

func MinInt

func MinInt(nums ...int) int

MinInt returns minimun of int numbers

func MkDirs

func MkDirs(basePath string, dirs ...string) (func(), error)

MkDirs creates directories

func PipeStdAll

func PipeStdAll() (inR, inW, outR, outW, errR, errW *os.File, restore func(), err error)

PipeStdAll pipes all standard streams temporarily

func PipeStderr

func PipeStderr() (errR, errW *os.File, restore func(), err error)

PipeStderr pipes standard error stream temporarily

func PipeStdin

func PipeStdin() (inR, inW *os.File, restore func(), err error)

PipeStdin pipes standard input stream temporarily

func PipeStdout

func PipeStdout() (outR, outW *os.File, restore func(), err error)

PipeStdout pipes standard output stream temporarily

func PipeStdoutAndStderr

func PipeStdoutAndStderr() (r, w *os.File, restore func(), err error)

PipeStdoutAndStderr pipes standard out and error streams together temporarily

func ReadFromStderrPipe

func ReadFromStderrPipe(errR, errW *os.File, str string) (string, error)

ReadFromStderrPipe reads a written string to stderr through a pipe

func ReadFromStdoutPipe

func ReadFromStdoutPipe(outR, outW *os.File, str string) (string, error)

ReadFromStdoutPipe reads a written string to stdout through a pipe

func ReplaceOSArgs

func ReplaceOSArgs(args []string) func()

ReplaceOSArgs replaces current args with custom args and returns a restore function

func SeedWithNow

func SeedWithNow()

SeedWithNow seeds the random generator with time now

func Shuffle

func Shuffle(a []Generic)

Shuffle shuffles an array in O(n) time

func WriteToStdinPipe

func WriteToStdinPipe(inR, inW *os.File, str string) (string, error)

WriteToStdinPipe writes a string to stdin through a pipe

Types

This section is empty.

Jump to

Keyboard shortcuts

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