goutils

module
v0.0.0-...-95f1a29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2023 License: MIT

README

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL