Skip to content

Instantly share code, notes, and snippets.

@yuriatgoogle
Created January 7, 2020 19:17
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 yuriatgoogle/61c8e3378b8e930ff93770a787f5f200 to your computer and use it in GitHub Desktop.
Save yuriatgoogle/61c8e3378b8e930ff93770a787f5f200 to your computer and use it in GitHub Desktop.
func main() {
r := mux.NewRouter()
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
rand.Seed(time.Now().UnixNano())
n := rand.Intn(10) // n will be between 0 and 10
fmt.Printf("randon number was %d\n", n)
if n < 6 {
http.Error(w, "error!", 500)
} else {
fmt.Fprintf(w, "Hello World!")
}
})
http.ListenAndServe(":8080", r)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment