Skip to content

liu-wh/goutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Utils

Network Util

Install

go get github.com/liu-wh/goutils/network

Ping - Get network latency from local host to remote host with icmp protocol, not exec.run

func main() {
	host := "www.baidu.com"
	num := 10
	report, err := network.Ping(host, num)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Lost=%d(%d%% loss)\nMinimum = %v, Maximum = %v, Average = %v", report.LostNum, report.LostPer, report.MinLatency, report.MaxLatency, report.AvgLatency)
}

image

Convert Util

Install

go get github.com/liu-wh/goutils/convert

Str2bytes, Bytes2str - Use pointers to do string and byte conversion, which is more efficient

Bytes2Human - Convert the byte int to k, m, g string

About

go utils, include network, convert...

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages