本文整理汇总了Golang中go/types.Var.Pkg方法的典型用法代码示例。如果您正苦于以下问题:Golang Var.Pkg方法的具体用法?Golang Var.Pkg怎么用?Golang Var.Pkg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类go/types.Var
的用法示例。
在下文中一共展示了Var.Pkg方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: field
func (p *exporter) field(f *types.Var) {
// anonymous fields have "" name
name := ""
if !f.Anonymous() {
name = f.Name()
}
// qualifiedName will always emit the field package for
// anonymous fields because "" is not an exported name.
p.qualifiedName(f.Pkg(), name)
p.typ(f.Type())
}
示例2: varPtrName
func (c *funcContext) varPtrName(o *types.Var) string {
if isPkgLevel(o) && o.Exported() {
return c.pkgVar(o.Pkg()) + "." + o.Name() + "$ptr"
}
name, ok := c.p.varPtrNames[o]
if !ok {
name = c.newVariableWithLevel(o.Name()+"$ptr", isPkgLevel(o))
c.p.varPtrNames[o] = name
}
return name
}
示例3: fieldName
// fieldName is like qualifiedName but it doesn't record the package
// for blank (_) or exported names.
func (p *exporter) fieldName(f *types.Var) {
name := f.Name()
// anonymous field with unexported base type name: use "?" as field name
// (bname != "" per spec, but we are conservative in case of errors)
if f.Anonymous() {
base := f.Type()
if ptr, ok := base.(*types.Pointer); ok {
base = ptr.Elem()
}
if named, ok := base.(*types.Named); ok && !named.Obj().Exported() {
name = "?"
}
}
p.string(name)
if name == "?" || name != "_" && !f.Exported() {
p.pkg(f.Pkg(), false)
}
}