Enable your Golang applications to self update. Inspired by Chrome based on Heroku's hk.
Requires Golang 1.8 or higher.
- Tested on Mac, Linux, Arm, and Windows
- Creates binary diffs with bsdiff allowing small incremental updates (which means you need to get bzip2 installed on your machine for this package to work)
- Falls back to full binary update if diff fails to match SHA
go get -u github.com/EliCDavis/go-selfupdate/...
updater := selfupdate.NewUpdater(version, "http://updates.yourdomain.com/", "myapp")
// run an update in the background
go func () {
updated, err := updater.Run()
if err != nil {
log.Printf("Error updating: %s", err.Error())
} else {
log.Printf("Update applied: %t", updated)
}
}
If you prefer to instead of keeping this app updated, but a different file, just specify the path:
updater := selfupdate.NewUpdater(version, "http://updates.yourdomain.com/", "myapp").
SetUpdatableResolver(NewSpecificFileUpdatableResolver("path/to/your/file"))
// run an update in the background
go func () {
updated, err := updater.Run()
if err != nil {
log.Printf("Error updating: %s", err.Error())
} else {
log.Printf("Update applied: %t", updated)
}
}
go-selfupdate myapp 1.2
This will create a folder in your project called, public you can then rsync or transfer this to your webserver or S3.
If you are cross compiling you can specify a directory:
go-selfupdate /tmp/mybinares/ 1.2
The directory should contain files with the name, $GOOS-$ARCH. Example:
windows-386
darwin-amd64
linux-arm
If you are using goxc you can output the files with this naming format by specifying this config:
"OutPath": "{{.Dest}}{{.PS}}{{.Version}}{{.PS}}{{.Os}}-{{.Arch}}",
Uses mockgen to generate mocks for our interfaces. If you make any changes to any of the interface signatures, you'll need to update the mocks using the command:
go generate ./...