Documentation ¶
Index ¶
- Constants
- Variables
- func BoolToString(b bool) string
- func ContextTODO() context.Context
- func Convert_RuneToString(r rune) string
- func Erroref(e error, formmat string, v ...any)
- func GO_ants(f func())
- func GetServiceName() string
- func Getenv(key string) string
- func GetenvBool(key string) bool
- func GetenvFloat32(key string) float32
- func GetenvFloat64(key string) float64
- func GetenvInt(key string) int
- func GetenvInt32(key string) int32
- func GetenvInt64(key string) int64
- func GetenvStringSplit(key string, split ...string) []string
- func GetenvUInt(key string) uint
- func GetenvUInt32(key string) uint32
- func GetenvUInt64(key string) uint64
- func Go(f func())
- func Init(opt ZserviceOption)
- func Int64ToByte(i int64) []byte
- func Int64ToString(i int64) string
- func IntToString(i int) string
- func IntToUint32(i int) uint32
- func IsInteger(s string) bool
- func IsNum(s string) bool
- func JsonMustMarshal(v any) []byte
- func JsonMustMarshalString(v any) string
- func JsonMustUnmarshal(v []byte) any
- func JsonMustUnmarshal_MapAny(v []byte) map[string]any
- func JsonMustUnmarshal_StringArray(v []byte) []string
- func ListFilter(arr any, fn func(item any) bool) any
- func ListFilterString(arr []string, fn func(item string) bool) []string
- func ListHas(arr interface{}, fn func(item any) bool) bool
- func ListRemoveDuplicates(arr interface{}) interface{}
- func ListRemoveFirst(arr interface{}, i int) interface{}
- func LogDebug(v ...any)
- func LogDebugCaller(caller int, v ...any)
- func LogDebugCallerf(caller int, format string, v ...any)
- func LogDebugf(format string, v ...any)
- func LogError(v ...any)
- func LogErrorCaller(caller int, v ...any)
- func LogErrorCallerf(caller int, format string, v ...any)
- func LogErrore(e error)
- func LogErrorf(format string, v ...any)
- func LogInfo(v ...any)
- func LogInfoCaller(caller int, v ...any)
- func LogInfoCallerf(caller int, format string, v ...any)
- func LogInfof(format string, v ...any)
- func LogPanic(v ...any)
- func LogPanicCaller(caller int, v ...any)
- func LogPanicCallerf(caller int, format string, v ...any)
- func LogPanicf(format string, v ...any)
- func LogWarn(v ...any)
- func LogWarnCaller(caller int, v ...any)
- func LogWarnCallerf(caller int, format string, v ...any)
- func LogWarnf(format string, v ...any)
- func MD5String(str string) string
- func MaxInt(nums ...int) int
- func MaxInt64(nums ...int64) int64
- func Md5Bytes(data []byte) string
- func MergeEnv(envs map[string]string)
- func MinInt(nums ...int) int
- func MinInt64(nums ...int64) int64
- func ProtobufMustMarshal(pb proto.Message) []byte
- func ProtobufMustUnmarshal(bt []byte, pb proto.Message)
- func RandomFloat32Range(min float32, max float32) float32
- func RandomFloat64Range(min float64, max float64) float64
- func RandomInt(count int) int
- func RandomInt64(count int64) int64
- func RandomInt64Range(min int64, max int64) int64
- func RandomIntRange(min int, max int) int
- func RandomMD5() string
- func RandomMD5_XID() string
- func RandomMD5_XID_Random() string
- func RandomString(count int) string
- func RandomStringLow(count int) string
- func RandomStringUP(count int) string
- func RandomString_AllCharset(count int) string
- func RandomUInt32Range(min uint32, max uint32) uint32
- func RandomUint32(count uint32) uint32
- func RandomXID() string
- func Setenv(key string, value string)
- func Sprint(v ...any) string
- func SprintQuote(v ...any) string
- func Stop()
- func StringSplit(s string, sep string, clearEmpty ...bool) []string
- func StringToBoolean(s string) bool
- func StringToFloat(str string) float32
- func StringToFloat32(str string) float32
- func StringToFloat64(str string) float64
- func StringToInt(str string) int
- func StringToInt32(str string) int32
- func StringToInt64(str string) int64
- func StringToUint(str string) uint
- func StringToUint32(str string) uint32
- func StringToUint64(str string) uint64
- func StructTo_MapAny(v any) map[string]any
- func TestAction(name string, cb func())
- func UInt64ToString(u uint64) string
- func Uint32ToInt(u uint32) int
- func Uint32ToString(u uint32) string
- func UintToString(u uint) string
- func WaitStop()
- type Context
- func (ctx *Context) Deadline() (deadline time.Time, ok bool)
- func (ctx *Context) Done() <-chan struct{}
- func (ctx *Context) Err() error
- func (ctx *Context) GetS2S() string
- func (ctx *Context) LogDebug(v ...any)
- func (ctx *Context) LogDebugf(f string, v ...any)
- func (ctx *Context) LogError(v ...any)
- func (ctx *Context) LogErrorf(f string, v ...any)
- func (ctx *Context) LogInfo(v ...any)
- func (ctx *Context) LogInfof(f string, v ...any)
- func (ctx *Context) LogPanic(v ...any)
- func (ctx *Context) LogPanicf(f string, v ...any)
- func (ctx *Context) LogWarn(v ...any)
- func (ctx *Context) LogWarnf(f string, v ...any)
- func (ctx *Context) Since() time.Duration
- func (ctx *Context) SinceTrace() time.Duration
- func (ctx *Context) Value(key any) any
- type ContextS2S
- type Error
- func GetIp() ([]string, *Error)
- func HttpGet(ctx *Context, url string, params map[string]any, header map[string]string) ([]byte, *Error)
- func HttpPost(ctx *Context, url string, params map[string]any, header map[string]string) (body []byte, e *Error)
- func HttpPostJson(ctx *Context, url string, params map[string]any, header map[string]string) (body []byte, e *Error)
- func HttpRequestSend(ctx *Context, in *http.Request) ([]byte, *Error)
- func LoadFileEnv(envFile string) *Error
- func LoadStringEnv(envStr string) *Error
- func Md5File(path string) (string, *Error)
- func NewError(v ...any) *Error
- func NewErrorCaller(skip int, str string, e error) *Error
- func NewErrore(e error) *Error
- func NewErroref(e error, f string, v ...any) *Error
- func NewErrorf(f string, v ...any) *Error
- func StructDeepcopy(a any, b any) *Error
- func WriteFileToTempDir(name string, data []byte) *Error
- type Time
- func (ex Time) Add(d time.Duration) Time
- func (ex Time) AddDate(years int, months int, days int) Time
- func (ex Time) After(u time.Time) bool
- func (ex Time) AfterNow() bool
- func (ex Time) Before(u time.Time) bool
- func (ex Time) BeforeNow() bool
- func (ex Time) Clock() (h, m, s int)
- func (ex Time) Compare(u time.Time) int
- func (ex Time) Date() (year int, month time.Month, day int)
- func (ex Time) Day() int
- func (ex Time) Equal(u time.Time) bool
- func (ex Time) GobDecode(data []byte) error
- func (ex Time) GobEncode() ([]byte, error)
- func (ex Time) Hour() int
- func (ex Time) ISOWeek() (year int, week int)
- func (ex Time) In(loc *time.Location) Time
- func (ex Time) IsDST() bool
- func (ex Time) IsZero() bool
- func (ex Time) Local() Time
- func (ex Time) Location() *time.Location
- func (ex Time) MarshalBinary() ([]byte, error)
- func (ex Time) MarshalJSON() ([]byte, error)
- func (ex Time) MarshalText() ([]byte, error)
- func (ex Time) Minute() int
- func (ex Time) Month() time.Month
- func (ex Time) Nanosecond() int
- func (ex Time) Round(d time.Duration) Time
- func (ex *Time) Scan(value any) error
- func (ex Time) Second() int
- func (ex Time) Sub(u time.Time) time.Duration
- func (ex Time) Truncate(d time.Duration) Time
- func (ex Time) UTC() Time
- func (ex Time) Unix() int64
- func (ex Time) UnixMicro() int64
- func (ex Time) UnixMilli() int64
- func (ex Time) UnixNano() int64
- func (ex Time) UnmarshalBinary(data []byte) error
- func (ex Time) UnmarshalJSON(data []byte) error
- func (ex Time) UnmarshalText(data []byte) error
- func (ex Time) Value() (driver.Value, error)
- func (ex Time) Weekday() time.Weekday
- func (ex Time) Year() int
- func (ex Time) YearDay() int
- func (ex Time) Zone() (name string, offset int)
- func (ex Time) ZoneBounds() (start, end time.Time)
- type Vector3
- type ZService
- func (z *ZService) AddDependService(sArr ...*ZService) *ZService
- func (z *ZService) GetState() uint32
- func (z *ZService) LogDebug(v ...any)
- func (z *ZService) LogDebugCaller(caller int, v ...any)
- func (z *ZService) LogDebugf(f string, v ...any)
- func (z *ZService) LogError(v ...any)
- func (z *ZService) LogErrorCaller(caller int, v ...any)
- func (z *ZService) LogErrorf(f string, v ...any)
- func (z *ZService) LogInfo(v ...any)
- func (z *ZService) LogInfoCaller(caller int, v ...any)
- func (z *ZService) LogInfof(f string, v ...any)
- func (z *ZService) LogPanic(v ...any)
- func (z *ZService) LogPanicCaller(caller int, v ...any)
- func (z *ZService) LogPanicf(f string, v ...any)
- func (z *ZService) LogWarn(v ...any)
- func (z *ZService) LogWarnCaller(caller int, v ...any)
- func (z *ZService) LogWarnf(f string, v ...any)
- func (z *ZService) Start() *ZService
- func (z *ZService) StartDone()
- func (z *ZService) Stop() error
- func (z *ZService) WaitStart() *ZService
- func (z *ZService) WaitStop()
- type ZserviceOption
Constants ¶
View Source
const ( Code_Zero = 0 // 如果出现 0 表示业务未处理状态码 Code_Succ = 1 // 成功 Code_Fail = 2 // 失败 Code_Limit = 3 // 限制/上限 Code_Auth = 4 // 鉴权失败/无权 Code_NotImplement = 5 // 未实现 Code_Params = 6 // 参数错误 Code_NotFound = 7 // 资源不存在/没找到/数据未查询到 Code_Again = 8 // 等待,重试 Code_Repetition = 9 // 数据重复, 数据已存在,数据相同 Code_Reject = 10 // 拒绝 Code_Fatal = 11 // 代码执行阻断执行错误,严重错误,服务断开 )
内置状态码
View Source
const ( S_S2S_CTX = "Z-S2S-CTX" // 服务端 链路传输的 Context S_C2S_Token = "Z-C2S-TK" // 客户端 token S_C2S_Time = "Z-C2S-TI" // 客户端 时间戳 S_C2S_Sign = "Z-C2S-SI" // 客户端 签名 )
View Source
const ( Time_1m = time.Minute // 1 分钟 Time_10Day = time.Hour * 24 * 10 // 10 天 )
Variables ¶
View Source
var ISDebug = false
View Source
var Version = "0.2.1"
Functions ¶
func ContextTODO ¶
func GetenvBool ¶
func GetenvFloat32 ¶ added in v0.1.7
func GetenvFloat64 ¶ added in v0.1.7
func GetenvInt32 ¶ added in v0.1.7
func GetenvInt64 ¶ added in v0.1.7
func GetenvUInt ¶ added in v0.1.8
func GetenvUInt32 ¶
func GetenvUInt64 ¶ added in v0.1.7
func Int64ToByte ¶
func JsonMustMarshal ¶
func JsonMustMarshalString ¶
func JsonMustUnmarshal ¶
func LogDebugCaller ¶
func LogDebugCallerf ¶
func LogErrorCaller ¶
func LogErrorCallerf ¶
func LogInfoCaller ¶
func LogInfoCallerf ¶
func LogPanicCaller ¶
func LogPanicCallerf ¶
func LogWarnCaller ¶
func LogWarnCallerf ¶
func ProtobufMustMarshal ¶ added in v0.1.7
func ProtobufMustUnmarshal ¶ added in v0.1.7
func RandomMD5_XID_Random ¶ added in v0.1.10
func RandomMD5_XID_Random() string
md5 xid + random string
func RandomString_AllCharset ¶ added in v0.1.10
func StructTo_MapAny ¶
func TestAction ¶
func TestAction(name string, cb func())
Types ¶
type Context ¶
type Context struct { ContextS2S StartTime time.Time // 当前上下文启动时间 Service *ZService // 服务 GinCtx *gin.Context CTX_mu sync.Mutex CTX_done atomic.Value CTX_err error CTX_values sync.Map }
集成链路、日志、错误功能
type ContextS2S ¶
type ContextS2S struct { TraceTime time.Time `json:"tt,omitempty"` // 链路初始化时间 TraceID string `json:"ti,omitempty"` // 链路ID TraceSpanID int `json:"tsi,omitempty"` // 链路 , 自增处理 TraceService string `json:"ts,omitempty"` // 链路服务, 之前的服务 RequestIP string `json:"ip,omitempty"` // 请求IP NowService string `json:"ns,omitempty"` // 当前服务 AuthToken string `json:"at,omitempty"` // token AuthTokenSign string `json:"ats,omitempty"` // 授权的签名 ClientSign string `json:"cs,omitempty"` // 客户端签名 ClientTime uint32 `json:"ct,omitempty"` // 客户端签名的时间 }
上下文内部交互信息
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
------------- Error -------------
func HttpGet ¶
func HttpGet(ctx *Context, url string, params map[string]any, header map[string]string) ([]byte, *Error)
发送 HttpGet 请求
func HttpPost ¶
func HttpPost(ctx *Context, url string, params map[string]any, header map[string]string) (body []byte, e *Error)
发送 post 请求
func HttpPostJson ¶
func HttpPostJson(ctx *Context, url string, params map[string]any, header map[string]string) (body []byte, e *Error)
发送 json 请求
func WriteFileToTempDir ¶ added in v0.1.2
写入文件到临时目录
type Time ¶
扩展 time 包
func TimeUnixMicro ¶
func TimeUnixMilli ¶
func (Time) MarshalBinary ¶
func (Time) MarshalJSON ¶
func (Time) MarshalText ¶
func (Time) Nanosecond ¶
func (Time) UnmarshalBinary ¶
func (Time) UnmarshalJSON ¶
func (Time) UnmarshalText ¶
func (Time) ZoneBounds ¶
type ZService ¶
type ZService struct {
// contains filtered or unexported fields
}
func (*ZService) AddDependService ¶
添加依赖
func (*ZService) LogDebugCaller ¶ added in v0.2.0
func (*ZService) LogErrorCaller ¶
func (*ZService) LogInfoCaller ¶
func (*ZService) LogPanicCaller ¶
func (*ZService) LogWarnCaller ¶
Source Files ¶
- const.Code.go
- const.String.go
- const.time.go
- fn.boolean.go
- fn.env.go
- fn.http.go
- fn.is.go
- fn.json.go
- fn.list.go
- fn.logger.go
- fn.math.go
- fn.md5.go
- fn.net.go
- fn.number.go
- fn.os.go
- fn.protobuf.go
- fn.random.go
- fn.string.go
- fn.struct.go
- fn.test.go
- type.Context.go
- type.Error.go
- type.Time.go
- type.Vector3.go
- type.Zservice.go
- type.ZserviceOption.go
- zservice.go
Click to show internal directories.
Click to hide internal directories.