Documentation ¶
Overview ¶
Package genutil collects in place the utility functions used in various golang scripts
Index ¶
- func AbsInt(_ival int) int
- func AbsInt64(_ival int64) int64
- func AddCalDate(_date string, _offset int) string
- func AllDirs(_dir string) (paths, dirs []string)
- func AnyPathOK(_path string) bool
- func AnySplit(str, splitstr string) []string
- func AnySplit2(str, splitstr string) (splitter, part0, part1 string)
- func AnySplit3(str, splitstr string) (splitter0, splitter2, part0, part1, part2 string)
- func BashExecOrDie(_verbose bool, _cmd, _dir string) string
- func ByteToint0(_str []byte) int
- func CalDatelist(_begdate, _enddate string, _includeBeg, _includeEnd bool) []string
- func CalcPriceIfZero(_px, _badpx string, _val, _qty float64) string
- func CallerInfo2() string
- func CheckFileIsReadableAndNonzeroOrDie(_fname string)
- func ChompChar(_str string, _chompchar uint8) string
- func ChompParens(_str string, _trimSpace bool) string
- func ChompQuotes(_str string, _trimSpace bool) string
- func ChompStr(_str, _chompstr string) string
- func CleanAndSplitOnSeparator(_str, _insep, _sep string) []string
- func CleanAndSplitOnSpaces(_str, _sep string) []string
- func CleanString(_str string) string
- func CleanStringMaximally(_str string) string
- func ColonSplit2(str string) (part1, part2 string)
- func ColonSplit3(str string) (part1, part2, part3 string)
- func ColonSplit4(str string) (part0, part1, part2, part3 string)
- func ColonSplit5(str string) (part0, part1, part2, part3, part4 string)
- func ColonSplit5Len(str string) (nn int, part0, part1, part2, part3, part4 string)
- func CommaSplit2(str string) (part0, part1 string)
- func CommaSplit7(str string) (part0, part1, part2, part3, part4, part5, part6 string)
- func CompressType(_fname string) int
- func CompressionBasename(_fname string) string
- func CopyStrSlice(_strarr []string, _prefix, _suffix string) []string
- func CsvCountTuple(_csvlist, _sep string) int
- func CsvLastTuple(_csvlist, _sep string) string
- func CsvLastTupleElem(_csvlist, _sep, _elemsep, _badval string, _partno int) string
- func DDDashMMDashYY2YYYYMMDD(_dt string) string
- func DDSlashMMSlashYYYY2YYYYMMDD(_dt string) string
- func DD_MMM_YY2yyyymmdd(_bsl []byte) int64
- func DashSplit2(str string) (part0, part1 string)
- func Date2YYYYMMDD(_today, _dt string) string
- func DateParts(_date string) (int, int)
- func EmptyIfZero(_num, _ccy string) string
- func EnsureDirOrDie(_dirBase, _dirName string) string
- func EqualAndZeroStrings(_lstr, _rstr string) bool
- func EqualFloats(_f1, _f2 float64) bool
- func EqualsSplit2(str string) (part0, part1 string)
- func EqualsSplit2Trimmed(str string) (part0, part1 string)
- func EqualsSplit6(str string) (part0, part1, part2, part3, part4, part5 string)
- func ExecCommandOrDie(_verbose bool, _cmd string)
- func FileAsofCurrent(_path, _dt string, _num int) string
- func FileAsofPrevious(_path, _dt string, _num int) string
- func FileExecutable(_path string) bool
- func FileInfo(_fname, _sep string, _fullinfo bool) string
- func FileInfoSysStr(_sys interface{}, _sep string) string
- func FileList(_dname string) []string
- func FileSize(_fname string) int
- func FilenameExpandUser(_fname string) string
- func FillDate(pat string, ctime time.Time) string
- func Flatline2(_str0, _str1 string) string
- func FlipIfFalseFloat(_flipIfFalse bool, _val1, _val2 float64) (float64, float64)
- func FlipIfFalseInt(_flipIfFalse bool, _val1, _val2 int) (int, int)
- func FlipIfFalseInt64(_flipIfFalse bool, _val1, _val2 int64) (int64, int64)
- func FlipIfFalseStr(_flipIfFalse bool, _val1, _val2 string) (string, string)
- func Float64ToHuman(num float64) string
- func FloatTernary(_aIfTrue bool, _a, _b float64) float64
- func GenKVFromMap(_kvmap map[string]string) string
- func GetFileLineCount(_fname, _comments string) (int64, error)
- func GetKV(_list, _kk, _def string) string
- func GetKVFloat(_list, _kk string, _def float64) float64
- func GetLastSunday(_timezone string) string
- func GetLatestDatedDir(parentdir string) string
- func GetLatestFileWithPattern(pattern string) string
- func GetLogicalDate(_timezone string, _time string) string
- func GetMapFromKV(_list string) map[string]string
- func GetNocasekeyKV(_list, _kk, _def string) string
- func GetNumLines(_fname string) int64
- func GetParentDir(_dir string) (parent string, ok bool)
- func GetSecondLatestFileWithPattern(pattern string) string
- func GetSplitTrimmedPart(_str, _sep, _badstr string, _partno int) string
- func GetSplitTrimmedPartFloat64(_str, _sep string, _bad float64, _partno int) float64
- func GetSplitTrimmedPartInt64(_str, _sep string, _bad int64, _partno int) int64
- func GetYyyymmddFromFilenameYymmddFromEndWithSuffixLen(_fname string, _suffLen int, _def string) string
- func GetYyyymmddFromFilenameYyyymmFromEndWithSuffixLen(_fname string, _suffLen int, _def string) string
- func Green(in string) (out string)
- func GreenBold(in string) (out string)
- func HatSplit2(str string) (part0, part1 string)
- func Hhmmss2Seconds(_hhmmss string) float64
- func Hhmmss2Timetz(_localTime, _timezone string) (time.Time, bool)
- func Hhmmsstz2Timetz(_time, _fromTZ, _toTZ string) (string, bool)
- func Hostname() string
- func IncrementMaxId(_idmap *map[string]int64, _kk string) int64
- func IndexNl(_buffer []byte, _buflen, _rowBegin int) int
- func Int64Ternary(_aIfTrue bool, _a, _b int64) int64
- func IntSliceContains(_sl []int, _num int) bool
- func IntTernary(_aIfTrue bool, _a, _b int) int
- func IsCancellingStrings(_lstr, _rstr string, _leftneg *bool) bool
- func IsCommentLine(_line []byte, _commenttags []string) bool
- func IsDigit(_bb byte) bool
- func IsPositiveInteger(_str string) bool
- func IsYYYYMMDD(_str string) bool
- func IsZipFilename(_fname string) bool
- func JoinSlice(_strarr []string, _sep string) string
- func JoinSliceLimitingColumns(_strarr []string, _sep, _rowsep string, _maxcol int) string
- func JoinSliceWithReverse(_strarr []string, _sep string, _reverse bool) string
- func KB2GB(_kb string) string
- func KeysBoolMap(_aset *map[string]bool) []string
- func Kilos(num float64) string
- func ListContainsByte(_bb byte, _list ...byte) bool
- func ListContainsStr(_str string, _list ...string) bool
- func MMDDYYYY2yyyymmdd(_bsl []byte) int64
- func MMM2MM(_MMM string) string
- func MMSlashDDSlashYYYY2YYYYMMDD(_dt string) string
- func MakeDirOrDie(_dirBase, _dirName string) string
- func MaxFloat(_ival1, _ival2 float64) float64
- func MaxInt(_ival1, _ival2 int) int
- func MaxInt64(_ival1, _ival2 int64) int64
- func Millions(num float64) string
- func MinFloat(_ival1, _ival2 float64) float64
- func MinInt(_ival1, _ival2 int) int
- func MinInt64(_ival1, _ival2 int64) int64
- func ModifyKV(_list, _kk, _val string) string
- func NewBoolMap() map[string]bool
- func NewBoolMapFromCsv(_csv, _sep string) map[string]bool
- func NewInt64BoolMap() map[int64]bool
- func Now() string
- func NowTZ(_timezone string) string
- func OpenAny(_fname string) *bufio.Reader
- func OpenAnyErr(_fname string) (*bufio.Reader, error)
- func OpenAnyIO(_fname string) *io.Reader
- func OverrideWithKVMap(_mp map[string]string, _key, _alt string) string
- func PathExists(_path string) (bool, error)
- func PathIsDir(_path string) bool
- func PathOK(_path string) bool
- func PathRemoveOrPanic(_fname string) bool
- func PreviousYYYYMM(_dt string) string
- func PreviousYYYYMMDD(_dt string, _num int) string
- func ReadableFilename(_fname string) (ofname string, ofcmd *exec.Cmd, ofcode int)
- func ReadableFilenameCommand(_fname string) string
- func ReadableFilenameTimestamp(_fname string) string
- func Red(in string) (out string)
- func RedBold(in string) (out string)
- func RemoveCompressionVariants(_fname string, _keepbase bool)
- func ResolveDir(_dir string, doCheck bool) string
- func Resplit(_str, _osep, _njoin, _nsep string) []string
- func SearchForFileWithPattern(pat string) (bool, string)
- func SepMap(_sep string, _anycase bool) string
- func SepReplace(_str, _insep, _outsep string) string
- func SepSplit2(str, _sep string) (part0, part1 string)
- func SepSplit4(str, _sep string) (part0, part1, part2, part3 string)
- func SetupLogger(_logfilepath, _logcontentprefix string) (lglocal *log.Logger, err error)
- func ShrinkSep(_str string, _ch byte) string
- func SlashSplit2(str string) (part0, part1 string)
- func SlashSplit3(str string) (part0, part1, part2 string)
- func SlashSplit5(str string) (part0, part1, part2, part3, part4 string)
- func SliceContainsStr(s []string, e string) bool
- func SliceFloatsAdd(_arr []float64) float64
- func SliceIndexStr(s []string, e string) int
- func SmartFlatline2(_str0, _str1 string) string
- func SortedKeysByVal_String2Float64_AbsAscending(_mp *map[string]float64) []string
- func SortedKeysByVal_String2Float64_AbsDescending(_mp *map[string]float64) []string
- func SortedKeysByVal_String2Float64_Ascending(_mp *map[string]float64) []string
- func SortedKeysByVal_String2Float64_Descending(_mp *map[string]float64) []string
- func SortedKeys_Int2Int(_mp *map[int]int) []int
- func SortedKeys_String2Bool(_mp *map[string]bool) []string
- func SortedKeys_String2Float64(_mp *map[string]float64) []string
- func SortedKeys_String2Int(_mp *map[string]int) []string
- func SortedKeys_String2Int64(_mp *map[string]int64) []string
- func SortedKeys_String2String(_mp *map[string]string) []string
- func SortedUniqueKeys(_strs ...[]string) (strs []string)
- func SpaceSplit2(str string) (part0, part1 string)
- func SpaceSplitter(inp rune) bool
- func SplitFilename(_fname string, _extlist []string) (string, string, bool)
- func SplitFilename2(_str string, _ii interface{}) (string, string)
- func SplitFilename3(_str string, _ii0, _ii1 interface{}) (string, string, string)
- func SplitFilename4(_str string, _ii0, _ii1, _ii2 interface{}) (string, string, string, string)
- func SplitOrNull(_str, _sep string) []string
- func SplitToIntSlice(_str, _sep string) []int
- func SplitToStrSlice(_str, _sep string) []string
- func SplitYYYYMMDD(_yyyymmdd int64) (yyyy, mm, dd int64)
- func Str2Bool(_str string) bool
- func StrAbs(_num string) string
- func StrAbsDivFloat(_bsl1 string, _num float64) string
- func StrAddFloat(_bsl1 string, _num float64) string
- func StrAddInt(_bsl1 string, _num int64) string
- func StrAddint(_bsl1 string, _num int) string
- func StrAorB(_a, _b string) string
- func StrCapped(_str string, _cap int) string
- func StrDivFloat(_bsl1 string, _num float64) string
- func StrDropComponent(_str, _sep string, _drop int, _doPanic bool) (string, string)
- func StrFloatsAbsDiff(_bsl1, _bsl2 string) string
- func StrFloatsAdd(_bsl1, _bsl2 string) string
- func StrFloatsAplusBminusC(_bsl1, _bsl2, _bsl3 string) string
- func StrFloatsAplusminusBminusC(_bsl1 string, _plusminus int64, _bsl2, _bsl3 string) string
- func StrFloatsDiff(_bsl1, _bsl2 string) string
- func StrFloatsDiv(_bsl1, _bsl2, _def string) string
- func StrFloatsMult(_bsl1, _bsl2 string) string
- func StrFloatsMult3Zero(_bsl1, _bsl2, _bsl3 string) string
- func StrIntsAdd(_bsl1, _bsl2 string) string
- func StrInvert(_bsl1 string) string
- func StrIsInt(_str string) bool
- func StrMultFloat(_bsl1 string, _num float64) string
- func StrNegate(_bsl1 string) string
- func StrNonzeroAorB(_a, _accy, _b, _bccy string) string
- func StrReplaceComponent(_str, _sep string, _reploc int, _rep string, _doPanic bool) (string, string)
- func StrReplaceWithMap(_instr string, _mp map[string]string) string
- func StrSignAsFloat(_bsl1 string, _snum float64) string
- func StrSin(_str, _sin string) bool
- func StrSliceContains(_sl []string, _num string) bool
- func StrTernary(_aIfTrue bool, _a, _b string) string
- func StrToFloat(_bsl string) float64
- func StrToFloatAbs(_bsl string) float64
- func StrYYYY_MM_DD2yyyymmdd(_dt string) string
- func StryyyymmddInRange(_yyyymmdd, _startdate, _enddate string) bool
- func StryyyymmddInRangeClosedOpen(_yyyymmdd, _startdate, _enddate string) bool
- func StryyyymmddInRangeOpenClosed(_yyyymmdd, _startdate, _enddate string) bool
- func StryyyymmddInRangeOpenOpen(_yyyymmdd, _startdate, _enddate string) bool
- func StryyyymmddLT(_dt1, _dt2 string) bool
- func StryyyymmddLTEQ(_dt1, _dt2 string) bool
- func StryyyymmddLTEQTernary(_dt1, _dt2, _trueStr, _falseStr string) string
- func StryyyymmddLTTernary(_dt1, _dt2, _trueStr, _falseStr string) string
- func Thousands(_num float64) string
- func Time2YYYYMMDD(_tt time.Time) int
- func Timetz2Timetz(_time time.Time, _timezone string) time.Time
- func ToBool(_str string, _def bool) bool
- func ToFloat(_bsl []byte) float64
- func ToInt(_str string, _def int64) int64
- func Today() string
- func TodayTZ(_timezone string) string
- func Toint(_str string, _def int) int
- func Toint0(_str string) int
- func TwoStrToFloat(_bsl1, _bsl2 string) (float64, float64)
- func UniqueKeys(_strs ...[]string) (strs []string)
- func UpdateBoolMap(_aset *map[string]bool, _keys []string)
- func UpdateBoolMapFromCsv(_aset *map[string]bool, _csv, _sep string)
- func UpdateMaxId(_idmap *map[string]int64, _kk, _newid string) int64
- func WritableFilename(_fname string) (ofname string, ofcode int)
- func WriteStringToFile(_str, _fname string)
- func WriteStringToGzipFile(_str, _fname string)
- func YYYYMMDD2M_D_YYYY(_dt string) string
- func YYYY_MM_DD2yyyymmdd(_bsl []byte) int64
- func YYYY_MM_DD_HH_MM_SS2yyyymmdd_hhmmss(_bsl []byte) (int64, int64)
- func YYYY_MM_DD_HH_MM_SS_mmm_zz2yyyymmdd_hhmmss_mmm_zz(_bsl []byte) (int64, int64, int64, int64)
- func Yyyymmdd2SimpleJulian_Since_1900(_yyyymmdd int64) int64
- func ZipFirstFileInfo(_zipfile string, _verbose bool) (string, string, string, int)
- type GzFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCalDate ¶
AddCalDate adds number of dates to specified date
func BashExecOrDie ¶
BashExecOrDie executes the string cmd with /bin/bash and panics on any kind of failure
func ByteToint0 ¶
ByteToint0 converts bytestring to int, with default 0
func CalDatelist ¶
CalDatelist creates list of dates from the range, possibly including/excluding the begin/end dates
func CalcPriceIfZero ¶
CalcPriceIfZero returns price calculation if the input price was bad
func CallerInfo2 ¶
func CallerInfo2() string
CallerInfo2 is used to embellish error messages with the caller name
func CheckFileIsReadableAndNonzeroOrDie ¶
func CheckFileIsReadableAndNonzeroOrDie(_fname string)
CheckFileIsReadableAndNonzeroOrDie is shorthand
func ChompParens ¶
ChompParens eliminates dual delimiting strings if present
func ChompQuotes ¶
ChompQuotes eliminates dual delimiting quotes if present
func CleanAndSplitOnSeparator ¶
CleanAndSplitOnSeparator trims each line obtained by splitting input paragraph at newline. Each line is split on separator insep, and joined back by specified separator
func CleanAndSplitOnSpaces ¶
CleanAndSplitOnSpaces trims each line obtained by splitting input paragraph at newline. Each line is split on space, and joined back by specified separator
func CleanStringMaximally ¶
CleanStringMaximally removes various chars from name
func ColonSplit2 ¶
ColonSplit2 is shorthand splitter
func ColonSplit3 ¶
ColonSplit3 is shorthand splitter
func ColonSplit4 ¶
ColonSplit4 is shorthand splitter
func ColonSplit5 ¶
ColonSplit5 is shorthand splitter
func ColonSplit5Len ¶
ColonSplit5Len is shorthand splitter, which also returns the number of parts found
func CommaSplit2 ¶
CommaSplit2 is shorthand splitter
func CommaSplit7 ¶
CommaSplit7 is shorthand splitter
func CompressType ¶
CompressType returns a numeric code based on the compression type indicated in the filename
func CompressionBasename ¶
CompressionBasename returns uncompressed filename of the input filename
func CopyStrSlice ¶
CopyStrSlice copies a string slice, optionally with prefix and suffix
func CsvCountTuple ¶
CsvCountTuple counts the number of parts under specified separator
func CsvLastTuple ¶
CsvLastTuple returns the last item in the tuple, or blank
func CsvLastTupleElem ¶
CsvLastTupleElem returns the numbered sub-element of the csv's last element (itself viewed as an elemlist)
func DDDashMMDashYY2YYYYMMDD ¶
DDDashMMDashYY2YYYYMMDD is shorthand convert 9-FEB-13 (DD-MMM-YY) --> 20130209 (YYYYMMDD)
func DDSlashMMSlashYYYY2YYYYMMDD ¶
DDSlashMMSlashYYYY2YYYYMMDD is shorthand convert 27/11/2013 (DD/MM/YYYY) --> 20131127 (YYYYMMDD) convert 9/2/2013 (D/M/YYYY) --> 20130209 (YYYYMMDD)
func DD_MMM_YY2yyyymmdd ¶
DD_MMM_YY2yyyymmdd converts date format
func DashSplit2 ¶
DashSplit2 is shorthand splitter
func Date2YYYYMMDD ¶
Date2YYYYMMDD converts a date (by guessing) from one of several formats to YYYYMMDD
func DateParts ¶
DateParts is a utility to convert some date mnemonics Do not call this directly for NBD/PBD etc, although today might be sort of safe
func EmptyIfZero ¶
EmptyIfZero returns empty string or the currency amount if nonzero
func EnsureDirOrDie ¶
EnsureDirOrDie dies if the dir did not exist and could not be created
func EqualAndZeroStrings ¶
EqualAndZeroStrings tells if strings are equal, and both zero
func EqualsSplit2 ¶
EqualsSplit2 is shorthand splitter
func EqualsSplit2Trimmed ¶
EqualsSplit2Trimmed is shorthand splitter
func EqualsSplit6 ¶
EqualsSplit6 is shorthand splitter
func ExecCommandOrDie ¶
ExecCommandOrDie executes the given command and panics on any kind of failure
func FileAsofCurrent ¶
FileAsofCurrent replaces YYYYMMDD with older dates until it finds a readable file (any compression variant) Today is considered
func FileAsofPrevious ¶
FileAsofPrevious replaces YYYYMMDD with older dates until it finds a readable file (any compression variant) Today is not considered
func FileExecutable ¶
FileExecutable returns whether the given file or directory exists or not, and is executable
func FileInfoSysStr ¶
FileInfoSysStr formats file info into readable form call it with stat.Sys()
func FilenameExpandUser ¶
func FlipIfFalseFloat ¶
FlipIfFalseFloat helps compensate for golang not having ternary op a
func FlipIfFalseInt ¶
FlipIfFalseInt helps compensate for golang not having ternary op a
func FlipIfFalseInt64 ¶
FlipIfFalseInt64 helps compensate for golang not having ternary op a
func FlipIfFalseStr ¶
FlipIfFalseStr helps compensate for golang not having ternary op a
func FloatTernary ¶
FloatTernary is shorthand
func GenKVFromMap ¶
GenKVFromMap returns the map as a csvlist of kvps
func GetFileLineCount ¶
GetFileLineCount counts non-comment lines of a file
func GetKVFloat ¶
GetKVFloat obtains the value from csvlist of kvps or the default
func GetLastSunday ¶
GetLastSunday returns the most recent sunday
func GetLatestDatedDir ¶
GetLatestDatedDir is shorthand
func GetLatestFileWithPattern ¶
GetLatestFileWithPattern is shorthand
func GetLogicalDate ¶
GetLogicalDate returns today. Or tomorrow if it is now past the specified time.
func GetMapFromKV ¶
GetMapFromKV returns the csvlist of kvps as a map
func GetNocasekeyKV ¶
GetNocasekeyKV (case-insensitively) obtains the value from csvlist of kvps or the default.
func GetNumLines ¶
GetNumLines counts number of lines in any compression variant of file
func GetParentDir ¶
GetParentDir returns parent dir of supplied dir, setting bool to false if no parent
func GetSecondLatestFileWithPattern ¶
GetSecondLatestFileWithPattern is shorthand
func GetSplitTrimmedPart ¶
GetSplitTrimmedPart returns the numbered part (or _badstr if there was an error)
func GetSplitTrimmedPartFloat64 ¶
GetSplitTrimmedPartFloat64 returns the numbered part (or _bad if there was an error)
func GetSplitTrimmedPartInt64 ¶
GetSplitTrimmedPartInt64 returns the numbered part (or _bad if there was an error)
func GetYyyymmddFromFilenameYymmddFromEndWithSuffixLen ¶
func GetYyyymmddFromFilenameYymmddFromEndWithSuffixLen(_fname string, _suffLen int, _def string) string
GetYyyymmddFromFilenameYymmddFromEndWithSuffixLen grabs the YYMMDD from filenames of form foo_YYMMDD.zip, but extend with the decade
func GetYyyymmddFromFilenameYyyymmFromEndWithSuffixLen ¶
func GetYyyymmddFromFilenameYyyymmFromEndWithSuffixLen(_fname string, _suffLen int, _def string) string
GetYyyymmddFromFilenameYyyymmFromEndWithSuffixLen grab the YYMMDD from filenames of form foo_YYYYMM.zip, but extend with 1st day of month
func Hhmmss2Seconds ¶
Hhmmss2Seconds converts to (possibly fractional) seconds
func Hhmmss2Timetz ¶
Hhmmss2Timetz converts specified HHMMSS time to today in the specified timezone, return in time.Time It returns false if tz is invalid
func Hhmmsstz2Timetz ¶
Hhmmsstz2Timetz converts HHMMSS time in one timezone (fromTZ) to another (toTZ)
func IncrementMaxId ¶
IncrementMaxId increments the max id
func IntSliceContains ¶
IntSliceContains is shorthand
func IsCancellingStrings ¶
IsCancellingStrings checks if strings are offsetting numbers, and informs which is the negative one
func IsCommentLine ¶
IsCommentLine checks if a line is one of the list of comment types
func IsPositiveInteger ¶
IsPositiveInteger returns true if the string is int > 0
func IsZipFilename ¶
IsZipFilename checks for any kind of .zip or .ZIP or .ZiP file
func JoinSliceLimitingColumns ¶
JoinSliceLimitingColumns joins slice elements using named separator, and breaking into new "rows" when max cols is reached
func JoinSliceWithReverse ¶
JoinSliceWithReverse joins slice elements using named separator, and optionally in reverse
func ListContainsByte ¶
ListContainsByte checks if given byte is in list
func ListContainsStr ¶
ListContainsStr checks if given string is in list
func MMDDYYYY2yyyymmdd ¶
MMDDYYYY2yyyymmdd converts bytestring date of 02/03/2014 format to int64
func MMSlashDDSlashYYYY2YYYYMMDD ¶
MMSlashDDSlashYYYY2YYYYMMDD is shorthand convert 11/27/2013 (MM/DD/YYYY) --> 20131127 (YYYYMMDD) convert 2/9/2013 (M/D/YYYY) --> 20130209 (YYYYMMDD)
func MakeDirOrDie ¶
MakeDirOrDie panics if unable to create the dir (or if it exists)
func NewBoolMapFromCsv ¶
NewBoolMapFromCsv returns a map where each element of the supplied string is set true
func OpenAny ¶
OpenAny returns buffered reader for the content of the specified file, or available compression variant
func OpenAnyErr ¶
OpenAnyErr returns buffered reader for the content of the specified file, or available compression variant It is more error conscious than OpenAny()
func OpenAnyIO ¶
OpenAnyIO returns unbuffered reader for the content of the specified file, or available compression variant
func OverrideWithKVMap ¶
OverrideWithKVMap does map lookup with a default
func PathExists ¶
PathExists returns whether the given file or directory exists or not
func PathRemoveOrPanic ¶
PathRemoveOrPanic panics if it fails to remove a directory
func PreviousYYYYMMDD ¶
PreviousYYYYMMDD is shorthand
func ReadableFilename ¶
ReadableFilename returns information for subsequent reading of the specified file If not found, it looks for compression variants of the file
func ReadableFilenameCommand ¶
ReadableFilenameCommand returns the command portion of the output of ReadableFilename()
func ReadableFilenameTimestamp ¶
ReadableFilenameTimestamp returns the timestamp of the output of ReadableFilename()
func RemoveCompressionVariants ¶
RemoveCompressionVariants removes all compression variants of the specified filename, optionally preserving the base filename
func ResolveDir ¶
ResolveDir returns Directory after resolving multiple dots, for example ..../foo will return absolute path in great-grand-parent dir Optionally it will check if the directory exists Return empty string on any error
func SearchForFileWithPattern ¶
SearchForFileWithPattern is shorthand
func SepReplace ¶
SepReplace replaces one named separator with another
func SetupLogger ¶
SetupLogger returns a logger
func ShrinkSep ¶
ShrinkSep removes Semi at EOL and shrinks multiple Semi to single Semi prior to EOL
func SlashSplit2 ¶
SlashSplit2 is shorthand splitter
func SlashSplit3 ¶
SlashSplit3 is shorthand splitter
func SlashSplit5 ¶
SlashSplit5 is shorthand splitter
func SliceContainsStr ¶
SliceContainsStr checks if given string is in the slice
func SliceFloatsAdd ¶
SliceFloatsAdd adds slice elements of the slice
func SliceIndexStr ¶
SliceIndexStr calculates index of string in slice
func SmartFlatline2 ¶
SmartFlatline2 combines 2 strings, potentially eliminating newline on the first. In addition, it guesses whether to insert line-ending period.
func SortedKeysByVal_String2Float64_AbsAscending ¶
SortedKeysByVal_String2Float64_AbsAscending sorts by value for that maptype
func SortedKeysByVal_String2Float64_AbsDescending ¶
SortedKeysByVal_String2Float64_AbsDescending sorts by value for that maptype
func SortedKeysByVal_String2Float64_Ascending ¶
SortedKeysByVal_String2Float64_Ascending sorts by value for that maptype
func SortedKeysByVal_String2Float64_Descending ¶
SortedKeysByVal_String2Float64_Descending sorts by value for that maptype
func SortedKeys_Int2Int ¶
SortedKeys_Int2Int returns sorted keys of that type
func SortedKeys_String2Bool ¶
SortedKeys_String2Bool returns sorted keys of that type
func SortedKeys_String2Float64 ¶
SortedKeys_String2Float64 returns sorted keys of that type
func SortedKeys_String2Int ¶
SortedKeys_String2Int returns sorted keys of that type
func SortedKeys_String2Int64 ¶
SortedKeys_String2Int64 returns sorted keys of that type
func SortedKeys_String2String ¶
SortedKeys_String2String returns sorted keys of that type
func SortedUniqueKeys ¶
SortedUniqueKeys returns sorted array of unique strings within the input string array
func SpaceSplit2 ¶
SpaceSplit2 is shorthand splitter
func SpaceSplitter ¶
SpaceSplitter informs if the input char is a split char
func SplitFilename ¶
SplitFilename returns (filename, extension, ok) from the input filename, for an allowed list of extensions, e.g. ["txt", "DAT", ...]
func SplitFilename2 ¶
SplitFilename2 splits based on (consumed) string or position (negative counts from right)
func SplitFilename3 ¶
SplitFilename3 splits into 3 parts, using delim which is either string or positional index (which may be negative for counting from end)
func SplitFilename4 ¶
SplitFilename4 splits into 4 parts, using delim which is either string or positional index (which may be negative for counting from end)
func SplitOrNull ¶
SplitOrNull on empty input returns null slice, unlike plain strings.Split which will return 1 element slice
func SplitToIntSlice ¶
SplitToIntSlice convert "1,2,3" to slice of ints
func SplitToStrSlice ¶
SplitToStrSlice converts "1,2,3" to slice of strings, ignoring blanks
func SplitYYYYMMDD ¶
SplitYYYYMMDD splits date into parts
func StrAbsDivFloat ¶
StrAbsDivFloat is shorthand
func StrDropComponent ¶
StrDropComponent drops the indicated component
func StrFloatsAbsDiff ¶
StrFloatsAbsDiff is shorthand
func StrFloatsAplusBminusC ¶
StrFloatsAplusBminusC is shorthand
func StrFloatsAplusminusBminusC ¶
StrFloatsAplusminusBminusC is shorthand
func StrFloatsMult3Zero ¶
StrFloatsMult3Zero returns 0 if any items are missing
func StrMultFloat ¶
StrMultFloat returns the result as a float, of multiplying a string and a float
func StrNonzeroAorB ¶
StrNonzeroAorB returns empty string or one of the currency amounts if nonzero
func StrReplaceComponent ¶
func StrReplaceComponent(_str, _sep string, _reploc int, _rep string, _doPanic bool) (string, string)
StrReplaceComponent replaces the indicated component
func StrReplaceWithMap ¶
StrReplaceWithMap replaces substrings in the input string based on the map passed
func StrSignAsFloat ¶
StrSignAsFloat is shorthand
func StrSliceContains ¶
StrSliceContains is shorthand
func StrTernary ¶
StrTernary is shorthand for the missing golang string ternary operatory
func StrToFloatAbs ¶
StrToFloatAbs converts string to absolute float
func StrYYYY_MM_DD2yyyymmdd ¶
StrYYYY_MM_DD2yyyymmdd removes underscores or spaces from date
func StryyyymmddInRange ¶
StryyyymmddInRange checks if STARTDATE <= yyyymmdd <= ENDDATE
func StryyyymmddInRangeClosedOpen ¶
StryyyymmddInRangeClosedOpen checks if STARTDATE <= yyyymmdd < ENDDATE
func StryyyymmddInRangeOpenClosed ¶
StryyyymmddInRangeOpenClosed checks if STARTDATE < yyyymmdd <= ENDDATE
func StryyyymmddInRangeOpenOpen ¶
StryyyymmddInRangeOpenOpen checks if STARTDATE < yyyymmdd < ENDDATE
func StryyyymmddLT ¶
StryyyymmddLT returns true if firstdate < seconddate use AddCalDate if you want to compare offsetted dates
func StryyyymmddLTEQ ¶
StryyyymmddLTEQ returns true if firstdate <= seconddate use AddCalDate if you want to compare offsetted dates
func StryyyymmddLTEQTernary ¶
StryyyymmddLTEQTernary is shorthand
func StryyyymmddLTTernary ¶
StryyyymmddLTTernary is shorthand
func Time2YYYYMMDD ¶
Time2YYYYMMDD converts time.Time to date string YYYYMMDD
func Timetz2Timetz ¶
Timetz2Timetz convert input time to the specified timezone
func TwoStrToFloat ¶
TwoStrToFloat converts 2 strings to 2 floats
func UniqueKeys ¶
UniqueKeys returns array of unique strings within the input string array
func UpdateBoolMap ¶
UpdateBoolMap updates the map, setting elements of the slice to true
func UpdateBoolMapFromCsv ¶
UpdateBoolMapFromCsv updates the map setting elements of the string to true
func UpdateMaxId ¶
UpdateMaxId updates the max id
func WritableFilename ¶
WritableFilename returns information for subsequent writing of the specified file Any compression variants of the file are removed.
func WriteStringToGzipFile ¶
func WriteStringToGzipFile(_str, _fname string)
WriteStringToGzipFile is shorthand
func YYYY_MM_DD2yyyymmdd ¶
YYYY_MM_DD2yyyymmdd converts bytestring date to int64
func YYYY_MM_DD_HH_MM_SS2yyyymmdd_hhmmss ¶
YYYY_MM_DD_HH_MM_SS2yyyymmdd_hhmmss converts "2020-01-09 16:45:07" format dates to (YYYYMMDD, HHMMSS) string pair
func YYYY_MM_DD_HH_MM_SS_mmm_zz2yyyymmdd_hhmmss_mmm_zz ¶
YYYY_MM_DD_HH_MM_SS_mmm_zz2yyyymmdd_hhmmss_mmm_zz converts "2020-01-09 16:45:07.mmm-zz" format dates to (YYYYMMDD, HHMMSS, mmm, zz) string pair Here zz is timezone from pgsql in hours from GMT
func Yyyymmdd2SimpleJulian_Since_1900 ¶
Yyyymmdd2SimpleJulian_Since_1900 returns simple julian of input date
Types ¶
type GzFile ¶
type GzFile struct {
// contains filtered or unexported fields
}
GzFile is used to write to regular or gz file, removing existing compression variant first
func OpenGzFile ¶
OpenGzFile Opens a file for buffered writing, optionally using gzip compression