auto-fix-go is a tool that automatically fixes Go code by running tests, submitting failures and source code to a language model, and making source edits in a loop to drive a program to completion.
Installation
Ensure you have Go 1.22 or later installed on your system.
Install the tool using go install:
go install github.com/tmc/misc/auto-fix-go@latest
This will download, compile, and install the auto-fix-go binary in your $GOPATH/bin directory.
Make sure your $GOPATH/bin is in your system's PATH.
Usage
Run auto-fix-go by providing the directory containing the Go project you want to fix:
auto-fix-go /path/to/your/go/project
The tool will:
Run tests in the specified directory
If tests fail, it will submit the source code and test output to a language model
Apply the suggested fixes
Repeat the process until all tests pass
Requirements
Go 1.22 or later
An Anthropic API key set in the ANTHROPIC_API_KEY environment variable
Development
If you want to contribute to the project or run it from source: