π€ GPT4Go π
GPT4Go: AI-Powered Test Case Generation for Golang π§ͺ
English | δΈζ
GPT4Go is an open-source project that auto-generates test case files for Golang using OpenAI's ChatGPT π. The project helps developers quickly create test cases for their functions, ensuring that their code is tested efficiently and comprehensively π§ͺ.
π Features
- π― Auto-generates test cases for Golang functions using OpenAI's ChatGPT.
- π« Skips generating test cases for already tested functions.
- π‘ Provides suggestions for breaking down large functions for better software engineering practices.
- π Generates well-organized, easy-to-read test case code.
π Installation
-
Ensure that you have Golang installed on your system π». If not, please follow the official installation guide.
-
Clone the repository π¦:
git clone https://github.com/tianshanghong/GPT4Go.git
- Change into the project directory π:
cd GPT4Go
- Build the project π¨:
go build .
- Set the required environment variables π:
export OPENAI_API_KEY=your_openai_api_key
export GPT_MODEL=model_name # (optional, defaults to gpt-3.5-turbo)
From the OpenAI website, you can obtain an API key for OpenAI π. You can also specify the model you want to use for generating test cases. The default model is gpt-3.5-turbo
, which is the fastest model available π, while gpt-4
is the most accurate model π―. You can find a list of all available models here.
π Usage
To generate test cases for a specific directory or file, run the following command:
./GPT4Go path/to/your/target/directory/or/file
This command will walk through the specified directory or file and generate test cases for all functions that do not have corresponding test cases in the _test.go
file.
Please note that you will need an API key for OpenAI to use the ChatGPT functionality π. You can obtain one from OpenAI's website.
π₯ Contributing
Contributions are welcome! Please feel free to submit pull requests π₯, report bugs π, or suggest new features π‘ through the GitHub issues page.
π License
GPT4Go is licensed under the MIT License π.
π Acknowledgements
This project is built using OpenAI's ChatGPT, a powerful language model for generating human-like responses π§ . You can learn more about ChatGPT and GPT-4 architecture on the OpenAI website.