This approach is powerful, but also laborious - at least in my experience, it’s too much work for relatively simple transformations.
I generally use gopatch instead. It uses the same mechanism under the hood, but the patch files are much less effort to write.