packagecommonimport("fmt""net""runtime/debug""hilo-userCenter/common/mylogrus")funcCheckGoPanic(){ifr:=recover();r!=nil{//打印错误堆栈信息mylogrus.MyLog.Errorf("ACTION PANIC: %v, stack: %v",r,string(debug.Stack()))}}// 获取内网地址funcGetClientIpV2()(string,error){addrs,err:=net.InterfaceAddrs()iferr!=nil{return"",err}for_,address:=rangeaddrs{// 检查ip地址判断是否回环地址ifipNet,ok:=address.(*net.IPNet);ok&&ipNet.IP.IsGlobalUnicast(){//if ipNet, ok := address.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {ifipNet.IP.To4()!=nil{returnipNet.IP.String(),nil}}}return"",fmt.Errorf("can not find the client ip address")}