我想使用類型斷言 frominterface{}到我確定其內容interface{}已嵌入引用的類型。https://play.golang.org/p/G8YrS7WZyQUpackage mainimport "fmt"type S1 struct {}type S2 struct {*S1}func main() { s := interface{}(&S2{&S1{}}) // I do not know the s type, but know that it is of `struct {*S1}` _, ok := s.(*S1) fmt.Println(ok)}在 Go 中甚至有可能嗎?
從 interface{} 到嵌入類型的類型斷言
慕的地8271018
2022-05-05 18:01:02