Skip to content

Commit

Permalink
allow json upload field to be nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkelam committed Aug 5, 2024
1 parent c746e66 commit dc7a0b7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type Speed struct {
Unit string `json:"unit"`
}
type SpeedResults struct {
Download Speed `json:"download"`
Upload Speed `json:"upload,omitempty"`
Download Speed `json:"download"`
Upload *Speed `json:"upload"`
}

var (
Expand Down Expand Up @@ -157,7 +157,9 @@ func printFinalSpeeds(downloadSpeed *Speed, uploadSpeed *Speed, checkUpload bool
if jsonOutput {
results := SpeedResults{
Download: *downloadSpeed,
Upload: *uploadSpeed,
}
if checkUpload {
results.Upload = uploadSpeed
}
utils.PrintJSON("%s\n", toJSON(results))
} else {
Expand Down

0 comments on commit dc7a0b7

Please sign in to comment.