https://github.com/smola/gocompat
Go API compatibility checker.
https://github.com/smola/gocompat
compatibility compatibility-testing golang golang-tools
Last synced: about 1 year ago
JSON representation
Go API compatibility checker.
- Host: GitHub
- URL: https://github.com/smola/gocompat
- Owner: smola
- License: apache-2.0
- Created: 2018-12-10T10:02:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-19T05:01:06.000Z (about 3 years ago)
- Last Synced: 2025-04-19T12:13:53.816Z (about 1 year ago)
- Topics: compatibility, compatibility-testing, golang, golang-tools
- Language: Go
- Size: 82 KB
- Stars: 16
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: changes.go
- License: LICENSE
Awesome Lists containing this project
README
# gocompat [](https://pkg.go.dev/github.com/smola/gocompat)  [](https://codecov.io/github/smola/gocompat)
**gocompat** is a tool to check compatibility between Go API versions.
## Usage
### Listing all symbols
**gocompat** considers an API as all exported symbols in a given set of packages as well as all exported symbols reachable from them. You can check this for the current package as follows:
```bash
gocompat reach .
```
### Compare current version against reference data
**gocompat** can save your API for later comparison. Usage example:
```bash
git checkout v1.0.0
gocompat save ./...
git checkout master
gocompat compare ./...
```
### Comparing two git reference
**gocompat** can compare the API of two git references in a repository. For example:
```
gocompat compare --git-refs=v0.1.0..master ./...
```
## Declaring your compatibility guarantees
There is almost no API change in Go that is fully backwards compatibility ([see this post for more](https://blog.merovius.de/2015/07/29/backwards-compatibility-in-go.html)). By default, gocompat uses a strict approach in which most changes to exported symbols are considered incompatible. The `--exclude=` flag can be used to exclude a change type from results.
Most users will probably want to use compatibility guarantees analogous to the [Go 1 compatibility promise](https://golang.org/doc/go1compat). You can use the `--go1compat` for that, which is a shorthand for `--exclude=TopLevelDeclarationAdded --exclude=FieldAdded --exclude=MethodAdded`. For example:
```
gocompat compare --go1compat --from-git=v1.0.0..v1.1.0 ./...
```
If you are using [Semantic Versioning](https://semver.org/), you might want to use the strict defaults for patch versions.
## License
Released under the terms of the Apache License Version 2.0, see [LICENSE](LICENSE).