Doesn't work, how do I debug?
andrejohansson opened this issue · 3 comments
I have an application that I crosscompile and upload to a folder on a server. The structure when uploaded is:
archive/online-cli/
| online-cli.darwin-amd64.json
| online-cli.linux-amd64.json
| windows-amd64.json
|
+---17
| online-cli.darwin-amd64.gz
| online-cli.linux-amd64.gz
| online-cli.windows-amd64.gz
|
\---18
online-cli.darwin-amd64.gz
online-cli.linux-amd64.gz
windows-amd64.gz
My code for updating is this:
func main() {
updater := &selfupdate.Updater{
CurrentVersion: version,
ApiURL: "http://updates.mysite.com/",
BinURL: "http://updates.mysite.com/",
DiffURL: "http://updates.mysite.com/",
Dir: "archive/online-cli/",
CmdName: appname, // app name
Requester: mr,
}
if updater != nil {
log.Info("Checking for new versions...")
err := updater.ForegroundRun()
if err != nil {
log.Fatal(err.Error())
}
}
...
However this will not update, and it does not give an error either. I have tested the urls and the files are reachable. How would I move on to debug this issue? Is there something I've missed?
I can't tell you anything to turn on to debug the code (caveat: I'm still figuring out the code myself), but I think you need to do 2 things:
- Remove the
online-cli
parts from the beginning of the filenames - Don't set the
Requestor
part of the Updater struct
@joerocklin thanks for your comments, but unfortunately neither of the fixes did any difference for me. Have you succeeded in getting updates?
@andrejohansson I have indeed. Looking at your setup again, the Dir
value is a directory local to the running binary where the updates will be downloaded into. The CmdName
value is appended to the URLs to find the appropriate binaries. So maybe try this struct:
updater := &selfupdate.Updater{
CurrentVersion: version,
ApiURL: "http://updates.mysite.com/archive/",
BinURL: "http://updates.mysite.com/archive/",
DiffURL: "http://updates.mysite.com/archive/",
Dir: "update-tmp",
CmdName: "online-cli", // app name
}