Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
proposal: cmd/fix: allow third party packages to migrate using go fix #40162
After I read most recent blog post https://blog.golang.org/module-compatibility.
I'm currently not sure how this can be achieved exactly.
@ianlancetaylor The fix doesn't have to be perfect.
In the case of a changed function signature:
Find all affected references to that function.
The maintainer provides fixes for specific usages of this function e.g. in a ast.CallExpr.
Warn about all other uses which couldn't be fixed automatically, and describe what exactly needs to be changed.
import ( oldmodule "module/v1" "module/v2" )
(I don't propose prefixing the old version with "old", just for illustration.)
@lu4p I understand that the maintainer provides the fix. If it doesn't have to be perfect, then I'm not sure why it needs any particular support from the Go toolchain. The maintainer can just say: this is what you have to change, and here is a program that can do most of the changes for you. That program can be a go fix module.
What do you think should change in the Go toolchain?
@ianlancetaylor You are right it would probably only make sense to provide "perfect" fixes.
Maybe we can have some code generation tool which can outline all the possible cases so no case is missed. Another approach would be to force the implementation of a
Which would generate a file like
There probably needs to be a seperate directory where all fixfiles are stored, because reserving a directory name like fixes is not hard make this configurable in the modfile with a new directive like
The fixfiles should be normal go files, but they probably need a standard layout (version, affected subpackage, description), therfore a