1 Star 0 Fork 0

孙立/eureka-client

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
util.go 425 Bytes
一键复制 编辑 原始数据 按行查看 历史
leisure 提交于 2019-06-11 16:27 . [UPDATE]api
package eureka_client
import (
"net"
)
// getLocalIP 获取本地ip
func getLocalIP() string {
addrs, err := net.InterfaceAddrs()
if err != nil {
return ""
}
for _, address := range addrs {
// check the address type and if it is not a loopback the display it
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
return ipnet.IP.String()
}
}
}
return ""
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/JackSun6/eureka-client.git
git@gitee.com:JackSun6/eureka-client.git
JackSun6
eureka-client
eureka-client
master

搜索帮助