Simplest example of web server printing "Hello world" in Go
This is an example Go web server which does nothing but print "Hello world."
package main import ( "net/http" "log" ) func reply(rw http.ResponseWriter, req *http.Request) { rw.Write([]byte("<html><body><p>Hello world.\n</p></body></html>")) } func main() { http.HandleFunc("/", reply) log.Fatal(http.ListenAndServe(":8082", nil)) }
Copyright © Ben Bullock 2009-2024. All
rights reserved.
For comments, questions, and corrections, please email
Ben Bullock
(benkasminbullock@gmail.com).
/
Privacy /
Disclaimer