Documentation
¶
Overview ¶
数据转换
Index ¶
- Constants
- Variables
- func AddStatus(status *Status)
- func AddStatusText(lang string, code int32, text string)
- func AppendPrivateBlocks(bs ...string)
- func BoolElem() reflect.Value
- func BoolSliceElem() reflect.Value
- func Cause(err error) error
- func Certificate(host ...string) (tls.Certificate, error)
- func DeepCopy(dst, src interface{}) error
- func Elem(v reflect.Type) reflect.Value
- func Extract(addr string) (string, error)
- func Float32Elem() reflect.Value
- func Float32SliceElem() reflect.Value
- func Float64Elem() reflect.Value
- func Float64SliceElem() reflect.Value
- func GenTK(account string) string
- func GetText(lang string, code int32) string
- func HostPort(addr string, port interface{}) string
- func IPs() []string
- func Int32Elem() reflect.Value
- func Int32MapElem(v reflect.Type) reflect.Value
- func Int32SliceElem() reflect.Value
- func Int64Elem() reflect.Value
- func Int64MapElem(v reflect.Type) reflect.Value
- func Int64SliceElem() reflect.Value
- func IntElem() reflect.Value
- func IntMapElem(v reflect.Type) reflect.Value
- func IntSliceElem() reflect.Value
- func Is(a, b error) bool
- func IsCode(err error, code int32) bool
- func IsLocal(addr string) bool
- func IsStack() bool
- func Listen(addr string, fn func(string) (net.Listener, error)) (net.Listener, error)
- func MapElem(k, v reflect.Type) reflect.Value
- func ParseBool(v interface{}) bool
- func ParseFloat32(v interface{}) float32
- func ParseFloat64(v interface{}) float64
- func ParseInt(v interface{}) int
- func ParseInt32(v interface{}) int32
- func ParseInt64(v interface{}) int64
- func ParseSlice(v interface{}) []interface{}
- func ParseStr(v interface{}) string
- func ParseStrSlice(v []interface{}) []string
- func ParseTK(token string) (string, error)
- func ParseUint(v interface{}) uint
- func ParseUint32(v interface{}) uint32
- func ParseUint64(v interface{}) uint64
- func Proxy(service string, address []string) (string, []string, bool)
- func Ptr(v reflect.Type) reflect.Value
- func SetDefaultLang(lang string)
- func SliceElem(v reflect.Type) reflect.Value
- func SliceTwoElem(v reflect.Type) reflect.Value
- func StatusText(code int32) string
- func StrElem() reflect.Value
- func StrMapElem(v reflect.Type) reflect.Value
- func StrSliceElem() reflect.Value
- func StructToDict(data interface{}) map[string]interface{}
- func ToDict(data interface{}) map[string]interface{}
- func ToJson(data interface{}) []byte
- func ToStruct(data interface{}, obj interface{}) error
- func Wrap(err error, args ...interface{}) error
- type Buffer
- type Entry
- type Error
- func Exists(args ...interface{}) *Error
- func Finished(args ...interface{}) *Error
- func Forbidden(args ...interface{}) *Error
- func Invalid(args ...interface{}) *Error
- func New(code int32, a ...interface{}) *Error
- func NotFound(args ...interface{}) *Error
- func Other(args ...interface{}) *Error
- func Parse(err error) *Error
- func Server(args ...interface{}) *Error
- func Started(args ...interface{}) *Error
- func Timeout(args ...interface{}) *Error
- func Unauthorized(args ...interface{}) *Error
- func Unavailable(args ...interface{}) *Error
- func Universal(args ...interface{}) *Error
- func Unknown(args ...interface{}) *Error
- type Frame
- type StackTrace
- type Status
- type Stream
Constants ¶
const ( CodeOk int32 = 0 CodeUniversal = 1 CodeUnknown = 2 CodeInvalid = 3 CodeExists = 4 CodeStarted = 90 CodeFinished = 91 CodeOther = 99 // HTTP Status Code (100 ~ 600) CodeForbidden = 403 CodeNotFound = 404 CodeTimeout = 408 CodeServerError = 500 ErrNewPlayer // 创建玩家失败 ErrTokenEmpty // token is empty ErrTokenDecrypt // token decrypt failed ErrTokenFormat // token format is invalid ErrTokenExpired // token expired UnknownError // 未知错误 ErrParam // 参数错误 ErrParamNil // 请求参数为空 ErrParse // 解析失败 ErrDB // 数据库操作失败 ErrRedis // 缓存操作失败 ErrConnect // 连接失败 )
Game System Error Code (1 ~ 99)
const ( MyTimeInterval = 60 * 10 MyTimeExpired = 60 * 60 * 24 )
Variables ¶
var ( RefTypeStr = reflect.TypeOf("") RefTypeInt = reflect.TypeOf(0) RefTypeInt32 = reflect.TypeOf(int32(0)) RefTypeInt64 = reflect.TypeOf(int64(0)) RefTypeFloat32 = reflect.TypeOf(float32(0)) RefTypeFloat64 = reflect.TypeOf(float64(0)) RefTypeBool = reflect.TypeOf(false) )
var ( Lang = map[string]*Status{ "en-us": NewStatus("en-us"), "zh-cn": NewStatus("zh-cn"), } )
Functions ¶
func AddStatusText ¶
AddStatusText 注册语言环境信息
func AppendPrivateBlocks ¶
func AppendPrivateBlocks(bs ...string)
AppendPrivateBlocks append private network blocks
func BoolSliceElem ¶
func Cause ¶
Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:
type causer interface { Cause() error }
If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.
func Certificate ¶
func Certificate(host ...string) (tls.Certificate, error)
func Float32Elem ¶
func Float32SliceElem ¶
func Float64Elem ¶
func Float64SliceElem ¶
func Int32SliceElem ¶
func Int64SliceElem ¶
func IntSliceElem ¶
func Listen ¶
Listen takes addr:portmin-portmax and binds to the first available port Example: Listen("localhost:5000-6000", fn)
func ParseFloat32 ¶
func ParseFloat32(v interface{}) float32
ParseFloat32 convert interface to float32.
func ParseFloat64 ¶
func ParseFloat64(v interface{}) float64
ParseFloat64 convert interface to float64.
func ParseSlice ¶
func ParseSlice(v interface{}) []interface{}
func ParseStrSlice ¶
func ParseStrSlice(v []interface{}) []string
ParseStrSlice convert []interface to []string
func SliceTwoElem ¶
反射创建切片 (以 .Addr.Interface() 获取指针数据)
func StrSliceElem ¶
func StructToDict ¶
func StructToDict(data interface{}) map[string]interface{}
StructToDict 结构体转字典 (不支持嵌套)
Types ¶
type Error ¶
type Error struct { Code int32 `json:"code"` Status string `json:"status"` Detail string `json:"detail"` // contains filtered or unexported fields }
func New ¶
New returns an error with the supplied proto. New also records the stack trace at the point it was called.
func (Error) StackTrace ¶
func (s Error) StackTrace() StackTrace
type Frame ¶
type Frame uintptr
Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.
func (Frame) Format ¶
Format formats the frame according to the fmt.Formatter interface.
%s source file %d source line %n function name %v equivalent to %s:%d
Format accepts flags.go that alter the printing of some verbs, as follows:
%+s function name and path of source file relative to the compile time GOPATH separated by \n\t (<funcname>\n\t<path>) %+v equivalent to %+s:%d
func (Frame) MarshalText ¶
MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.
type StackTrace ¶
type StackTrace []Frame
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
func (StackTrace) Format ¶
func (st StackTrace) Format(s fmt.State, verb rune)
Format formats the stack of Frames according to the fmt.Formatter interface.
%s lists source files for each Frame in the stack %v lists the source file and line number for each Frame in the stack
Format accepts flags.go that alter the printing of some verbs, as follows:
%+v Prints filename, function, and line number for each Frame in the stack.