Files
llgo/cl/_testgo/strucintf/in.go

28 lines
438 B
Go
Raw Normal View History

package main
2024-05-24 23:06:11 +08:00
import "github.com/goplus/llgo/cl/internal/foo"
func Foo() any {
return struct{ v int }{1}
}
func main() {
2024-05-24 23:06:11 +08:00
v := Foo()
if x, ok := v.(struct{ v int }); ok {
println(x.v)
} else {
println("Foo: not ok")
}
bar := foo.Bar()
if x, ok := bar.(struct{ V int }); ok {
2024-05-24 22:47:45 +08:00
println(x.V)
} else {
2024-05-24 22:47:45 +08:00
println("Bar: not ok")
}
if x, ok := foo.F().(struct{ v int }); ok {
2024-05-24 22:47:45 +08:00
println(x.v)
} else {
2024-05-24 22:47:45 +08:00
println("F: not ok")
}
}