Last active
November 8, 2015 01:01
-
-
Save wm/1bf55a659fedd83fe570 to your computer and use it in GitHub Desktop.
casting-vs-calling
This file contains hidden or 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
| http.Handle("/yolo2", http.HandlerFunc(Yolo)) |
This file contains hidden or 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
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| ) | |
| type Lol struct{} | |
| func (l *Lol) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintln(w, "LOL") | |
| } | |
| func main() { | |
| http.Handle("/lol", &Lol{}) | |
| http.ListenAndServe(":3000", nil) | |
| } |
This file contains hidden or 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
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| ) | |
| func Yolo(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintln(w, "YOLO") | |
| } | |
| func main() { | |
| http.Handle("/yolo2", http.HandlerFunc(Yolo)) | |
| http.ListenAndServe(":3000", nil) | |
| } |
This file contains hidden or 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
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| ) | |
| func Rofl(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintln(w, "ROFL") | |
| } | |
| func main() { | |
| http.HandleFunc("/yolo2", Yolo) | |
| http.ListenAndServe(":3000", nil) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment