From b02d93d8a3250e9dde4a312ecc35a1af215c47c9 Mon Sep 17 00:00:00 2001 From: des <18638715007@163.com> Date: Wed, 29 Apr 2026 00:00:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8D=95=E6=8E=A2=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/zire/main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/zire/main.go b/cmd/zire/main.go index c41155f..ac94ab2 100644 --- a/cmd/zire/main.go +++ b/cmd/zire/main.go @@ -3,6 +3,7 @@ package main import ( "errors" "fmt" + "go/types" "os" "path/filepath" "regexp" @@ -24,6 +25,7 @@ func main() { } pkgs, err := packages.Load(cfg, "./...") tools.Check(err, "加载包失败") + var funcs []*types.Func for _, pkg := range pkgs { fmt.Println("当前包") fmt.Println(pkg.Name) @@ -34,10 +36,21 @@ func main() { if !reg.MatchString(name) { continue } - fmt.Println(name) + fun, ok := scope.Lookup(name).(*types.Func) + if !ok { + continue + } + funcs = append(funcs, fun) + test := fun.Type().(*types.Signature) + tup := test.Params() + fmt.Println(tup) } break } + + // 收集之后要做什么? + // 然后,外界会任意挑一个作为输出。 + // 此时,需要递归寻找并构建依赖,同时还需要防环 } func getModPath() (string, error) {