install to your project
go get github.com/Cocoon-break/speedtest
usage
Latency
func byLatency() {
report, err := speedtest.ByLatency("eth0", 60)
if err != nil {
fmt.Printf("failed:%s", err.Error())
return
}
fmt.Printf("%+v", report)
}
Distance
func byDistance() {
report, err := speedtest.ByDistance("eth0", 60)
if err != nil {
fmt.Printf("failed:%s", err.Error())
return
}
fmt.Printf("%+v", report)
}
BySpeedtestCli,the Preconditions is you installed speediest-cli
func bySpeedtestclit() {
report, err := speedtest.BySpeedtestCli([]string{"eth0"}, 120)
if err != nil {
fmt.Printf("failed:%s", err.Error())
return
}
fmt.Printf("%+v", report)
}
note: the result of speed unit is MB.