go-selfupdate icon indicating copy to clipboard operation
go-selfupdate copied to clipboard

Support for MacOS universal brinaries

Open jryannel opened this issue 1 year ago • 1 comments

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.

jryannel avatar Aug 22 '23 09:08 jryannel

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.

creativeprojects avatar Aug 23 '23 19:08 creativeprojects

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)

creativeprojects avatar Jun 16 '24 16:06 creativeprojects