Add basic friend logic

This commit is contained in:
Howl committed 2016-04-07 11:20:35 +02:00
1 parent f7819630ee
commit af71442e79
4 files changed
+153

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package common
import (
"fmt"
"strconv"
)
// Paginate creates an additional SQL LIMIT clause for paginating.
func Paginate(page, limit string) string {
var (
pInt int
lInt int
err error
)
if page == "" {
pInt = 1
} else {
pInt, err = strconv.Atoi(page)
if err != nil {
pInt = 1
}
}
if limit == "" {
lInt = 50
} else {
lInt, err = strconv.Atoi(limit)
if err != nil {
lInt = 50
}
}
start := (pInt - 1) * lInt
return fmt.Sprintf(" LIMIT %d,%d ", start, lInt)
}