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