From 18c67410d36db5c7b0a10dbf158722cb80047961 Mon Sep 17 00:00:00 2001 From: Pavak Paul Date: Thu, 21 Apr 2022 01:54:07 +0530 Subject: [PATCH] Starter net/http server --- main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 main.go diff --git a/main.go b/main.go new file mode 100644 index 0000000..7c8a196 --- /dev/null +++ b/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "net/http" +) + +const port = ":5000" + +func Home(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello, World!") +} + +func main() { + http.HandleFunc("/", Home) + + fmt.Printf("Starting web server on http://localhost%s\n", port) + + _ = http.ListenAndServe(port, nil) +}