func main() { s := student{1, "wqx", ‘m‘, 15, "hefei"} m := make(map[int]interface{}) m[0] = s v, ok := m[0].(student) // 断言 if ok { fmt.Println(v.age) } }
Go——空接口与断言
原文:https://www.cnblogs.com/cnloop/p/9449429.html