Skip to content

Commit

Permalink
Simplify JSON details marshaling
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Dec 16, 2024
1 parent 1be2b29 commit aabfd1a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,11 @@ func (c *versionCmd) run(cmd *cobra.Command, _ []string) error {
details["extensions"] = list
}

jsonDetails, err := json.Marshal(details)
if err != nil {
return fmt.Errorf("failed produce a JSON version details: %w", err)
if err := json.NewEncoder(c.gs.Stdout).Encode(details); err != nil {
return fmt.Errorf("failed to encode/output version details: %w", err)
}

_, err = fmt.Fprintln(c.gs.Stdout, string(jsonDetails))
return err
return nil
}

func getCmdVersion(gs *state.GlobalState) *cobra.Command {
Expand Down

0 comments on commit aabfd1a

Please sign in to comment.