Documentation ¶
Index ¶
- Constants
- func Deviation(randomVars []float64) float64
- func Expectation(randomVars []float64) float64
- func IntSliToSQLVarchars(ints []int64) string
- func Max(vars []int64) (maxVar int64)
- func Normallization(randomVars []int64) []float64
- func RandID() int64
- func RandStr(size int) string
- func SameChar(content string) bool
- func StdDeviation(randomVars []float64) float64
- func StrSliToSQLVarchars(s []string) string
- func StrToIntSli(s string, delimiter string) ([]int64, error)
- func StripPrefix(s string, prefix string, suffix string) string
- type JSONTime
- type Pagination
Examples ¶
Constants ¶
const (
// DefaultPerPage .
DefaultPerPage = 20
)
const (
// TimeFormat .
TimeFormat = "2006-01-02 15:04:05"
)
Variables ¶
This section is empty.
Functions ¶
func IntSliToSQLVarchars ¶
IntSliToSQLVarchars convert int slice to string, eg: [1,2,3] -> "1,2,3"
Example ¶
fmt.Println(IntSliToSQLVarchars([]int64{1, 2, 3}))
Output: 1,2,3
func StrSliToSQLVarchars ¶
StrSliToSQLVarchars convert string slice to varchar in sql syntax eg: ["default", "deleted", "modified"] -> " 'default', 'deleted', 'modified' " so that we can used it in 'SELECT * ... WHERE xxx IN ('default', 'deleted', 'modified')'
Example ¶
fmt.Println(StrSliToSQLVarchars([]string{"default", "deleted", "modified"}))
Output: 'default','deleted','modified'
func StrToIntSli ¶
StrToIntSli convert string to int slice, eg: "1,2,3" -> [1,2,3]
Example ¶
fmt.Println(StrToIntSli("1,2,3", ","))
Output: [1 2 3] <nil>
Types ¶
type Pagination ¶
Pagination perform page algorithm
func (*Pagination) OffsetLimit ¶
func (p *Pagination) OffsetLimit(total int64) (offset int64, limit int64)
OffsetLimit calculate "offset" and "start" with total_counts
func (*Pagination) Page ¶
func (p *Pagination) Page(total int64) (from int64, to int64)
Page calculate "from", "to" with total_counts index start from 1
func (*Pagination) SimplePage ¶
func (p *Pagination) SimplePage() (from int64, to int64)
SimplePage calculate "from", "to" without total_counts "from" index start from 1
func (*Pagination) VagueOffsetLimit ¶
func (p *Pagination) VagueOffsetLimit() (offset int64, limit int64)
VagueOffsetLimit calculate "offset", "limit" without total_counts