3
0
Fork 0
This repository has been archived on 2024-11-14. You can view files and clone it, but cannot push or open issues or pull requests.
ThemeParkPlus-Socket/command/public_ip.go
2022-08-12 21:08:47 +02:00

22 lines
No EOL
335 B
Go
Executable file

package command
import (
"io/ioutil"
"net/http"
)
func GetPublicIp() (str string, err error) {
url := "https://api.ipify.org?format=text"
resp, err := http.Get(url)
if err != nil {
return "", err
}
defer resp.Body.Close()
ip, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
return string(ip), nil
}