Created
May 9, 2025 14:42
-
-
Save tedmax100/54e8b5a418411aad663db335ec033cd2 to your computer and use it in GitHub Desktop.
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" | |
| "io" | |
| "log" | |
| "net/http" | |
| ) | |
| // Greet sends a personalised greeting to writer. | |
| func Greet(writer io.Writer, name string) { | |
| fmt.Fprintf(writer, "Hello, %s", name) | |
| } | |
| // MyGreeterHandler says Hello, world over HTTP. | |
| func MyGreeterHandler(w http.ResponseWriter, r *http.Request) { | |
| Greet(w, "world") | |
| } | |
| func main() { | |
| log.Fatal(http.ListenAndServe(":5000", http.HandlerFunc(MyGreeterHandler))) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment