2013/2/19 minux <
minu...@gmail.com>:
> after unhexify the address to a byte slice and rearrange the byte order,
> just cast it to net.IP
> (make sure the length is 4 or 16 for IPv4 and IPv6, respectively)
Thanks =)! Last question - how can i rearrange byte order ? This is
nothing outputs on last Printf.
func main() {
var ip []uint8
b, err := hex.DecodeString("0101A8C0")
if err != nil {
return
}
fmt.Printf("%+v\n", b)
buf := bytes.NewBuffer(b)
err = binary.Read(buf, binary.LittleEndian, &ip)
if err != nil {
fmt.Println("binary.Read failed:", err)
}
fmt.Printf("%+v\n", ip)
2013/2/19 minux <
minu...@gmail.com>: