panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x5391c]
goroutine 10 [running]:
net/http.(*switchWriter).Write(0xc200078790, 0xc2000e9800, 0x5, 0x800, 0x0, ...)
/usr/local/go/src/pkg/net/http/chunked.go:0 +0x5c
bufio.(*Writer).Flush(0xc200095b80, 0xc20009c420, 0xc200000008)
/usr/local/go/src/pkg/bufio/bufio.go:465 +0x14a
net/http.(*response).Flush(0xc2000b3700)
/usr/local/go/src/pkg/net/http/server.go:952 +0x4a
main.func·001()
/tmp/ab.go:17 +0x1e2
created by main.handler
/tmp/ab.go:20 +0xac
when the handler returned, the goroutine shouldn't do any operation on it anymore.
On Nov 1, 2013 2:13 PM, "Fumin Wang" <awaw...@gmail.com> wrote:
>
> Right, thanks for your observations, that resonates with what's being said in https://groups.google.com/forum/#!searchin/golang-nuts/http$20flush/golang-nuts/vzVgBwJ1q2c/jCS_twDIScAJ
>
> I wonder are you able to answer these further questions?
> * Why abruptly panic with a runtime error instead of an error return value which is the standard way of reporting errors?
checking that every method call on responsewriter is valid will slow everything down.
besides panic for programmer error is also an idiom for Go.
> * Why isn't the error raised in the earlier Write `w.Write([]byte("hello"))` but only in the Flush?
i'd say this is implementation detail so you'd better read the source code to find it out yourself.