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 IfToLower(s string) string
- func IfToUpper(s string) string
- func IncrementIPRange(ip net.IP)
- func IsIPv4(s string) bool
- func IsIPv6(s string) bool
- func ParseVendorSpecificContentType(cType string) string
- func ReadFile(path string, fs http.FileSystem) ([]byte, error)
- func StartTimeStampUpdater()
- func StatusMessage(status int) string
- 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 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.
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 IfToLower ¶
IfToLower returns an lowercase version of the input ASCII string.
It first checks if the string contains any uppercase characters before converting it.
For strings that are already lowercase,this function will be faster than `ToLower`.
In the case of mixed-case or uppercase strings, this function will be slightly slower than `ToLower`.
func IfToUpper ¶
IfToUpper returns an uppercase version of the input ASCII string.
It first checks if the string contains any lowercase characters before converting it.
For strings that are already uppercase,this function will be faster than `ToUpper`.
In the case of mixed-case or lowercase strings, this function will be slightly slower than `ToUpper`.
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 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 starts a concurrent function which stores the timestamp to an atomic value per second, which is much better for performance than determining it at runtime each time
func StatusMessage ¶
StatusMessage returns the correct message for the provided HTTP statuscode
func Timestamp ¶
func Timestamp() uint32
Timestamp returns the current time. Make sure to start the updater once using StartTimeStampUpdater() before calling.
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 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.