22 lines
284 B
Go
22 lines
284 B
Go
package netx
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
func GetPublicIp() string {
|
|
req, err := http.Get("http://ip.thuanle.me")
|
|
if err != nil {
|
|
return err.Error()
|
|
}
|
|
defer req.Body.Close()
|
|
|
|
body, err := io.ReadAll(req.Body)
|
|
if err != nil {
|
|
return err.Error()
|
|
}
|
|
|
|
return string(body)
|
|
}
|