1
0
Fork 0
dns-updater/ip/resolver/decoder/myip.go

20 lines
318 B
Go

package decoder
import (
"encoding/json"
"io"
)
func MyIP(r io.Reader) ([]byte, error) {
var v struct {
Ip string `json:"ip"`
Country string `json:"country"`
Cc string `json:"cc"`
}
var val []byte
err := json.NewDecoder(r).Decode(&v)
if err == nil {
val = []byte(v.Ip)
}
return val, err
}