Version a Go module by adding a retract directive to your go.mod file and publishing a new version with the updated file.
- Add a retract directive to your
go.modfile specifying the versions to retract.
retract v1.0.0
- Increment your version number in
go.modto the next semantic version.
module example.com/myapp
go 1.21
retract v1.0.0
- Commit the changes and create a new git tag matching the new version.
git add go.mod
git commit -m "Retract v1.0.0 and release v1.0.1"
git tag v1.0.1
git push origin v1.0.1
- Verify the retraction is visible on the module proxy.
go list -m -versions example.com/myapp