GithubHelp home page GithubHelp logo

astfunc's Introduction

目标

使用ast获取指定方法的入参,出参类型,以及这个方法中调用的方法的入参和出参

使用场景

将这些信息提供给AI工具,由AI工具生成单测,相比于单纯将方法提供给AI,AI可以获取更多的上下文,生成的单测也会更加准确

使用示例

package main

import (
	"fmt"

	"github.com/lwydyby/astfunc"
)

func main() {
	result := astfunc.GetFuncWithDependency(".", "A")
	fmt.Println(result)
}

结果

方法所在项目module为:github.com/lwydyby/astfunc 
方法的package为: 1
需要添加单元测试的方法如下:
func A(a string) string {
        return B()
}
测试方法的入参结构为:

string
测试方法的返回结构为:

string
测试方法内调用的方法入参和返回分别为:

方法名: B
入参: 
返回类型: string

astfunc's People

Contributors

lwydyby avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.