utils

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package utils provides utilitary functions.

Index

Constants

View Source
const (
	WIDTHSUBS          int             = 20
	TitleColor         color.Attribute = color.FgMagenta
	InfoNameColor      color.Attribute = color.Bold
	InfoValueColor     color.Attribute = color.FgYellow
	BranchDefaultColor color.Attribute = color.FgBlue
	BranchChangedColor color.Attribute = color.FgYellow

	SuccessColor color.Attribute = color.FgGreen
	FailureColor color.Attribute = color.FgRed
)

Variables

This section is empty.

Functions

func CenterLine added in v0.4.0

func CenterLine(line string, width int) string

func ErrorBox added in v0.4.0

func ErrorBox(format string, args ...interface{})

func FileExists

func FileExists(fpath string) (bool, os.FileInfo)

FileExists check if a target exists and is a file.

check, info := utils.FileExists("/etc/passwd")
if check {
   fmt.Printf("size: %d\n", info.Size())
}

func FileIsExecutable

func FileIsExecutable(fpath string) bool

FileIsExecutable file exists and is executable

func GetHomeDir

func GetHomeDir() string

GetHomeDir get the user's homedir

func MkdirP

func MkdirP(dirname string, mode int) error

MkdirP

err := utils.MkdirP("/lala", int(0755))
if err != nil {
  panic(err)
}

func PanicOnError

func PanicOnError(fmtstr string, err error)

PanicOnError missing godoc.

func PrintError

func PrintError(fmtstr string, err error) error

PrintError if err is not nil print fmtstr as error.

func PrintFailed added in v0.4.0

func PrintFailed(format string, args ...interface{})

func PrintFatal

func PrintFatal(fmtstr string, err error) error

PrintFatal missing godoc.

func PrintStatus added in v0.4.0

func PrintStatus(colorattr color.Attribute, status, format string, args ...interface{})

func PrintSuccess added in v0.4.0

func PrintSuccess(format string, args ...interface{})

func TextBox added in v0.4.0

func TextBox(title, format string, args ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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