Por que esse servidor Web simples é chamado número par vezes?
Estou tentando aprender a programação da Web Go, e aqui está um servidor Web simples: ele imprime os horários que estão sendo chamados.
package main
import (
"fmt"
"net/http"
)
var calls int
// HelloWorld print the times being called.
func HelloWorld(w http.ResponseWriter, r *http.Request){
calls++
fmt.Fprintf(w, "You've called me %d times", calls)
}
func main() {
fmt.Printf("Started server at http://localhost%v.\n", 5000)
http.HandleFunc("/", HelloWorld)
http.ListenAndServe(":5000", nil)
}
Quando atualizo a página, recebi:
You've called me 1 times
You've called me 3 times
You've called me 5 times
....
Pergunta: Por que é 1, 3, 5 vezes, e não 1,2,3 ...? Qual é a ordem da funçãoHelloWorld
sendo chamado?