Documentation ¶
Index ¶
- func CheckError(err error, exitCode int)
- func EndOfDay(t time.Time) time.Time
- func GetHTTPStatusMessage(code int) string
- func HumanSize(size float64) string
- func HumanSizeWithPrecision(size float64, precision int) string
- func InArray(value interface{}, array interface{}) (found bool, index int)
- func RemoveDuplicatesFromStringArray(arr []string) []string
- func RemoveStringFromSlice(a string, slice []string) []string
- func SQLDateToTime(d string) (time.Time, error)
- func SQLDatetimeToTime(d string) (time.Time, error)
- func SetInterval(fct func(), milliseconds int, async bool) chan<- bool
- func SetTimeout(fct func(), milliseconds int)
- func StartOfDay(t time.Time) time.Time
- func StringArrayIntersection(arr1, arr2 []string) []string
- func StringInSlice(a string, slice []string) bool
- func StringSliceDiff(a, b []string) []string
- func SubPath(path, pattern string) string
- func TimeToSQLDate(t time.Time) string
- func TimeToSQLDatetime(t time.Time) string
- func Ucfirst(s string) string
- func Yesterday() time.Time
- type HTTPResponse
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHTTPStatusMessage ¶ added in v1.0.8
GetHTTPStatusMessage returns a message for a HTTP status code.
func HumanSize ¶ added in v1.0.9
HumanSize returns a human-readable approximation of a size capped at 1 valid number (eg. "2.7MB", "796.0KB").
func HumanSizeWithPrecision ¶ added in v1.0.9
HumanSizeWithPrecision allows the size to be in any precision, instead of 1 digit precision used in HumanSize.
func RemoveDuplicatesFromStringArray ¶ added in v1.0.7
RemoveDuplicatesFromStringArray removes duplicates strings from slice.
func RemoveStringFromSlice ¶ added in v1.0.7
RemoveStringFromSlice removes string from slice.
func SQLDateToTime ¶ added in v1.0.4
SQLDateToTime converts SQL date to time.Time.
func SQLDatetimeToTime ¶ added in v1.0.4
SQLDatetimeToTime converts SQL date to time.Time.
func SetInterval ¶ added in v1.0.10
SetInterval executes a function that is repeated at regular intervals and returns a channel to clear the interval. Usage: interval := setInterval(myFunction, 1000, false) To clear interval: interval <- true
func SetTimeout ¶ added in v1.0.10
func SetTimeout(fct func(), milliseconds int)
SetTimeout runs a function after a given period of time.
func StartOfDay ¶ added in v1.0.7
StartOfDay returns a the first time of a day.
func StringArrayIntersection ¶ added in v1.0.7
StringArrayIntersection returns the intersection of two slices.
func StringInSlice ¶ added in v1.0.7
StringInSlice finds string in slice.
Example ¶
ok := StringInSlice("Coucou", []string{"Coucou", "Hello"}) fmt.Println(ok)
Output: true
func StringSliceDiff ¶ added in v1.0.7
StringSliceDiff returns differences between two slices.
Example ¶
a := []string{"one", "two", "three", "four", "five", "six"} b := []string{"two", "seven", "four", "six"} diff := StringSliceDiff(a, b) fmt.Printf("diff: %v\n", diff)
Output: diff: [one three five]
func TimeToSQLDate ¶ added in v1.0.5
TimeToSQLDate returns a time to SQL date format (YYYY-MM-DD).
func TimeToSQLDatetime ¶ added in v1.0.5
TimeToSQLDatetime returns a time to SQL datetime format (YYYY-MM-DD HH:MM:SS).
Types ¶
type HTTPResponse ¶ added in v1.0.4
type HTTPResponse struct { Code int `json:"code" xml:"code"` Message string `json:"message" xml:"message"` Data interface{} `json:"data,omitempty" xml:"data"` }
HTTPResponse type
func GetHTTPInternalServerError ¶ added in v1.0.4
func GetHTTPInternalServerError(message string) HTTPResponse
GetHTTPInternalServerError returns 500 error.
func GetHTTPResponse ¶ added in v1.0.4
func GetHTTPResponse(code int, message string, data interface{}) HTTPResponse
GetHTTPResponse returns HTTPResponse type.