Created
November 28, 2023 14:10
-
-
Save sitaramshelke/f7b498d331f85079e7e652ba86d50873 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: To extract executable | |
func getExecutableFromAsset(assetId AssetId, format AssetFormat) ([]byte, error) { | |
buff, err := downloadAssetFromID(assetId) | |
if format == Zip { | |
zipReader, err := zip.NewReader(bytes.NewReader(buff.Bytes()), int64(buff.Len())) | |
// Zip reader logic | |
} else if format == Tar { | |
gzipReader, err := gzip.NewReader(buff) | |
tarReader := tar.NewReader(gzipReader) | |
} | |
return nil, fmt.Errorf("executable not found in archive") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment