utils

package
v1.23.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuneKindNum   = "num"
	RuneKindLower = "lower"
	RuneKindUpper = "upper"
	RuneKindChar  = "char"
)
View Source
const (
	BYTE = 1 << (10 * iota)
	KILOBYTE
	MEGABYTE
	GIGABYTE
	TERABYTE
	PETABYTE
	EXABYTE
)

Variables

View Source
var (
	TimeForever               = time.Date(9893, time.December, 26, 0, 0, 0, 0, time.UTC) // 伟人8000年诞辰
	MaxDuration time.Duration = 1<<63 - 1
)

Functions

func BoolPointer added in v1.22.2

func BoolPointer(b bool) *bool

BoolPointer converts bool to *bool

func BoolToFloat64

func BoolToFloat64(a bool) float64

func BoolToString

func BoolToString(a bool) string

func CheckStructFieldsEmpty added in v1.23.0

func CheckStructFieldsEmpty(obj any) error

CheckStructFieldsEmpty check all struct fileds not empty. Now only check string and int.

func ConvertBytes

func ConvertBytes(bytes float64) string

ConvertBytes 保留两位小数

func CopyFileByLine

func CopyFileByLine(dest, src string) (lineCount int64, err error)

func DayStartTime

func DayStartTime(t time.Time) time.Time

DayStartTime 返回当天0点

func EnsurePathExists

func EnsurePathExists(dirname string) error

func FormatMysqlDumpTime

func FormatMysqlDumpTime(t *time.Time) string

func GeneratePassword

func GeneratePassword() string

func JoinFlagName

func JoinFlagName(prefix, key string) string

func MakePassword

func MakePassword(input string) (string, error)

func NextDayStartTime

func NextDayStartTime(t time.Time) time.Time

func RandomRune

func RandomRune(n int, kind string) []rune

func RoundTo

func RoundTo(n float64, decimals uint32) float64

保留n位小数

func StrOrDef

func StrOrDef(s string, def string) string

func TimeZeroToNull

func TimeZeroToNull(t *time.Time) *time.Time

func ToUint

func ToUint(id string) uint

func UintToStr

func UintToStr(i *uint) string

func ValidPassword

func ValidPassword(input string) error

func ValidatePassword

func ValidatePassword(password string, hashedPassword string) error

func WaitGroupWithTimeout added in v1.22.0

func WaitGroupWithTimeout(wg *sync.WaitGroup, timeout time.Duration) bool

WaitGroupWithTimeout waits for the waitgroup for the specified max timeout. Returns true if waiting timed out.

Types

type DesEncryptor

type DesEncryptor struct {
	Key []byte
}

func (*DesEncryptor) DecryptBase64

func (e *DesEncryptor) DecryptBase64(input string) (string, error)

func (*DesEncryptor) EncryptBase64

func (e *DesEncryptor) EncryptBase64(input string) (string, error)

func (*DesEncryptor) Padding

func (e *DesEncryptor) Padding(cipherText []byte, blockSize int) []byte

func (*DesEncryptor) UnPadding

func (e *DesEncryptor) UnPadding(data []byte) []byte

Directories

Path Synopsis
* OCI Distribution Specification Client * * For more information visit below URL * https://github.com/opencontainers/distribution-spec/blob/main/spec.md#endpoints *
* OCI Distribution Specification Client * * For more information visit below URL * https://github.com/opencontainers/distribution-spec/blob/main/spec.md#endpoints *
httputil
gin

Jump to

Keyboard shortcuts

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