Last active
August 29, 2015 14:24
-
-
Save falsecz/7c9c75ac5fa1ce23bc54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Konec requestu | |
Spinkacek | |
Zkousim flush | |
Volam flush | |
panic: runtime error: invalid memory address or nil pointer dereference | |
[signal 0xb code=0x1 addr=0x8 pc=0x4ed7d] | |
goroutine 21 [running]: | |
runtime.panic(0x2573c0, 0x3e87a4) | |
/usr/local/Cellar/go/1.3.3/libexec/src/pkg/runtime/panic.c:279 +0xf5 | |
net/http.(*chunkWriter).flush(0xc2080520c0) | |
/usr/local/Cellar/go/1.3.3/libexec/src/pkg/net/http/server.go:275 +0x4d | |
net/http.(*response).Flush(0xc2080520a0) | |
/usr/local/Cellar/go/1.3.3/libexec/src/pkg/net/http/server.go:1024 +0x66 | |
main.func·001() | |
/private/tmp/trusty/a.go:19 +0x266 | |
created by main.handler | |
/private/tmp/trusty/a.go:22 +0x188 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"time" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) | |
canFlush := true | |
go func() { | |
fmt.Println("Spinkacek") | |
time.Sleep(time.Second * 2) | |
fmt.Println("Zkousim flush") | |
if f, ok := w.(http.Flusher); ok { | |
if canFlush { | |
fmt.Println("Volam flush") | |
f.Flush() | |
} else { | |
fmt.Println("Uz nevolam flush") | |
} | |
} | |
}() | |
fmt.Println("Konec requestu") | |
canFlush = false | |
} | |
func main() { | |
http.HandleFunc("/", handler) | |
http.ListenAndServe(":8080", nil) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"time" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) | |
go func() { | |
fmt.Println("Spinkacek") | |
time.Sleep(time.Second * 2) | |
fmt.Println("Zkousim flush") | |
if f, ok := w.(http.Flusher); ok { | |
fmt.Println("Volam flush") | |
f.Flush() | |
} | |
}() | |
fmt.Println("Konec requestu") | |
} | |
func main() { | |
http.HandleFunc("/", handler) | |
http.ListenAndServe(":8080", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment