1 Star 0 Fork 0

aspnmy/i18n4go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ast.go 437 Bytes
一键复制 编辑 原始数据 按行查看 历史
package common
import (
"errors"
"fmt"
"go/ast"
)
func ImportsForASTFile(astFile *ast.File) (*ast.GenDecl, error) {
for _, declaration := range astFile.Decls {
decl, ok := declaration.(*ast.GenDecl)
if !ok || len(decl.Specs) == 0 {
continue
}
if _, ok = decl.Specs[0].(*ast.ImportSpec); ok {
return decl, nil
}
}
return nil, errors.New(fmt.Sprintf("Could not find imports for root node:\n\t%#v\n", astFile))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/Aodao/i18n4go.git
git@gitee.com:Aodao/i18n4go.git
Aodao
i18n4go
i18n4go
v0.2.3

搜索帮助