data

package
v2.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EarthRadiusMeters = 6371000.0

EarthRadiusMeters 地球平均半径(米)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(key []byte, ciphertext string) (string, error)

Decrypt 解密函数 - 使用AES-GCM模式

func DistanceInMeters

func DistanceInMeters(lat1, lon1, lat2, lon2 float64) float64

DistanceInMeters 计算两个经纬度之间的距离(米)

func Encrypt

func Encrypt(key []byte, plaintext string) (string, error)

Encrypt 加密函数 - 使用AES-GCM模式

func FormatFloat

func FormatFloat(num float64, decimal int) float64

FormatFloat 格式化浮点数,保留decimal位小数

func GenerateRandomAlphanumeric

func GenerateRandomAlphanumeric(length int) string

GenerateRandomAlphanumeric 生成随机字母数字字符串

func GenerateRandomIndexes

func GenerateRandomIndexes(max, count int) []int

GenerateRandomIndexes 生成不重复的随机索引

func GetRandomUnique

func GetRandomUnique[T any](arr []T, count int) ([]T, error)

GetRandomUnique 从切片中随机获取count个元素(不重复)

func Paginate

func Paginate[T any](page int32, pageSize int32, list []T) (total, totalPage int64, res []T)

Paginate 数据做分页

func ParseInt

func ParseInt(s string) int64

ParseInt 处理字符串,返回其整数部分,非数字则返回0

func ToSlice

func ToSlice[T any](s any, split string) ([]T, error)

ToSlice 字符串转切片,例如1,2,3转成[]T{1,2,3}

func TruncateToTwoDecimal

func TruncateToTwoDecimal(num float64) float64

TruncateToTwoDecimal 保留两位浮点数小数(截断不四舍五入)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL