Open okkero opened 7 months ago
sample.go
package main import ( "fmt" "net/http" "reflect" ) type responseWriter struct { http.ResponseWriter } func (w *responseWriter) Flush() { fmt.Println("Flushing...") if flusher, ok := w.ResponseWriter.(http.Flusher); ok { flusher.Flush() } } type dummy struct{} func (d *dummy) Header() http.Header { fmt.Println("Dummy Header") return nil } func (d *dummy) Write(data []byte) (int, error) { fmt.Println("Dummy Write ", data) return 0, nil } func (d *dummy) WriteHeader(responseCode int) { fmt.Println("Dummy WriteHeader ", responseCode) } func foo(rw http.ResponseWriter) { var respCodeOverrideWriter = &responseWriter{ResponseWriter: rw} var flusher http.Flusher = respCodeOverrideWriter fmt.Println("responseWriter is http.Flusher. We can call Flush manually:") flusher.Flush() var httpResponseWriter http.ResponseWriter = respCodeOverrideWriter _, ok := httpResponseWriter.(http.Flusher) fmt.Println("Is responseWriter http.Flusher?", ok) } func main() { foo(&dummy{}) }
responseWriter is http.Flusher. We can call Flush manually: Flushing... Is responseWriter http.Flusher? true
responseWriter is http.Flusher. We can call Flush manually: Flushing... Is responseWriter http.Flusher? false
v0.15.1
See this issue in the Traefik repo for context
The following program
sample.go
triggers an unexpected resultExpected result
Got
Yaegi Version
v0.15.1
Additional Notes
See this issue in the Traefik repo for context