Documentation
¶
Index ¶
- Constants
- Variables
- func BoolToString(b bool) 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 ContainsNumberAny(s uint, strs ...uint) bool
- func DecodeFileBase64(base64Str string) ([]byte, error)
- func DeduplicateIds(ids string) string
- func EnsureDir(dirPath string) error
- func EqualsAnyIgnoreCase(s string, strs ...string) bool
- func ExtractEmails(text string) []string
- func FileExists(filePath string) bool
- func FormatDate(tm time.Time) string
- func FormatMail(name, mail string) string
- func FormatTime(tm time.Time) string
- func GenerateRandomString(length int, charset string) string
- func GetCachePath(rootPath, filename 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 IsBlank(str string) bool
- func IsMatchPath(path, smath string) bool
- func IsNotBlank(str string) bool
- func MD5(data []byte) string
- func MD5Str(data string) string
- func Millisecond() uint32
- func ParseMail(recipient string) (name string, mail string, err error)
- func ParseTemplate(templateStr string, bodyString string) (string, error)
- func ParserCron(cronStr string) error
- func RemoveDuplicates(nums []string) []string
- func ReplaceAllRegex(path, regex, math string) string
- func SplitAndDeduplicate(text, sep string) []string
- func SplitPath(path string) []string
- func StringToBool(s string) bool
- func StringToInt(s string) int
- func StringToUInt(s string) uint
- func StringToUintIds(ids string) []uint
- func ValidateURL(urlStr string) error
- func WriteBase64File(base64Str string, dst string) error
- func WriteFile(bytes []byte, dst string) error
- type Config
- func (cfg *Config) GetBooleanOrDefault(section, name string, defaultValue bool) bool
- func (cfg *Config) GetInt(section, name string) (int, error)
- func (cfg *Config) GetInt64OrDefault(section, name string, defaultValue int64) int64
- func (cfg *Config) GetIntOrDefault(section, name string, defaultValue int) int
- func (cfg *Config) GetString(section, name string) string
- func (cfg *Config) GetStringOrDefault(section, name string, defaultValue string) string
- func (cfg *Config) Save() error
- func (cfg *Config) SetBoolean(section, key string, value bool) error
- func (cfg *Config) SetInt(section, key string, value int) error
- func (cfg *Config) SetString(section, key string, value string) error
- type Request
- func (r *Request) Call(link string, jsonData []byte) ([]byte, error)
- func (r *Request) CallApi(link string, header map[string]string, method string, body []byte) ([]byte, error)
- func (r *Request) CallApiForResponse(link string, header map[string]string, method string, body []byte) (*Response, error)
- func (r *Request) CallBreak(link string, jsonData []byte) ([]byte, error)
- func (r *Request) Get(link string) ([]byte, error)
- func (r *Request) JustCall(link string, jsonData []byte) error
- type Response
- type RetryTransport
Constants ¶
View Source
const ( // Alphanumeric 包含大小写字母和数字 Alphanumeric = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" // Lowercase 仅包含小写字母 Lowercase = "abcdefghijklmnopqrstuvwxyz" // Uppercase 仅包含大写字母 Uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // Numeric 仅包含数字 Numeric = "0123456789" // WithSpecialChars 包含字母、数字和常见特殊字符 WithSpecialChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()" )
预设字符集
View Source
const DefaultChunkSize = 4096 // 4KB
DefaultChunkSize 常用分块大小:4KB,与大多数操作系统页大小一致
Variables ¶
View Source
var DateFormat = "2006-01-02"
View Source
var TimestampFormat = "2006-01-02 15:04:05"
Functions ¶
func BoolToString ¶
func CalculateMD5 ¶
CalculateMD5 计算字节数组的MD5哈希值(自动分块处理)
func CalculateMD5WithChunkSize ¶
CalculateMD5WithChunkSize 支持自定义分块大小的MD5计算 适合处理超大字节数组,避免一次性加载全部数据
func ContainsAny ¶
func ContainsAnyIgnoreCase ¶
func ContainsNumberAny ¶
func DecodeFileBase64 ¶
DecodeBase64 解码base64字符串为字节数组
func DeduplicateIds ¶
func EqualsAnyIgnoreCase ¶
func ExtractEmails ¶
func FileExists ¶
func FormatDate ¶
func FormatMail ¶
func FormatTime ¶
func GenerateRandomString ¶
GenerateRandomString 生成指定长度的随机字符串 length: 字符串长度 charset: 字符集,如果为空则使用默认的字母数字字符集
func GetCachePath ¶
func GetEnvBool ¶ added in v0.2.9
func GetEnvBoolOrDefault ¶ added in v0.2.9
func GetEnvIntOrDefault ¶ added in v0.2.9
func GetEnvOrDefault ¶ added in v0.2.9
func IsMatchPath ¶
func IsNotBlank ¶
func Millisecond ¶
func Millisecond() uint32
func ParserCron ¶
func RemoveDuplicates ¶
func ReplaceAllRegex ¶
func SplitAndDeduplicate ¶
func StringToBool ¶ added in v0.2.9
func StringToInt ¶ added in v0.2.9
func StringToUInt ¶ added in v0.2.9
func StringToUintIds ¶
func ValidateURL ¶
func WriteBase64File ¶
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func (*Config) GetBooleanOrDefault ¶
func (*Config) GetInt64OrDefault ¶
func (*Config) GetIntOrDefault ¶
func (*Config) GetStringOrDefault ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func NewRequest() *Request
func (*Request) CallApiForResponse ¶
type RetryTransport ¶
type RetryTransport struct {
Transport http.RoundTripper
Retries int
}
Click to show internal directories.
Click to hide internal directories.