$ mkdir hello; cd hello/
Create and edit file hello_world.go
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
err := http.ListenAndServe(":8080", helloWorld())
if err != nil {
log.Fatal(err)
}
}
func helloWorld() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello world")
}
}
Compile and execute your command
$ go run .