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
🎯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.
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
- 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
gpt-3.5-turbo, which is the fastest model available
gpt-4 is the most accurate model
To generate test cases for a specific directory or file, run the following command:
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
Please note that you will need an API key for OpenAI to use the ChatGPT functionality
Contributions are welcome! Please feel free to submit pull requests
GPT4Go is licensed under the MIT License
This project is built using OpenAI's ChatGPT, a powerful language model for generating human-like responses