Documentation
¶
Index ¶
- Constants
- Variables
- func AddQuery(rawUrl string, key string, value string) (string, error)
- func BinarySearch[T types.Ordered](data []T, value T) int
- func CRC(content []byte) uint32
- func Copy(src interface{}) interface{}
- func CopySlice[T any](data []T) []T
- func Decrypt(cipherText []byte, key []byte, iv ...[]byte) ([]byte, error)
- func DecryptCBC(cipherText []byte, key []byte, iv ...[]byte) ([]byte, error)
- func DecryptCFB(cipherText []byte, key []byte, unPadding int, iv ...[]byte) ([]byte, error)
- func Encrypt(plainText []byte, key []byte, iv ...[]byte) ([]byte, error)
- func EncryptCBC(plainText []byte, key []byte, iv ...[]byte) ([]byte, error)
- func EncryptCFB(plainText []byte, key []byte, padding *int, iv ...[]byte) ([]byte, error)
- func ExistDir(name string) (bool, error)
- func ExistFile(name string) (bool, error)
- func FanOut[T any](data types.IFanOut[T], number int) []T
- func FileSize(file *os.File) (int64, error)
- func FileSizeByPath(path string) (int64, error)
- func FuncCost(start time.Time, printer Printer)
- func GetDateAgo(ago int64, format ...string) string
- func GetTimeFromTimestamp(tm int64, format ...string) string
- func HashBytes(content []byte, hashType ...string) string
- func HashFile(path string, hashType ...string) (string, error)
- func LogModule(module string, fields ...map[string]interface{}) *logrus.Entry
- func LogWithCtx(ctx context.Context, module string, fields ...map[string]interface{}) *logrus.Entry
- func Max[T types.Ordered](data ...T) T
- func Min[T types.Ordered](data ...T) T
- func Mkdirs(path string, perms ...os.FileMode) error
- func PKCS5Padding(src []byte, blockSize int) []byte
- func PKCS5UnPadding(src []byte, blockSize int) ([]byte, error)
- func QueryUrl(rawUrl string, key string) (string, error)
- func ReadDir(path string) ([]string, []string, error)
- func ReadFile(path string) ([]byte, error)
- func ReadLine(buffer *bufio.Reader) ([]byte, error)
- func ReadLines(path string) ([][]byte, error)
- func ResponseFail[T any](c *gin.Context, httpCode int, code int, msg string, data ...T)
- func ResponseFailDefault[T any](c *gin.Context, msg string, data ...T)
- func ResponseSuccess[T any](c *gin.Context, code int, msg string, data T)
- func ResponseSuccessDefault[T any](c *gin.Context, data T)
- func ReverseSlice[T any](data []T)
- func RunPeriod(interval time.Duration, handler func(), closeCh ...chan struct{})
- func RunSafe(handler func(), errHandler ...types.ErrHandler)
- func ScanStd(handler LineHandler, hints ...string) error
- func SelectAll[T any](data T, prefix ...string) string
- func SliceEqual[T comparable](a []T, b []T) bool
- func SliceMax[T types.Ordered](data []T) T
- func SliceMin[T types.Ordered](data []T) T
- func SortComparator[T types.IComparator](data T)
- func SortSlice[T types.Ordered](data []T, reverseOpts ...bool)
- func SortSliceWithComparator[T any](data []T, comparator func(i, j int) bool)
- func SplitFile(path string) (string, string, error)
- func UniqueSlice[T comparable](data []T) []T
- func WaitGroup(number int, handler types.WaitGroupHandler, closeHandler ...func()) error
- func WriteFile(path string, content []byte, append bool) (int64, error)
- func ZeroPadding(cipherText []byte, blockSize int) ([]byte, int)
- func ZeroUnPadding(plaintext []byte, unPadding int) []byte
- type BuiltinSet
- func (s BuiltinSet[K]) Clear()
- func (s BuiltinSet[K]) Delete(k K)
- func (s BuiltinSet[K]) Difference(other BuiltinSet[K]) BuiltinSet[K]
- func (s BuiltinSet[K]) ForEach(cb func(k K))
- func (s BuiltinSet[K]) ForEachIf(cb func(k K) bool)
- func (s BuiltinSet[K]) Has(k K) bool
- func (s BuiltinSet[K]) Insert(k K) bool
- func (s BuiltinSet[K]) InsertN(ks ...K) int
- func (s BuiltinSet[K]) Intersection(other BuiltinSet[K]) BuiltinSet[K]
- func (s BuiltinSet[K]) IsDisjointOf(other BuiltinSet[K]) bool
- func (s BuiltinSet[K]) IsEmpty() bool
- func (s BuiltinSet[K]) IsSubsetOf(other BuiltinSet[K]) bool
- func (s BuiltinSet[K]) IsSupersetOf(other BuiltinSet[K]) bool
- func (s BuiltinSet[K]) Keys() []K
- func (s BuiltinSet[K]) Len() int
- func (s BuiltinSet[K]) Remove(k K) bool
- func (s BuiltinSet[K]) RemoveN(ks ...K) int
- func (s BuiltinSet[K]) String() string
- func (s BuiltinSet[K]) Union(other BuiltinSet[K]) BuiltinSet[K]
- func (s BuiltinSet[K]) Update(other BuiltinSet[K])
- type CounterMap
- type EUnit
- type IBufferPool
- type ICacheBuffer
- type ILimit
- type IPriorityChan
- type Interface
- type LineHandler
- type ListNode
- type Printer
- type SecTimestamp
- type SortedMap
- type Tuple
Constants ¶
const (
// IVDefaultValue is the default value for IV.
IVDefaultValue = "I Love Go Frame!"
)
Variables ¶
var DefaultPermOpen = os.FileMode(0666)
var ErrorCipherTextInvalid = fmt.Errorf("cipherText is not a multiple of the block size")
var ErrorCipherTextTooShort = fmt.Errorf("cipherText too short")
var ErrorInvalidBlockLen = fmt.Errorf("invalid blocklen")
var ErrorInvalidDataLen = fmt.Errorf("invalid data len")
var ErrorInvalidPadding = fmt.Errorf("invalid padding")
var LineBreak = []byte{'\n'}
Functions ¶
func Copy ¶
func Copy(src interface{}) interface{}
Copy creates a deep copy of whatever is passed to it and returns the copy in an interface{}. The returned value will need to be asserted to the correct type.
func DecryptCBC ¶
DecryptCBC decrypts `cipherText` using CBC mode. Note that the key must be 16/24/32 bit length. The parameter `iv` initialization vector is unnecessary.
func DecryptCFB ¶
DecryptCFB decrypts `plainText` using CFB mode. Note that the key must be 16/24/32 bit length. The parameter `iv` initialization vector is unnecessary.
func EncryptCBC ¶
EncryptCBC encrypts `plainText` using CBC mode. Note that the key must be 16/24/32 bit length. The parameter `iv` initialization vector is unnecessary.
func EncryptCFB ¶
EncryptCFB encrypts `plainText` using CFB mode. Note that the key must be 16/24/32 bit length. The parameter `iv` initialization vector is unnecessary.
func FileSizeByPath ¶
FileSizeByPath 通过路径计算文件的大小(Byte单位)
func GetTimeFromTimestamp ¶
GetTimeFromTimestamp 根据时间戳打印对应的日期
func LogWithCtx ¶
func PKCS5Padding ¶
func ReadLine ¶
ReadLine 按行读取文件内容 为了提升性能,使用前需将文件转换为buffer reader file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close() buffer := bufio.NewReader(file) ReadLine(buffer)
func ResponseFail ¶
func ResponseSuccessDefault ¶
func RunSafe ¶
func RunSafe(handler func(), errHandler ...types.ErrHandler)
func SortSliceWithComparator ¶
SortSliceWithComparator 针对切片的自定义排序
func WaitGroup ¶
func WaitGroup(number int, handler types.WaitGroupHandler, closeHandler ...func()) error
func ZeroUnPadding ¶
Types ¶
type BuiltinSet ¶
type BuiltinSet[K comparable] map[K]struct{}
BuiltinSet is an associative container that contains an unordered set of unique objects of type K.
func SetOf ¶
func SetOf[K comparable](ks ...K) BuiltinSet[K]
SetOf creates a new BuiltinSet object with the initial content from ks.
func (BuiltinSet[K]) Clear ¶
func (s BuiltinSet[K]) Clear()
Clear implements the Container interface.
func (BuiltinSet[K]) Delete ¶
func (s BuiltinSet[K]) Delete(k K)
Delete deletes an element from the set. It returns nothing, so it's faster than Remove.
func (BuiltinSet[K]) Difference ¶
func (s BuiltinSet[K]) Difference(other BuiltinSet[K]) BuiltinSet[K]
Difference returns a new set with elements in the set that are not in other.
func (BuiltinSet[K]) ForEach ¶
func (s BuiltinSet[K]) ForEach(cb func(k K))
ForEach implements the Set interface.
func (BuiltinSet[K]) ForEachIf ¶
func (s BuiltinSet[K]) ForEachIf(cb func(k K) bool)
ForEachIf implements the Container interface.
func (BuiltinSet[K]) Insert ¶
func (s BuiltinSet[K]) Insert(k K) bool
Insert implements the Set interface.
func (BuiltinSet[K]) InsertN ¶
func (s BuiltinSet[K]) InsertN(ks ...K) int
InsertN implements the Set interface.
func (BuiltinSet[K]) Intersection ¶
func (s BuiltinSet[K]) Intersection(other BuiltinSet[K]) BuiltinSet[K]
Intersection returns a new set with elements common to the set and other.
func (BuiltinSet[K]) IsDisjointOf ¶
func (s BuiltinSet[K]) IsDisjointOf(other BuiltinSet[K]) bool
IsDisjointOf return True if the set has no elements in common with other. Sets are disjoint if and only if their intersection is the empty set.
func (BuiltinSet[K]) IsEmpty ¶
func (s BuiltinSet[K]) IsEmpty() bool
IsEmpty implements the Container interface.
func (BuiltinSet[K]) IsSubsetOf ¶
func (s BuiltinSet[K]) IsSubsetOf(other BuiltinSet[K]) bool
IsSubsetOf tests whether every element in the set is in other.
func (BuiltinSet[K]) IsSupersetOf ¶
func (s BuiltinSet[K]) IsSupersetOf(other BuiltinSet[K]) bool
IsSupersetOf tests whether every element in other is in the set.
func (BuiltinSet[K]) Keys ¶
func (s BuiltinSet[K]) Keys() []K
Keys return a copy of all keys as a slice.
func (BuiltinSet[K]) Remove ¶
func (s BuiltinSet[K]) Remove(k K) bool
Remove implements the Set interface.
func (BuiltinSet[K]) RemoveN ¶
func (s BuiltinSet[K]) RemoveN(ks ...K) int
RemoveN implements the Set interface.
func (BuiltinSet[K]) String ¶
func (s BuiltinSet[K]) String() string
String implements the fmt.Stringer interface.
func (BuiltinSet[K]) Union ¶
func (s BuiltinSet[K]) Union(other BuiltinSet[K]) BuiltinSet[K]
Union returns a new set with elements from the set and other.
func (BuiltinSet[K]) Update ¶
func (s BuiltinSet[K]) Update(other BuiltinSet[K])
Update adds all elements from other to set. set |= other.
type CounterMap ¶
type CounterMap[K comparable] map[K]int
func NewCounterMap ¶
func NewCounterMap[K comparable](data []K) CounterMap[K]
func (CounterMap[K]) Equal ¶
func (c CounterMap[K]) Equal(other CounterMap[K]) bool
type IBufferPool ¶
func NewBufferPool ¶
func NewBufferPool(baseline int) IBufferPool
type ICacheBuffer ¶
func NewCacheBuffer ¶
func NewCacheBuffer[T any](fetcher types.FetchHandler[T]) ICacheBuffer[T]
type IPriorityChan ¶
type IPriorityChan[T any] interface { Get() T TryGet() T GetWithTimeout(timeout time.Duration) (T, error) HandleSignal(highHandler types.PriorityHandler, lowHandler types.PriorityHandler) error }
func NewPriorityChan ¶
func NewPriorityChan[T any](size int) IPriorityChan[T]
type Interface ¶
type Interface interface {
DeepCopy() interface{}
}
Interface for delegating copy process to type
type LineHandler ¶
type SecTimestamp ¶
type SecTimestamp int64
SecTimestamp 用于mysql的秒时间戳类型
func NewSecTimestamp ¶
func NewSecTimestamp(t time.Time) SecTimestamp
func (*SecTimestamp) Scan ¶
func (s *SecTimestamp) Scan(src interface{}) error
func (*SecTimestamp) Time ¶
func (s *SecTimestamp) Time() time.Time