package lib

import "git.wntrmute.dev/kyle/goutils/lib"

Package lib contains functions useful for most programs.

Index

Constants

const (
	// ExitSuccess is the successful exit status.
	//
	// It should be called on successful exit.
	ExitSuccess = 0

	// ExitFailure is the failing exit status.
	ExitFailure = 1
)

Functions

func Duration

func Duration(d time.Duration) string

Duration returns a prettier string for time.Durations.

func Err

func Err(exit int, err error, format string, a ...interface{})

Err displays a formatting error message to standard error, appending the error string, and exits with the status code from `exit`, à la err(3).

func Errx

func Errx(exit int, format string, a ...interface{})

Errx displays a formatted error message to standard error and exits with the status code from `exit`, à la errx(3).

func Itoa

func Itoa(i int, wid int) string

Itoa provides cheap integer to fixed-width decimal ASCII. Give a negative width to avoid zero-padding. Adapted from the 'itoa' function in the log/log.go file in the standard library.

func ProgName

func ProgName() string

ProgName returns what lib thinks the program name is, namely the basename of of argv0.

It is similar to the Linux __progname function.

func Warn

func Warn(err error, format string, a ...interface{}) (int, error)

Warn displays a formatted error message to standard output, appending the error string, à la warn(3).

func Warnx

func Warnx(format string, a ...interface{}) (int, error)

Warnx displays a formatted error message to standard error, à la warnx(3).

Types

type FileTime

type FileTime struct {
	Changed  time.Time
	Modified time.Time
	Accessed time.Time
}

FileTime contains the changed, modified, and accessed timestamps for a file.

func LoadFileTime

func LoadFileTime(path string) (FileTime, error)

LoadFileTime returns a FileTime associated with the file.

Source Files

defs.go ftime_unix.go lib.go

Version
v1.7.7 (latest)
Published
Jun 15, 2024
Platform
linux/amd64
Imports
5 packages
Last checked
4 days ago

Tools for package owners.