utils

package
v0.0.0-...-09eb631 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FileDoesNotExist = errors.New("file or directory does not exists")
)

Functions

func AskForConfirmation

func AskForConfirmation(s string) bool

func ConditionalOp

func ConditionalOp(message string, noop bool, fn func() error) error

func ConfigureITerm

func ConfigureITerm(hostname string)

func Contains

func Contains(str string, haystack ...string) bool

Contains returns a boolean whether a string is contained in a series of strings

func Copy

func Copy(src, dst string) error

Copy the src file to dst. Any existing file will be overwritten and will not Copy file attributes. From https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func CreateAndEdit

func CreateAndEdit(filePath string, content string) error

func CurrentTimeForFilename

func CurrentTimeForFilename() string

func EditFile

func EditFile(filePath string) error

func GetEnvWithDefault

func GetEnvWithDefault(key string, defaultValue string) string

func GetTerminalSize

func GetTerminalSize() (uint, uint, error)

func HasNonEmptyLines

func HasNonEmptyLines(lines []string) bool

func InRepository

func InRepository() bool

func IsITerm

func IsITerm() bool

func IsRepository

func IsRepository(repoDir string) bool

func JoinStringPointers

func JoinStringPointers(ptrs []*string, joinStr string) string

func OpenURI

func OpenURI(uriSegments ...string) error

func PathExists

func PathExists(filePath ...string) (bool, error)

func PickItem

func PickItem(label string, items []string) (string, error)

func Prompt

func Prompt(message string)

func ProperWordWrap

func ProperWordWrap(text string, lineWidth int) string

func Random

func Random(min, max int) int

func RemoveDuplicatesUnordered

func RemoveDuplicatesUnordered(elements []string) []string

func ResetITerm

func ResetITerm()

func RunCmd

func RunCmd(cmd string, args ...string) error

func RunCmdWithFullOutput

func RunCmdWithFullOutput(cmd string, args ...string) (string, error)

func RunCmdWithStdout

func RunCmdWithStdout(cmd string, args ...string) (string, error)

func SetBadge

func SetBadge(name string)

func TimeTrack

func TimeTrack(start time.Time, name string)

TimeTrack measure the excution time of a method

func factorial(n *big.Int) (result *big.Int) {
		// defer timeTrack(time.Now(), "factorial")
		// ... do some things, maybe even return under some condition
		return n
}

func WordWrap

func WordWrap(text string) string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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