Skip to content

Instantly share code, notes, and snippets.

@ariefrahmansyah
Created October 1, 2017 03:26
Show Gist options
  • Save ariefrahmansyah/803657a0049fc0aef891051ba13da20c to your computer and use it in GitHub Desktop.
Save ariefrahmansyah/803657a0049fc0aef891051ba13da20c to your computer and use it in GitHub Desktop.
Simple HTTP Server in Go Programming Language
package main
import (
"net/http"
"os"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
http.HandleFunc("/ping", ping)
http.ListenAndServe(":"+port, nil)
}
func ping(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("pong\n"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment