github.com/mattevans/edward@v1.9.2/examples/env/envcheck/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "log" 6 "net/http" 7 "os" 8 ) 9 10 func handler(w http.ResponseWriter, r *http.Request) { 11 fmt.Fprintf(w, "Hello: %s!", r.URL.Path[1:]) 12 } 13 14 func main() { 15 if len(os.Getenv("MUST_SET")) == 0 { 16 panic("MUST_SET was not set") 17 } 18 19 http.HandleFunc("/", handler) 20 fmt.Println("Starting to listen on port 51936") 21 err := http.ListenAndServe(":51936", nil) 22 if err != nil { 23 log.Fatal(err) 24 } 25 }