showwin / speedtest-go

CLI and Go API to Test Internet Speed using speedtest.net
MIT License
565 stars 115 forks source link

fix: json output not using speed format #220

Closed luevano closed 5 months ago

luevano commented 5 months ago

Closes #219

~Implemented Marshaler for ByteRate,~ Added extra DL/UL fields to Server so that the json output uses the specified format and scaling for the speed values.

Example output (string) (for default format/unit):

...
"dl_speed": "341.80 Mbps",
"ul_speed": "298.76 Mbps",
...

Example output (string) (for binary-bytes unit option):

...
"dl_speed": "40.79 MiB/s",
"ul_speed": "31.11 MiB/s",
...

Before output (float) (always the raw float value):

...
"dl_speed": 42814913.17295695,
"ul_speed": 37902142.46883963,
...
r3inbowari commented 5 months ago

Thank you very much @luevano, I left a comment.

luevano commented 5 months ago

Thank you very much @luevano, I left a comment.

Thanks for the feedback, I changed the fix to add new fields and use those for the json, it now outputs as string value and contains the autoscaled value and the correct unit.

Added example outputs in the OP.

Closing reason: https://github.com/showwin/speedtest-go/issues/219#issuecomment-2169231000