Skip to content

Instantly share code, notes, and snippets.

@Casxt
Last active July 11, 2018 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Casxt/b4f233e9d7d78d2a83ac4615bcd12ea5 to your computer and use it in GitHub Desktop.
Save Casxt/b4f233e9d7d78d2a83ac4615bcd12ea5 to your computer and use it in GitHub Desktop.
[Golang]从req.RemoteAddr中提取IP || Match IP from RemoteAddr
func route(res http.ResponseWriter, req *http.Request) {
path := req.URL.Path
log.Println(req.RemoteAddr[0:strings.LastIndex(req.RemoteAddr, ":")], req.Method, path)
}
//OutPut: 2018/07/11 14:54:35 [::1] GET /favicon.ic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment