gopatch
gopatch copied to clipboard
Multiple top-level declarations
It's currently impossible to have a patch that introduces a new top-level declaration while modifying another one.
For example, given,
func foo() {
re := regexp.MustCompile("foo")
// ...
}
We cannot build a patch that would turn it into the following.
var re = regexp.MustCompile("foo")
func foo() {
// ...
}
That's because we don't yet support patches with multiple top-level declarations in them so the following will fail to parse.
@@
var f, re identifier
var regex expression
@@
+var re = regexp.MustCompile(regex)
func f() {
- re := regexp.MustCompile(regex)
...
}
See also #3, #4