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 ๐งช.
- ๐ฏ 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 ๐:
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.
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.
Contributions are welcome! Please feel free to submit pull requests ๐ฅ, report bugs ๐, or suggest new features ๐ก through the GitHub issues page.
GPT4Go is licensed under the MIT License ๐.
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.