Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "net/http"
- "time"
- "fmt"
- )
- func main() {
- http.HandleFunc("/hello", hello)
- http.ListenAndServe(":8080", nil)
- }
- func hello(w http.ResponseWriter, r *http.Request) {
- s := time.Now()
- fmt.Println("Start: ", s)
- time.Sleep(15 * time.Second)
- w.Write([]byte("hello!"))
- e := time.Now()
- fmt.Println("Stop: ", e)
- }
- /* Output for the request run at same time
- Start: 2016-01-08 18:20:23.205378808 +0100 CET
- Stop: 2016-01-08 18:20:38.208704065 +0100 CET
- Start: 2016-01-08 18:20:38.210874469 +0100 CET
- Stop: 2016-01-08 18:20:53.21145758 +0100 CET
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement