Documentation
¶
Index ¶
- Constants
- func DecodeUriCompontent(encoded string) (string, error)
- func EncodeUriComponent(rawString string) string
- func ExternalIP() (string, error)
- func FileExists(name string) bool
- func FindService(what string)
- func GetCurrentDir() string
- func GetExcutableDir() string
- func IncGrpcListen(prefix string) (listen string, port int)
- func IncPort() int
- func IncPortAndAddr(prefix string) (addr string)
- func Intv(s string) (v int)
- func IsCancelled(err error) (ret bool)
- func IsCancelledOrDeadline(err error) (ret bool)
- func IsDeadline(err error) (ret bool)
- func JsonToString(in interface{}, pretty bool) string
- func LoadGRPCListen(prefix string) (listen string, id string, disabled bool, port int)
- func LoadHostDefinition(prefix string) (addr string)
- func LookupHostInfo() (ip net.IP, port int, err error)
- func LookupHostInfoOld() (net.IP, int, error)
- func Pollard(in interface{}) interface{}
- func PollardArray(in []interface{}) interface{}
- func Port() int
- func RandRandSeq() string
- func RandSeq(n int) string
- func ThisHost() (ip net.IP)
- func ThisHostname() string
- func UnescapeUnicode(b []byte) string
- func UrlEncodedSimple(str string) (string, error)
- func YamlToString(in interface{}, pretty bool) string
- type DiskStatus
- type EscapeError
Constants ¶
const (
DEFAULT_PORT = 6666
)
Variables ¶
This section is empty.
Functions ¶
func DecodeUriCompontent ¶
func EncodeUriComponent ¶
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 ExternalIP ¶
ExternalIP try to find the internet public ip address. it works properly in aliyun network.
TODO only available to get IPv4 address.
ExternalIP 尝试获得LAN地址. 对于aliyun来说,由于eth0是LAN地址,因此此函数能够正确工作; 对于本机多网卡的情况,通常这个函数的结果是正确的;
func FileExists ¶
func GetCurrentDir ¶
func GetCurrentDir() string
func GetExcutableDir ¶
func GetExcutableDir() string
func IncGrpcListen ¶
func IncPortAndAddr ¶
func IsCancelled ¶
func IsCancelledOrDeadline ¶
func IsDeadline ¶
func JsonToString ¶
func LoadGRPCListen ¶
LoadGRPCListen("server.grpc.apply")
func LoadHostDefinition ¶
LoadHostDefinition loads the dependence info from config entry `server.deps.xxx` LoadHostDefinition("server.deps.apply")
func LookupHostInfoOld ¶
LookupHostInfoOld 依据配置文件的 server.rpc_address 尝试解释正确的rpc地址,通常是IPv4的
func Pollard ¶
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 ¶
func PollardArray(in []interface{}) interface{}
func RandRandSeq ¶
func RandRandSeq() string
func UnescapeUnicode ¶
UnescapeUnicode 解码 \uxxxx 为 unicode 字符; 但是输入的 b 应该是 yaml 格式
func UrlEncodedSimple ¶
UrlEncoded encodes a string like Javascript's encodeURIComponent() Example: Turns "My String" to "My%20String"
func YamlToString ¶
Types ¶
type DiskStatus ¶
type EscapeError ¶
type EscapeError string
func (EscapeError) Error ¶
func (e EscapeError) Error() string