Last active
July 11, 2018 06:59
-
-
Save Casxt/b4f233e9d7d78d2a83ac4615bcd12ea5 to your computer and use it in GitHub Desktop.
[Golang]从req.RemoteAddr中提取IP || Match IP from RemoteAddr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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