Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed linter issues
Browse files Browse the repository at this point in the history
khareyash05 committed Nov 14, 2024
1 parent 4cc94be commit 8d58028
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
@@ -38,18 +38,17 @@ func rootCmd() *cmdBuilder.Cmd {
AddChildrenCmd(supportCmd()).
AddChildrenCmd(updateCmd()).
GuestRunFunc(func(ctx context.Context, cmdData *cmdBuilder.GuestCmdData) error {

homeDir, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("failed to get home directory: %v", err)
return fmt.Errorf("failed to get home directory: %w", err)
}

zcliPath := fmt.Sprintf("%s/.local/bin/zcli", homeDir)
cmd := exec.CommandContext(ctx, zcliPath, "update")
cmd.Stdout = cmdData.Stdout.GetWriter()
cmd.Stdin = os.Stdin
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to execute 'zcli update': %v", err)
return fmt.Errorf("failed to execute 'zcli update': %w", err)
}

cmdData.Stdout.PrintLines(
9 changes: 6 additions & 3 deletions src/cmd/update.go
Original file line number Diff line number Diff line change
@@ -36,7 +36,10 @@ func updateCmd() *cmdBuilder.Cmd {
fmt.Println("There is a new version available:", latestVersion.TagName)
fmt.Println("Do you want to update? (y/n)")
var input string
fmt.Scanln(&input)
if _, err := fmt.Scanln(&input); err != nil {
fmt.Println("Failed to read input:", err)
return err
}

if input == "y" {
target := determineTargetArchitecture()
@@ -58,7 +61,7 @@ func updateCmd() *cmdBuilder.Cmd {
}

type GitHubRelease struct {
TagName string `json:"tag_name"`
TagName string `json:"tagName"`
Body string `json:"body"`
}

@@ -73,7 +76,7 @@ func getLatestGitHubRelease(ctx context.Context) (GitHubRelease, error) {
Timeout: 4 * time.Second,
}

req, err := http.NewRequestWithContext(ctx, "GET", apiURL, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, apiURL, nil)
if err != nil {
return GitHubRelease{}, err
}

0 comments on commit 8d58028

Please sign in to comment.