Documentation
¶
Index ¶
- Constants
- func Duration(d time.Duration) string
- func Err(exit int, err error, format string, a ...any)
- func Errx(exit int, format string, a ...any)
- func HexEncode(b []byte, mode HexEncodeMode) string
- func IsDigit(b byte) bool
- func Itoa(i int, wid int) string
- func ParseDuration(s string) (time.Duration, error)
- func ProgName() string
- func Warn(err error, format string, a ...any) (int, error)
- func Warnx(format string, a ...any) (int, error)
- func WithCloser(w io.Writer) io.WriteCloser
- type DummyWriteCloser
- type FileTime
- type HexEncodeMode
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 )
const ( OneTrueDateFormat = "2006-01-02T15:04:05-0700" DateShortFormat = "2006-01-02" TimeShortFormat = "15:04:05" TimeShorterFormat = "15:04" TimeStandardDateTime = "2006-01-02 15:04" )
Variables ¶
This section is empty.
Functions ¶
func Err ¶
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 ¶
Errx displays a formatted error message to standard error and exits with the status code from `exit`, à la errx(3).
func HexEncode ¶ added in v1.13.0
func HexEncode(b []byte, mode HexEncodeMode) string
HexEncode encodes the given bytes as a hexadecimal string. It also supports a few other binary-encoding formats as well.
func Itoa ¶
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 ParseDuration ¶ added in v1.15.0
ParseDuration parses a duration string into a time.Duration. It supports standard units (ns, us/µs, ms, s, m, h) plus extended units: d (days, 24h), w (weeks, 7d), y (years, 365d). Units can be combined without spaces, e.g., "1y2w3d4h5m6s". Case-insensitive. Years and days are approximations (no leap seconds/months). Returns an error for invalid input.
func ProgName ¶
func ProgName() string
ProgName returns what lib thinks the program name is, namely the basename of argv0.
It is similar to the Linux __progname function.
func Warn ¶
Warn displays a formatted error message to standard output, appending the error string, à la warn(3).
func WithCloser ¶ added in v1.16.0
func WithCloser(w io.Writer) io.WriteCloser
Types ¶
type DummyWriteCloser ¶ added in v1.16.0
type DummyWriteCloser struct {
// contains filtered or unexported fields
}
DummyWriteCloser wraps an io.Writer in a struct with a no-op Close.
func (*DummyWriteCloser) Close ¶ added in v1.16.0
func (dwc *DummyWriteCloser) Close() error
type FileTime ¶
FileTime contains the changed, modified, and accessed timestamps for a file.
func LoadFileTime ¶
LoadFileTime returns a FileTime associated with the file.
type HexEncodeMode ¶ added in v1.13.0
type HexEncodeMode uint8
const ( // HexEncodeLower prints the bytes as lowercase hexadecimal. HexEncodeLower HexEncodeMode = iota + 1 // HexEncodeUpper prints the bytes as uppercase hexadecimal. HexEncodeUpper // HexEncodeLowerColon prints the bytes as lowercase hexadecimal // with colons between each pair of bytes. HexEncodeLowerColon // HexEncodeUpperColon prints the bytes as uppercase hexadecimal // with colons between each pair of bytes. HexEncodeUpperColon // HexEncodeBytes prints the string as a sequence of []byte. HexEncodeBytes // HexEncodeBase64 prints the string as a base64-encoded string. HexEncodeBase64 )
func ParseHexEncodeMode ¶ added in v1.13.0
func ParseHexEncodeMode(s string) HexEncodeMode
func (HexEncodeMode) String ¶ added in v1.13.0
func (m HexEncodeMode) String() string