Documentation
¶
Index ¶
- Constants
- func Decrypt(key []byte, ciphertext string) (string, error)
- func DistanceInMeters(lat1, lon1, lat2, lon2 float64) float64
- func Encrypt(key []byte, plaintext string) (string, error)
- func FormatFloat(num float64, decimal int) float64
- func GenerateRandomAlphanumeric(length int) string
- func GenerateRandomIndexes(max, count int) []int
- func GetRandomUnique[T any](arr []T, count int) ([]T, error)
- func Paginate[T any](page int32, pageSize int32, list []T) (total, totalPage int64, res []T)
- func ParseInt(s string) int64
- func ToSlice[T any](s any, split string) ([]T, error)
- func TruncateToTwoDecimal(num float64) float64
Constants ¶
View Source
const EarthRadiusMeters = 6371000.0
EarthRadiusMeters 地球平均半径(米)
Variables ¶
This section is empty.
Functions ¶
func DistanceInMeters ¶
DistanceInMeters 计算两个经纬度之间的距离(米)
func FormatFloat ¶
FormatFloat 格式化浮点数,保留decimal位小数
func GenerateRandomAlphanumeric ¶
GenerateRandomAlphanumeric 生成随机字母数字字符串
func GenerateRandomIndexes ¶
GenerateRandomIndexes 生成不重复的随机索引
func GetRandomUnique ¶
GetRandomUnique 从切片中随机获取count个元素(不重复)
func TruncateToTwoDecimal ¶
TruncateToTwoDecimal 保留两位浮点数小数(截断不四舍五入)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.