GPT4Go is an open-source project that auto-generates test case files for Golang using OpenAI's ChatGPT
π
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 gpt-3.5-turbo
, which is the fastest model available gpt-4
is the most accurate model
π
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
π₯
Contributing
Contributions are welcome! Please feel free to submit pull requests
π
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