1 Star 0 Fork 0

lonely / gometalinter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cache.go 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
Alec Thomas 提交于 2017-09-09 13:03 . Update all deps (#344).
// Copyright (c) 2015, Daniel Martí <mvdan@mvdan.cc>
// See LICENSE for licensing information
package check
import (
"go/ast"
"go/types"
)
type pkgTypes struct {
ifaces map[string]string
funcSigns map[string]bool
}
func (p *pkgTypes) getTypes(pkg *types.Package) {
p.ifaces = make(map[string]string)
p.funcSigns = make(map[string]bool)
done := make(map[*types.Package]bool)
addTypes := func(pkg *types.Package, top bool) {
if done[pkg] {
return
}
done[pkg] = true
ifs, funs := fromScope(pkg.Scope())
fullName := func(name string) string {
if !top {
return pkg.Path() + "." + name
}
return name
}
for iftype, name := range ifs {
// only suggest exported interfaces
if ast.IsExported(name) {
p.ifaces[iftype] = fullName(name)
}
}
for ftype := range funs {
// ignore non-exported func signatures too
p.funcSigns[ftype] = true
}
}
for _, imp := range pkg.Imports() {
addTypes(imp, false)
for _, imp2 := range imp.Imports() {
addTypes(imp2, false)
}
}
addTypes(pkg, true)
}
1
https://gitee.com/lonely0422/gometalinter.git
git@gitee.com:lonely0422/gometalinter.git
lonely0422
gometalinter
gometalinter
v3.0.0

搜索帮助