github.com/keygen-sh/go-update@v1.0.0/patcher.go (about) 1 package update 2 3 import ( 4 "io" 5 6 "github.com/keygen-sh/go-update/internal/binarydist" 7 ) 8 9 // Patcher defines an interface for applying binary patches to an old item to get an updated item. 10 type Patcher interface { 11 Patch(old io.Reader, new io.Writer, patch io.Reader) error 12 } 13 14 type patchFn func(io.Reader, io.Writer, io.Reader) error 15 16 func (fn patchFn) Patch(old io.Reader, new io.Writer, patch io.Reader) error { 17 return fn(old, new, patch) 18 } 19 20 // NewBSDifferPatcher returns a new Patcher that applies binary patches using 21 // the bsdiff algorithm. See http://www.daemonology.net/bsdiff/ 22 func NewBSDiffPatcher() Patcher { 23 return patchFn(binarydist.Patch) 24 }