1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
package main
import (
"net/http"
"net/http/httptest"
)
func main() {
var v1 interface{} = 1
var v2 interface{}
var v3 http.ResponseWriter = httptest.NewRecorder()
if r1, ok := v1.(string); ok {
_ = r1
println("unexpected")
}
if _, ok := v1.(string); ok {
println("unexpected")
}
if r2, ok := v2.(string); ok {
_ = r2
println("unexpected")
}
if _, ok := v2.(string); ok {
println("unexpected")
}
if r3, ok := v3.(http.Pusher); ok {
_ = r3
println("unexpected")
}
if _, ok := v3.(http.Pusher); ok {
println("unexpected")
}
println("bye")
}
// Output:
// bye
|