Skip to content

Instantly share code, notes, and snippets.

@monkrus
Created January 11, 2020 03:54
Show Gist options
  • Select an option

  • Save monkrus/a32d0becfb9c4a9c195688d29ce13857 to your computer and use it in GitHub Desktop.

Select an option

Save monkrus/a32d0becfb9c4a9c195688d29ce13857 to your computer and use it in GitHub Desktop.
Steps to set HTTP services in Go
package main
import (
"fmt"
"net/http"
)
func main() {
//step 2
http.HandleFunc("/", foo)
//step 1
http.ListenAndServe(":8080", nil)
}
//step 3
func foo(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello from foo")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment