Documentation ¶
Index ¶
- Constants
- func CloneMap(m map[string]interface{}) map[string]interface{}
- func CopySlice(s interface{}) interface{}
- func DecodeURIComponent(encoded string) (string, error)
- func EncodeURIComponent(rawString string) string
- func HostToIP(host string) string
- func IsSlice(v interface{}) bool
- func IsV4(ip net.IP) bool
- func IsV6(ip net.IP) bool
- func LookupHostInfo(ipv6Prefer, ipv4Prefer bool) (ip net.IP, port int, err error)
- func LookupHostInfoOld() (net.IP, int, error)
- func MergeMap(maps ...map[string]interface{}) map[string]interface{}
- func MergeSlice(target interface{}, source interface{}) interface{}
- func Pollard(in interface{}) interface{}
- func PollardArray(in []interface{}) interface{}
- func ThisHost() (ip net.IP)
- func ThisHostname() string
- func URLEncodedSimple(str string) (string, error)
- type Copier
- type DiskStatus
- type EscapeError
Constants ¶
const (
// DefaultPort is unused
DefaultPort = 6666
)
Variables ¶
This section is empty.
Functions ¶
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
DecodeURIComponent reverts the working by EncodeURIComponent
func EncodeURIComponent ¶ added in v1.7.33
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
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 LookupHostInfo ¶ added in v1.7.33
LookupHostInfo scans the network adapters on local machine, finds all available IPs
func LookupHostInfoOld ¶ added in v1.7.33
LookupHostInfoOld 依据配置文件的 server.rpc_address 尝试解释正确的rpc地址,通常是IPv4的
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 URLEncodedSimple ¶ added in v1.7.33
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