commit 54d1f91e7e260442dbcc151952dd58a689c600be Author: Muyao CHEN Date: Wed Jun 26 17:30:39 2024 +0200 Hello world diff --git a/cmd/hello-world/main.go b/cmd/hello-world/main.go new file mode 100644 index 0000000..87ca56e --- /dev/null +++ b/cmd/hello-world/main.go @@ -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) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6c69ec1 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module go-udemy-web-1 + +go 1.21.0