Skip to content

GPT4Go: AI-Powered Test Case Generation for Golang πŸ§ͺ

License

Notifications You must be signed in to change notification settings

tianshanghong/GPT4Go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– 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

  1. Ensure that you have Golang installed on your system πŸ’». If not, please follow the official installation guide.

  2. Clone the repository πŸ“¦:

git clone https://github.com/tianshanghong/GPT4Go.git
  1. Change into the project directory πŸ“‚:
cd GPT4Go
  1. Build the project πŸ”¨:
go build .
  1. 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.