add redis

This commit is contained in:
Jay
2018-04-18 14:16:29 +08:00
parent 4fd4c7018e
commit 6419162471
48 changed files with 9952 additions and 14 deletions
+7
View File
@@ -0,0 +1,7 @@
// +build appengine
package util
func BytesToString(b []byte) string {
return string(b)
}
+19
View File
@@ -0,0 +1,19 @@
package util
import "strconv"
func Atoi(b []byte) (int, error) {
return strconv.Atoi(BytesToString(b))
}
func ParseInt(b []byte, base int, bitSize int) (int64, error) {
return strconv.ParseInt(BytesToString(b), base, bitSize)
}
func ParseUint(b []byte, base int, bitSize int) (uint64, error) {
return strconv.ParseUint(BytesToString(b), base, bitSize)
}
func ParseFloat(b []byte, bitSize int) (float64, error) {
return strconv.ParseFloat(BytesToString(b), bitSize)
}
+12
View File
@@ -0,0 +1,12 @@
// +build !appengine
package util
import (
"unsafe"
)
// BytesToString converts byte slice to string.
func BytesToString(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}