{"modulePath":"github.com/andrewbytecoder/nmq","version":"v0.0.0-20261028105650-d8b0a59c570e","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\n## Variables\n\n```go\nvar (\n\t// Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC in milliseconds\n\t// You may customize this to set a different epoch for your application.\n\tEpoch int64 = 1288834974657\n\n\t// NodeBits holds the number of bits to use for SnowNode\n\t// Remember, you have a total 22 bits to share between SnowNode/Step\n\tNodeBits uint8 = 10\n\n\t// StepBits holds the number of bits to use for Step\n\t// Remember, you have a total 22 bits to share between SnowNode/Step\n\tStepBits uint8 = 12\n)\n```\n\n```go\nvar ErrInvalidBase32 = errors.New(\"invalid base32\")\n```\nErrInvalidBase32 is returned by ParseBase32 when given an invalid \\[]byte\n\n```go\nvar ErrInvalidBase58 = errors.New(\"invalid base58\")\n```\nErrInvalidBase58 is returned by ParseBase58 when given an invalid \\[]byte\n\n## Functions\n\n```go\nfunc Bytes2Data[T any](bytes []byte) (T, error)\n```\n\n```go\nfunc CreateProductZapLogger(op ...Option) (*zap.Logger, zap.AtomicLevel, error)\n```\nCreateProductZapLogger 创建一个生产级别的 zap 日志记录器。 返回的 zap.AtomicLevel 可用于运行时动态修改日志等级。\n\n```go\nfunc FileExists(filename string) bool\n```\n\n```go\nfunc NativelyLittle() bool\n```\nNativelyLittle 返回当前系统的字节序是否为 little-endian\n\n```go\nfunc NewZapWriter(logger *zap.Logger, level zapcore.Level) io.Writer\n```\nNewZapWriter 创建一个新的 io.Writer，输出到 zap.Logger level: 日志级别 (zap.InfoLevel, zap.WarnLevel 等)\n\n```go\nfunc PathExist(path string) bool\n```\nPathExist 判断路径是否存在\n\n## Types\n\n```go\ntype AtomicInt struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewAtomicInt(val int) *AtomicInt\n```\n\n```go\nfunc NewAtomicInt64(val int64) *AtomicInt\n```\n\n```go\nfunc (a *AtomicInt) Add(delta int)\n```\n\n```go\nfunc (a *AtomicInt) CompareAndSwap(oldVal, newVal int) bool\n```\n\n```go\nfunc (a *AtomicInt) CompareAndSwap64(oldVal, newVal int64) bool\n```\n\n```go\nfunc (a *AtomicInt) Dec() int\n```\n\n```go\nfunc (a *AtomicInt) Get() int\n```\n\n```go\nfunc (a *AtomicInt) Get64() int64\n```\n\n```go\nfunc (a *AtomicInt) Inc() int\n```\n\n```go\nfunc (a *AtomicInt) Load() int\n```\n\n```go\nfunc (a *AtomicInt) Reset()\n```\n\n```go\nfunc (a *AtomicInt) Set(val int)\n```\n\n```go\nfunc (a *AtomicInt) Set64(val int64)\n```\n\n```go\nfunc (a *AtomicInt) Store(val int)\n```\n\n```go\nfunc (a *AtomicInt) String() string\n```\n\n```go\nfunc (a *AtomicInt) Swap(newVal int) int\n```\n\n```go\nfunc (a *AtomicInt) Swap64(newVal int64) int64\n```\n\n```go\ntype JSONSyntaxError struct {\n\t// contains filtered or unexported fields\n}\n```\nA JSONSyntaxError is returned from UnmarshalJSON if an invalid ID is provided.\n\n```go\nfunc (j JSONSyntaxError) Error() string\n```\n\n```go\ntype LogConfig struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype Option interface {\n\t// contains filtered or unexported methods\n}\n```\nAn Option configures a Logger.\n\n```go\nfunc SetConsoleWriterSyncer(consoleWriter bool) Option\n```\n\n```go\nfunc SetLogCompress(compress bool) Option\n```\nSetLogCompress 设置是否压缩日志文件\n\n```go\nfunc SetLogFilename(filename string) Option\n```\nSetLogFilename 设置日志文件名\n\n```go\nfunc SetLogLevel(level zapcore.Level) Option\n```\nSetLogLevel 设置日志级别\n\n```go\nfunc SetLogLevelKey(levelKey string) Option\n```\nSetLogLevelKey 设置日志级别字段名\n\n```go\nfunc SetLogMaxAge(maxAge int) Option\n```\nSetLogMaxAge 设置日志文件最大保存天数\n\n```go\nfunc SetLogMaxBackups(maxBackups int) Option\n```\nSetLogMaxBackups 设置日志文件最大备份数\n\n```go\nfunc SetLogMaxSize(maxSize int) Option\n```\nSetLogMaxSize 设置日志文件最大大小（MB）\n\n```go\ntype SnowID int64\n```\nAn SnowID is a custom type used for a snowflake SnowID.  This is used so we can attach methods onto the SnowID.\n\n```go\nfunc ParseBase2(id string) (SnowID, error)\n```\nParseBase2 converts a Base2 string into a snowflake SnowID\n\n```go\nfunc ParseBase32(b []byte) (SnowID, error)\n```\nParseBase32 parses a base32 \\[]byte into a snowflake SnowID NOTE: There are many different base32 implementations so becareful when doing any interoperation.\n\n```go\nfunc ParseBase36(id string) (SnowID, error)\n```\nParseBase36 converts a Base36 string into a snowflake SnowID\n\n```go\nfunc ParseBase58(b []byte) (SnowID, error)\n```\nParseBase58 parses a base58 \\[]byte into a snowflake SnowID\n\n```go\nfunc ParseBase64(id string) (SnowID, error)\n```\n\n```go\nfunc ParseBytes(id []byte) (SnowID, error)\n```\n\n```go\nfunc ParseInt64(id int64) SnowID\n```\nParseInt64 converts an int64 into a snowflake SnowID\n\n```go\nfunc ParseIntBytes(id [8]byte) SnowID\n```\nParseIntBytes converts an array of bytes encoded as big endian integer as a snowflake SnowID\n\n```go\nfunc ParseString(id string) (SnowID, error)\n```\nParseString converts a string into a snowflake SnowID\n\n```go\nfunc (f SnowID) Base2() string\n```\nBase2 returns a string base2 of the snowflake SnowID\n\n```go\nfunc (f SnowID) Base32() string\n```\nBase32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation.\n\n```go\nfunc (f SnowID) Base36() string\n```\nBase36 returns a base36 string of the snowflake SnowID\n\n```go\nfunc (f SnowID) Base58() string\n```\nBase58 returns a base58 string of the snowflake SnowID\n\n```go\nfunc (f SnowID) Base64() string\n```\n\n```go\nfunc (f SnowID) Bytes() []byte\n```\n\n```go\nfunc (f SnowID) Int64() int64\n```\nInt64 returns an int64 of the snowflake SnowID\n\n```go\nfunc (f SnowID) IntBytes() [8]byte\n```\nIntBytes returns an array of bytes of the snowflake SnowID, encoded as a big endian integer.\n\n```go\nfunc (f SnowID) MarshalJSON() ([]byte, error)\n```\nMarshalJSON returns a json byte array string of the snowflake SnowID.\n\n```go\nfunc (f SnowID) Node() int64\n```\nNode SnowNode returns an int64 of the snowflake SnowID node number DEPRECATED: the below function will be removed in a future release.\n\n```go\nfunc (f SnowID) Step() int64\n```\nStep returns an int64 of the snowflake step (or sequence) number DEPRECATED: the below function will be removed in a future release.\n\n```go\nfunc (f SnowID) String() string\n```\n\n```go\nfunc (f SnowID) Time() int64\n```\nTime returns an int64 unix timestamp in milliseconds of the snowflake SnowID time DEPRECATED: the below function will be removed in a future release.\n\n```go\nfunc (f *SnowID) UnmarshalJSON(b []byte) error\n```\nUnmarshalJSON converts a json byte array of a snowflake SnowID into an SnowID type.\n\n```go\ntype SnowNode struct {\n\t// contains filtered or unexported fields\n}\n```\nA SnowNode struct holds the basic information needed for a snowflake generator node\n\n```go\nfunc NewSnowNode(node int64) (*SnowNode, error)\n```\nNewSnowNode returns a new snowflake node that can be used to generate snowflake IDs\n\n```go\nfunc (n *SnowNode) Generate() SnowID\n```\nGenerate creates and returns a unique snowflake SnowID To help guarantee uniqueness - Make sure your system is keeping accurate system time - Make sure you never have multiple nodes running with the same node SnowID\n\n```go\ntype ZapWriter struct {\n\t// contains filtered or unexported fields\n}\n```\nZapWriter 将 io.Writer 接口桥接到 zap.Logger\n\n```go\nfunc (w *ZapWriter) Flush()\n```\nFlush 将剩余缓冲区内容输出（例如程序退出时调用）\n\n```go\nfunc (w *ZapWriter) Write(p []byte) (n int, err error)\n```\nWrite 实现 io.Writer 接口\n\n","path":"github.com/andrewbytecoder/nmq/pkg/utils","name":"utils","synopsis":"","isRedistributable":true}
