suprlib

package module
v0.0.0-...-ead0c5d Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 21 Imported by: 0

README

汇聚流行Go语言库的代码,使得使用Go语言代码更加简便。

欢迎来Pull Requests

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEAD_CODE = errors.New("DEAD_CODE")
View Source
var JSON_MAP_TRANS_ERROR = errors.New("JSON_MAP_TRANS_ERROR")
View Source
var MAP_KEY_NOT_FOUND_ERROR = errors.New("MAP_KEY_NOT_FOUND_ERROR")
View Source
var NOT_FOUND_ERROR = errors.New("NOT_FOUND_ERROR")

Functions

func AppendToFile

func AppendToFile(filename string, b []byte) error

func Base64Decode

func Base64Decode(src string) ([]byte, error)

func Base64Encode

func Base64Encode(src []byte) string

func CloneMapInt64Int64

func CloneMapInt64Int64(data map[int64]int64) map[int64]int64

func CloneSliceInt64

func CloneSliceInt64(datas []int64) []int64

func ContainsKey

func ContainsKey(m map[string]interface{}, key string) bool

func ContainsKeys

func ContainsKeys(m map[string]interface{}, keys []string) bool

func F64Str

func F64Str(num float64) string

func FileExists

func FileExists(filename string) bool

func GZipDecode

func GZipDecode(in []byte) ([]byte, error)

func HmacSHA256

func HmacSHA256(msg []byte, secretKey []byte) ([]byte, error)

func HttpDelete

func HttpDelete(url string, headers map[string]string, body io.Reader) ([]byte, error)

func HttpGet

func HttpGet(url string, headers map[string]string, body io.Reader) ([]byte, error)

func HttpGetAsync

func HttpGetAsync(url string, headers map[string]string, body io.Reader, callback func([]byte, error))

func HttpPost

func HttpPost(url string, headers map[string]string, body io.Reader) ([]byte, error)

func HttpPostAsync

func HttpPostAsync(url string, headers map[string]string, body io.Reader, callback func([]byte, error))

func HttpPut

func HttpPut(url string, headers map[string]string, body io.Reader) ([]byte, error)

func I64Str

func I64Str(num int64) string

func Int64SliceContains

func Int64SliceContains(s []int64, data int64) bool

func Int64SliceIndexFirst

func Int64SliceIndexFirst(s []int64, data int64) int

func Int64SliceRemoveFirst

func Int64SliceRemoveFirst(s []int64, data int64) []int64

func Int64SliceRemoveSlice

func Int64SliceRemoveSlice(s []int64, datas []int64) []int64

func JsonMapGetInt64Value

func JsonMapGetInt64Value(data map[string]interface{}, key string) (int64, error)

func JsonMapGetUIntValue

func JsonMapGetUIntValue(data map[string]interface{}, key string) (uint, error)

func JsonMarshal

func JsonMarshal(v interface{}) []byte

func JsonToMap

func JsonToMap(s []byte) (map[string]interface{}, error)

func JsonToObj

func JsonToObj(s []byte, out interface{}) error

func MD5

func MD5(b []byte) string

func MapInt64Int64Keys

func MapInt64Int64Keys(data map[int64]int64) []int64

func MysqlAddIndex

func MysqlAddIndex(db *gorm.DB, table interface{}, index string) error

func MysqlCreateTable

func MysqlCreateTable(db *gorm.DB, tableName string, table interface{}) error

func MysqlHasTable

func MysqlHasTable(db *gorm.DB, tableName string) bool

func MysqlInsertIgnore

func MysqlInsertIgnore(db *gorm.DB, tableName string, datas interface{}) error

func MysqlNew

func MysqlNew(dbName string) *gorm.DB

func MysqlSelectSql

func MysqlSelectSql(db *gorm.DB, sql string, out interface{}) error

func NewWebsocket

func NewWebsocket(url string, origin string) (*websocket.Conn, error)

func PanicError

func PanicError(err error)

func ReadFile

func ReadFile(filename string) []byte

func ReadJsonArrayFile

func ReadJsonArrayFile(filename string) (interface{}, error)

func ReadJsonMapFile

func ReadJsonMapFile(filename string) (map[string]interface{}, error)

func RedisGet

func RedisGet(client *redis.Client, key string) (string, error)

func RedisNew

func RedisNew(ip string, port string, password string) *redis.Client

func RedisSet

func RedisSet(client *redis.Client, key string, value string) error

func Retry

func Retry(f func() error, counts int, delay time.Duration) error

Retry TODO 类型不好控制,以后支持泛型再说吧

func StrF64

func StrF64(s string) float64

func StrI64

func StrI64(s string) int64

func StrTime

func StrTime(s string) time.Time

func StringSliceContains

func StringSliceContains(datas []string, s string) bool

func TimeAdd

func TimeAdd(t time.Time, d string) time.Time

func TimeStr

func TimeStr(t time.Time) string

func TimeToTimestamp

func TimeToTimestamp(t time.Time) int64

func TimestampToTime

func TimestampToTime(timestamp int64) time.Time

func UIntSliceContains

func UIntSliceContains(s []uint, data uint) bool

func UIntSliceIndexFirst

func UIntSliceIndexFirst(s []uint, data uint) int

func UIntSliceRemoveFirst

func UIntSliceRemoveFirst(s []uint, data uint) []uint

func WebsocketReadBytes

func WebsocketReadBytes(conn *websocket.Conn) (data []byte, err error)

func WebsocketReadString

func WebsocketReadString(conn *websocket.Conn) (data string, err error)

func WebsocketWriteBytes

func WebsocketWriteBytes(conn *websocket.Conn, data []byte) error

func WebsocketWriteString

func WebsocketWriteString(conn *websocket.Conn, data string) error

func WriteCSVLine

func WriteCSVLine(filename string, datas ...string) error

func WriteFile

func WriteFile(filename string, datas []byte)

func WriteJsonFile

func WriteJsonFile(filename string, obj interface{}) error

Types

type Int64Slice

type Int64Slice []int64

Int64原地排序 sort.Sort(Int64Slice(datas))

func (Int64Slice) Len

func (p Int64Slice) Len() int

func (Int64Slice) Less

func (p Int64Slice) Less(i, j int) bool

func (Int64Slice) Swap

func (p Int64Slice) Swap(i, j int)

Jump to

Keyboard shortcuts

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