简单探索

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 ( import (
"errors" "errors"
"fmt" "fmt"
"go/types"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
@@ -24,6 +25,7 @@ func main() {
} }
pkgs, err := packages.Load(cfg, "./...") pkgs, err := packages.Load(cfg, "./...")
tools.Check(err, "加载包失败") tools.Check(err, "加载包失败")
var funcs []*types.Func
for _, pkg := range pkgs { for _, pkg := range pkgs {
fmt.Println("当前包") fmt.Println("当前包")
fmt.Println(pkg.Name) fmt.Println(pkg.Name)
@@ -34,10 +36,21 @@ func main() {
if !reg.MatchString(name) { if !reg.MatchString(name) {
continue 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 break
} }
// 收集之后要做什么?
// 然后,外界会任意挑一个作为输出。
// 此时,需要递归寻找并构建依赖,同时还需要防环
} }
func getModPath() (string, error) { func getModPath() (string, error) {