common_utils

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearNestedStruct added in v0.3.11

func ClearNestedStruct(s interface{}) interface{}

func Clone

func Clone(src interface{}) interface{}

Clone 浅克隆,可以克隆任意数据类型,对指针类型子元素无法克隆 获取类型:如果类型是指针类型,需要使用Elem()获取对象实际类型 获取实际值:如果值是指针类型,需要使用Elem()获取实际数据 说白了,Elem()就是获取反射数据的实际类型和实际值

func DeepClone

func DeepClone(src interface{}) interface{}

DeepClone 深度克隆,可以克隆任意数据类型

func DeepCopy

func DeepCopy(dst, src interface{}) error

DeepCopy 深度拷贝

func GenRandomStr

func GenRandomStr(length int) string

GenRandomStr 生成随机字符串

func GenSalt

func GenSalt(length int) string

GenSalt 生成盐值

func GetFreePort

func GetFreePort() (int, error)

GetFreePort 获取本机空闲端口

func GetLocalIp

func GetLocalIp() string

GetLocalIp 获取本机IP(获取第一个网卡)

func GetLocalPriorityIp

func GetLocalPriorityIp(priorityNetWork []string) string

GetLocalPriorityIp 获取本机IP(根据规则优先选取IP)

func GetTypeByContentType

func GetTypeByContentType(contentType string) string

GetTypeByContentType 根据文件类型获取文件后缀

func ReadConfig added in v0.3.3

func ReadConfig(configStr string, out interface{})

ReadConfig 读取配置文件.将配置文件字符串加载至实例中

func RemoteIp

func RemoteIp(req *http.Request) string

RemoteIp 获取请求客户端IP

func SplitStringArray added in v0.4.2

func SplitStringArray(arr []string, length int) [][]string

func StructToMap

func StructToMap(obj interface{}, tagName string) map[string]interface{}

StructToMap 结构体转Map

Types

This section is empty.

Jump to

Keyboard shortcuts

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