Documentation ¶
Index ¶
- Variables
- func AutoUpdate(allowTest bool)
- func Busy()
- func Fetch(projectName, curTag, os, arch, channel string, ...) errordeprecated
- func GetUpdate(projectName, curTag, os, arch, channel string) (string, string, string, error)deprecated
- func GetVars() map[string]string
- func Restart()
- func RestartProgram() error
- func RunAutoUpdateCheck() bool
- func SignalVersion(git, build string)
- func SignalVersionChannel(git, build, channel string)
- func SwitchChannel(channel string) bool
- func Unbusy()
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( PROJECT_NAME string = "unconfigured" MODE string = "DEV" CHANNEL string = "" // output of: git rev-parse --abbrev-ref HEAD GIT_TAG string = "" DATE_TAG string = "0" VERSION string = "" HOST string = "https://dist-go.tristandev.net/" )
var BeforeRestart func()
BeforeRestart is called just before the program is restarted, and can be used to prepare for restart, such as duplicating fds before exec/etc.
var RestartFunction func() error = RestartProgram
RestartFunction is the functions that actually performs the restart, and by default will be RestartProgram which is a OS dependent implementation
var UnameArchMatch = map[string]string{
"x86_64": "amd64",
"amd64": "amd64",
"i686": "386",
"powerpc": "ppc",
"ppc": "ppc",
"ppc64": "ppc64",
"armv7l": "arm",
"armv6l": "arm",
"armv7b": "armbe",
"armv6b": "armbe",
"aarch64": "arm64",
"aarch64_be": "arm64be",
"armv8b": "arm64be",
"armv8l": "arm64",
"mips": "mips",
}
uname -m
var UnameOsMatch = map[string]string{
"Linux": "linux",
"CYGWIN_*": "windows",
"MINGW*": "windows",
"WIN32": "windows",
"WINNT": "windows",
"Windows": "windows",
"Darwin*": "darwin",
"FreeBSD": "freebsd",
}
uname -s
Functions ¶
func AutoUpdate ¶
func AutoUpdate(allowTest bool)
func RestartProgram ¶ added in v0.2.2
func RestartProgram() error
func RunAutoUpdateCheck ¶
func RunAutoUpdateCheck() bool
RunAutoUpdateCheck will perform the update check, update the executable and return false if no update was performed. In case of update the program should restart and RunAutoUpdateCheck() should not return, but if it does, it'll return true.
func SignalVersion ¶
func SignalVersion(git, build string)
SignalVersion is called when seeing another peer running the same software to notify of its version. This will check if the peer is updated compared to us, and call RunAutoUpdateCheck() if necessary
func SignalVersionChannel ¶ added in v0.3.1
func SignalVersionChannel(git, build, channel string)
SignalVersionChannel performs the same as SignalVersion but will also check channel
func SwitchChannel ¶ added in v0.3.0
SwitchChannel will update the current running daemon to run on the given channel. It will return false if the running instance is already the latest version on that channel
Types ¶
type Version ¶ added in v0.3.3
type Version struct { ProjectName string // project's name Channel string // project channel (typically, branch name) DateTag string // version's date tag GitTag string // version's git tag (first 7 digits of git hash) UpdatePrefix string // internally used prefix }
func GetLatest ¶ added in v0.3.3
GetLatest returns the latest version information for a given projectName and channel
func (*Version) CheckArch ¶ added in v0.3.3
CheckArch checks if the provided version is compatible with the provided os and arch
func (*Version) Download ¶ added in v0.3.3
func (v *Version) Download(os, arch string) (io.ReadCloser, error)
Download returns a ReadCloser that allows reading the updated executable data. It will handle any decompression that might be needed, so the data can be read directly. Make sure to close the returned ReadCloser after usage.
func (*Version) Install ¶ added in v0.4.0
Install will download the update and replace the currently running executable data
func (*Version) IsCurrent ¶ added in v0.4.0
IsCurrent returns true if the version matches the currently running program