I know how to get the user IP from the *http.Request
struct:
strings.Split(r.RemoteAddr, ":")[0]
And I know how to define a template.FuncMap
:
funcMap = template.FuncMap{
// gets the time since the post was posted
"since": func(t time.Time) string {
s := time.Since(t).String()
return strings.Replace(s[:strings.LastIndex(s, "m")+1], "h", "h ", 1)
},
}
How would I get the users IP from a template function defined in the template.FuncMap
?