For some reasons go encodes the string like bytes and I'm wondering if it's a go bug. See the code below:
ip, _, err := net.ParseCIDR(cidr)
if err!=nil{
log.Panicf("can't parse cidr %s, err was %v", cidr, err)
}
type Ip struct{
Ip string
}
ips := string(ip)
j:= Ip{
Ip: ips,
}
b, err := json.Marshal(j)
if err != nil {
log.Printf("error:", err)
}
fmt.Fprintln(w, string(b))
It prints:
{"Ip":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\ufffd\ufffd\ufffd\ufffd\u0007+"}
I'm running Go from epel repository ( redhat ). I also made a snippet which returns similar results.