Google App Engine Golang - how to get user's IP address?

ThePiachu picture ThePiachu · Jun 20, 2013 · Viewed 10k times · Source

I want to integrate ReCAPTCHA to my GAE Golang web application. In order to verify a captcha, I need to get user's IP address. How can I fetch user's IP address from a form post?

Answer

Aigars Matulis picture Aigars Matulis · Feb 6, 2014

Use net.SplitHostPort:

ip, _, _ := net.SplitHostPort(r.RemoteAddr)