1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 13:20:55 +00:00

repaired the wrong IP when using in localhost (Mac os x)

it returns “[“ when using beego in local host(Mac os x 10.9) , it
appears that Request.remoAddr returns “[::1]:****”
This commit is contained in:
Max Lau 2013-12-20 18:56:02 +08:00
parent 3f0e55de56
commit b08a4a86c1

View File

@ -98,7 +98,9 @@ func (input *BeegoInput) IP() string {
} }
ip := strings.Split(input.Request.RemoteAddr, ":") ip := strings.Split(input.Request.RemoteAddr, ":")
if len(ip) > 0 { if len(ip) > 0 {
return ip[0] if ip[0] != "["{
return ip[0]
}
} }
return "127.0.0.1" return "127.0.0.1"
} }