Documentation ¶
Index ¶
- Constants
- Variables
- func NewReturn(kumayErr error, data string) ([]byte, error)
- type Counter
- type Err
- type MapFetcher
- func (mf *MapFetcher) Add(key string, value interface{})
- func (mf *MapFetcher) ClearErr()
- func (mf *MapFetcher) CopyMap(from *MapFetcher)
- func (mf *MapFetcher) Err() error
- func (mf *MapFetcher) Fetch(key string) interface{}
- func (mf *MapFetcher) FetchBool(key string) bool
- func (mf *MapFetcher) FetchFloat(key string) float64
- func (mf *MapFetcher) FetchInt(key string) int
- func (mf *MapFetcher) FetchString(key string) string
- func (mf *MapFetcher) FetchTime(key string) time.Time
- func (mf *MapFetcher) FetchTimeFromString(key, location string) time.Time
- func (mf *MapFetcher) GetMap() map[string]interface{}
- func (mf *MapFetcher) Len() int
- func (mf *MapFetcher) Remove(key string)
- type ReturnForm
Constants ¶
const ( ZeroInt = 0 ZeroFloat64 = 0 ZeroString = "" ZeroBool = false )
const ( // ExternalOK means the code from external server status code. ExternalOK = 1 // ReturnSuccess = 0 ReturnSuccess = -1 + iota // ReturnExternalServerError map to external server error code 1 ReturnExternalServerError // ReturnParamsError map to external server error code 2 ReturnParamsError // ReturnJSONError map to external server error code 3 ReturnJSONError // ReturnAlreadyLogin map to external server error code 4 ReturnAlreadyLogin // ReturnAccountOrPasswordError map to external server error code 5 ReturnAccountOrPasswordError // ReturnSessionError map to external server error code 6 ReturnSessionError // ReturnPasswordNotMatched map to external server error code 7 ReturnPasswordNotMatched // ReturnAccountNotExist map to external server error code 8 ReturnAccountNotExist // ReturnServerError is 503 server internal error. code 9 ReturnServerError ReturnUnauthorized )
Variables ¶
var ( // ErrMapFetcherKeyNotExist means the input key is not exist. ErrMapFetcherKeyNotExist = errors.New("map fetcher: key not exist") // ErrMapFetcherFaildAssertionTimeType means the time.Time type assertion faild. ErrMapFetcherFaildAssertionTimeType = errors.New("time.Time type assertion failed") // ErrMapFetcherFaildAssertionFloatType means the float64 type assertion faild. ErrMapFetcherFaildAssertionFloatType = errors.New("float64 type assertion failed") // ErrMapFetcherFaildAssertionStringType means the string type assertion faild. ErrMapFetcherFaildAssertionStringType = errors.New("string type assertion failed") // ErrMapFetcherFaildAssertionIntType means the int type assertion faild. ErrMapFetcherFaildAssertionIntType = errors.New("int type assertion failed") // ErrMapFetcherFaildAssertionBoolType means the bool type assertion faild. ErrMapFetcherFaildAssertionBoolType = errors.New("bool type assertion failed") )
Functions ¶
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a counting usage struct and provides functions to help couting.
func NewCounter ¶
NewCounter returns a Counter instance and the input num is the init number of the counter.
type MapFetcher ¶
type MapFetcher struct {
// contains filtered or unexported fields
}
MapFetcher is the wrapper for map[string]interface{}, and provides actions for easy usage of map actions.
func NewMapfetcher ¶
func NewMapfetcher(data map[string]interface{}) *MapFetcher
NewMapfetcher returns MapFetcher instance.
func (*MapFetcher) Add ¶
func (mf *MapFetcher) Add(key string, value interface{})
Add adds key value into map.
func (*MapFetcher) CopyMap ¶
func (mf *MapFetcher) CopyMap(from *MapFetcher)
CopyMap copies a MapFetcher's data map into self data map.
func (*MapFetcher) Err ¶
func (mf *MapFetcher) Err() error
Err returns MapFetcher holds err, it is using this article's thoughts: https://blog.golang.org/errors-are-values
func (*MapFetcher) Fetch ¶
func (mf *MapFetcher) Fetch(key string) interface{}
Fetch returns interface{} in the holding map by input key.
func (*MapFetcher) FetchBool ¶
func (mf *MapFetcher) FetchBool(key string) bool
FetchBool converts specific key value into boolean then returns.
func (*MapFetcher) FetchFloat ¶
func (mf *MapFetcher) FetchFloat(key string) float64
FetchFloat converts specific key value into float64 then returns.
func (*MapFetcher) FetchInt ¶
func (mf *MapFetcher) FetchInt(key string) int
FetchInt converts specific key value into int then returns.
func (*MapFetcher) FetchString ¶
func (mf *MapFetcher) FetchString(key string) string
FetchString converts specific key value into string then returns.
func (*MapFetcher) FetchTime ¶
func (mf *MapFetcher) FetchTime(key string) time.Time
FetchTime converts specific key value into time.Time then returns.
func (*MapFetcher) FetchTimeFromString ¶
func (mf *MapFetcher) FetchTimeFromString(key, location string) time.Time
FetchTimeFromString converts specific key value from string time into time.Time then returns.
func (*MapFetcher) GetMap ¶
func (mf *MapFetcher) GetMap() map[string]interface{}
GetMap returns whole map.
type ReturnForm ¶
ReturnForm is the kumay all server output form.