xutils

package
v1.27.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	X_PI   = math.Pi * 3000.0 / 180.0
	OFFSET = 0.00669342162296594323
	AXIS   = 6378245.0
)

Variables

This section is empty.

Functions

func AesDecryptCBC added in v1.24.9

func AesDecryptCBC(encrypted []byte, key []byte) (decrypted []byte)

func AesEncryptCBC added in v1.24.9

func AesEncryptCBC(origData []byte, key []byte) (encrypted []byte)

func BD09toGCJ02

func BD09toGCJ02(lon, lat float64) (float64, float64)

BD09toGCJ02 百度坐标系->火星坐标系

func BD09toWGS84

func BD09toWGS84(lon, lat float64) (float64, float64)

BD09toWGS84 百度坐标系->WGS84坐标系

func Base64Decode

func Base64Decode(str string) (string, error)

func Base64Encode

func Base64Encode(str string) string

func Bytes2Mac

func Bytes2Mac(b []byte) string

func BytesToInt

func BytesToInt(b []byte) int64

func ClientIp

func ClientIp(r *http.Request) string

func Crc32

func Crc32(str string) uint32

Crc32 crc32()

func CreateExcel added in v1.23.2

func CreateExcel(filename string, data [][]string) error

func CreateExcelFileWithData added in v1.24.9

func CreateExcelFileWithData[T any](data [][]T) *excelize.File

CreateExcelFileWithData 生成*excelize.File

func CreateExcelFileWithHeader added in v1.24.9

func CreateExcelFileWithHeader(headers map[string]*ExcelHeader, rows []map[string]any) *excelize.File

CreateExcelFileWithHeader 生成*excelize.File,通过设置头部字段来实现,头部和数据进行分离

func CurrentAbPath

func CurrentAbPath() string

CurrentAbPath 获取当前程序运行的工作目录 兼容go run

func FileExists

func FileExists(filename string) bool

FileExists file_exists()

func FirstLower added in v1.25.9

func FirstLower(s string) string

FirstLower 字符串首字母小写

func FirstUpper added in v1.25.9

func FirstUpper(s string) string

FirstUpper 字符串首字母大写

func FormatStrJson

func FormatStrJson(b []byte) []byte

func GCJ02toBD09

func GCJ02toBD09(lon, lat float64) (float64, float64)

GCJ02toBD09 火星坐标系->百度坐标系

func GCJ02toWGS84

func GCJ02toWGS84(lon, lat float64) (float64, float64)

GCJ02toWGS84 火星坐标系->WGS84坐标系

func GetDistance

func GetDistance(lng1, lat1, lng2, lat2 float64) float64

GetDistance 计算两个经纬度之间的距离, 参考链接:https://blog.csdn.net/gatieme/article/details/45599581 在线经纬度换算:https://tools.fun/distance.html 返回单位为:米

func HS256 added in v1.26.6

func HS256(key, data []byte) string

func IntToBytes

func IntToBytes(i interface{}) []byte

func InternalIp

func InternalIp(in string) bool

InternalIp 判断是不是内网IP,仅支持IPv4

func Ip2Location

func Ip2Location(in string) string

func IsBuildRun

func IsBuildRun() bool

IsBuildRun 判断是否是build编译的文件

func IsJson

func IsJson(b []byte) bool

func IsLocalIp added in v1.20.5

func IsLocalIp(ip string) bool

IsLocalIp 判断是否是本机ip

func Md5

func Md5(str string) string

Md5 md5()

func Md5File

func Md5File(path string) (string, error)

Md5File md5_file()

func ParseMac

func ParseMac(mac string) []byte

func ParseTag

func ParseTag(tag string) map[string]any

func PasswordHash

func PasswordHash(password string) (string, error)

func PasswordVerify

func PasswordVerify(password, hash string) bool

func RandFloat

func RandFloat(min, max float64) float64

func RandInt

func RandInt(min, max int64) int64

func RandStr

func RandStr(length int) string

func RecoverGo

func RecoverGo(f func(), recoverHandler func(err interface{}))

func RedisLocker added in v1.22.1

func RedisLocker(client *xredis.Client, key string, retries int, interval, expiration time.Duration) *xredis.RedisLocker

func Request

func Request(r *http.Request) url.Values

func Round

func Round(val float64, p int32) float64

func ServerIP

func ServerIP() (ip net.IP)

func ServerMac

func ServerMac() string

ServerMac 获取本机的MAC地址

func Sha1

func Sha1(str string) string

Sha1 sha1()

func Sha1File

func Sha1File(path string) (string, error)

Sha1File sha1_file()

func StrArrayEmpty

func StrArrayEmpty(arr []string) bool

func UniqueInt64

func UniqueInt64(data []int64) []int64

func WGS84toBD09

func WGS84toBD09(lon, lat float64) (float64, float64)

WGS84toBD09 WGS84坐标系->百度坐标系

func WGS84toGCJ02

func WGS84toGCJ02(lon, lat float64) (float64, float64)

WGS84toGCJ02 WGS84坐标系->火星坐标系

Types

type ExcelHeader added in v1.24.9

type ExcelHeader struct {
	Index int
	Title string
}

Jump to

Keyboard shortcuts

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