Skip to content

Instantly share code, notes, and snippets.

@sahajre
Created August 1, 2019 07:56
Show Gist options
  • Save sahajre/8e05971323f43492dd98f3d0d485bbf0 to your computer and use it in GitHub Desktop.
Save sahajre/8e05971323f43492dd98f3d0d485bbf0 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", helloWorldHandler)
printInstructions()
log.Fatal(http.ListenAndServe("localhost:8080", nil))
}
func helloWorldHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, 世界")
}
func printInstructions() {
fmt.Println(`Visit http://localhost:8080 in the web browser to see "Hello, 世界"`)
fmt.Println(`After that Press control+c to stop the server`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment