Skip to content

Instantly share code, notes, and snippets.

@sitaramshelke
Created November 28, 2023 13:54
Show Gist options
  • Save sitaramshelke/1c01b603ab43b6360b7215631a858c90 to your computer and use it in GitHub Desktop.
Save sitaramshelke/1c01b603ab43b6360b7215631a858c90 to your computer and use it in GitHub Desktop.
Snippet for self updatable go binaries
// 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