Simple implementation of self-update command. Currently tested on macOS only.
In the process of implementation, I considered ready-made solutions, like go-github-update and go-selfupdate, but in the end I decided not to use them. That is why i decided this way:
Extra dependencies. I don't think protobuf and appengine are useful here
Extra functionality. For example, integrations with Heroku and S3
Lack of functionality. For example, go-github-update searches the archive for files in format "binName_darwin_amd64" (instead darwin_x86_64) and there is no way to fix it easily
To test the feature, do next in shell:
$ go build -ldflags "-X main.version=v1.0.0" ferret/main.go && cp main /usr/local/bin/ferret && ferret version
Version:
Self: v1.0.0
Runtime: unknown
$ ferret selfupdate
Looking for a new version for darwin_x86_64
New version of Ferret available!
Update Ferret to v1.1.0
Download checksums and assets
Verify checksum
Uncompress cli_darwin_x86_64.tar.gz
Install new version
$ ferret version
Version:
Self: 1.1.0
Runtime: 0.15.0
Simple implementation of self-update command. Currently tested on macOS only.
In the process of implementation, I considered ready-made solutions, like go-github-update and go-selfupdate, but in the end I decided not to use them. That is why i decided this way:
go-github-update
searches the archive for files in format "binName_darwin_amd64" (instead darwin_x86_64) and there is no way to fix it easilyTo test the feature, do next in shell: