Skip to content

Instantly share code, notes, and snippets.

@sitaramshelke
Created November 28, 2023 14:05
Show Gist options
  • Save sitaramshelke/4151c828b6e7753bca7e73250a023c54 to your computer and use it in GitHub Desktop.
Save sitaramshelke/4151c828b6e7753bca7e73250a023c54 to your computer and use it in GitHub Desktop.
Snippet for self updatable go binaries
// Code snippet: Download the latest version
func downloadAssetFromID(assetId AssetId) (*bytes.Buffer, error) {
_, rdurl, err := githubClient.Repositories.DownloadReleaseAsset(context.Background(), "one2nc", "cloudlens", int64(assetId), nil)
resp, err := httpClient.Get(rdurl)
defer resp.Body.Close()
bin, err := io.ReadAll(resp.Body)
return bytes.NewBuffer(bin), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment