unsorted

package
v1.11.26 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPort is unused
	DefaultPort = 6666
)

Variables

This section is empty.

Functions

func CloneMap added in v1.7.33

func CloneMap(m map[string]interface{}) map[string]interface{}

CloneMap do the clone on map[string]interface{}

func CopySlice added in v1.7.33

func CopySlice(s interface{}) interface{}

CopySlice do a generic copy from slice to new slice.

func DecodeURIComponent added in v1.7.33

func DecodeURIComponent(encoded string) (string, error)

DecodeURIComponent reverts the working by EncodeURIComponent

func EncodeURIComponent added in v1.7.33

func EncodeURIComponent(rawString string) string

EncodeURIComponent convert 'a b/c' -> 'a+b%2fc' origin := "äöüHel/lo world" encoded := EncodeURIComponent(origin) fmt.Println(encoded)

s, _ := DecodeUriCompontent(encoded) fmt.Println(s)

func HostToIP added in v1.7.33

func HostToIP(host string) string

HostToIP would parse string and transform host to ip addresses.

The valid formats are:

host[:port],
scheme://host[:port]/path,

func IsSlice added in v1.7.33

func IsSlice(v interface{}) bool

IsSlice test the type of 'v' if it is golang Slice.

func IsV4 added in v1.7.33

func IsV4(ip net.IP) bool

IsV4 test ip if it's IPv4

func IsV6 added in v1.7.33

func IsV6(ip net.IP) bool

IsV6 test ip if it's IPv6

func LookupHostInfo added in v1.7.33

func LookupHostInfo(ipv6Prefer, ipv4Prefer bool) (ip net.IP, port int, err error)

LookupHostInfo scans the network adapters on local machine, finds all available IPs

func LookupHostInfoOld added in v1.7.33

func LookupHostInfoOld() (net.IP, int, error)

LookupHostInfoOld 依据配置文件的 server.rpc_address 尝试解释正确的rpc地址,通常是IPv4的

func MergeMap added in v1.7.33

func MergeMap(maps ...map[string]interface{}) map[string]interface{}

MergeMap do the recursive merge on a map[string]interface{}

func MergeSlice added in v1.7.33

func MergeSlice(target interface{}, source interface{}) interface{}

MergeSlice do a merging on generic slice type.

func Pollard added in v1.7.33

func Pollard(in interface{}) interface{}

Pollard 转换一个泛型对象中的全部 map[interface{}]interface{} 子对象为 map[string]interface{} 在转换完毕之后,新的返回对象将能够正确地被json编码: text = `age: 12 name: joe` obj, err := yaml.Unmarshal(text) b, err := json.Marshal(Pollard(obj))

典型的用途在于将 golang 对象直接json输出时

func PollardArray added in v1.7.33

func PollardArray(in []interface{}) interface{}

PollardArray converts 'in' to new return object A.

func ThisHost added in v1.7.33

func ThisHost() (ip net.IP)

ThisHost 返回当前服务器的LAN ip,通过本机名进行反向解析

func ThisHostname added in v1.7.33

func ThisHostname() string

ThisHostname 返回本机名

func URLEncodedSimple added in v1.7.33

func URLEncodedSimple(str string) (string, error)

URLEncodedSimple encodes a string like Javascript's encodeURIComponent() Example: Turns "My String" to "My%20String"

Types

type Copier added in v1.7.33

type Copier interface {
	SetIgnoreNames(ignoreNames ...string) Copier
	Copy(maps ...map[string]interface{}) (result map[string]interface{}, err error)
}

Copier for deep-clone

type DiskStatus

type DiskStatus struct {
	All  uint64 `json:"all"`
	Used uint64 `json:"used"`
	Free uint64 `json:"free"`
}

DiskStatus provides the disk usages

func DiskUsage

func DiskUsage(path string) (disk *DiskStatus)

DiskUsage is for disk usage of path/disk

type EscapeError added in v1.7.33

type EscapeError string

EscapeError is an error type

func (EscapeError) Error added in v1.7.33

func (e EscapeError) Error() string

Jump to

Keyboard shortcuts

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