Documentation
¶
Index ¶
- Constants
- Variables
- func AToTime(t string) time.Time
- func AddTask()
- func AtoF64(d string) float64
- func AtoI(d string) int
- func AtoI64(d string) int64
- func BtoI(b bool) int
- func CheckFilePathUpward(fileName string) (string, bool)
- func CheckFilePathUpwardFrom(fileName, basePath string) (string, bool)
- func DateToA(t time.Time) string
- func Debug(args ...any)
- func Debugf(format string, args ...any)
- func Decimal(val float64, pre int) float64
- func DirExists(name string) bool
- func DirNotExists(name string) bool
- func Error(args ...any)
- func Errorf(format string, args ...any)
- func F64toA(d int64) string
- func Fatal(args ...any)
- func Fatalf(format string, args ...any)
- func FileExists(name string) bool
- func FileNotExists(name string) bool
- func GetLocalIpByRemoteTcp(remoteHost string, remotePort uint64, timeOut time.Duration) (net.IP, error)
- func GetProcessName() string
- func GetUUIDString(id UUID) string
- func HttpClientSendReq(method string, urlPath string, params url.Values, data []byte, ...) ([]byte, error)
- func HttpGet(urlPath string, params url.Values, timeOut time.Duration) ([]byte, error)
- func HttpPostObject(urlPath string, params url.Values, obj any, timeOut time.Duration) ([]byte, error)
- func Info(args ...any)
- func Infof(format string, args ...any)
- func InitLogger(cfg *LogConfig) error
- func InitLoggerByPath(logFilePath string) error
- func IsNilObject(obj any) bool
- func IsNotNilObject(obj any) bool
- func Json2Str(obj any) string
- func LoadJsonObjectFromFile(obj any, filePath string) error
- func LogSync() error
- func MkdirForFile(filePath string) error
- func NewUUIDString() string
- func OpenExclusiveFile(filePath string) (*os.File, error)
- func OpenFileForAppend(filePath string) (*os.File, error)
- func OpenFileForRead(filePath string) (*os.File, error)
- func OpenFileForWrite(filePath string) (*os.File, error)
- func ParseAddr(addr string) (host string, port int, err error)
- func RegLoggerProvider(provider LoggerProvider)
- func ResetSnowNode(node int64)
- func SaveJsonObjectToFile(obj any, filePath string) error
- func SetRunMode(mode RunMode)
- func SplitFilePath(txt string) (dir, name, ext string)
- func Str2Json(data string, obj any) (ok bool)
- func SumMd5Data(data []byte) string
- func SumMd5String(str string) string
- func TaskDone()
- func TimeMsToA(t time.Time) string
- func TimeToA(t time.Time) string
- func UUIDEquals(u1, u2 UUID) bool
- func WaitForAllTasksDone()
- func Warn(args ...any)
- func Warnf(format string, args ...any)
- func WriteFile(filePath string, data []byte) error
- type AppCmd
- type AppCmdHandler
- type AppFlagBase
- type AppFlagBool
- type AppFlagCmdBase
- type AppFlagFloat64
- type AppFlagInt
- type AppFlagInt64
- type AppFlagMgr
- type AppFlagString
- type AppFlagUint
- type EmptyStruct
- type IAppFlag
- type IAppFlagBool
- type IAppFlagFloat64
- type IAppFlagInt
- type IAppFlagInt64
- type IAppFlagString
- type IAppFlagUint
- type IFixDefaultValue
- type ILocker
- type IQueue
- type IRWLocker
- type IRunnable
- type ITcpAcceptor
- type InterfaceStructure
- type JoAppStatus
- type JoLogger
- type LinkList
- func (l *LinkList[T]) Back() *ListNode[T]
- func (l *LinkList[T]) Front() *ListNode[T]
- func (l *LinkList[T]) Init() *LinkList[T]
- func (l *LinkList[T]) InsertAfter(v T, mark *ListNode[T]) *ListNode[T]
- func (l *LinkList[T]) InsertBefore(v T, mark *ListNode[T]) *ListNode[T]
- func (l *LinkList[T]) Len() int
- func (l *LinkList[T]) MoveAfter(n, mark *ListNode[T])
- func (l *LinkList[T]) MoveBefore(n, mark *ListNode[T])
- func (l *LinkList[T]) MoveToBack(n *ListNode[T])
- func (l *LinkList[T]) MoveToFront(n *ListNode[T])
- func (l *LinkList[T]) PushBack(v T) *ListNode[T]
- func (l *LinkList[T]) PushBackList(lst *LinkList[T])
- func (l *LinkList[T]) PushBackSlice(s []T)
- func (l *LinkList[T]) PushFront(v T) *ListNode[T]
- func (l *LinkList[T]) PushFrontList(lst *LinkList[T])
- func (l *LinkList[T]) Remove(n *ListNode[T]) T
- func (l *LinkList[T]) ToSlice() []T
- type ListNode
- type Locker
- type LogConfig
- type LogLevel
- type LoggerProvider
- type NoneLocker
- type NoneLogger
- func (l *NoneLogger) Debug(...any)
- func (l *NoneLogger) Debugf(string, ...any)
- func (l *NoneLogger) Error(...any)
- func (l *NoneLogger) Errorf(string, ...any)
- func (l *NoneLogger) Fatal(...any)
- func (l *NoneLogger) Fatalf(format string, args ...any)
- func (l *NoneLogger) Info(...any)
- func (l *NoneLogger) Infof(string, ...any)
- func (l *NoneLogger) Sync() error
- func (l *NoneLogger) Warn(...any)
- func (l *NoneLogger) Warnf(string, ...any)
- type NoneRWLocker
- type Queue
- type RWLocker
- type RunMode
- type Set
- type SnowID
- type StdLogger
- func (l *StdLogger) Debug(args ...any)
- func (l *StdLogger) Debugf(format string, args ...any)
- func (l *StdLogger) Error(args ...any)
- func (l *StdLogger) Errorf(format string, args ...any)
- func (l *StdLogger) Fatal(args ...any)
- func (l *StdLogger) Fatalf(format string, args ...any)
- func (l *StdLogger) Info(args ...any)
- func (l *StdLogger) Infof(format string, args ...any)
- func (l *StdLogger) Sync() error
- func (l *StdLogger) Warn(args ...any)
- func (l *StdLogger) Warnf(format string, args ...any)
- type TcpAcceptor
- type TcpServer
- type UUID
- type UdpServer
Constants ¶
View Source
const ( FilePermNone = 0000 FilePermUserExOnly = FilePermNone + 0100 FilePermUserWrOnly = FilePermNone + 0200 FilePermUserRdOnly = FilePermNone + 0400 FilePermUserRdWr = FilePermUserRdOnly | FilePermUserWrOnly FilePermUserAll = FilePermUserExOnly | FilePermUserRdWr FilePermGroupExOnly = FilePermNone + 0010 FilePermGroupWrOnly = FilePermNone + 0020 FilePermGroupRdOnly = FilePermNone + 0040 FilePermGroupRdWr = FilePermGroupRdOnly | FilePermGroupWrOnly FilePermGroupAll = FilePermGroupExOnly | FilePermGroupRdWr FilePermOtherExOnly = FilePermNone + 0001 FilePermOtherWrOnly = FilePermNone + 0002 FilePermOtherRdOnly = FilePermNone + 0004 FilePermOtherRdWr = FilePermOtherRdOnly | FilePermOtherWrOnly FilePermOtherAll = FilePermOtherExOnly | FilePermOtherRdWr FilePermOsDef = FilePermUserRdWr | FilePermGroupRdWr | FilePermOtherRdOnly FilePermAll = FilePermUserAll | FilePermGroupAll | FilePermOtherAll )
View Source
const ( LogLevelStrDebug = "DEBUG" LogLevelStrInfo = "INFO" LogLevelStrWarn = "WARN" LogLevelStrError = "ERROR" LogLevelStrFatal = "FATAL" LogLevelStrUnknown = "UNKNOWN" )
View Source
const ( DefTimeFormatMs = "2006-01-02 15:04:05.000" DefTimeFormat = "2006-01-02 15:04:05" DefDateFormat = "2006-01-02" )
Variables ¶
View Source
var ZeroTime time.Time
Functions ¶
func CheckFilePathUpward ¶
func CheckFilePathUpwardFrom ¶
func DirNotExists ¶
func FileExists ¶
func FileNotExists ¶
func GetLocalIpByRemoteTcp ¶
func GetProcessName ¶
func GetProcessName() string
func GetUUIDString ¶
func HttpClientSendReq ¶
func HttpPostObject ¶
func InitLogger ¶
func InitLoggerByPath ¶
func IsNilObject ¶
func IsNotNilObject ¶
func LoadJsonObjectFromFile ¶
func MkdirForFile ¶
func NewUUIDString ¶
func NewUUIDString() string
func RegLoggerProvider ¶
func RegLoggerProvider(provider LoggerProvider)
func ResetSnowNode ¶
func ResetSnowNode(node int64)
func SaveJsonObjectToFile ¶
func SetRunMode ¶
func SetRunMode(mode RunMode)
func SplitFilePath ¶
func SumMd5Data ¶
func SumMd5String ¶
func UUIDEquals ¶
func WaitForAllTasksDone ¶
func WaitForAllTasksDone()
Types ¶
type AppCmd ¶
type AppCmd struct {
AppFlagCmdBase
// contains filtered or unexported fields
}
func NewAppCmd ¶
func NewAppCmd(handler AppCmdHandler, name, usage string) *AppCmd
func (*AppCmd) GetHandler ¶
func (cmd *AppCmd) GetHandler() AppCmdHandler
type AppCmdHandler ¶
type AppCmdHandler func()
type AppFlagBase ¶
type AppFlagBase struct {
AppFlagCmdBase
// contains filtered or unexported fields
}
func (*AppFlagBase) Exist ¶
func (af *AppFlagBase) Exist() bool
func (*AppFlagBase) GetLongName ¶
func (af *AppFlagBase) GetLongName() string
func (*AppFlagBase) GetShortName ¶
func (af *AppFlagBase) GetShortName() string
func (*AppFlagBase) Init ¶
func (af *AppFlagBase) Init(shortName, longName, usage string)
type AppFlagBool ¶
type AppFlagBool struct {
AppFlagBase
}
func NewAppFlagBool ¶
func NewAppFlagBool(shortName, longName, usage string) *AppFlagBool
func (*AppFlagBool) GetBool ¶
func (af *AppFlagBool) GetBool() bool
type AppFlagCmdBase ¶
type AppFlagCmdBase struct {
// contains filtered or unexported fields
}
func (*AppFlagCmdBase) GetName ¶
func (af *AppFlagCmdBase) GetName() string
func (*AppFlagCmdBase) GetUsage ¶
func (af *AppFlagCmdBase) GetUsage() string
func (*AppFlagCmdBase) Init ¶
func (af *AppFlagCmdBase) Init(name, usage string)
type AppFlagFloat64 ¶
type AppFlagFloat64 struct {
AppFlagBase
// contains filtered or unexported fields
}
func NewAppFlagFloat64 ¶
func NewAppFlagFloat64(shortName, longName, usage string, defVal float64) *AppFlagFloat64
func (*AppFlagFloat64) GetFloat64 ¶
func (af *AppFlagFloat64) GetFloat64() float64
type AppFlagInt ¶
type AppFlagInt struct {
AppFlagBase
// contains filtered or unexported fields
}
func NewAppFlagInt ¶
func NewAppFlagInt(shortName, longName, usage string, defVal int) *AppFlagInt
func (*AppFlagInt) GetInt ¶
func (af *AppFlagInt) GetInt() int
type AppFlagInt64 ¶
type AppFlagInt64 struct {
AppFlagBase
// contains filtered or unexported fields
}
func NewAppFlagInt64 ¶
func NewAppFlagInt64(shortName, longName, usage string, defVal int64) *AppFlagInt64
func (*AppFlagInt64) GetInt64 ¶
func (af *AppFlagInt64) GetInt64() int64
type AppFlagMgr ¶
type AppFlagMgr struct {
// contains filtered or unexported fields
}
func NewAppFlagMgr ¶
func NewAppFlagMgr() *AppFlagMgr
func (*AppFlagMgr) RegisterCmd ¶
func (mgr *AppFlagMgr) RegisterCmd(cmd *AppCmd)
func (*AppFlagMgr) RegisterMainCmd ¶
func (mgr *AppFlagMgr) RegisterMainCmd(handler AppCmdHandler)
type AppFlagString ¶
type AppFlagString struct {
AppFlagBase
// contains filtered or unexported fields
}
func NewAppFlagString ¶
func NewAppFlagString(shortName, longName, usage string, defVal string) *AppFlagString
func (*AppFlagString) GetString ¶
func (af *AppFlagString) GetString() string
type AppFlagUint ¶
type AppFlagUint struct {
AppFlagBase
// contains filtered or unexported fields
}
func NewAppFlagUint ¶
func NewAppFlagUint(shortName, longName, usage string, defVal uint) *AppFlagUint
func (*AppFlagUint) GetUint ¶
func (af *AppFlagUint) GetUint() uint
type EmptyStruct ¶
type EmptyStruct struct {
}
type IAppFlagBool ¶
type IAppFlagFloat64 ¶
type IAppFlagInt ¶
type IAppFlagInt64 ¶
type IAppFlagString ¶
type IAppFlagUint ¶
type IFixDefaultValue ¶
type IFixDefaultValue interface {
FixDefaultValue() error
}
type ITcpAcceptor ¶
type InterfaceStructure ¶
func AsInterfaceStructure ¶
func AsInterfaceStructure(obj any) InterfaceStructure
type JoAppStatus ¶
type JoAppStatus int
const ( JoAppStatusNone JoAppStatus = iota JoAppStatusFlagsParsed )
func (JoAppStatus) String ¶
func (st JoAppStatus) String() string
type JoLogger ¶
type JoLogger interface {
Debug(args ...any)
Info(args ...any)
Warn(args ...any)
Error(args ...any)
Fatal(args ...any)
Debugf(format string, args ...any)
Infof(format string, args ...any)
Warnf(format string, args ...any)
Errorf(format string, args ...any)
Fatalf(format string, args ...any)
Sync() error
}
type LinkList ¶
type LinkList[T any] struct { // contains filtered or unexported fields }
func NewLinkList ¶ added in v0.8.5
func (*LinkList[T]) InsertAfter ¶ added in v0.8.5
func (*LinkList[T]) InsertBefore ¶ added in v0.8.5
func (*LinkList[T]) MoveBefore ¶ added in v0.8.5
func (*LinkList[T]) MoveToBack ¶ added in v0.8.5
func (*LinkList[T]) MoveToFront ¶ added in v0.8.5
func (*LinkList[T]) PushBackList ¶ added in v0.8.5
func (*LinkList[T]) PushBackSlice ¶ added in v0.8.5
func (l *LinkList[T]) PushBackSlice(s []T)
func (*LinkList[T]) PushFrontList ¶ added in v0.8.5
type ListNode ¶
type ListNode[T any] struct { // contains filtered or unexported fields }
func NewListNode ¶ added in v0.8.5
type LogConfig ¶
type LogConfig struct {
Level string `json:"level"` // 输出的最低日志等级, DEBUG < INFO < WARN < ERROR < FATAL
FileName string `json:"fileName"` // 输出日志文件名
MaxSize int `json:"maxSize"` // 日志文件的最大大小, 单位 MB, 默认 100 MB
MaxAge int `json:"maxAge"` // 根据文件名中编码的时间戳保留的旧日志文件的最大天数
MaxBackups int `json:"maxBackups"` // 要保留的旧日志文件的最大数量, 默认是保留所有旧的日志文件
OutToStdIo bool `json:"outToStdIo"` // 是否输出到控制台, 默认输出
TraceStack bool `json:"traceStack"` // 是否输出堆栈信息
}
func FixLogConfigDefValues ¶
func NewLogConfig ¶
func NewLogConfig() *LogConfig
type LoggerProvider ¶
type NoneLocker ¶
type NoneLocker struct {
}
func (*NoneLocker) Lock ¶
func (*NoneLocker) Lock()
func (*NoneLocker) Unlock ¶
func (*NoneLocker) Unlock()
type NoneLogger ¶
type NoneLogger struct {
}
func (*NoneLogger) Debug ¶
func (l *NoneLogger) Debug(...any)
func (*NoneLogger) Debugf ¶
func (l *NoneLogger) Debugf(string, ...any)
func (*NoneLogger) Error ¶
func (l *NoneLogger) Error(...any)
func (*NoneLogger) Errorf ¶
func (l *NoneLogger) Errorf(string, ...any)
func (*NoneLogger) Fatal ¶
func (l *NoneLogger) Fatal(...any)
func (*NoneLogger) Fatalf ¶
func (l *NoneLogger) Fatalf(format string, args ...any)
func (*NoneLogger) Info ¶
func (l *NoneLogger) Info(...any)
func (*NoneLogger) Infof ¶
func (l *NoneLogger) Infof(string, ...any)
func (*NoneLogger) Sync ¶
func (l *NoneLogger) Sync() error
func (*NoneLogger) Warn ¶
func (l *NoneLogger) Warn(...any)
func (*NoneLogger) Warnf ¶
func (l *NoneLogger) Warnf(string, ...any)
type NoneRWLocker ¶ added in v0.8.5
type NoneRWLocker struct {
NoneLocker
}
func (*NoneRWLocker) RLock ¶ added in v0.8.5
func (*NoneRWLocker) RLock()
func (*NoneRWLocker) RUnlock ¶ added in v0.8.5
func (*NoneRWLocker) RUnlock()
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
func NewSafeQueue ¶ added in v0.8.5
func NewUnsafeQueue ¶ added in v0.8.5
type RWLocker ¶
type RWLocker struct {
// contains filtered or unexported fields
}
func NewRWLocker ¶
func NewRWLocker() *RWLocker
type RunMode ¶
type RunMode int
func GetRunMode ¶
func GetRunMode() RunMode
func (RunMode) IsUnderDev ¶
func (RunMode) IsUnderProd ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func NewSet ¶
func NewSet[T comparable]() *Set[T]
type TcpAcceptor ¶
type TcpAcceptor struct {
// contains filtered or unexported fields
}
func (*TcpAcceptor) Accept ¶
func (a *TcpAcceptor) Accept(conn *net.TCPConn)
Source Files
¶
- app_cmd.go
- app_flag.go
- app_flag_base.go
- app_flag_mgr.go
- app_impl.go
- app_status.go
- convert.go
- empty_struct.go
- env.go
- file.go
- http_client.go
- id.go
- json.go
- link_list.go
- list_node.go
- locker.go
- locker_impl.go
- locker_none.go
- locker_rw.go
- log_api.go
- log_config.go
- log_env.go
- log_level.go
- logger.go
- logger_none.go
- logger_provider.go
- logger_provider_zap.go
- logger_stdio.go
- md5.go
- net.go
- object.go
- path.go
- queue.go
- queue_impl.go
- run_mode.go
- runnable.go
- runtime.go
- set.go
- tcp_acceptor.go
- tcp_server.go
- time.go
- udp_server.go
- waiter.go
Click to show internal directories.
Click to hide internal directories.