Skip to content

Commit

Permalink
use anonymous struct
Browse files Browse the repository at this point in the history
  • Loading branch information
yuandrew committed Aug 29, 2024
1 parent 717ebd3 commit b31c425
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/latest_sdk_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (p *LatestSdkVersionConfig) flags() []cli.Flag {
}

type GitHubApiVersion struct {
Name string `json:"name"`
TagName string `json:"tag_name"`
}

func getLatestSdkVersion(config LatestSdkVersionConfig) error {
Expand All @@ -55,13 +55,15 @@ func getLatestSdkVersion(config LatestSdkVersionConfig) error {
return fmt.Errorf("failed to read body of GitHub Get request: %w", err)
}

var version GitHubApiVersion
var version struct {
TagName string `json:"tag_name"`
}
err = json.Unmarshal(body, &version)
if err != nil {
return fmt.Errorf("failed to decode json response: %w", err)
}

fmt.Println(strings.TrimPrefix(version.Name, "v"))
fmt.Println(strings.TrimPrefix(version.TagName, "v"))

return nil
}

0 comments on commit b31c425

Please sign in to comment.