utils

package
v0.0.0-...-3f5828c Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryToHex

func BinaryToHex(bin string) (hex string, err error)

二进制 转换成 十六进制

func BinaryToString

func BinaryToString(bin string) (string, error)

二进制 转换成 字符串

func ClientIP

func ClientIP(r *http.Request) string

获取客户端 IP

func ClientPublicIP

func ClientPublicIP(r *http.Request) string

获取客户端公网 IP

func FillWidth

func FillWidth(str string, width int) string

数据前位 0 补足到指定宽度的倍数

func HasLocalIP

func HasLocalIP(ip net.IP) bool

检测 IP 地址是否是内网地址

func HasLocalIPAddr

func HasLocalIPAddr(ip string) bool

检测 IP 地址字符串是否是内网地址

func HexToBinary

func HexToBinary(hex string) (bin string, err error)

十六进制 转换成 二进制

func HexToString

func HexToString(str string) (string, error)

十六进制 转换成 字符串

func IP2Long

func IP2Long(ip net.IP) (uint, error)

把 net.IP 转为数值

func IPString2Long

func IPString2Long(ip string) (uint, error)

ip 字符串转为数值

func IsZero

func IsZero(v interface{}) bool

判断一个变量是否零值

func Long2IP

func Long2IP(i uint) (net.IP, error)

把数值转为 net.IP

func Long2IPString

func Long2IPString(i uint) (string, error)

把数值转为 ip 字符串

func NewTimeCounter

func NewTimeCounter() timeCounter

创建计时器容器

func RemoteIP

func RemoteIP(r *http.Request) string

通过 RemoteAddr 获取 IP 地址, 快速解析方法, 不一定准确

func ServerIp

func ServerIp() (ip string)

服务端 IP

func SetFieldValue

func SetFieldValue(binding interface{}, name string, value interface{}) error

为结构体的指定属性赋值

func StringToBinary

func StringToBinary(str string) (string, error)

字符串 转换成 二进制

func StringToHex

func StringToHex(str string) (bin string)

字符串 转换成 十六进制

func StructToStruct

func StructToStruct(binding interface{}, value interface{}) error

将 结构体 value 的值赋值给 结构体 binding

Types

This section is empty.

Jump to

Keyboard shortcuts

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