Skip to content

EliCDavis/go-selfupdate

 
 

Repository files navigation

go-selfupdate

GoDoc Build Status

Enable your Golang applications to self update. Inspired by Chrome based on Heroku's hk.

Requires Golang 1.8 or higher.

Features

  • 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

QuickStart

Install library and update/patch creation utility

go get -u github.com/EliCDavis/go-selfupdate/...

Enable your App to Self Update

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)
    }
}

Push Out and Update

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}}",

Development

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 ./...

About

Enable your Go applications to self update

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 92.9%
  • Shell 6.8%
  • HTML 0.3%