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 (

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 ( or use the discussion group at Google Groups. / Privacy / Disclaimer