Skip to content

speedtest with go ,speedtest bylatency or bydistance ,and use offical cli get output json. 指定网卡测速

Notifications You must be signed in to change notification settings

Cocoon-break/speedtest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

speedtest

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.

About

speedtest with go ,speedtest bylatency or bydistance ,and use offical cli get output json. 指定网卡测速

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages