This is an old revision of the document!
client1:~/gowebd# cat main.go
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
http.HandleFunc("/", HelloServer)
fmt.Printf("Starting server at port 80\n")
if err := http.ListenAndServe(":80", nil); err != nil {
log.Fatal(err)
}
}
func HelloServer(w http.ResponseWriter, r *http.Request) {
name, err := os.Hostname()
if err != nil {
panic(err)
}
fmt.Fprint(w, "Hello world from " + name + " ver1.1\n")
}