Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved reports #63

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

czechbol
Copy link
Contributor

@czechbol czechbol commented Apr 9, 2023

Waiting until #62 is merged

  • the updated dependencies bring gocsv.MarshalStringWithoutHeaders which I depend on here

I have improved the report structs.
This way there is no need to differentiate between json and csv output formats until all the way at the end when printing the output.

I also replaced the os.Stdout.Write with fmt.Print and fmt.Println as it also writes to Stdout, the json output wasn't properly terminated (no newline char at the end) and this way the number of imports was reduced. It's also easier to use and doesn't change the behavior.

#35 is unaffected, it works fine, no extra newlines are added (same with when on master without this PR)

speedtest-cli ❯ go run main.go --verbose --json > result.json 2> result.log
speedtest-cli ❯  go run main.go --csv-header
Timestamp,Server Name,Address,Ping,Jitter,Download,Upload,Share,IP
speedtest-cli ❯ cat result.json | jq
[
  {
    "timestamp": "2023-04-09T13:30:39.251614354+02:00",
    "server": {
      "name": "Virginia, United States, OVH",
      "url": "https://speed.riverside.rocks/"
    },
    "client": {
      "ip": "",
      "hostname": "",
      "city": "",
      "region": "",
      "country": "",
      "loc": "",
      "org": "",
      "postal": "",
      "timezone": ""
    },
    "bytes_sent": 189792256,
    "bytes_received": 182674200,
    "ping": 7,
    "jitter": 0.27,
    "upload": 97.32,
    "download": 93.67,
    "share": ""
  }
]
speedtest-cli ❯ tail result.log
Sponsored by: Riverside Rocks @ https://riverside.rocks
Failed when parsing get IP result: json: cannot unmarshal string into Go struct field GetIPResult.rawIspInfo of type defs.IPInfoResponse
Received payload: {"processedString":"2001:470:6e:1c2::2 - Unknown ISP","rawIspInfo":""}
You're testing from: {"processedString":"2001:470:6e:1c2::2 - Unknown ISP","rawIspInfo":""}
Failed when reading HTTP response: context deadline exceeded (Client.Timeout or context cancellation while reading body)
Failed when reading HTTP response: context deadline exceeded (Client.Timeout or context cancellation while reading body)
Failed when reading HTTP response: context deadline exceeded (Client.Timeout or context cancellation while reading body)
Failed when making HTTP request: Post "https://speed.riverside.rocks/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Failed when making HTTP request: Post "https://speed.riverside.rocks/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Failed when making HTTP request: Post "https://speed.riverside.rocks/empty.php": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

@czechbol czechbol marked this pull request as draft April 9, 2023 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant