You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On occasions when we must delete a package from a repo, we would like to provide existing clients some way to continue to use it, even though it will never be updated again. One way to achieve that is to carve out a subdirectory of the repo module as a separate module, tag it with a version, and then delete it from the repo. This way the package is available indefinitely at its latest version even though it no longer exists in the main branch of the repo. This process was used for the cmd/cover tool (see #56783) and the go/pointer package (see #59676), both within the golang.org/x/tools repo.
However, the process requires a sequence of several rather subtle CLs and the creation of many tags (each of which carries a risk of hard-to-fix mistakes). We should document the theory and practice of this approach to make it easier in future, perhaps in https://go.dev/ref/mod, or in the Go wiki.
If someone would like to make a run at adding this documentation, the steps we have used in previous deprecations are:
Use go mod init to create a go.mod file in the directory to be deleted, and use go mod edit -replace to add any replace directives needed to resolve imports from other modules in the same repo. Run go mod tidy to fill in any other requirements as needed. Review and merge the commit.
When this commit is published, it creates a pseudo-version for the module in the parent directory which does not contain the package to be deleted.
Within the new module, use go mod edit -dropreplace to drop the replace directives, then go get the parent module at the commit merged in step (1). Review and merge the commit.
Noting here that the sequence ends up being one CL shorter when the package is standalone, since there are no local replace directives to add and later on remove. For example, see CL 505956 and its two ancestor CLs that delete x/tools/go/vcs, a package not used by the rest of x/tools.