go-selfupdate
go-selfupdate copied to clipboard
Support for MacOS universal brinaries
MacOS supports universal binaries. These are binraries which have the amd64 and arm64 target in one binary. How would this be supported by this library.
I saw there is some code to detect the go os and arch version. In case of darwin amd64|arm64 host system the release should also try to detect a "_darwin_universal" file I guess.
Currently we work around this by creating an universal binary and copying it as amd64 and arm64 target.
That's possible assuming there's a way to detect the type of binary it's currently running (so it can update to a similar one). I suppose it shouldn't be too difficult.
Would that work for you?
Proposal
I'm proposing adding a new field in the configuration where you can set the Arch
of the universal binary:
updater, err := selfupdate.NewUpdater(selfupdate.Config{
UniversalArch: "universal",
})
if err != nil {
log.Fatal(err)
}
release, found, err := updater.DetectLatest(context.Background(), selfupdate.NewRepositorySlug("owner", "cli-tool"))
if err != nil {
log.Fatal(err)
}
Default
The default value is empty (which is the current behaviour)