This is a creation in Article, where the information may have evolved or changed.
html file See http://www.ieyebrain.com:8080/pts/src/master/package mainimport ("Flag" "Net/http" "io "" Strings "" StrConv ") type clientinfo struct {id intip stringname string}var (Addr = flag. String ("addr", ": 9191", "pts master address") Clients = make (map[int] Clientinfo) sn = 0) type web struct {w http. Responsewriterreq *http. Request }func newweb (w http. Responsewriter, req *http. Request) *Web {return &Web{w:w,req:req}}func (p *web) getclientip () String {r := p.req ip := r.header.get ("X-Real-IP") if ip == "" { ip = strings. Split (r.remoteaddr, ":") [0] } if ip == "[" { ip = "LocAlhost " } return ip}func (p *web) begintag ( tag string) {io. WriteString (p.w, "<" + tag + > ")}func (P *web) endtag (tag string) {io. WriteString (p.w, "</" + tag + ">")}func (P *web) tagval (tag string, val string) {io. WriteString (p.w, "<" + tag + ">" + val + "</" + tag + ">")}func (P *web) write (val string) {io. WriteString (P.w, val)}func (p *web) htmltmpl (title string, body string) {p.begintag ("HTML") P.begintag ("Head") P.tagval ("title", title) P.endtag ("Head") p.write (body) P.endtag ( "Body") P.endtag ("HTML")}func listhandler (w http. Responsewriter, req *http. Request) {web := newweb (w,req) web.begintag ("html") Web.begintag (" Head ") Web.tagval (" title ", " Pts master ") Web.endtag (" Head ") Web.begintag (" Body ") Web.begintag ("ul") For _,v := range clients {web.begintag ("Li") web.write (StrConv. Itoa (v.id)) web.write (" : ") Web.write (V.IP) web.endtag ("Li")}web.write ('