gotestyourself / gotest.tools

A collection of packages to augment the go testing package and support common patterns.
https://gotest.tools/v3
Other
513 stars 50 forks source link

Define a separate Go module for the testify migration tool #266

Open dolmen opened 1 year ago

dolmen commented 1 year ago

gty-migrate-from-testify brings its own dependencies which are not used in general for users of gotest.tools/v3/assert.

By defining a new Go module for gty-migrate-from-testify, the dependency problem will be contained. golang.org/x/tools will disapear from the root go.mod.

How to do it:

cd assert/cmd/gty-migrate-from-testify
go mod init gotest.tools/assert/cmd/gty-migrate-from-testify
go mod tidy
git add go.mod go.sum
sed -i= 's!gotest.tools/v3/assert/cmd/gty-migrate-from-testify!gotest.tools/assert/cmd/gty-migrate-from-testify/v1!' doc.go
git add doc.go 
cd ../..
go mod tidy # Cleanup dependencies which were used only by gty-migrate-from-testify
git add go.mod go.sum
sed -i= 's!gotest.tools/v3/assert/cmd/gty-migrate-from-testify!gotest.tools/assert/cmd/gty-migrate-from-testify/v1!' assert/assert.go
git add assert/assert.go
git commit -m "assert/cmd/gty-migrate-from-testify: define Go module"
git tag -a assert/cmd/gty-migrate-from-testify/v1.0.0
git push --tags
dnephin commented 1 year ago

Sounds good! When this tool was first written modules didn't exist, but now I think it's a good idea to make it a separate module.

I think at the same time it would be good to change the import path. I've noticed there are often problems when a package exist in different modules.