Documentation
¶
Index ¶
- Constants
- func ByteSize(bytes uint64) string
- func ConvertToBytes(humanReadableString string) int
- func CopyBytes(b []byte) []byte
- func CopyString(s string) string
- func EqualFold[S byteSeq](b, s S) bool
- func FunctionName(fn any) string
- func GetArgument(arg string) bool
- func GetMIME(extension string) string
- func IncrementIPRange(ip net.IP)
- func IsIPv4(s string) bool
- func IsIPv6(s string) bool
- func ParseFloat32[S byteSeq](s S) (float32, error)
- func ParseFloat64[S byteSeq](s S) (float64, error)
- func ParseInt[S byteSeq](s S) (int64, error)
- func ParseInt16[S byteSeq](s S) (int16, error)
- func ParseInt32[S byteSeq](s S) (int32, error)
- func ParseInt8[S byteSeq](s S) (int8, error)
- func ParseUint[S byteSeq](s S) (uint64, error)
- func ParseUint16[S byteSeq](s S) (uint16, error)
- func ParseUint32[S byteSeq](s S) (uint32, error)
- func ParseUint8[S byteSeq](s S) (uint8, error)
- func ParseVendorSpecificContentType(cType string, caseInsensitive ...bool) string
- func ReadFile(path string, fs http.FileSystem) ([]byte, error)
- func StartTimeStampUpdater()
- func StatusMessage(status int) string
- func StopTimeStampUpdater()
- func Timestamp() uint32
- func ToLower(b string) string
- func ToLowerBytes(b []byte) []byte
- func ToString(arg any, timeFormat ...string) string
- func ToUpper(b string) string
- func ToUpperBytes(b []byte) []byte
- func Trim[S byteSeq](s S, cutset byte) S
- func TrimLeft[S byteSeq](s S, cutset byte) S
- func TrimRight[S byteSeq](s S, cutset byte) S
- func UUID() string
- func UUIDv4() string
- func UnsafeBytes(s string) []byte
- func UnsafeString(b []byte) string
- func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error
- type CBORMarshal
- type CBORUnmarshal
- type JSONMarshal
- type JSONUnmarshal
- type MsgPackMarshal
- type MsgPackUnmarshal
- type Signed
- type Unsigned
- type XMLMarshal
- type XMLUnmarshal
Constants ¶
const MIMEOctetStream = "application/octet-stream"
Variables ¶
This section is empty.
Functions ¶
func ByteSize ¶
ByteSize returns a human-readable byte string of the form 10M, 12.5K, and so forth. The unit that results in the smallest number greater than or equal to 1 is always chosen. Maximum supported input is math.MaxUint64 / 10 (≈ 1844674407370955161).
func ConvertToBytes ¶
ConvertToBytes returns integer size of bytes from human-readable string, ex. 42kb, 42M Returns 0 if string is unrecognized
func EqualFold ¶
func EqualFold[S byteSeq](b, s S) bool
EqualFold tests ascii strings or bytes for equality case-insensitively
func IncrementIPRange ¶
IncrementIPRange Find available next IP address
func IsIPv4 ¶
IsIPv4 works the same way as net.ParseIP, but without check for IPv6 case and without returning net.IP slice, whereby IsIPv4 makes no allocations.
func IsIPv6 ¶
IsIPv6 works the same way as net.ParseIP, but without check for IPv4 case and without returning net.IP slice, whereby IsIPv6 makes no allocations.
func ParseFloat32 ¶
ParseFloat32 parses a decimal ASCII string or byte slice into a float32. It returns (0, false) on error or if the parsed value overflows float32.
func ParseFloat64 ¶
ParseFloat64 parses a decimal ASCII string or byte slice into a float64. It delegates the actual parsing to parseFloat.
func ParseInt ¶
ParseInt parses a decimal ASCII string or byte slice into an int64. Returns the parsed value and nil on success, else 0 and an error.
func ParseInt16 ¶
ParseInt16 parses a decimal ASCII string or byte slice into an int16.
func ParseInt32 ¶
ParseInt32 parses a decimal ASCII string or byte slice into an int32.
func ParseUint ¶
ParseUint parses a decimal ASCII string or byte slice into a uint64. It returns the parsed value and nil on success. If the input contains non-digit characters, it returns 0 and an error.
func ParseUint16 ¶
ParseUint16 parses a decimal ASCII string or byte slice into a uint16.
func ParseUint32 ¶
ParseUint32 parses a decimal ASCII string or byte slice into a uint32.
func ParseUint8 ¶
ParseUint8 parses a decimal ASCII string or byte slice into a uint8.
func ParseVendorSpecificContentType ¶
ParseVendorSpecificContentType check if content type is vendor specific and if it is parsable to any known types. If its not vendor specific then returns the original content type.
func ReadFile ¶
func ReadFile(path string, fs http.FileSystem) ([]byte, error)
ReadFile returns the raw content of a file
func StartTimeStampUpdater ¶
func StartTimeStampUpdater()
StartTimeStampUpdater launches a background goroutine that updates the cached timestamp every second. It is safe to call multiple times; only the first call will start the updater.
func StatusMessage ¶
StatusMessage returns the correct message for the provided HTTP statuscode
func StopTimeStampUpdater ¶
func StopTimeStampUpdater()
StopTimeStampUpdater stops the background updater goroutine. Call this on app shutdown to avoid leaking goroutines.
func Timestamp ¶
func Timestamp() uint32
Timestamp returns the current cached Unix timestamp (seconds). Call StartTimeStampUpdater() once at app startup for best performance.
func ToLowerBytes ¶
ToLowerBytes converts ascii slice to lower-case
func ToUpperBytes ¶
ToUpperBytes converts ascii slice to upper-case
func TrimLeft ¶
func TrimLeft[S byteSeq](s S, cutset byte) S
TrimLeft is the equivalent of strings/bytes.TrimLeft
func TrimRight ¶
func TrimRight[S byteSeq](s S, cutset byte) S
TrimRight is the equivalent of strings/bytes.TrimRight
func UUIDv4 ¶
func UUIDv4() string
UUIDv4 returns a Random (Version 4) UUID. The strength of the UUIDs is based on the strength of the crypto/rand package.
func UnsafeBytes ¶
UnsafeBytes returns a byte pointer without allocation.
func UnsafeString ¶
UnsafeString returns a string pointer without allocation
Types ¶
type CBORMarshal ¶
CBORMarshal returns the CBOR encoding of v.
type CBORUnmarshal ¶
CBORUnmarshal parses the CBOR-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an error.
type JSONMarshal ¶
JSONMarshal returns the JSON encoding of v.
type JSONUnmarshal ¶
JSONUnmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError.
type MsgPackMarshal ¶
MsgPackMarshal returns the MsgPack encoding of v.
type MsgPackUnmarshal ¶
MsgPackUnmarshal parses the MsgPack-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError.
type XMLMarshal ¶
XMLMarshal returns the XML encoding of v.
type XMLUnmarshal ¶
XMLUnmarshal parses the XML-encoded data and stores the result in the value pointed to by v. If v is nil or not a pointer, Unmarshal returns an InvalidUnmarshalError.