Documentation
¶
Overview ¶
Used for print everything as json.Marshal Created by simplejia 9/2016
Index ¶
- Variables
- func Get(gpp *GPP) (body []byte, err error)
- func Hash33(src string) int
- func Iprint(a ...interface{}) string
- func IprintD(a ...interface{})
- func IsInnerIp(src_ip string) bool
- func ListenAndServe(addr string, handler http.Handler) error
- func Post(gpp *GPP) (body []byte, err error)
- func RemoveAnnotation(src []byte) []byte
- func Slice2Interface(slice interface{}) (ret []interface{})
- type GPP
- type Server
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GRACEFUL_ENV = "GRACEFUL=true"
View Source
var LocalIp = func() string { ifaces, err := net.Interfaces() if err != nil { log.Println("utils.LocalIp error:", err) return "" } for _, iface := range ifaces { if iface.Flags&net.FlagUp == 0 { continue } if iface.Flags&net.FlagLoopback != 0 { continue } addrs, err := iface.Addrs() if err != nil { log.Println("utils.LocalIp error:", err) return "" } for _, addr := range addrs { var ip net.IP switch v := addr.(type) { case *net.IPNet: ip = v.IP case *net.IPAddr: ip = v.IP } if ip == nil || ip.IsLoopback() { continue } ip = ip.To4() if ip == nil { continue } if IsInnerIp(ip.String()) { return ip.String() } } } log.Println("utils.LocalIp failed!") return "" }()
Functions ¶
func IprintD ¶
func IprintD(a ...interface{})
Example ¶
package main import "time" type P struct { I int } type C struct { P J string T time.Time M map[int]*P } func main() { var v interface{} IprintD(v) v = 1 IprintD(v) v = "str" IprintD(v) v = &P{I: 1} IprintD(v) v = &C{P: P{I: 1}, J: "a", M: map[int]*P{1: &P{I: 2}}} IprintD(v) v = map[string]int{"a": 1} IprintD(v) v = map[int]int{1: 2} IprintD(v) v = map[interface{}]int{1: 2} IprintD(v) i := 1 v = map[*int]int{&i: 2} IprintD(v) v = map[int]*C{1: &C{P: P{I: 1}, J: "a", M: map[int]*P{1: &P{I: 2}}}} IprintD(v) }
Output: null 1 "str" { "I": 1 } { "J": "a", "M": { "1": { "I": 2 } }, "P": { "I": 1 }, "T": "0001-01-01T00:00:00Z" } { "a": 1 } { "1": 2 } { "1": 2 } { "1": 2 } { "1": { "J": "a", "M": { "1": { "I": 2 } }, "P": { "I": 1 }, "T": "0001-01-01T00:00:00Z" } }
func RemoveAnnotation ¶
func Slice2Interface ¶
func Slice2Interface(slice interface{}) (ret []interface{})
Types ¶
Click to show internal directories.
Click to hide internal directories.