Documentation
¶
Overview ¶
file_util.go
gzip-util.go
misc-utis.go
os-util.go
string
text-util.go
time.go
tty-utils.go
Index ¶
- Constants
- func ByteCountIEC(b int64) string
- func ByteCountSI(b int64) string
- func CreateGzipFile(in io.Reader, fileName string) (reader *bufio.Reader, err error)
- func CreateGzipReader(in io.Reader) (reader *bufio.Reader, err error)
- func EscapeShellSpecialChars(source string) string
- func EscapeSpecialChars(source string, charSet string) string
- func ExitErrorf(rc int, format string, args ...interface{})
- func ExitMessagef(rc int, format string, args ...interface{})
- func ExpandDirPathAndMakeParent(specPath string) (expandedPath string, err error)
- func ExpandFilePathAndMakeParent(specPath string) (expandedPath, expandedParent string, err error)
- func ExpandFilePathAndMakeParentV(specPath string, maps ...map[string]string) (expandedPath, expandedParent string, err error)
- func ExpandPath(sourcePath string) (expandedPath string, err error)
- func ExpandPathV(sourcePath string, maps ...map[string]string) (expandedPath string, err error)
- func ExpandRealPath(sourcePath string) (expandedRealPath string, err error)
- func FileSize(filePath string) (size int64)
- func GetProgramDirPath() (dir string, err error)
- func GetProgramPath() (exec string, err error)
- func IsDirectory(filePath string) bool
- func IsRegularFile(filePath string) bool
- func IsSymLink(filePath string) bool
- func IsSymLinkByDirEntry(e os.DirEntry) bool
- func JoinMap(m map[string]any, kvSep, itemSep string) string
- func JoinStringMap(m map[string]string, kvSep, itemSep string) string
- func MakeDir(dirPath string) (err error)
- func MakeParentDir(filePath string) (dir string, err error)
- func MoveFile(sourcePath, destPath string) (int64, error)
- func NewEnglishPrinter() *message.Printer
- func OnCond(cond bool, trueValue, falseValue string) string
- func OnCondIface(cond bool, trueValue, falseValue interface{}) interface{}
- func OnCondInt(cond bool, trueValue, falseValue int) int
- func OnCondInt64(cond bool, trueValue, falseValue int64) int64
- func OnEmpty(s string, altValues ...string) (value string)
- func OnOk(cond bool) string
- func OnStringIndex(index uint, values ...string) (value string)
- func OnSuccess(cond bool) string
- func PadStringRight(s string, pad string, size int, suffix string) (paddedString string)
- func ParseMemSize(s string) (size int64, err error)
- func ParseParamPairs(source io.Reader, separator string, ...) (err error)
- func ParseParamPairsFile(sourceFile string, separator string, ...) (err error)
- func ParseTimeInterval(spec string, defaultUnit byte) (interval int64, err error)
- func RandBool() bool
- func RemoveQuotes(s string) string
- func S2Int32(s string, defaultValue int32) int32
- func S2Uint32(s string, defaultValue uint32) uint32
- func ScopedSplitByRune(s string, sep rune, scopeOpeners, scopeClosers string, maxParts int) (parts []string)
- func SplitByRune(s string, sep rune, maxParts int) (parts []string)
- func SplitPair(source, sep string) (left, right string)
- func StartsWith(s string, aliases ...string) bool
- func StreamIsTerminal(fh *os.File) bool
- func StringSeconds2GoDuration(s string) (secs time.Duration)
- func StringTimestamp2GoTime(s string) (ts time.Time)
- func UnescapeBlanks(source string) string
- func UnescapeSpecialChars(source string, charSet, specialChars string) string
- type TTYContext
- func (self *TTYContext) BlackFg(fd uint) string
- func (self *TTYContext) BlueFg(fd uint) string
- func (self *TTYContext) Bold(fd uint) string
- func (self *TTYContext) BoldOff(fd uint) string
- func (self *TTYContext) BrownFg(fd uint) string
- func (self *TTYContext) Clean()
- func (self *TTYContext) CyanFg(fd uint) string
- func (self *TTYContext) FgColor(fd uint, n uint) string
- func (self *TTYContext) GreenFg(fd uint) string
- func (self *TTYContext) Init()
- func (self *TTYContext) IsTTY(fd uint) bool
- func (self *TTYContext) Italic(fd uint) string
- func (self *TTYContext) ItalicOff(fd uint) string
- func (self *TTYContext) MagentaFg(fd uint) string
- func (self *TTYContext) RedFg(fd uint) string
- func (self *TTYContext) Reset(fd uint) string
- func (self *TTYContext) Underline(fd uint) string
- func (self *TTYContext) UnderlineOff(fd uint) string
- func (self *TTYContext) WhiteFg(fd uint) string
- type TextTemplate
Constants ¶
View Source
const ( NONE = iota BLACK RED GREEN BLUE BROWN // YELLOW CYAN MAGENTA WHITE )
View Source
const GZIP_SUFFIX = ".gz"
View Source
const STDERR uint = 2
View Source
const STDIN uint = 0
View Source
const STDOUT uint = 1
Variables ¶
This section is empty.
Functions ¶
func ByteCountIEC ¶
Credits: https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/
func ByteCountSI ¶
Credits: https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/
func CreateGzipFile ¶
func EscapeShellSpecialChars ¶
func EscapeSpecialChars ¶
func ExitErrorf ¶
func ExitMessagef ¶
func ExpandPath ¶
func ExpandPathV ¶
func ExpandRealPath ¶
func GetProgramDirPath ¶
func GetProgramPath ¶
func IsDirectory ¶
func IsRegularFile ¶
func IsSymLinkByDirEntry ¶
func MakeParentDir ¶
func MoveFile ¶
* Ispirata a https://stackoverflow.com/a/50741908
func NewEnglishPrinter ¶
func OnCondIface ¶
func OnCondIface(cond bool, trueValue, falseValue interface{}) interface{}
func OnCondInt64 ¶
func OnStringIndex ¶
func PadStringRight ¶
func ParseMemSize ¶
func ParseParamPairs ¶
func ParseParamPairsFile ¶
func ParseTimeInterval ¶
Convert the spec string to a number of seconds. spec is a number, optionally followed by a time unit among 's'(seconds), 'm'(minutes), 'h'(hours), and 'd'(days) If the time unit is omitted, defaultUnit is used. Empty spec returns 0 seconds.
func RemoveQuotes ¶
func ScopedSplitByRune ¶
func StartsWith ¶
func StreamIsTerminal ¶
func StringTimestamp2GoTime ¶
func UnescapeBlanks ¶
func UnescapeSpecialChars ¶
Types ¶
type TTYContext ¶
type TTYContext struct {
// contains filtered or unexported fields
}
func (*TTYContext) BlackFg ¶
func (self *TTYContext) BlackFg(fd uint) string
func (*TTYContext) BlueFg ¶
func (self *TTYContext) BlueFg(fd uint) string
func (*TTYContext) Bold ¶
func (self *TTYContext) Bold(fd uint) string
func (*TTYContext) BoldOff ¶
func (self *TTYContext) BoldOff(fd uint) string
func (*TTYContext) BrownFg ¶
func (self *TTYContext) BrownFg(fd uint) string
func (*TTYContext) Clean ¶
func (self *TTYContext) Clean()
func (*TTYContext) CyanFg ¶
func (self *TTYContext) CyanFg(fd uint) string
func (*TTYContext) GreenFg ¶
func (self *TTYContext) GreenFg(fd uint) string
func (*TTYContext) Init ¶
func (self *TTYContext) Init()
func (*TTYContext) IsTTY ¶
func (self *TTYContext) IsTTY(fd uint) bool
func (*TTYContext) Italic ¶
func (self *TTYContext) Italic(fd uint) string
func (*TTYContext) ItalicOff ¶
func (self *TTYContext) ItalicOff(fd uint) string
func (*TTYContext) MagentaFg ¶
func (self *TTYContext) MagentaFg(fd uint) string
func (*TTYContext) RedFg ¶
func (self *TTYContext) RedFg(fd uint) string
func (*TTYContext) Reset ¶
func (self *TTYContext) Reset(fd uint) string
func (*TTYContext) Underline ¶
func (self *TTYContext) Underline(fd uint) string
func (*TTYContext) UnderlineOff ¶
func (self *TTYContext) UnderlineOff(fd uint) string
func (*TTYContext) WhiteFg ¶
func (self *TTYContext) WhiteFg(fd uint) string
type TextTemplate ¶
type TextTemplate struct { UserName string Uid string ProgramDir string HomeDir string // contains filtered or unexported fields }
func NewTextTemplate ¶
func NewTextTemplate(args ...string) (instance *TextTemplate)
func (*TextTemplate) AddVar ¶
func (self *TextTemplate) AddVar(name, value string)
func (*TextTemplate) Expand ¶
func (self *TextTemplate) Expand(template string) string
func (*TextTemplate) ExpandEnv ¶
func (self *TextTemplate) ExpandEnv(template string) (result string)
func (*TextTemplate) String ¶
func (self *TextTemplate) String() string
Click to show internal directories.
Click to hide internal directories.