Permalink
Browse files

gofmt

  • Loading branch information...
1 parent c6b39fb commit 8fa1292ae5dbd4b64cb9b3f0bb44336d6eb2b998 @mmcgrana committed Nov 17, 2012
Showing with 18 additions and 18 deletions.
  1. +18 −18 examples/streaming-http-servers/streaming-http-servers.go
View
36 examples/streaming-http-servers/streaming-http-servers.go
@@ -1,28 +1,28 @@
package main
import (
- "fmt"
- "net/http"
- "time"
+ "fmt"
+ "net/http"
+ "time"
)
func stream(resp http.ResponseWriter, req *http.Request) {
- respf, ok := resp.(http.Flusher)
- if !ok {
- panic("not flushable")
- }
- fmt.Println("stream")
- resp.WriteHeader(200)
- for i := 0; i < 10; i++ {
- n, err := resp.Write([]byte("tick\n"))
- respf.Flush()
- fmt.Println("tick", n, err)
- time.Sleep(time.Second * 1)
- }
+ respf, ok := resp.(http.Flusher)
+ if !ok {
+ panic("not flushable")
+ }
+ fmt.Println("stream")
+ resp.WriteHeader(200)
+ for i := 0; i < 10; i++ {
+ n, err := resp.Write([]byte("tick\n"))
+ respf.Flush()
+ fmt.Println("tick", n, err)
+ time.Sleep(time.Second * 1)
+ }
}
func main() {
- http.HandleFunc("/", stream)
- fmt.Println("serve")
- http.ListenAndServe(":5000", nil)
+ http.HandleFunc("/", stream)
+ fmt.Println("serve")
+ http.ListenAndServe(":5000", nil)
}

0 comments on commit 8fa1292

Please sign in to comment.