1
0
mirror of https://github.com/golang/go synced 2024-10-02 16:18:38 -06:00
go/doc/articles/wiki/final-test.patch

37 lines
830 B
Diff
Raw Normal View History

*** final.go 2015-06-14 23:59:22.000000000 +0200
--- final-test.go 2015-06-15 00:15:41.000000000 +0200
***************
*** 7,12 ****
--- 7,14 ----
import (
"html/template"
"io/ioutil"
+ "log"
+ "net"
"net/http"
"regexp"
)
***************
*** 85,89 ****
http.HandleFunc("/edit/", makeHandler(editHandler))
http.HandleFunc("/save/", makeHandler(saveHandler))
! log.Fatal(http.ListenAndServe(":8080", nil))
}
--- 87,101 ----
http.HandleFunc("/edit/", makeHandler(editHandler))
http.HandleFunc("/save/", makeHandler(saveHandler))
! l, err := net.Listen("tcp", "127.0.0.1:0")
! if err != nil {
! log.Fatal(err)
! }
! err = ioutil.WriteFile("final-test-port.txt", []byte(l.Addr().String()), 0644)
! if err != nil {
! log.Fatal(err)
! }
! s := &http.Server{}
! s.Serve(l)
! return
}