Documentation
¶
Index ¶
- Variables
- func AesDecECBString(ciphertext []byte, key []byte) (string, error)
- func AesDecrypt(decryptStr string, key []byte, iv []byte) (string, error)
- func AesEncECBString(plaintext []byte, key []byte) ([]byte, error)
- func AesEncrypt(encryptStr string, key []byte, iv []byte) (string, error)
- func Base64DecodeString(text, tp string) (string, error)
- func Base64EncodeString(text []byte, tp string) string
- func CheckPhoneNumber(phoneNumber string) bool
- func ConnectSftp(user, password, host string, port int) (*sftp.Client, error)
- func ContainUpperLowerNumberSpecial(str string, num int) bool
- func ConvertTo[T any](value any) (T, error)
- func ConvertToWithDefault[T any](value any, defaultValue T) T
- func DynamicGetStructField(s any, fieldPath string, capitalizeFirst bool) (any, error)
- func DynamicGetStructFieldByList(s any, fieldNames []string, capitalizeFirst bool) (any, error)
- func DynamicUpdateStructField(s any, fieldName string, newValue interface{}) error
- func EndPadByte(data []byte, pad string, size int) []byte
- func EndPadString(text, pad string, size int) string
- func FirstNonZero[T comparable](values ...T) T
- func FirstNonZeroByAny(values ...any) any
- func FormatAndSortJSON(jsonStr string) (string, error)
- func FormatDurationFromMilliseconds(ms int64) string
- func GetClientIp(c *fasthttp.RequestCtx) string
- func GetFormatTimeByTimestamp(ts int64) string
- func GetTimeByTimestamp(ts int64) string
- func GetTimestampByStr(datetime string) int64
- func GlobDir(dir string, fileList *FileListTmp) error
- func HasKeyBoardContinuousChar(pwd string, keyBoardSize int, dictionary string) bool
- func Includes[S ~[]E, E comparable](strArr S, subStr E) bool
- func IncludesAny(arr []any, s any) bool
- func InterfaceToJson(i any) (string, error)
- func IsDigit(text string) bool
- func IsEmpty(v any) bool
- func IsEmpty2(v any) bool
- func IsValidIP(ip string) bool
- func IsZero[T comparable](v T) bool
- func JSFilter[T any](s []T, f func(int, T) bool) []T
- func JSMap[T any, R any](s []T, f func(T) R) []R
- func Length(strs ...string) int
- func Md5Encode(text string) string
- func Nanoid(l int) string
- func NanoidAlphabet(l int, alphabets ...string) string
- func NanoidAlphabetType(alphabetType string, l int) string
- func ParseTime(layout, value string) (time.Time, error)
- func ParseTimeByTimestamp(ts int64) time.Time
- func PathExists(path string) (bool, error)
- func ReadLargeFileByLine(filename string, processFunc func(int, string, ...any) bool, options ...any) error
- func SendSftp(user, password, host string, port int, filename string, remoteFilePath string) (int, error)
- func SetNestedField(data interface{}, fieldName string, value string) error
- func Sha256Encode(context string) string
- func ShuffleString(text string) string
- func SortKeysRecursive(v interface{}) interface{}
- func StartPadString(text, pad string, size int) string
- func StringsConcat(strs ...string) string
- func StringsJoin(strs ...string) string
- func SubStrStr(s, substr string) string
- func Ternary[T any](condition bool, trueVal, falseVal T) T
- func TimeToObjectId(t time.Time) primitive.ObjectID
- func Ucs2Decode(hexStr string, endianness string) (string, error)
- func Ucs2Encode(str string, endianness string) (string, error)
- func UniqueByKey[T, E comparable](data []map[T]E, key T) []map[T]E
- func UploadFileToSftp(sftpClient *sftp.Client, localFilename string, remotePath string) (int, error)
- func ValidatePhoneNumber(tel string) bool
- type FileListTmp
- type SendSftpResult
- type StringBuilder
Constants ¶
This section is empty.
Variables ¶
var Timezone = "Asia/Shanghai"
var TimezoneLocation *time.Location
var TimezoneOffset = 8 * 3600 // 东八区的时间偏移量,单位为秒
Functions ¶
func AesDecECBString ¶ added in v0.0.20
AES-128-ECB 解密函数 pkcs5Padding
func AesDecrypt ¶
aes 解密 aes-128-cbc pkcs5Padding
func AesEncECBString ¶ added in v0.0.20
AES-128-ECB 加密函数 pkcs5Padding
func AesEncrypt ¶
aes 加密 aes-128-cbc pkcs5Padding
func Base64DecodeString ¶ added in v0.0.20
base64 decode
func Base64EncodeString ¶ added in v0.0.20
base64 encode
func ConnectSftp ¶
ConnectSftp 创建 SFTP 客户端连接 !!!! 即将废弃,请参考 gitee.com/aly1a/boat-go/module/sftp 包中的 SftpClient 结构体和相关方法
func ContainUpperLowerNumberSpecial ¶
检查是否包含大小写字母以及数字和特殊字符中的指定位数
func ConvertToWithDefault ¶ added in v0.2.4
ConvertToWithDefault 带默认值的转换
func DynamicGetStructField ¶ added in v0.2.4
DynamicGetStructField 获取结构体字段值(支持点号分隔的路径)
func DynamicGetStructFieldByList ¶ added in v0.2.4
DynamicGetStructFieldByList 按字段列表递归获取值
func DynamicUpdateStructField ¶ added in v0.2.4
DynamicUpdateStructField 动态修改结构体字段值
func FirstNonZero ¶ added in v0.0.20
func FirstNonZero[T comparable](values ...T) T
FirstNonZero 返回第一个非零值
func FirstNonZeroByAny ¶ added in v0.0.20
FirstNonZeroByAny 返回第一个非空值
func FormatAndSortJSON ¶ added in v0.0.20
FormatAndSortJSON 格式化并排序 JSON 字符串
func FormatDurationFromMilliseconds ¶ added in v0.2.0
格式时间从毫秒开始
func GetFormatTimeByTimestamp ¶ added in v0.2.4
通过时间戳获取格式化的时间字符串
func GetTimeByTimestamp ¶ added in v0.0.22
通过时间戳获取格式化的时间字符串
func GetTimestampByStr ¶ added in v0.0.22
格式化的时间字符串转时间戳
func HasKeyBoardContinuousChar ¶
键盘序检查
func IncludesAny ¶
inludes interface slices.Contains 不能比较 []any
func NanoidAlphabet ¶
NanoidAlphabet 使用自定义字母表生成随机字符串
func NanoidAlphabetType ¶
NanoidAlphabetType 使用类型化字母表生成随机字符串 alphabetType: "number,upperCase,lowerCase" 组合
func ReadLargeFileByLine ¶ added in v0.2.0
func ReadLargeFileByLine(filename string, processFunc func(int, string, ...any) bool, options ...any) error
ReadLargeFileByLine 按行读取文件
func SendSftp ¶
func SendSftp(user, password, host string, port int, filename string, remoteFilePath string) (int, error)
SendSftp 发送单个文件到 SFTP 服务器
func SetNestedField ¶ added in v0.2.0
SetNestedField 设置嵌套字段的值 data: 要设置字段值的数据结构,支持嵌套结构体 fieldName: 字段名,支持嵌套字段,用点号分隔(如 "field1.field2.field3") value: 要设置的值,字符串类型,会根据目标字段类型进行类型转换 返回值: 如果设置成功返回nil,如果发生错误返回error
func SortKeysRecursive ¶ added in v0.0.20
func SortKeysRecursive(v interface{}) interface{}
SortKeysRecursive 递归对 map 的 key 排序,并处理嵌套结构
func StartPadString ¶
StartPadString 向前补充字符串到指定长度
func StringsConcat ¶ added in v0.2.4
StringsConcat 高效字符串拼接(预分配内存)
func TimeToObjectId ¶ added in v0.2.0
time to mongodb object id
func Ucs2Decode ¶ added in v0.0.12
UCS2 解码
func Ucs2Encode ¶ added in v0.0.12
UCS2 编码
func UniqueByKey ¶ added in v0.0.20
func UniqueByKey[T, E comparable](data []map[T]E, key T) []map[T]E
对[]map[string]any进行去重
Types ¶
type FileListTmp ¶
type FileListTmp struct {
DirBase string
Files []string
Childs []*FileListTmp
}
FileListTmp 目录文件列表结构
type SendSftpResult ¶ added in v0.2.5
SendSftpResult SFTP 发送结果
type StringBuilder ¶ added in v0.2.5
type StringBuilder struct {
// contains filtered or unexported fields
}
StringBuilder 高性能字符串拼接器
func NewStringBuilder ¶ added in v0.2.4
func NewStringBuilder(initialCapacity int) *StringBuilder
NewStringBuilder 创建拼接器,可预分配容量
func (*StringBuilder) Append ¶ added in v0.2.5
func (sb *StringBuilder) Append(strs ...string) *StringBuilder
Append 追加字符串
func (*StringBuilder) AppendRune ¶ added in v0.2.5
func (sb *StringBuilder) AppendRune(r rune) *StringBuilder
AppendRune 追加单个字符
func (*StringBuilder) Reset ¶ added in v0.2.5
func (sb *StringBuilder) Reset() *StringBuilder
Reset 重置拼接器以便复用
func (*StringBuilder) String ¶ added in v0.2.5
func (sb *StringBuilder) String() string
String 获取最终结果