set custom user-agent on all requests #84
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR sets a custom user-agent on all requests set by the speedtest library:
showwin/speedtest-go <version>
. This UserAgent can be overridden with a newOption
,WithUserAgent
. ThisWithUserAgent
option is just a convenience function -- it wraps the transport on the client's Doer to add auser-agent
to all requests. As such, you can use it with a custom Doer if you want (as long as you pass the custom doer first), or you can just implement your own User-Agent on the doer you pass in.I thought this might be a little nicer way to handle user-agents, but this PR is definitely a little opinionated, glad to adjust or close, just lmk :-)
New Unit Tests are added to test the user-agent behavior, and all tests pass:
Note: to access the
speedtest-go
version, I had to move it tospeedtest.go
, so if you like this behavior, new releases will need to bump the version there instead.