From b08a4a86c101cbf4e5320682b1d84d2996eab83a Mon Sep 17 00:00:00 2001 From: Max Lau Date: Fri, 20 Dec 2013 18:56:02 +0800 Subject: [PATCH] repaired the wrong IP when using in localhost (Mac os x) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit it returns “[“ when using beego in local host(Mac os x 10.9) , it appears that Request.remoAddr returns “[::1]:****” --- context/input.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/context/input.go b/context/input.go index 6c60e72c..e9fc5295 100644 --- a/context/input.go +++ b/context/input.go @@ -98,7 +98,9 @@ func (input *BeegoInput) IP() string { } ip := strings.Split(input.Request.RemoteAddr, ":") if len(ip) > 0 { - return ip[0] + if ip[0] != "["{ + return ip[0] + } } return "127.0.0.1" }