init code
This commit is contained in:
21
internal/utils/netx/ip.go
Normal file
21
internal/utils/netx/ip.go
Normal file
@@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user