utils

package
v1.1.67 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package utils implements some utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertIdentifier

func ConvertIdentifier(s string) string

func CreateDir added in v1.1.55

func CreateDir(dir string) error

func Decrypt added in v1.1.55

func Decrypt(encoded string, key []byte) ([]byte, error)

Decrypt decrypts a base64-encoded ciphertext using AES encryption with a given key. It returns the plaintext.

func Encrypt added in v1.1.55

func Encrypt(plaintext, key []byte) (string, error)

Encrypt encrypts plaintext using AES encryption with a given key. It returns a base64-encoded ciphertext.

func GormErrorWithLogger added in v1.1.55

func GormErrorWithLogger(ctx context.Context) func(err error, formatWithArgs ...interface{}) error

func IsDigit

func IsDigit(b byte) bool

func IsHexDigit

func IsHexDigit(b byte) bool

func IsInteger

func IsInteger(s string) bool

func IsUnsignedInteger

func IsUnsignedInteger(s string) bool

func PathExists added in v1.1.55

func PathExists(path string) bool

func ReadPartFile added in v1.1.55

func ReadPartFile(path string) ([]string, error)

ReadPartFile read part of file: top 50 lines and bottom 50 lines

func RelativePathBaseOn

func RelativePathBaseOn(basePath, filePath string) string

RelativePathBaseOn changes relative path base on the basePath

func Zip added in v1.1.55

func Zip(srcFile string, destZip string) error

Zip ZIP 压缩

Types

type GormErrorWrapper added in v1.1.55

type GormErrorWrapper func(err error, formatWithArgs ...interface{}) error

type WaitGroupMap

type WaitGroupMap struct {
	// contains filtered or unexported fields
}

func NewWaitGroups

func NewWaitGroups() *WaitGroupMap

func (*WaitGroupMap) Add

func (w *WaitGroupMap) Add(delta int, key string)

func (*WaitGroupMap) AddMany

func (w *WaitGroupMap) AddMany(delta int, keys ...string)

func (*WaitGroupMap) Done

func (w *WaitGroupMap) Done(key string)

func (*WaitGroupMap) DoneMany

func (w *WaitGroupMap) DoneMany(keys ...string)

func (*WaitGroupMap) Wait

func (w *WaitGroupMap) Wait(key string)

func (*WaitGroupMap) WaitMany

func (w *WaitGroupMap) WaitMany(keys ...string)

type WithErrorMessage added in v1.1.55

type WithErrorMessage func(c *errorx.ErrCode, err error, formatWithArgs ...interface{}) error

func ErrMsgWithLogger added in v1.1.55

func ErrMsgWithLogger(ctx context.Context) WithErrorMessage

Jump to

Keyboard shortcuts

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