mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
21 lines
310 B
Go
21 lines
310 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
)
|
|
|
|
func GetCurrentIP(url string) (string, error) {
|
|
response, err := http.Get(url)
|
|
defer response.Body.Close()
|
|
|
|
if err != nil {
|
|
fmt.Println("Cannot get IP...")
|
|
return "", err
|
|
}
|
|
|
|
body, _ := ioutil.ReadAll(response.Body)
|
|
return string(body), nil
|
|
}
|