Documentation ¶
Index ¶
- Constants
- Variables
- func AESGCMDecryptFile(key, inputFile, outputFile string) error
- func AESGCMDecryptText(key string, ciphertextHex string) (string, error)
- func AESGCMEncryptFile(key, inputFile, outputFile string) error
- func AESGCMEncryptText(key, plaintext string) (string, error)
- func AppendFile(name string, data []byte) error
- func BCryptCompareHashAndPassword(pwd, hash string) bool
- func BCryptGenerateFromPassword(pwd string) (string, error)
- func ByteStringUnsafe(b []byte) string
- func Collect[T any](iter Iterator[T]) []T
- func CountWeek(TimeFormat string) int
- func CronRun(ctx context.Context, corn string, task ...func()) error
- func CronRunM(ctx context.Context, corn string, task ...func()) error
- func DeDuplicate[T comparable](items []T) []T
- func DeDuplicateInPlace[T Numbers](items []T) []T
- func DeleteForm[R any](hc *HttpClient, url string, data url.Values) (R, error)
- func Difference[T comparable](items1, items2 []T) []T
- func DifferenceBoth[T comparable](items1, items2 []T) []T
- func Do[R any](hc *HttpClient, request *http.Request) (R, error)
- func FileExists(filename string) bool
- func First[T any](objs []T) (T, bool)
- func GenerateOTP(account string) (string, string, error)
- func GenerateRSA() ([]byte, []byte, error)
- func Get[R any](hc *HttpClient, url string, params url.Values) (R, error)
- func Hash(s string) string
- func IP() string
- func In[T comparable](e T, items []T) bool
- func InitCert(certPEM, keyPEM []byte) error
- func InitLogger(w ...io.Writer)
- func InitYitterID(workID uint16)
- func InitZerolog(level string, w ...io.Writer)
- func Intersection[T comparable](s1, s2 []T) (inter []T)
- func IsASCII(s string) bool
- func IsNil(x any) bool
- func IsTimeExistIntersection(startTime, endTime time.Time, anotherStartTime, anotherEndTime time.Time) bool
- func IsTimestampExistIntersection(startTime, endTime int64, anotherStartTime, anotherEndTime int64) bool
- func JsonEncode(t any) ([]byte, error)
- func JsonIndentEncode(t any, prefix, indent string) ([]byte, error)
- func LocalAddr() string
- func LowerTitle(s string) string
- func MaxNumber[T Numbers](e ...T) T
- func MinNumber[T Numbers](e ...T) T
- func NewConsoleWriter() zerolog.ConsoleWriter
- func NewFileWriter(fileName string, opts ...LumberjackOption) *lumberjack.Logger
- func NewResolver(address string) *net.Resolver
- func NextNanoID() string
- func NextUUID() string
- func NextXID() string
- func NextYitterID() int64
- func NextYitterStringID() string
- func NotIn[T comparable](e T, items []T) bool
- func NowTimeString() string
- func NullTimeString(tm sql.NullTime) string
- func Pagination[T any](page, pageSize int, s []T) []T
- func PathExists(path string) bool
- func PathIsDir(path string) bool
- func PathIsFile(path string) bool
- func Pinyin(s, sep string) string
- func PostForm[R any](hc *HttpClient, url string, data url.Values) (R, error)
- func PostJson[T, R any](hc *HttpClient, url string, data T) (R, error)
- func PostMultipartForm[R any](hc *HttpClient, url string, fieldValues url.Values, files []FormFile) (R, error)
- func PrintAllElements[E comparable](s *Set[E])
- func PrintAllElementsPull[E comparable](s *Set[E])
- func PrintAllElementsPush[E comparable](s *Set[E])
- func PunycodeEncode(s string) (string, error)
- func PutForm[R any](hc *HttpClient, url string, data url.Values) (R, error)
- func RandNumber(max int64) int64
- func RandomBytes(length int) ([]byte, error)
- func RandomHexString(length int) (string, error)
- func Reduce[T, V any](iter Iterator[V], f Reducer[T, V]) T
- func RemoveInvisibleChars(s string) string
- func RemoveItem[T any](items []T, index int) []T
- func RemoveItemNoOrder[T any](items []T, index int) []T
- func Reverse[T any](items []T)
- func SHA256(text string) string
- func SetJsonSlog()
- func SetTextSlog()
- func SplitNString(s string, index int) string
- func StringByteUnsafe(s string) []byte
- func TickerRun(ctx context.Context, d time.Duration, task ...Task) error
- func TickerRunContext(ctx context.Context, d time.Duration, task ...TaskContext) error
- func TickerRunWithStartTimeContext(ctx context.Context, wg *sync.WaitGroup, tm time.Time, d time.Duration, ...) error
- func TimeString(tm time.Time) string
- func TimerRun(ctx context.Context, tm time.Time, task ...Task) error
- func TodayZeroTime() time.Time
- func TodayZeroTimestamp() int64
- func TrackTime(pre time.Time) time.Duration
- func VersionInfo() (string, string)
- func WriteFile(name string, data []byte) error
- func WriteFileSafe(name string, data []byte) error
- func ZeroTime(tm time.Time) time.Time
- func ZeroTimestamp(ts int64) int64
- type DefaultResponse
- type FormFile
- type HttpClient
- type Iterator
- type LumberjackOption
- type NotifyHook
- type Numbers
- type Reducer
- type Set
- type SliceIterator
- type Task
- type TaskContext
Constants ¶
const ISSUER = "rice"
Variables ¶
var ( // Cert is a self signed certificate Cert tls.Certificate // CertPool contains the self signed certificate CertPool *x509.CertPool )
var Logger zerolog.Logger
Functions ¶
func AESGCMDecryptFile ¶ added in v0.0.45
func AESGCMDecryptText ¶ added in v0.0.45
func AESGCMEncryptFile ¶ added in v0.0.45
func AESGCMEncryptText ¶ added in v0.0.45
func AppendFile ¶ added in v0.0.47
AppendFile 往文件末尾追加内容
func BCryptCompareHashAndPassword ¶
BCryptCompareHashAndPassword true or false
func BCryptGenerateFromPassword ¶
BCryptGenerateFromPassword generate hash from password
func ByteStringUnsafe ¶ added in v0.0.41
ByteStringUnsafe []byte to string
func DeDuplicate ¶ added in v0.0.24
func DeDuplicate[T comparable](items []T) []T
DeDuplicate slice 去重
func DeDuplicateInPlace ¶ added in v0.0.24
func DeDuplicateInPlace[T Numbers](items []T) []T
DeDuplicateInPlace slice 就地去重
func DeleteForm ¶ added in v0.0.49
func Difference ¶ added in v0.0.24
func Difference[T comparable](items1, items2 []T) []T
Difference 取 items1 中有,而 items2 中没有的
func DifferenceBoth ¶ added in v0.0.24
func DifferenceBoth[T comparable](items1, items2 []T) []T
DifferenceBoth 取 slice1, slice2 的差集
func GenerateRSA ¶ added in v0.0.45
func InitLogger ¶ added in v0.0.24
func InitYitterID ¶ added in v0.0.45
func InitYitterID(workID uint16)
func InitZerolog ¶ added in v0.0.38
func Intersection ¶ added in v0.0.24
func Intersection[T comparable](s1, s2 []T) (inter []T)
Intersection 两个 slice 的交集
func IsTimeExistIntersection ¶ added in v0.0.24
func IsTimeExistIntersection(startTime, endTime time.Time, anotherStartTime, anotherEndTime time.Time) bool
IsTimeExistIntersection 两个时间段是否有交集 false 没有交集,true 有交集
func IsTimestampExistIntersection ¶ added in v0.0.24
func IsTimestampExistIntersection(startTime, endTime int64, anotherStartTime, anotherEndTime int64) bool
IsTimestampExistIntersection 两个时间段是否有交集 false 没有交集,true 有交集
func JsonEncode ¶ added in v0.0.27
func JsonIndentEncode ¶ added in v0.0.47
func MaxNumber ¶
func MaxNumber[T Numbers](e ...T) T
MaxNumber booleans, numbers, strings, pointers, channels, arrays
func NewConsoleWriter ¶ added in v0.0.37
func NewConsoleWriter() zerolog.ConsoleWriter
func NewFileWriter ¶ added in v0.0.42
func NewFileWriter(fileName string, opts ...LumberjackOption) *lumberjack.Logger
func NewResolver ¶ added in v0.0.45
func NextNanoID ¶ added in v0.0.47
func NextNanoID() string
func NextYitterID ¶ added in v0.0.45
func NextYitterID() int64
func NextYitterStringID ¶ added in v0.0.45
func NextYitterStringID() string
func NowTimeString ¶ added in v0.0.49
func NowTimeString() string
func NullTimeString ¶ added in v0.0.47
func Pagination ¶ added in v0.0.47
Pagination 切片分页
func PostJson ¶ added in v0.0.45
func PostJson[T, R any](hc *HttpClient, url string, data T) (R, error)
PostJson application/json
func PostMultipartForm ¶ added in v0.0.45
func PostMultipartForm[R any](hc *HttpClient, url string, fieldValues url.Values, files []FormFile) (R, error)
PostMultipartForm multipart/form-data
func PrintAllElements ¶ added in v0.0.47
func PrintAllElements[E comparable](s *Set[E])
func PrintAllElementsPull ¶ added in v0.0.47
func PrintAllElementsPull[E comparable](s *Set[E])
func PrintAllElementsPush ¶ added in v0.0.47
func PrintAllElementsPush[E comparable](s *Set[E])
func PunycodeEncode ¶ added in v0.0.45
func RandNumber ¶ added in v0.0.25
RandNumber generate a number range [0, max)
func RandomBytes ¶ added in v0.0.45
func RandomHexString ¶ added in v0.0.45
func RemoveInvisibleChars ¶ added in v0.0.26
RemoveInvisibleChars 移除字符串中的不可见字符
func RemoveItem ¶ added in v0.0.24
RemoveItem 移除 slice 中的一个元素
func RemoveItemNoOrder ¶ added in v0.0.24
RemoveItemNoOrder 移除 slice 中的一个元素,无序
func SetJsonSlog ¶ added in v0.0.45
func SetJsonSlog()
func SetTextSlog ¶ added in v0.0.45
func SetTextSlog()
func SplitNString ¶ added in v0.0.39
func TickerRunContext ¶
TickerRunContext 立即开始以 ticker 的方式执行 task
func TickerRunWithStartTimeContext ¶
func TickerRunWithStartTimeContext(ctx context.Context, wg *sync.WaitGroup, tm time.Time, d time.Duration, task ...TaskContext) error
TickerRunWithStartTimeContext 到达 tm 时间之后,开始以 tikcer 的方式执行 task
func TimeString ¶ added in v0.0.45
func TodayZeroTime ¶
func TodayZeroTimestamp ¶
func TodayZeroTimestamp() int64
func VersionInfo ¶ added in v0.0.27
VersionInfo 返回 git revision 和 go version
func WriteFileSafe ¶ added in v0.0.47
WriteFileSafe 安全的写入文件,如果文件已经存在则跳过写入
func ZeroTimestamp ¶
Types ¶
type DefaultResponse ¶ added in v0.0.48
type HttpClient ¶ added in v0.0.48
type HttpClient struct {
// contains filtered or unexported fields
}
func DefaultHttpClient ¶ added in v0.0.48
func DefaultHttpClient() *HttpClient
func NewHttpClient ¶ added in v0.0.48
func NewHttpClient(client *http.Client, logger *slog.Logger) *HttpClient
type Iterator ¶ added in v0.0.24
func NewSliceIterator ¶ added in v0.0.24
NewSliceIterator Create an iterator over the slice xs
type LumberjackOption ¶
type LumberjackOption func(*lumberjack.Logger)
func Compress ¶
func Compress(b bool) LumberjackOption
func LocalTime ¶
func LocalTime(b bool) LumberjackOption
func MaxAge ¶
func MaxAge(i int) LumberjackOption
func MaxBackups ¶
func MaxBackups(i int) LumberjackOption
func MaxSize ¶
func MaxSize(i int) LumberjackOption
type NotifyHook ¶ added in v0.0.32
func NewNotifyHook ¶ added in v0.0.32
func NewNotifyHook() *NotifyHook
type Set ¶ added in v0.0.47
type Set[E comparable] struct { // contains filtered or unexported fields }
Set holds a set of elements.
func Union ¶ added in v0.0.47
func Union[E comparable](s1, s2 *Set[E]) *Set[E]
Union returns the union of two sets.
type SliceIterator ¶ added in v0.0.24
type SliceIterator[T any] struct { Elements []T // contains filtered or unexported fields }
func (*SliceIterator[T]) Next ¶ added in v0.0.24
func (iter *SliceIterator[T]) Next() bool
Next Move to next value in collection
func (*SliceIterator[T]) Value ¶ added in v0.0.24
func (iter *SliceIterator[T]) Value() T
Value Get current element