Documentation ¶
Index ¶
- Variables
- func AmountToFloat64(amount uint64, decimals uint8) float64
- func AmountToString(amount uint64, decimals uint8) string
- func AmountToUint64(amount float64, decimals uint8) uint64
- func AnyToString(v interface{}) string
- func Base58ToBytes(s string) ([]byte, error)
- func Base64ToBytes(s string) ([]byte, error)
- func BytesToBase58(b []byte) string
- func BytesToBase64(b []byte) string
- func Capitalize(s string) string
- func DownloadFile(url string) ([]byte, error)
- func Float64ToString(amount float64) string
- func FullyQualifiedStructName(v interface{}) string
- func GetFileByPath(path string) ([]byte, error)
- func GetFileContentType(input io.Reader) (string, error)
- func GetFileContentTypeByBytes(input []byte) (string, error)
- func GetFileNameWithoutExtension(fileName string) string
- func GetFileSize(file io.ReadSeeker) (int64, error)
- func GetFileTypeByURI(uri string) string
- func GetMaxFileParts(file io.ReadSeeker, partSize int64) (int64, error)
- func GetVarType(v interface{}) string
- func IntAmountToFloat64(amount int64, decimals uint8) float64
- func IsAudioResponse(r *http.Request) bool
- func IsCssResponse(r *http.Request) bool
- func IsFormRequest(r *http.Request) bool
- func IsHtmlResponse(r *http.Request) bool
- func IsImageResponse(r *http.Request) bool
- func IsJavascriptResponse(r *http.Request) bool
- func IsJsonRequest(r *http.Request) bool
- func IsJsonResponse(r *http.Request) bool
- func IsMultipartRequest(r *http.Request) bool
- func IsTextRequest(r *http.Request) bool
- func IsTextResponse(r *http.Request) bool
- func IsVideoResponse(r *http.Request) bool
- func IsXmlRequest(r *http.Request) bool
- func IsXmlResponse(r *http.Request) bool
- func MapToStruct(source map[string]interface{}, target interface{}, customTag string) error
- func MergeIntoMap(dst, src map[string]interface{}) map[string]interface{}
- func MergeIntoMapRecursively(dst, src map[string]interface{}) map[string]interface{}
- func NamedStruct(fallback func(v interface{}) string) func(v interface{}) string
- func NewContextWithCancel(log interface{ ... }) (context.Context, context.CancelFunc)
- func ParseFileSize(s string) (int64, error)
- func Pointer[T any](v T) *T
- func PrettyPrint(v ...interface{})
- func PrettyString(v interface{}) string
- func SanitizeEmail(s string) (string, error)
- func StructName(v interface{}) string
- func StructToMap(source interface{}, customTag string) (map[string]interface{}, error)
- func ToSnakeCase(s string) string
- func ToTitleCase(s string) string
- func TrimRightZeros(str string) string
- func TrimStringBetween(str, start, end string) string
- func UcFirst(s string) string
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidEmailAddress = errors.New("invalid email address") ErrInvalidIcanSuffix = errors.New("invalid ICAN suffix") )
var ( ErrInvalidReader = errors.New("invalid reader") ErrEmptyInput = errors.New("empty input") ErrInvalidPartSize = errors.New("part size must be greater than 0") )
Predefined errors
Functions ¶
func AmountToFloat64 ¶
AmountToFloat64 converts amount lamports to float64 with given decimals.
func AmountToString ¶
AmountToString converts amount lamports to string with given decimals.
func AmountToUint64 ¶
AmountToUint64 converts amount from float64 to uint64 with given decimals.
func Base58ToBytes ¶
Base58ToBytes converts base58 string to bytes.
func Base64ToBytes ¶
Base64ToBytes converts base64 string to bytes.
func BytesToBase58 ¶
BytesToBase58 converts bytes to base58 string.
func BytesToBase64 ¶
BytesToBase64 converts bytes to base64 string.
func DownloadFile ¶
DownloadFile downloads the file from the given URL and returns the bytes.
func Float64ToString ¶
Float64ToString converts float64 to string with minimum number of decimals. For example, 1.000000000 will be converted to "1", 1.100000000 will be converted to "1.1".
func FullyQualifiedStructName ¶ added in v0.1.4
func FullyQualifiedStructName(v interface{}) string
FullyQualifiedStructName name returns object name in format [package].[type name]. It ignores if the value is a pointer or not.
func GetFileByPath ¶
GetFileByPath returns the file bytes from the given path. If the path is a URL, it will download the file and return the bytes. If the path is a local file, it will read the file and return the bytes.
func GetFileContentType ¶
GetFileContentType returns the content type of a file.
func GetFileContentTypeByBytes ¶
GetFileContentTypeByBytes returns the content type of a file.
func GetFileNameWithoutExtension ¶
Get the file name without extension. fileName string: the file name.
func GetFileSize ¶
func GetFileSize(file io.ReadSeeker) (int64, error)
Get the file size. file io.ReadSeeker: the file to be uploaded.
func GetFileTypeByURI ¶
GetFileTypeByURI returns the file type of the given URI
func GetMaxFileParts ¶
func GetMaxFileParts(file io.ReadSeeker, partSize int64) (int64, error)
Get max file parts can be if the file is split into parts with the given part size. The max file parts is 10000. file io.ReadSeeker: the file to be uploaded. partSize int64: the part size.
func GetVarType ¶
func GetVarType(v interface{}) string
GetVarType returns the type of the given variable as a string.
func IntAmountToFloat64 ¶
IntAmountToFloat64 converts int64 amount lamports to float64 with given decimals.
func IsAudioResponse ¶ added in v0.1.3
is response accepted as audio?
func IsCssResponse ¶ added in v0.1.3
is response accepted as css?
func IsFormRequest ¶ added in v0.1.3
Is request a form request?
func IsHtmlResponse ¶ added in v0.1.3
is response accepted as html?
func IsImageResponse ¶ added in v0.1.3
is response accepted as image?
func IsJavascriptResponse ¶ added in v0.1.3
is response accepted as javascript?
func IsJsonRequest ¶ added in v0.1.3
Is request a json request?
func IsJsonResponse ¶ added in v0.1.3
is response accepted as json?
func IsMultipartRequest ¶ added in v0.1.3
Is request a multipart request?
func IsTextRequest ¶ added in v0.1.3
Is request a text request?
func IsTextResponse ¶ added in v0.1.3
is response accepted as text?
func IsVideoResponse ¶ added in v0.1.3
is response accepted as video?
func IsXmlRequest ¶ added in v0.1.3
Is request a xml request?
func IsXmlResponse ¶ added in v0.1.3
is response accepted as xml?
func MapToStruct ¶
MapToStruct maps a map to a struct. The map key must be the same as the struct field name or the custom tag name. The map value must be the same type as the struct field type. The target must be a non-nil pointer to a struct.
func MergeIntoMap ¶ added in v0.1.5
MergeIntoMap merges `src` map into `dst` map. `dst` - destination map, `src` - source map if the same key exists in both maps, the value from the second map will be used. if the first map is nil, a new map will be created. if the second map is nil, the first map will be returned. if both maps are nil, a new map will be created.
func MergeIntoMapRecursively ¶ added in v0.1.5
MergeIntoMapRecursively recursively merges `src` map into `dst` map. `dst` - destination map, `src` - source map if the same key exists in both maps, the value from the second map will be used. if the first map is nil, a new map will be created. if the second map is nil, the first map will be returned. if both maps are nil, a new map will be created. if the value for a given key is a map, it will be merged recursively.
func NamedStruct ¶ added in v0.1.4
NamedStruct returns the name from a message implementing the following interface:
type namedStruct interface { Name() string }
It ignores if the value is a pointer or not.
func NewContextWithCancel ¶ added in v0.1.1
func NewContextWithCancel( log interface { Printf(format string, v ...interface{}) }, ) (context.Context, context.CancelFunc)
NewContextWithCancel returns a new context with a cancel function. The context will be canceled when an interrupt signal is received.
func ParseFileSize ¶
Parse file size from string to int64
func Pointer ¶
func Pointer[T any](v T) *T
Pointer is a helper to make a pointer to the given value.
func PrettyPrint ¶
func PrettyPrint(v ...interface{})
PrettyPrint prints the given interface in a pretty format
func PrettyString ¶
func PrettyString(v interface{}) string
PrettyString returns the given interface in a pretty format
func SanitizeEmail ¶
SanitizeEmail cleans email address from dots, dashes, etc
func StructName ¶ added in v0.1.4
func StructName(v interface{}) string
StructName name returns struct name in format [type name]. It ignores if the value is a pointer or not.
func StructToMap ¶
StructToMap converts a struct to a map. The map key will be the struct field name or the custom tag name. The map value will be the struct field value. The source must be a struct or a pointer to a struct.
func TrimRightZeros ¶
TrimRightZeros trims trailing zeros from string.
func TrimStringBetween ¶
Trim string between two substrings and return the string without it and substrings.
Types ¶
This section is empty.