MCPcopy Create free account
hub / github.com/code-scan/Goal / IPinfo

Function IPinfo

Gconvert/ip.go:23–42  ·  view source on GitHub ↗
(ip string, token string)

Source from the content-addressed store, hash-verified

21}
22
23func IPinfo(ip string, token string) IPinfoResult {
24 var result IPinfoResult
25 http := Ghttp.Http{}
26 http.New("GET", fmt.Sprintf("https://ipinfo.io/%s/json", ip))
27 if token != "" {
28 http.SetHeader("Authorization", fmt.Sprintf("Bearer %s", token))
29 }
30 http.Execute()
31 defer http.Close()
32 ret, err := http.Byte()
33 if err != nil {
34 log.Println("[!] IPinfo Error: ", err)
35 return result
36 }
37 if err = json.Unmarshal(ret, &result); err != nil {
38 log.Println("[!] IPinfo Unmarshal Error: ", err)
39 }
40 return result
41
42}

Callers 1

TestConvertFunction · 0.92

Calls 5

NewMethod · 0.95
SetHeaderMethod · 0.95
ExecuteMethod · 0.95
CloseMethod · 0.95
ByteMethod · 0.95

Tested by 1

TestConvertFunction · 0.74