misc

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalizeTCPAddr

func CanonicalizeTCPAddr(addr *net.TCPAddr) *net.TCPAddr

CanonicalizeTCPAddr takes a TCPAddr and returns a TCPAddr with the same value, but with the guarantee that two calls to CanonicalizeTCPAddr with the same TCPAddr value will return the same pointer.

func CompareIP

func CompareIP(a net.IP, b net.IP) int

CompareIP returns {a < b: -1, a == b: 0, a > b: +1}.

func CompareTCPAddr

func CompareTCPAddr(a *net.TCPAddr, b *net.TCPAddr) int

CompareTCPAddr returns {a < b: -1, a == b: 0, a > b: +1}.

func ErrorOrNil added in v0.4.6

func ErrorOrNil(multi multierror.Error) error

ErrorOrNil is a variant of multierror.(*Error).ErrorOrNil that always makes defensive copies of the error and its list, rather than re-using them. It also auto-flattens the list.

func ParseBool

func ParseBool(str string) (bool, error)

ParseBool parses a boolean value.

func ParseIP

func ParseIP(host string) (net.IP, error)

ParseIP parses an IP address.

func ParseIPAndZone

func ParseIPAndZone(host string) (net.IP, string, error)

ParseIPAndZone parses a string in "<ip>%<zone>" format.

func ParsePort

func ParsePort(port string) (uint16, error)

ParsePort parses a port number.

func ParseTCPAddr

func ParseTCPAddr(str, defaultPort string) (*net.TCPAddr, error)

ParseTCPAddr parses a string in "<ip>:<port>" format.

func ParseTCPAddrList

func ParseTCPAddrList(str, defaultPort string) ([]*net.TCPAddr, error)

ParseTCPAddrList parses a string in "<ip>:<port>,<ip>:<port>,..." format.

func SplitHostPort

func SplitHostPort(str, defaultPort string) (host string, port string, err error)

SplitHostPort splits a string in "<host>:<port>" format, except that if a port is not present in the string and defaultPort is non-empty, then defaultPort is used instead.

func StrictUnmarshalJSON

func StrictUnmarshalJSON(raw []byte, v interface{}) error

StrictUnmarshalJSON is a variant of json.Unmarshal that always sets DisallowUnknownFields() and UseNumber().

func TryBase64DecodeString

func TryBase64DecodeString(str string) ([]byte, error)

TryBase64DecodeString attempts to decode base-64 byte array using any of the standard base-64 encodings.

Types

type Base64DecodeError added in v0.4.7

type Base64DecodeError struct {
	Input string
	Err   error
}

Base64DecodeError represents failure to convert a base-64 string to []byte.

func (Base64DecodeError) Error added in v0.4.7

func (err Base64DecodeError) Error() string

Error fulfills the error interface.

func (Base64DecodeError) Unwrap added in v0.4.7

func (err Base64DecodeError) Unwrap() error

Unwrap returns the underlying cause of this error.

type LookupCache added in v0.4.7

type LookupCache struct {
	// contains filtered or unexported fields
}

LookupCache is a thread-safe cache that remembers the results of OS user and group lookups.

func (*LookupCache) GroupByID added in v0.4.7

func (cache *LookupCache) GroupByID(gid uint32) (*user.Group, error)

GroupByID is a cached wrapper of "os/user".LookupGroupId.

func (*LookupCache) GroupByName added in v0.4.7

func (cache *LookupCache) GroupByName(groupName string) (*user.Group, error)

GroupByName is a cached wrapper of "os/user".LookupGroup.

func (*LookupCache) UserByID added in v0.4.7

func (cache *LookupCache) UserByID(uid uint32) (*user.User, error)

UserByID is a cached wrapper of "os/user".LookupId.

func (*LookupCache) UserByName added in v0.4.7

func (cache *LookupCache) UserByName(userName string) (*user.User, error)

UserByName is a cached wrapper of "os/user".Lookup.

Jump to

Keyboard shortcuts

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