I hereby claim:
- I am sitaramshelke on github.
- I am sitaramshelke (https://keybase.io/sitaramshelke) on keybase.
- I have a public key whose fingerprint is 84E0 BFC7 D4B6 E61B 2DB2 D53D 3969 963E 0E35 C14F
To claim this, I am signing this object:
// Code snippet: Apply the self-update | |
bin, err := getExecutableFromAsset(assetId, format) | |
if err != nil { | |
// Handle error - can't get executable | |
} | |
updateOpts := selfupdate.Options{} | |
if err = selfupdate.Apply(bytes.NewBuffer(bin), updateOpts); err != nil { | |
// Handle error - update failed, roll back if necessary | |
} |
// 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) |
// 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 |
// 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) |
// Code snippet: Form an executable name based on assets in releases page | |
executableName := "cloudlens_" + strings.TrimPrefix(latest.GetTagName(), "v") + "_" + runtime.GOOS + "_" + runtime.GOARCH |
// Code snippet: Fetch the latest release information from GitHub | |
latest, _, err := githubClient.Repositories.GetLatestRelease(context.Background(), "<org>", "<repo>") |
puts "=========== Iterative ============" | |
def fib(n) | |
i = 0 | |
f = 0 | |
s = 1 | |
puts f | |
puts s | |
while i < n - 2 | |
t = f | |
f = s |
I hereby claim:
To claim this, I am signing this object: