Skip to content

Commit bb162f6

Browse files
committed
Expose net.Conn for running a speedtest
1 parent ae46caa commit bb162f6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/speedtest/speedtest_client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,22 @@ func RunClient(direction Direction, duration time.Duration, host string) ([]Resu
1919
if err != nil {
2020
return nil, err
2121
}
22+
return RunClientWithConn(direction, duration, conn)
23+
}
2224

25+
func RunClientWithConn(direction Direction, duration time.Duration, conn net.Conn) ([]Result, error) {
2326
conf := config{TestDuration: duration, Version: version, Direction: direction}
2427

2528
defer conn.Close()
2629
encoder := json.NewEncoder(conn)
2730

28-
if err = encoder.Encode(conf); err != nil {
31+
if err := encoder.Encode(conf); err != nil {
2932
return nil, err
3033
}
3134

3235
var response configResponse
3336
decoder := json.NewDecoder(conn)
34-
if err = decoder.Decode(&response); err != nil {
37+
if err := decoder.Decode(&response); err != nil {
3538
return nil, err
3639
}
3740
if response.Error != "" {

0 commit comments

Comments
 (0)