A production-ready CLI tool for analyzing breaking changes in Go dependency upgrades.
Upgrading Go dependencies is risky. Your code might compile successfully after bumping a version, but runtime breaks or unexpected behavior can slip through. While Go's semantic versioning and module system help, they don't catch everything—especially when maintainers accidentally break compatibility or you're jumping multiple versions.
go-semver-audit performs static analysis to compare the public API surface of your current dependency version against a proposed upgrade, then checks which exported symbols your code actually uses. It produces a risk report highlighting potential breaking changes that affect your project.
Think of it as a safety net before you commit to that upgrade.
- Install:
go install github.com/devblac/go-semver-audit/cmd/go-semver-audit@latest - Run once:
go-semver-audit -upgrade github.com/pkg/errors@v0.9.1 - Read the text report (default). Use
-jsonfor CI or-strictto fail on warnings.
- Before bumping a dependency (especially majors or multi-version jumps)
- When you need proof that an upgrade is safe for your code
- When a team asks “what will this break?” and you need a quick, actionable report
- API Diff Analysis: Compares exported types, functions, methods, and interfaces between dependency versions
- Usage-Aware: Only reports breaking changes for APIs you actually use in your code
- Risk Reports: Clear, actionable output showing removed functions, changed signatures, modified interfaces
- Batch Mode: Analyze multiple dependency upgrades in one run
- Dead Dependency Detection: Optionally identify unused dependencies after upgrades
- CI-Friendly: JSON output mode and non-zero exit codes for automation
- Static Analysis Only: No code execution, no compilation of untrusted code
go install github.com/devblac/go-semver-audit/cmd/go-semver-audit@latestgit clone https://github.com/devblac/go-semver-audit.git
cd go-semver-audit
go build -o bin/go-semver-audit ./cmd/go-semver-auditAnalyze a single dependency upgrade in the current directory:
go-semver-audit -upgrade github.com/gin-gonic/gin@v1.9.0go-semver-audit -path ./myproject -upgrade github.com/pkg/errors@v0.9.1go-semver-audit -upgrade github.com/stretchr/testify@v1.8.0 -jsongo-semver-audit -upgrade github.com/gorilla/mux@v1.8.0 -html > audit.htmlgo-semver-audit -upgrade golang.org/x/sync@v0.5.0 -strictgo-semver-audit -upgrade github.com/gorilla/mux@v1.8.0 -unused- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Audit dependency upgrade
env:
MODULE: github.com/pkg/errors
VERSION: v0.9.1
run: go-semver-audit -upgrade ${MODULE}@${VERSION} -json -strict > semver-report.json
- uses: actions/upload-artifact@v4
with:
name: semver-report
path: semver-report.jsonAnalyzing upgrade: github.com/example/lib v1.2.0 -> v2.0.0
⚠️ BREAKING CHANGES DETECTED
Removed Functions:
- lib.OldHelper (used in: main.go:45, utils/helper.go:12)
Changed Signatures:
- lib.ParseConfig
Old: func ParseConfig(path string) (*Config, error)
New: func ParseConfig(path string, opts ...Option) (*Config, error)
Used in: config/loader.go:23
Modified Interfaces:
- lib.Handler
Removed method: Handle(ctx context.Context) error
Added method: HandleWithContext(ctx context.Context, meta Metadata) error
Implementations found in: handlers/http.go:67
Summary: 3 breaking changes affecting 4 locations in your code.
| Flag | Description | Default |
|---|---|---|
-path |
Path to Go project to analyze | . (current directory) |
-upgrade |
Dependency upgrade in format module@version |
(required) |
-json |
Output results as JSON | false |
-html |
Output results as HTML | false |
-strict |
Exit non-zero on warnings (not just errors) | false |
-unused |
Report unused dependencies after upgrade | false |
-v |
Verbose output | false |
-help |
Show help message | - |
- Parse Current State: Load your Go project and identify current dependency versions
- Fetch Versions: Download/cache both old and new versions of the target dependency
- Extract APIs: Parse exported symbols (types, functions, methods, interfaces) from both versions
- Analyze Usage: Scan your codebase to find which exported symbols you actually import and use
- Diff & Compare: Identify removed symbols, changed signatures, modified interfaces
- Generate Report: Output only breaking changes that affect symbols you use
This tool performs static analysis only and has inherent limitations:
- Cannot detect behavioral changes: If a function signature stays the same but behavior changes, we won't catch it
- Reflection blind spots: Dynamic calls via reflection may not be detected as usage
- Vendored dependencies: Analysis assumes standard module layout; vendored code may not be handled correctly
- CGO dependencies: Modules with cgo may not be fully analyzable
- Semantic compatibility: We detect API surface changes, not semantic versioning violations
- Build tags: May not analyze all conditional compilation branches
- Type aliases: Complex type aliasing chains may be oversimplified
This tool is a safety aid, not a guarantee. Always test your upgrades thoroughly.
The project includes comprehensive test coverage and continuous integration.
# Run all tests
go test ./...
# Run tests with coverage
make test-coverage
# Run with race detector
go test -race ./...See TESTING.md for detailed testing documentation.
CI runs automatically on all pull requests and pushes to main/develop branches:
- Tests across multiple OS (Linux, Windows, macOS) and Go versions (1.21, 1.22)
- Linting with
go vet,gofmt, andstaticcheck - Coverage reporting via Codecov
- Build verification
- Tag a version:
git tag v0.x.y && git push origin v0.x.y - CI (GitHub Actions) builds cross-platform binaries via GoReleaser and publishes the GitHub Release
- Local dry run:
goreleaser release --skip=publish --clean
Contributions welcome! This project aims to stay minimal and focused.
# Clone the repository
git clone https://github.com/devblac/go-semver-audit.git
cd go-semver-audit
# Run tests
make test
# Run all checks (format, lint, test)
make check- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Write tests for your changes
- Ensure all tests pass and code is formatted (
go fmt ./...) - Commit with clear messages (
git commit -m 'Add detection for interface embedding') - Push and open a Pull Request
- Follow Effective Go guidelines
- Keep functions small and focused
- Use table-driven tests
- Document exported functions and types
- Handle errors explicitly, no silent failures
Use GitHub Issues to report bugs or suggest features. Include:
- Go version (
go version) - Operating system
- Full command you ran
- Expected vs actual behavior
- Minimal reproduction example if possible
- golang.org/x/exp/apidiff: Experimental API diff tool (library-focused)
- go mod graph: Visualize dependency graphs
- nancy: Vulnerability scanner for Go dependencies
MIT License - see LICENSE file for details.
Built with golang.org/x/tools/go/packages for robust Go code analysis.