Documentation ¶
Overview ¶
Package utils provides some common utility methods
Index ¶
- func ByteCountIEC(b int64) string
- func ByteCountSI(b int64) string
- func DecryptData(data string) (string, error)
- func EncryptData(data string) (string, error)
- func GetDurationAsString(d time.Duration) string
- func GetIPFromRemoteAddress(remoteAddress string) string
- func GetTimeAsMsSinceEpoch(t time.Time) int64
- func GetTimeFromMsecSinceEpoch(msec int64) time.Time
- func IsStringInSlice(obj string, list []string) bool
- func IsStringPrefixInSlice(obj string, list []string) bool
- func NilIfEmpty(s string) *string
- func RemoveDecryptionKey(encryptData string) string
- func SetUmask(umask int, configValue string)
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteCountIEC ¶
ByteCountIEC returns humanized size in IEC (binary) format
func ByteCountSI ¶
ByteCountSI returns humanized size in SI (decimal) format
func DecryptData ¶
DecryptData decrypts data encrypted using EncryptData
func EncryptData ¶
EncryptData encrypts data using the given key
func GetDurationAsString ¶
GetDurationAsString returns a string representation for a time.Duration
func GetIPFromRemoteAddress ¶
GetIPFromRemoteAddress returns the IP from the remote address. If the given remote address cannot be parsed it will be returned unchanged
func GetTimeAsMsSinceEpoch ¶
GetTimeAsMsSinceEpoch returns unix timestamp as milliseconds from a time struct
func GetTimeFromMsecSinceEpoch ¶
GetTimeFromMsecSinceEpoch return a time struct from a unix timestamp with millisecond precision
func IsStringInSlice ¶
IsStringInSlice searches a string in a slice and returns true if the string is found
func IsStringPrefixInSlice ¶
IsStringPrefixInSlice searches a string prefix in a slice and returns true if a matching prefix is found
func NilIfEmpty ¶
NilIfEmpty returns nil if the input string is empty
func RemoveDecryptionKey ¶
RemoveDecryptionKey returns encrypted data without the decryption key
Types ¶
type VersionInfo ¶
type VersionInfo struct { Version string `json:"version"` BuildDate string `json:"build_date"` CommitHash string `json:"commit_hash"` }
VersionInfo defines version details
func (*VersionInfo) GetVersionAsString ¶
func (v *VersionInfo) GetVersionAsString() string
GetVersionAsString returns the string representation of the VersionInfo struct