util

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Validate = validator.New()

Functions

func BoolPtr

func BoolPtr(b bool) *bool

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to string without a memory allocation.

func CleanHTMLTag added in v1.0.7

func CleanHTMLTag(htmlContent string) string

func CompositeURL

func CompositeURL(urls ...string) string

func CopyDir

func CopyDir(srcPath, desPath string) error

func CopyFile

func CopyFile(src, des string) (written int64, err error)

func FileIsExisted

func FileIsExisted(filename string) bool

func GenUUIDWithOutDash

func GenUUIDWithOutDash() string

func GetClientIP

func GetClientIP(ctx context.Context) string

func GetQueryBool

func GetQueryBool(ctx *gin.Context, key string, defaultValue bool) (bool, error)

func GetUserAgent

func GetUserAgent(ctx context.Context) string

func HTMLFormatWordCount added in v1.0.7

func HTMLFormatWordCount(html string) int64

func IfElse

func IfElse(condition bool, a, b interface{}) interface{}

func Int32Ptr

func Int32Ptr(i int32) *int32

func Int64Ptr added in v1.0.5

func Int64Ptr(i int64) *int64

func MakeDir

func MakeDir(dir string) error

func MapKeyToArray

func MapKeyToArray[K comparable, V any](m map[K]V) []K

func Md5Hex

func Md5Hex(str string) string

func MustGetQueryBool

func MustGetQueryBool(ctx *gin.Context, key string) (bool, error)

func MustGetQueryInt

func MustGetQueryInt(ctx *gin.Context, key string) (int, error)

func MustGetQueryInt32

func MustGetQueryInt32(ctx *gin.Context, key string) (int32, error)

func MustGetQueryInt64

func MustGetQueryInt64(ctx *gin.Context, key string) (int64, error)

func MustGetQueryString

func MustGetQueryString(ctx *gin.Context, key string) (string, error)

func ParamBool

func ParamBool(ctx *gin.Context, key string) (bool, error)

func ParamInt32

func ParamInt32(ctx *gin.Context, key string) (int32, error)

func ParamInt64

func ParamInt64(ctx *gin.Context, key string) (int64, error)

func ParamString

func ParamString(ctx *gin.Context, key string) (string, error)

func RainbowPage

func RainbowPage(page, total, display int) []int

func Slug

func Slug(slug string) string

func StringPtr

func StringPtr(s string) *string

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts string to byte slice without a memory allocation.

func TimeFormat

func TimeFormat(totalSeconds int) string

TimeFormat format time interval to human-readable

func TimePtr

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

func Unzip

func Unzip(src string, dest string) ([]string, error)

func ZipFile

func ZipFile(dst string, srcs ...string) (err error)

Types

type CounterCache

type CounterCache[K comparable] struct {
	// contains filtered or unexported fields
}

func NewCounterCache

func NewCounterCache[K comparable](refreshDuration time.Duration, batchIncr func(map[K]int64), singleIncr func(K, int64)) *CounterCache[K]

func (*CounterCache[K]) Get

func (c *CounterCache[K]) Get(key K) int64

func (*CounterCache[K]) IncrBy

func (c *CounterCache[K]) IncrBy(key K, value int64) int64

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any]() Queue[T]

func NewQueueCap

func NewQueueCap[T any](initialCapacity int) Queue[T]

func (Queue[T]) IsEmpty

func (q Queue[T]) IsEmpty() bool

func (*Queue[T]) Next

func (q *Queue[T]) Next() T

func (Queue[T]) Peek

func (q Queue[T]) Peek() T

func (*Queue[T]) Push

func (q *Queue[T]) Push(element T)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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