I think this tool just needs to be replaced from what to what.
For example this looks like this
goreplacepkg -from ioutil.ReadAll -to io.ReadAll
Here we think his parameters are the same, then the tool just needs to parse the go file, find the path of the import in this go file, and the methods under this path. Then do the replacement,Finally a new file is generated,
github.com/google/go-cmp/cmp is added to import, and the original
k8s.io/apimachinery/pkg/util/diff can be removed if he is no longer used.
For example, the input file would look like this
package test
func A()string{
var a = "test"
var b = "test1"
return diff.ObjectDiff(a,b)
}
func B()string{
var a = "test"
var b= 'test1"
return diff.ObjectGoPrintSideBySide(a,b)
}
Execution of commands
The final file he generates may look like this
package test
import (
)
func A()string{
var a = "test"
var b = "test1"
return cmp.Diff(a,b)
}
func B()string{
var a = "test"
var b= 'test1"
return diff.ObjectGoPrintSideBySide(a,b)
}
He doesn't need to know the go version, he just needs the user to pass in the input and output