Created
August 12, 2020 16:09
-
-
Save ErezYalon/da3a5dc84bf559653ad393f5bf5ad3b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "net/http" | |
import "fmt" | |
import "log" | |
var visistsCounter uint64 = 0; | |
func updateVisitsCounter () uint64 { | |
visistsCounter++ | |
return visistsCounter | |
} | |
func main () { | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
var counter uint64 = updateVisitsCounter() | |
fmt.Fprintf(w, "Hello, you're visitor #%d", counter) | |
}) | |
log.Fatal(http.ListenAndServe(":8080", nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment