Documentation
¶
Index ¶
- Constants
- func BlankIf(in, defaultValue string) (out string)
- func CloneMap(m map[string]interface{}) map[string]interface{}
- func CopySlice(s interface{}) interface{}
- func DecodeUriCompontent(encoded string) (string, error)
- func DecodeZigZagInt(b []byte) (r int64, ate int)
- func DecodeZigZagUint(b []byte) (r uint64, ate int)
- func EncodeUriComponent(rawString string) string
- func FileExists(name string) bool
- func FindService(what string)
- func GetCurrentDir() string
- func GetExcutableDir() string
- func HostToIp(host string) string
- func IncGrpcListen(prefix string) (listen string, port int)
- func IncPort() int
- func IncPortAndAddr(prefix string) (addr string)
- func Int64SecondsToTime(utcTimeSeconds int64) (tm time.Time)
- func Int64ToTime(utcTime int64) (tm time.Time)
- func Int64ToTimestamp(utcTime int64) (ts *timestamp.Timestamp)
- 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 IsSlice(v interface{}) bool
- func IsV4(ip net.IP) bool
- func IsV6(ip net.IP) bool
- func LoadGRPCListenConfig(prefix string) (listen string, id string, disabled bool, port int)
- func LoadGRPCListenSpecialConfig(prefix, serviceName string) (listen string, id string, disabled bool, port int)
- func LoadHostDefinition(prefix string) (addr string)
- func LookupHostInfo(ipv6Prefer, ipv4Prefer bool) (ip net.IP, port int, err error)
- func LookupHostInfoOld() (net.IP, int, error)
- func LookupHostInfoOld2() (ip net.IP, port int, err error)
- func MergeMap(maps ...map[string]interface{}) map[string]interface{}
- func MergeSlice(target interface{}, source interface{}) interface{}
- func NullIf(in, defaultValue interface{}) (out interface{})
- func Pollard(in interface{}) interface{}
- func PollardArray(in []interface{}) interface{}
- func Port() int
- func PressAnyKeyToContinue(msg ...string) (input string)
- func PressEnterToContinue(msg ...string) (input string)
- func RandRandSeq() string
- func RandSeq(n int) string
- func RandSeqln(n int) string
- func String(length int) string
- func StringVariantLength(minLength, maxLength int) string
- func StringWithCharset(length int, charset string) string
- func ThisHost() (ip net.IP)
- func ThisHostname() string
- func TimeToTimestamp(tm time.Time) (ts *timestamp.Timestamp)
- func TimestampToTime(ts *timestamp.Timestamp) (tm time.Time)
- func UrlEncodedSimple(str string) (string, error)
- func ZeroIf(in, defaultValue uint64) (out uint64)
- func ZeroIfAny(in, defaultValue interface{}) (out interface{})
- type Copier
- type DiskStatus
- type EscapeError
Constants ¶
const (
DEFAULT_PORT = 6666
)
const (
DefaultNilTimeNano = -6795364578871345152 // =DefaultNilTime
)
Variables ¶
This section is empty.
Functions ¶
func DecodeUriCompontent ¶
func DecodeZigZagInt ¶
DecodeZigZagInt 解码 protobuffer 的变长整数(int8,int16,int32,int64)
func DecodeZigZagUint ¶
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 FileExists ¶
FileExists returns true if the file `name` was existed.
func GetCurrentDir ¶
func GetCurrentDir() string
GetCurrentDir returns the current os working directory pathname.
func GetExcutableDir ¶
func GetExcutableDir() string
GetExcutableDir returns this executable file pathname
func HostToIp ¶
HostToIp would parse string and transform host to ip addresses.
The valid formats are:
host[:port], scheme://host[:port]/path,
func IncGrpcListen ¶
IncGrpcListen for grpc server
func IncPortAndAddr ¶
func Int64SecondsToTime ¶
func Int64ToTimestamp ¶
func IsCancelled ¶
func IsCancelledOrDeadline ¶
func IsDeadline ¶
func LoadGRPCListenConfig ¶
LoadGRPCListenConfig loads config info of MAIN grpc service Generally, it loads a map from `prefix` (such as "server.grpc.<service-name>") and extract sub-keys: "listen", "id", "disabled"
func LoadGRPCListenSpecialConfig ¶
func LoadGRPCListenSpecialConfig(prefix, serviceName string) (listen string, id string, disabled bool, port int)
LoadGRPCListenConfig loads config info from `prefix`.`serviceName`
func LoadHostDefinition ¶
LoadHostDefinition loads the dependence info from config entry `server.deps.xxx` LoadHostDefinition("server.deps.apply")
func LookupHostInfo ¶
func LookupHostInfoOld ¶
LookupHostInfoOld 依据配置文件的 server.rpc_address 尝试解释正确的rpc地址,通常是IPv4的
func MergeSlice ¶
func MergeSlice(target interface{}, source interface{}) interface{}
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 PressAnyKeyToContinue ¶
func PressEnterToContinue ¶
func RandRandSeq ¶
func RandRandSeq() string
RandRandSeq returns a random string with random length (1..127)
func RandSeqln ¶
RandSeqln returns a random string with specified length 'n', and it has a '\n' character tail.
func StringVariantLength ¶
String returns a random string with length specified
func StringWithCharset ¶
StringWithCharset generate random string
func UrlEncodedSimple ¶
UrlEncoded encodes a string like Javascript's encodeURIComponent() Example: Turns "My String" to "My%20String"
Types ¶
type DiskStatus ¶
type EscapeError ¶
type EscapeError string
func (EscapeError) Error ¶
func (e EscapeError) Error() string