0
4
llucycodes42
The code declares a package named main and imports the fmt and net/http packages. Next, the function greet is created and it takes two arguments, w and r. The first argument, w, is used to write to and the second argument, r, is used to write to. The function prints "Hello World! 9:21" to the console.
Shortcut: helloweb
package main
import (
"fmt"
"net/http"
"time"
)
func greet(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World! %s", time.Now())
}
func main() {
http.HandleFunc("/", greet)
http.ListenAndServe(":8080", nil)
}