util

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyString    string
	EmptyBool      bool
	EmptyByte      []byte
	EmptyInt       int
	EmptyInt32     int32
	EmptyInterface interface{}
)

Functions

func ApplyTemplate

func ApplyTemplate(tpl []byte, data interface{}) string

func BailOnError

func BailOnError(err error)

func Command

func Command(cmd ...string)

func Dim added in v1.0.2

func Dim(text ...string) string

func ExtractGitHubHandleFromEmail

func ExtractGitHubHandleFromEmail(email string) string

func FileExists

func FileExists(name string) bool

func FindGoWorkFile

func FindGoWorkFile(path string) (string, bool)

func FindMainFileInDirectory

func FindMainFileInDirectory(directoryPath string) (string, error)

func GetCurrentGoVersion

func GetCurrentGoVersion() string

func GetGitHubInfo

func GetGitHubInfo() (handle, email string, err error)

Function to get GitHub handle and email from global Git config

func GetLastChange

func GetLastChange(dirs ...string) (time.Time, error)

func Highlight

func Highlight(text ...string)

func HighlightCommand

func HighlightCommand(cmd string, args ...string)

func HighlightComment

func HighlightComment(txt string)

func Highlighter added in v1.0.2

func Highlighter(text ...string) string

func InSlice

func InSlice[V comparable](item V, slice []V) bool

InSlice determines whether a value is in the slice. Uses generics to specify type.

func IndexOf

func IndexOf[V comparable](slice []V, target V) int

IndexOf returns the position of the specified item

func InsertArgAt

func InsertArgAt(index int, value string) error

InsertArgAt inserts an argument into os.Args at the specified position

func Map

func Map[V comparable](slice []V, fn func(el V) V) []V

func Output

func Output(cmd string, cwd ...string) ([]byte, error)

func ReadTextFile

func ReadTextFile(path string) (string, error)

func RemoveArgAt

func RemoveArgAt(index int) error

RemoveArgAt removes the os.Arg at the specified index

func Run

func Run(cmd string, cwd ...string) error

func Stderr

func Stderr(msg interface{}, exit ...bool)

func Stdout

func Stdout(txt string, exit ...bool)

func Stream added in v1.0.2

func Stream(cmd string, cwd ...string) error

func StreamNoHighlight added in v1.0.5

func StreamNoHighlight(cmd string, cwd ...string) error

func StreamNoStdErr added in v1.0.7

func StreamNoStdErr(cmd string, cwd ...string) error

func StreamNoStdErrNoHighlight added in v1.0.7

func StreamNoStdErrNoHighlight(cmd string, cwd ...string) error

func StreamRaw added in v1.0.2

func StreamRaw(cmd string, cwd ...string) error

func StreamRawNoHighlight added in v1.0.5

func StreamRawNoHighlight(cmd string, cwd ...string) error

func SubtleHighlight

func SubtleHighlight(text ...string)

func SubtleHighlighter added in v1.0.2

func SubtleHighlighter(text ...string) string

func WriteFile

func WriteFile(path string, content []byte, exitOnError ...bool) error

func WriteTextFile

func WriteTextFile(path string, content string, exitOnError ...bool) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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