mirror of
https://github.com/golang/go
synced 2024-11-24 21:30:10 -07:00
37 lines
819 B
Diff
37 lines
819 B
Diff
|
*** 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))
|
||
|
|
||
|
! 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
|
||
|
}
|