Skip to content

Instantly share code, notes, and snippets.

@msdousti
Created May 4, 2025 15:25
Show Gist options
  • Save msdousti/c64b772f1c10c0f12e44e51fa2aa7c7f to your computer and use it in GitHub Desktop.
Save msdousti/c64b772f1c10c0f12e44e51fa2aa7c7f to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math/rand"
"net/http"
"time"
)
func hello(w http.ResponseWriter, req *http.Request) {
if rand.Float64() < 0.1 {
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
} else {
time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond)
fmt.Fprintf(w, "hello\n")
}
}
func main() {
http.HandleFunc("/", hello)
http.ListenAndServe(":8000", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment