简单探索

This commit is contained in:
2026-04-29 00:00:57 +08:00
parent 9263de1654
commit b02d93d8a3

View File

@@ -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) {