Enable your Golang applications to easily and safely to self update.
Here is the list of projects using this package.
It provides the flexibility to implement different updating user experiences like auto-updating, or manual user-initiated updates, and updates from different sources.
The gopher in this image was created by Takuya Ueda, licensed under Creative Commons 3.0 Attributions license.
- Flexible way to provide updates (ex: using Github or Gitlab!)
- Cross platform support (Mac, Linux, Arm, and Windows)
- RSA signature verification
- Tooling to generate and verify signatures
- Background update
- Rollback feature
- No external dependencies
go get -u github.com/mouuff/go-rocket-update/...
Here is an example using Github releases:
u := &updater.Updater{
Provider: &provider.Github{
RepositoryURL: "github.com/mouuff/go-rocket-update-example",
ArchiveName: fmt.Sprintf("binaries_%s.zip", runtime.GOOS),
},
ExecutableName: fmt.Sprintf("go-rocket-update-example_%s_%s", runtime.GOOS, runtime.GOARCH),
Version: "v0.0.1",
}
if _, err := u.Update(); err != nil {
log.Println(err)
}
For more examples, please take a look at some code samples and this example project.
The updater uses a Provider
as an input source for updates. It provides files and version for the updater.
Here is few examples of providers:
provider.Github
: It will check for the latest release on Github with a specific archive name (zip or tar.gz)provider.Gitlab
: It will check for the latest release on Gitlab with a specific archive name (zip or tar.gz)provider.Local
: It will use a local folder, version will be defined in the VERSION file (can be used for testing, or in a company with a shared folder for example)provider.Zip
: It will use azip
file. The version is defined by the file name (Example:binaries-v1.0.0.tar.gz
). Use GlobNewestFile to find the right file.provider.Gzip
: Same asprovider.Zip
but with atar.gz
file.
The updater will list the files and retrieve them the same way for all the providers:
The directory should have files containing ExecutableName
.
Example directory content with ExecutableName: fmt.Sprintf("test_%s_%s", runtime.GOOS, runtime.GOARCH)
:
test_windows_amd64.exe
test_darwin_amd64
test_linux_arm
We recommend using goxc for compiling your Go application for multiple platforms.
- To update the binary, you need to have the right permissions for the folder where it is installed. For example, if the binary is in a folder like "Program Files", the process will need to acquire admin permissions.
This project is currently under construction, here is some of the things to come:
- More documentation and examples
- Variable templating
- Mutliple providers (enables the use of another provider if the first one is down)
- Update channels for Github provider (alpha, beta, ...)
- Validation of the executable being installed