gitlab.com/ethan.reesor/vscode-notebooks/yaegi@v0.0.0-20220417214422-5c573557938e/_test/interface44.go (about) 1 package main 2 3 type S struct { 4 a int 5 } 6 7 func main() { 8 var i interface{} = S{a: 1} 9 10 s, ok := i.(S) 11 if !ok { 12 println("bad") 13 return 14 } 15 println(s.a) 16 } 17 18 // Output: 19 // 1