Skip to content

Instantly share code, notes, and snippets.

@nictuku
Created February 6, 2018 01:22
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 nictuku/47297939ba47ac1c84d9f4b502edf654 to your computer and use it in GitHub Desktop.
Save nictuku/47297939ba47ac1c84d9f4b502edf654 to your computer and use it in GitHub Desktop.
Example Golang HTTP Server
package main
import (
"fmt"
"log"
"net/http"
)
type helloWorldHandler struct{}
func (h helloWorldHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World")
}
func main() {
err := http.ListenAndServe(":8080", helloWorldHandler{})
log.Fatal("HelloWorld ListenAndServe error", err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment