1 Star 1 Fork 0

wzshiming / gotype

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
types_interface.go 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
wzshiming 提交于 2019-01-08 12:34 . fixes
package gotype
import (
"bytes"
)
type typeInterface struct {
typeBase
all types
anonymo types
method types
}
func (t *typeInterface) String() string {
buf := bytes.NewBuffer(nil)
buf.WriteString("interface{")
for i, v := range t.all {
if i != 0 {
buf.WriteString("; ")
}
buf.WriteString(v.String())
}
buf.WriteByte('}')
return buf.String()
}
func (t *typeInterface) Kind() Kind {
return Interface
}
func (t *typeInterface) NumMethod() int {
return t.method.Len()
}
func (t *typeInterface) Method(i int) Type {
return t.method.Index(i)
}
func (t *typeInterface) MethodByName(name string) (Type, bool) {
b, ok := t.method.Search(name)
if ok {
return b, true
}
for _, v := range t.anonymo {
v := v.Declaration()
b, ok := v.MethodByName(name)
if ok {
return b, true
}
}
return nil, false
}
func (t *typeInterface) NumField() int {
return t.all.Len()
}
func (t *typeInterface) Field(i int) Type {
return t.all.Index(i)
}
func (t *typeInterface) FieldByName(name string) (Type, bool) {
b, ok := t.all.Search(name)
if ok {
return b, true
}
return nil, false
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/wzshiming/gotype.git
git@gitee.com:wzshiming/gotype.git
wzshiming
gotype
gotype
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891