Documentation ¶
Index ¶
- Constants
- func AppendFile(dir, filename string, data []byte) error
- func ByteToMap(data []byte) (map[string]interface{}, error)
- func ByteToStruct(data []byte, out interface{}) error
- func ContainsString(slice []string, value string) bool
- func CopyFile(src, dst string) error
- func CopyFileForce(src, dst string, overwrite bool) error
- func CreateDir(dir string) error
- func CustomSize(format string, size float64, base float64, _map []string) string
- func DeepClone(data interface{}) interface{}
- func FindItem(slice []string, value string) (int, bool)
- func GetMapValue(m map[string]interface{}, key string, defaultValue interface{}) interface{}
- func GetMapValueString(m map[string]interface{}, key string, defaultValue string) string
- func IsDirExists(dirname string) bool
- func IsFileExists(filename string) bool
- func JoinMap(dst, src map[string]interface{})
- func JoinStringMap(dst, src map[string]string)
- func ListDirs(dir string) ([]types.File, error)
- func ListFiles(dir string) ([]types.File, error)
- func MapToStruct(tagName string, in map[string]interface{}, out interface{}) error
- func ParseSize(sizeStr string) (int64, error)
- func ParseSizeWithDefault(size string, defaultSize int64) int64
- func RandID() string
- func RandIDWithLength(length int) string
- func RandUUID() string
- func ReadFile(dir, filename string) ([]byte, error)
- func RemoveDir(dir string) error
- func RemoveFileOrEmptyDir(file string) error
- func SmartSleep(duration time.Duration)
- func StructToByte(data interface{}) ([]byte, error)
- func StructToMap(data interface{}) map[string]interface{}
- func ToBinarySizeString(size float64) string
- func ToDecimalSizeString(size float64) string
- func ToDecimalSizeStringWithPrecision(size float64, precision int) string
- func ToDuration(duration string, defaultDuration time.Duration) time.Duration
- func ToStruct(data []byte, out interface{}) error
- func UpdatePagination(pagination *storageTY.Pagination) *storageTY.Pagination
- func ValidDuration(duration, defaultDuration string) string
- func WriteFile(dir, filename string, data []byte) error
Constants ¶
const ( // Decimal KB = 1000 MB = 1000 * KB GB = 1000 * MB TB = 1000 * GB PB = 1000 * TB // Binary KiB = 1024 MiB = 1024 * KiB GiB = 1024 * MiB TiB = 1024 * GiB PiB = 1024 * TiB )
See: http://en.wikipedia.org/wiki/Binary_prefix
const ( TagNameYaml = "yaml" TagNameJSON = "json" TagNameNone = "" )
contants
Variables ¶
This section is empty.
Functions ¶
func ByteToStruct ¶
ByteToStruct converts []byte to interface
func ContainsString ¶
ContainsString returns the available status
func CopyFileForce ¶
copies from a location to another location with optional overwrite
func CustomSize ¶
CustomSize returns a human-readable approximation of a size using custom format.
func GetMapValue ¶
GetMapValue returns fetch and returns with a key. if not available returns default value
func GetMapValueString ¶
GetMapValueString returns value, if not available returns defaultValue
func IsDirExists ¶
IsDirExists checks the directory availability
func IsFileExists ¶
IsFileExists checks the file availability
func JoinMap ¶
func JoinMap(dst, src map[string]interface{})
JoinMap joins two maps. put all the values into 'dst' map from 'src' map
func JoinStringMap ¶
JoinStringMap joins two string maps. put all the values into 'dst' map from 'src' map
func MapToStruct ¶
MapToStruct converts string to struct
func ParseSize ¶
ParseSize returns an integer from a human-readable specification of a size using SI standard (eg. "44kB", "17MB", "17MiB").
func ParseSizeWithDefault ¶
ParseSizeWithDefault returns with default
func RandIDWithLength ¶
RandIDWithLength returns random id with supplied charset
func SmartSleep ¶
SmartSleep waits till the duration reaches
func StructToByte ¶
StructToByte converts interface to []byte
func StructToMap ¶
func StructToMap(data interface{}) map[string]interface{}
StructToMap converts struct to a map
func ToBinarySizeString ¶
ToBinarySizeString returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").
func ToDecimalSizeString ¶
ToDecimalSizeString with 2 decimal
func ToDecimalSizeStringWithPrecision ¶
ToDecimalSizeStringWithPrecision allows the size to be in any precision,
func ToDuration ¶
ToDuration converts the string duration to time.Duration, if failed returns the default
func UpdatePagination ¶
func UpdatePagination(pagination *storageTY.Pagination) *storageTY.Pagination
UpdatePagination updates if nil
func ValidDuration ¶
ValidDuration verifies the duration, if it hits error returns the default duration
Types ¶
This section is empty.