Created
November 28, 2023 13:54
-
-
Save sitaramshelke/1c01b603ab43b6360b7215631a858c90 to your computer and use it in GitHub Desktop.
Snippet for self updatable go binaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code snippet: Lookup executable in the latest release information | |
var assetId AssetId | |
var format AssetFormat | |
loop: | |
for _, v := range latest.Assets { | |
asset := *v.Name | |
switch { | |
case strings.Contains(asset, ".zip"): | |
if strings.EqualFold(asset, executableName+".zip") { | |
assetId = AssetId(*v.ID) | |
format = Zip | |
break loop | |
} | |
case strings.Contains(asset, ".tar.gz"): | |
if strings.EqualFold(asset, executableName+".tar.gz") { | |
assetId = AssetId(*v.ID) | |
format = Tar | |
break loop | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment