Documentation
¶
Index ¶
- Constants
- Variables
- func ByteSlice2String(bs []byte) string
- func Capture(ctx context.Context, level zapcore.Level, err error, context, scope string)
- func EncodeSqIDs(numbers ...uint64) (string, error)
- func GenerateUniqueID() (numericID int64, alphaNumericID string, err error)
- func GetContext(ctx context.Context, c *fiber.Ctx) context.Context
- func GetEnv() string
- func GetLogger() *zap.Logger
- func LoadTimeZone() *time.Location
- func Log(ctx context.Context, level zapcore.Level, message, context, scope string)
- func String2ByteSlice(str string) []byte
- type Response
Constants ¶
View Source
const (
APP = "bible"
)
Variables ¶
View Source
var ( InitHelper = sync.OnceValue(func() (err error) { if snowflakeNode, err = snowflake.NewNode(1); err != nil { return } envSqIDsMinLength, ok := os.LookupEnv("SQIDS_MIN_LENGTH") if !ok || envSqIDsMinLength == "" { return errors.New("env SQIDS_MIN_LENGTH requires a positive integer") } sqIDsMinLength, err := strconv.Atoi(envSqIDsMinLength) if err != nil { return } sqIDs, err = sqids.New(sqids.Options{ Alphabet: lowerCaseAlphanumerics, MinLength: min(uint8(sqIDsMinLength), math.MaxUint8), }) if err != nil { return } location, ok := os.LookupEnv("TIME_ZONE") if !ok || location == "" { return errors.New("env TIME_ZONE is required") } timeZone, err = time.LoadLocation(location) return }) )
View Source
var ( InitLogger = sync.OnceFunc(func() { encoderCfg := zap.NewProductionEncoderConfig() encoderCfg.TimeKey = "timestamp" encoderCfg.EncodeTime = zapcore.ISO8601TimeEncoder logger = zap.Must(zap.Config{ Level: zap.NewAtomicLevelAt(zap.InfoLevel), Development: false, DisableCaller: true, DisableStacktrace: true, Sampling: nil, Encoding: "json", EncoderConfig: encoderCfg, OutputPaths: []string{ "stderr", }, ErrorOutputPaths: []string{ "stderr", }, InitialFields: map[string]interface{}{}, }.Build()) }) )
Functions ¶
func ByteSlice2String ¶
func EncodeSqIDs ¶
func GenerateUniqueID ¶
func LoadTimeZone ¶
func String2ByteSlice ¶
Types ¶
type Response ¶
type Response struct { Code int `json:"code"` Message string `json:"message,omitempty"` Data interface{} `json:"data,omitempty"` App string `json:"app"` }
func NewResponse ¶
func (*Response) WriteResponse ¶
Click to show internal directories.
Click to hide internal directories.