udemy-go-web-1/cmd/hello-world/main.go

19 lines
307 B
Go
Raw Normal View History

2024-06-26 15:30:39 +00:00
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
n, err := fmt.Fprintf(w, "Hello world")
if err != nil {
fmt.Println(err)
}
fmt.Printf("Number of bytes written: %d\n", n)
})
_ = http.ListenAndServe(":8080", nil)
}