util

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnexpectedEOF = errors.New(
		"unexpected end of input after escape character",
	)
	ErrUnknownEscapeSequence = errors.New("unknown escape sequence")
)

Functions

func AddYamlExtension

func AddYamlExtension(file string) string

AddYamlExtension adds .yaml extension if not present if it has .yml extension, replace it with .yaml

func FileExists

func FileExists(file string) bool

FileExists returns true if file exists.

func FormatTime

func FormatTime(t time.Time) string

FormatTime returns formatted time.

func LogErr

func LogErr(action string, err error)

LogErr logs error if it's not nil.

func MatchExtension

func MatchExtension(file string, exts []string) bool

MatchExtension returns true if extension matches.

func MustGetUserHomeDir

func MustGetUserHomeDir() string

MustGetUserHomeDir returns current working directory. Panics is os.UserHomeDir() returns error

func MustGetwd

func MustGetwd() string

MustGetwd returns current working directory. Panics is os.Getwd() returns error

func MustTempDir

func MustTempDir(pattern string) string

MustTempDir returns temporary directory. This function is used only for testing.

func OpenOrCreateFile

func OpenOrCreateFile(file string) (*os.File, error)

OpenOrCreateFile opens file or creates it if it doesn't exist.

func ParseTime

func ParseTime(val string) (time.Time, error)

ParseTime parses time string.

func SplitCommand

func SplitCommand(cmd string) (cmdx string, args []string)

SplitCommand splits command string to program and arguments.

func SplitCommandWithParse

func SplitCommandWithParse(cmd string) (cmdx string, args []string)

SplitCommandWithParse splits command string to program and arguments.

func TruncString

func TruncString(val string, max int) string

TruncString TurnString returns truncated string.

func ValidFilename

func ValidFilename(str string) string

ValidFilename makes filename valid by replacing reserved characters.

Types

This section is empty.

Jump to

Keyboard shortcuts

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