utils

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2020 License: AGPL-3.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PendingGenerateResource, _ = GetDataFromBase64String("iVBORw0KGgoAAAANSUhEUgAAAfQAAADwBAMAAAAEHosbAAAAG1BMVEUAAADMzMyZmZkzMzNmZmZ/f38ZGRmysrJMTEwh+DPkAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEOklEQVR4nO3YzW/bNhjHcfpN9jGP8iIfI2xrdrQLrLs67Zpdo21pelTWdbnGSTPvaBdosT+7z8OXxAFkIDu0Vrfv59AmpEjoJ1IkFecAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMC/JCqfNNV0Dja1GR0Vv36+O/piLLrsNdVo9EyaKnpzbfLkMZ1vfnptIGdnZ6XUDTUbo0+lOJKiqUlDFy1mqbP5aUPNpujZfK92b6WpSUMXLeYHfHXVULPpvvtiS0P1mFRfQfSLnYaaTffd8SvDsHF9eGQX7eCj2y2+n79z9hCeFq/0/7fzJ2HCp4LsPJ+EJWHln1P/1vmlfqZV0itvrSp0IX9WS9c/yk9cV2Q3lbaQjzPdcQNdtQ81+lhsBevpbxcheihwlyIHIXp1/5ZXujFa9JXIXy51Ib/L0s2tlY8eS1vIx6mu3HHxU7mv0eWbni56Q/mtLEP0UODK/GUeopez1LYv757rcpfpweBHbRu7kEqWA3n9QU570/GzVNpCFucHmWUycyP9+aLwM3q6q7+F6KEg05FchejzZWp7oe/7yq660qtd6kLy2g3H+iSuwiYRSlvIH2mk7uvEdeXSp9GZXto4h+ihYKD13ZDAFvjS2rjjQy0c+3TZfRf6IKyFvUUaPZW2kE8+dl1bsI9n7mLXL3rzSRzPVKAJ0+DdR7ep39/TqyY2e1IXOj9cVvu5Yg1jaQvJYrH4TmeofwSnfrj0hi3kNEQPBcNdW85qa2ET/nyx0F/sQCv7oVzq1IXf9t2bD+Kjp9IWiq9hx9/hod/hOwf+FBdXeF/gOg+jh4a+TR7OfFKnLvz58Fx/9NFTaQul6IWO/uJB9M56dBv1eG01s3/tOdiMWVzfRY9d2FWXkr8O73oqbaEYvRsPZzGplT4YdXvX46iHU+8ovuvOpeipC7uquvFdpXe9nWL0gW29b+qU1Ja56Xr0gSbohWtt4QvLvR1usmcpeurCrrKXIox6Km2hGL2v27eNYkxqk/p4PbrVD8K1A/+9apu87tw2qjF66sIvevrojndSw7VTUJvE6OHkMUlJp3ouna9Ht/ppuDaTGzvI2fnHjjS7KXrqwo/6TOfIji2OqbSF0kGrysNBNr7a+eSprEfX+pcSr13J7S8yLmudBt+Gg2zoJ3bh3/X9fyr9rB/mH1NpC6Xo3fj5EgdZt+wHE97q9+K1I9uullXtTzb53TKXuggrvBSXMhvo50u3rXvbXXT3vvje3UXXj9a/H2xuzv1cfEzX/jEvTtxKfxmV18v76LGLsK8Xs95imZU3qfTr1vyXuv+83gsd42Lbd7EVI/tyy7d9F1uRyateOd72XWyHfaY2/d32f8C2q1YeTD6/7Pn1ybbvAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAL+ITrOa6fKadMcEAAAAASUVORK5CYII=")

Functions

func Btoi

func Btoi(b bool) int

Btoi transforms a boolean to an int. 1 for true, false otherwise

func DirExists

func DirExists(path string) (bool, error)

DirExists returns true if the given path exists and is a directory

func EmptyDir

func EmptyDir(path string) error

EmptyDir will recursively remove the contents of a directory at the given path

func EnsureDir

func EnsureDir(path string) error

EnsureDir will create a directory at the given path if it doesn't already exist

func FileExists

func FileExists(path string) (bool, error)

FileExists returns true if the given path exists

func FileType

func FileType(filePath string) (types.Type, error)

FileType uses the filetype package to determine the given file path's type

func FixWindowsPath

func FixWindowsPath(str string) string

FixWindowsPath replaces \ with / in the given path because sometimes the \ isn't recognized as valid on windows

func GetBase64StringFromData

func GetBase64StringFromData(data []byte) string

GetBase64StringFromData returns the given byte slice as a base64 encoded string

func GetDataFromBase64String

func GetDataFromBase64String(encodedString string) ([]byte, error)

GetDataFromBase64String returns the given base64 encoded string as a byte slice

func GetHomeDirectory

func GetHomeDirectory() string

GetHomeDirectory returns the path of the user's home directory. ~ on Unix and C:\Users\UserName on Windows

func GetVTTTime

func GetVTTTime(totalSeconds float64) (s string)

GetVTTTime returns a timestamp appropriate for VTT files (hh:mm:ss.mmm)

func GetYMDFromDatabaseDate

func GetYMDFromDatabaseDate(dateString string) string

func IsValidFloat64

func IsValidFloat64(value float64) bool

IsValidFloat64 ensures the given value is a valid number (not NaN) which is not equal to 0

func ListDir

func ListDir(path string) []string

ListDir will return the contents of a given directory path as a string slice

func MD5FromBytes

func MD5FromBytes(data []byte) string

func MD5FromFilePath

func MD5FromFilePath(filePath string) (string, error)

func MD5FromString

func MD5FromString(str string) string

func NaturalCompare

func NaturalCompare(a, b string) bool

func NaturalSort

func NaturalSort(l []string)

func ParseDateStringAsFormat

func ParseDateStringAsFormat(dateString string, format string) (string, error)

func ParseDateStringAsTime

func ParseDateStringAsTime(dateString string) (time.Time, error)

func ProcessBase64Image

func ProcessBase64Image(imageString string) (string, []byte, error)

ProcessBase64Image transforms a base64 encoded string from a form post and returns the MD5 hash of the data and the image itself as a byte slice.

func RemoveDir

func RemoveDir(path string) error

RemoveDir removes the given file path along with all of its contents

func StrFilter

func StrFilter(vs []string, f func(string) bool) []string

func StrInclude

func StrInclude(vs []string, t string) bool

func StrIndex

func StrIndex(vs []string, t string) int

func StrMap

func StrMap(vs []string, f func(string) string) []string

func Touch

func Touch(path string) error

Touch creates an empty file at the given path if it doesn't already exist

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL