Hello world

This commit is contained in:
Muyao CHEN 2024-06-26 17:30:39 +02:00
commit 54d1f91e7e
2 changed files with 21 additions and 0 deletions

18
cmd/hello-world/main.go Normal file
View File

@ -0,0 +1,18 @@
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)
}

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module go-udemy-web-1
go 1.21.0