如何获得所有定义的类型? [英] How to get all defined types?

查看:57
本文介绍了如何获得所有定义的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

package demo

type People struct {
    Name string
    Age  uint
}

type UserInfo struct {
    Address  string
    Hobby    []string
    NickNage string
}

另一个包:

import "demo"

在此软件包中,如何获得从演示软件包中导出的所有类型?

in this package, how can I get all the types exported from the demo package?

推荐答案

Go在包级别不保留结构,接口或变量的主列表,因此,您所提出的要求是不可能的.

Go retains no master list of structs, interfaces, or variables at the package level, so what you ask is unfortunately impossible.

这篇关于如何获得所有定义的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆