Documentation
¶
Index ¶
- Constants
- Variables
- func AnyArrayContainsIgnoreCase(s []string, strs ...string) bool
- func AnyContainsIgnoreCase(s string, strs ...string) bool
- func ArrayIntContains(arr []int, str int) bool
- func BoolToString(b bool) string
- func CRC(len int, key string) string
- func CalculateMD5(data []byte) (string, error)
- func CalculateMD5WithChunkSize(data []byte, chunkSize int) (string, error)
- func ContainsAny(s string, strs ...string) bool
- func ContainsAnyIgnoreCase(s string, strs ...string) bool
- func CreateDirIfNoExists(path string) error
- func CreateFileIfNoExists(path string) error
- func DecodeFileBase64(base64Str string) ([]byte, error)
- func DecryptByCBC(cipherText string, key string, iv string) (string, error)
- func DeduplicateIds(ids string) string
- func EncryptByCBC(text string, key string, iv string) (string, error)
- func EqualsAnyIgnoreCase(s string, strs ...string) bool
- func ExistsFile(path string) bool
- func ExtractEmails(text string) []string
- func FormatDate(tm time.Time) string
- func FormatMail(name, mail string) string
- func FormatTime(tm time.Time) string
- func GenerateQrcode(content string, writeCloser io.WriteCloser, opts ...standard.ImageOption) error
- func GenerateRandomNum(length int) string
- func GenerateRandomString(length int, charset string) string
- func GenerateRandomStringByAlphanumeric(length int) string
- func GetCachePath(rootPath, filename string) string
- func GetDomainFromHost(host string) string
- func GetDomainFromURL(rawURL string) string
- func GetEnv(key string) string
- func GetEnvBool(key string) bool
- func GetEnvBoolOrDefault(key string, defaultValue bool) bool
- func GetEnvInt(key string) int
- func GetEnvIntOrDefault(key string, defaultValue int) int
- func GetEnvOrDefault(key, defaultValue string) string
- func GetHost(rawURL string) string
- func GetMap(key string, value any) map[string]any
- func GetNowTime() time.Time
- func GetStructFullName(v any) string
- func GetStructName(v any) string
- func HidePhone(phone string) string
- func Index2Str(index int, charset string) string
- func IsAfter(pre string, now time.Time, timestampFormat string) bool
- func IsBlank(str string) bool
- func IsDomain(str string) bool
- func IsImagePath(path string) bool
- func IsMatch(value, regx string) bool
- func IsMatchPath(path, smath string) bool
- func IsNotBlank(str string) bool
- func IsNumber(value string) bool
- func IsWhite(c color.Color) bool
- func JoinValues(values ...any) string
- func JsonEncode(v any) (string, error)
- func MD5(data []byte) string
- func MD5Str(data string) string
- func Millisecond() uint32
- func NewPtr[T any](v T) T
- func NewSlice[T any](v T) []T
- func NowDateFormatTime(timestampFormat string) string
- func NowDateTime() string
- func Number2String(number int64, charset string) string
- func OfMap(key string, value any) map[string]any
- func OfMap2(key string, value any, key2 string, value2 any) map[string]any
- func ParseFormatTime(timeStr, timestampFormat string) (time.Time, error)
- func ParseMail(recipient string) (name string, mail string, err error)
- func ParseTemplate(templateStr string, data map[string]interface{}) (string, error)
- func ReadFile(path string) (string, error)
- func ReadFileBytes(path string) ([]byte, error)
- func RemoveDuplicates(nums []string) []string
- func ReplaceAllRegex(path, regex, math string) string
- func Second() int64
- func Second2Base62() string
- func SplitAndDeduplicate(text, sep string) []string
- func SplitPath(path string) []string
- func StartsWithAnyIgnoreCase(s string, prefix ...string) bool
- func StringToBool(s string) bool
- func StringToInt(s string) int
- func StringToUInt(s string) uint
- func StringToUintIds(ids string) []uint
- func SubStringAndPadSpace(value string, length int) string
- func Trim(value string) string
- func WithRoundedSquareShape() standard.ImageOption
- func WriteBase64File(base64Str string, dst string) error
- func WriteBytesFile(file *os.File, dataS ...[]byte) error
- func WriteBytesFilePath(path string, dataS ...[]byte) error
- func WriteFile(bytes []byte, dst string) error
- type BufferWriteCloser
- type Configure
- type File
- func (f *File) Abs() string
- func (f *File) Child(path string) (*File, error)
- func (f *File) Close() error
- func (f *File) Exists() (flag bool, err error)
- func (f *File) IsDir() bool
- func (f *File) IsDisk() bool
- func (f *File) List() ([]*File, error)
- func (f *File) MkDirs() error
- func (f *File) ModTime() (*time.Time, error)
- func (f *File) Name() string
- func (f *File) OpenAppendOrCreate() error
- func (f *File) OpenAppendWrite() (*bufio.Writer, error)
- func (f *File) OpenOrCreate() error
- func (f *File) OpenWrite() (*bufio.Writer, error)
- func (f *File) Parent() string
- func (f *File) ParentFile() (*File, error)
- func (f *File) ReadAll() ([]byte, error)
- func (f *File) ReadBytes(p []byte) (n int, err error)
- func (f *File) ToRawFile() (*os.File, error)
- func (f *File) Truncate() error
- func (f *File) WriteAppendBytes(data []byte) error
- func (f *File) WriteBytes(data []byte) error
- type ShapeRoundedSquare
Constants ¶
const ( // Alphanumeric 包含大小写字母和数字 Alphanumeric = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" // Lowercase 仅包含小写字母 Lowercase = "abcdefghijklmnopqrstuvwxyz" // Uppercase 仅包含大写字母 Uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // Numeric 仅包含数字 Numeric = "0123456789" // WithSpecialChars 包含字母、数字和常见特殊字符 WithSpecialChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()" )
预设字符集
const DefaultChunkSize = 4096 // 4KB
DefaultChunkSize 常用分块大小:4KB,与大多数操作系统页大小一致
Variables ¶
var DateFormat = "2006-01-02"
var TimestampFormat = "2006-01-02 15:04:05"
Functions ¶
func AnyArrayContainsIgnoreCase ¶ added in v0.1.2
AnyArrayContainsIgnoreCase 检查目标字符串切片 s 中是否存在任意一个字符串,忽略大小写地包含任意一个待匹配字符串 strs 参数 s: 源字符串切片 参数 strs: 可变参数,待匹配的一个或多个子字符串 返回值: 只要 s 中有一个字符串包含任意一个 strs 中的子字符串(忽略大小写),返回 true;否则返回 false
func AnyContainsIgnoreCase ¶ added in v0.1.2
func ArrayIntContains ¶ added in v0.1.1
func BoolToString ¶
func CalculateMD5 ¶
CalculateMD5 计算字节数组的MD5哈希值(自动分块处理)
func CalculateMD5WithChunkSize ¶
CalculateMD5WithChunkSize 支持自定义分块大小的MD5计算 适合处理超大字节数组,避免一次性加载全部数据
func ContainsAny ¶
func ContainsAnyIgnoreCase ¶
func CreateDirIfNoExists ¶ added in v0.0.2
func CreateFileIfNoExists ¶ added in v0.1.2
func DecodeFileBase64 ¶
DecodeBase64 解码base64字符串为字节数组
func DecryptByCBC ¶
DecryptByCBC AES-256-CBC 解密实现
func DeduplicateIds ¶
func EncryptByCBC ¶
EncryptByCBC AES-256-CBC 加密实现
func EqualsAnyIgnoreCase ¶
func ExistsFile ¶ added in v0.0.2
ExistsFile 判断指定路径是否为**存在的文件**(非目录、非不存在) 返回值:true=文件存在;false=文件不存在/是目录/其他错误
func ExtractEmails ¶ added in v0.1.2
func FormatDate ¶
func FormatMail ¶ added in v0.1.2
func FormatTime ¶
func GenerateQrcode ¶
func GenerateQrcode(content string, writeCloser io.WriteCloser, opts ...standard.ImageOption) error
func GenerateRandomNum ¶
func GenerateRandomString ¶
GenerateRandomString 生成指定长度的随机字符串 length: 字符串长度 charset: 字符集,如果为空则使用默认的字母数字字符集
func GetCachePath ¶
func GetDomainFromHost ¶
func GetDomainFromURL ¶
func GetEnvBool ¶ added in v0.1.2
func GetEnvBoolOrDefault ¶ added in v0.1.2
func GetEnvIntOrDefault ¶ added in v0.1.2
func GetEnvOrDefault ¶ added in v0.1.2
func GetNowTime ¶
func GetStructFullName ¶ added in v0.1.2
func GetStructName ¶ added in v0.1.2
func IsImagePath ¶ added in v0.1.2
IsImageByURL 通过URL路径判断是否为图片 参数:rawURL 原始URL字符串(如"https://example.com/photo.jpg?width=100") 返回:bool(是否为图片)、error(URL解析错误)
func IsMatchPath ¶
func IsNotBlank ¶
func JoinValues ¶ added in v0.0.4
func JsonEncode ¶ added in v0.1.2
func Millisecond ¶
func Millisecond() uint32
func NowDateFormatTime ¶ added in v0.1.2
func NowDateTime ¶
func NowDateTime() string
func Number2String ¶
func ParseFormatTime ¶ added in v0.1.2
func ParseTemplate ¶ added in v0.1.1
func ReadFileBytes ¶
func RemoveDuplicates ¶
func ReplaceAllRegex ¶
func Second2Base62 ¶
func Second2Base62() string
func SplitAndDeduplicate ¶
func StartsWithAnyIgnoreCase ¶ added in v0.0.4
func StringToBool ¶
func StringToInt ¶
func StringToUInt ¶
func StringToUintIds ¶
func SubStringAndPadSpace ¶ added in v0.1.2
SubStringAndPadSpace 截取字符串到指定长度,若原字符串长度不足则右侧补空格 参数:
value - 原始字符串 length - 目标字符串长度
返回值:
截取/填充后的指定长度字符串
func WithRoundedSquareShape ¶
func WithRoundedSquareShape() standard.ImageOption
func WriteBase64File ¶
func WriteBytesFilePath ¶ added in v0.0.2
Types ¶
type BufferWriteCloser ¶ added in v0.0.3
type BufferWriteCloser struct {
// contains filtered or unexported fields
}
func CreateBufferWriteCloser ¶ added in v0.0.3
func CreateBufferWriteCloser() *BufferWriteCloser
func (*BufferWriteCloser) Bytes ¶ added in v0.0.3
func (w *BufferWriteCloser) Bytes() []byte
func (*BufferWriteCloser) Close ¶ added in v0.0.3
func (w *BufferWriteCloser) Close() error
type File ¶ added in v0.0.2
type File struct {
// contains filtered or unexported fields
}
func GetRootPath ¶ added in v0.0.2
func (*File) OpenAppendOrCreate ¶ added in v0.0.2
func (*File) OpenAppendWrite ¶ added in v0.0.2
func (*File) OpenOrCreate ¶ added in v0.0.2
func (*File) ParentFile ¶ added in v0.0.2
func (*File) WriteAppendBytes ¶ added in v0.0.2
func (*File) WriteBytes ¶ added in v0.0.2
type ShapeRoundedSquare ¶
func (*ShapeRoundedSquare) Draw ¶
func (s *ShapeRoundedSquare) Draw(ctx *standard.DrawContext)
func (*ShapeRoundedSquare) DrawFinder ¶
func (s *ShapeRoundedSquare) DrawFinder(ctx *standard.DrawContext)