Documentation ¶
Overview ¶
Package lib contains functions useful for most programs.
Index ¶
- Constants
- func Duration(d time.Duration) string
- func Err(exit int, err error, format string, a ...interface{})
- func Errx(exit int, format string, a ...interface{})
- func Itoa(i int, wid int) string
- func LoadCertificate(path string) (*x509.Certificate, error)
- func LoadCertificates(path string) ([]*x509.Certificate, error)
- func ProgName() string
- func ReadCertificate(in []byte) (cert *x509.Certificate, rest []byte, err error)
- func ReadCertificates(in []byte) (certs []*x509.Certificate, err error)
- func Warn(err error, format string, a ...interface{}) (int, error)
- func Warnx(format string, a ...interface{}) (int, error)
- type FileTime
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 )
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 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 LoadCertificate ¶ added in v1.1.0
func LoadCertificate(path string) (*x509.Certificate, error)
LoadCertificate tries to read a single certificate from disk. If the file contains multiple certificates (e.g. a chain), only the first certificate is returned.
func LoadCertificates ¶ added in v1.1.0
func LoadCertificates(path string) ([]*x509.Certificate, error)
LoadCertificates tries to read all the certificates in a file, returning them in the order that it found them in the file.
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 ReadCertificate ¶ added in v1.1.0
func ReadCertificate(in []byte) (cert *x509.Certificate, rest []byte, err error)
ReadCertificate reads a DER or PEM-encoded certificate from the byte slice.
func ReadCertificates ¶ added in v1.1.0
func ReadCertificates(in []byte) (certs []*x509.Certificate, err error)
ReadCertificates tries to read all the certificates in a PEM-encoded collection.
Types ¶
type FileTime ¶
FileTime contains the changed, modified, and accessed timestamps for a file.
func LoadFileTime ¶
LoadFileTime returns a FileTime associated with the file.