utils

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestBuffer string // The buffer for testing mode.
)

Functions

func Change2RootDir

func Change2RootDir() bool

Ensure that the current working directory is the root directory of the project.

func GenerateKey

func GenerateKey(base string) (string, error)

Generate an APP key by SHA3-256 for the device.

func GenerateRunTimeCode

func GenerateRunTimeCode() (string, error)

Generate a random runtime code.

func GenerateSN

func GenerateSN() (string, error)

Generate a serial number by uuid v4 and custom rule(24 bits + 5 bits(-)).

func GetPrivateKeyBytes

func GetPrivateKeyBytes() ([]byte, error)

Get the private key bytes from the local file.

func InitLogger

func InitLogger()

func IsValidData

func IsValidData(iData interface{}, exclude []string) bool

Check if the given data is all not empty except the excluded fields.

func OverwriteGinLog

func OverwriteGinLog(ctx *QCSExtractGINCtx)

Overwrite the default logger of Gin Framework.

func Record

func Record(level logrus.Level, msg string)

func SignMessage

func SignMessage(message []byte) ([]byte, error)

Sign the given message with specified hashing method.

func TimeUnitStrToTimeDuration

func TimeUnitStrToTimeDuration(unit string) (time.Duration, error)

Convert the time unit string to time.Duration.

func WaitForShutdown

func WaitForShutdown(server *http.Server)

Gracefully shutdown the server.

Types

type AccessLog

type AccessLog struct {
	Type     string `json:"type"`
	Time     string `json:"time"`
	Level    string `json:"level"`
	Status   int    `json:"status"`
	Latency  string `json:"latency"`
	ClientIP string `json:"client_ip"`
	Method   string `json:"method"`
	Path     string `json:"path"`
}

type QCSExtractGINCtx

type QCSExtractGINCtx struct {
	StatusCode int
	Latency    time.Duration
	ClientIP   string
	Method     string
	FullPath   string
}

type QCSJSONFormatter

type QCSJSONFormatter struct {
	*logrus.TextFormatter
}

func (*QCSJSONFormatter) Format

func (f *QCSJSONFormatter) Format(entry *logrus.Entry) ([]byte, error)

type QCSTextFormatter

type QCSTextFormatter struct {
	*logrus.TextFormatter
}

func (*QCSTextFormatter) Format

func (f *QCSTextFormatter) Format(entry *logrus.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL