ping

package
v0.0.0-...-794d9ef Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: MIT, MIT Imports: 4 Imported by: 0

README

ping - a go wrapper for ping command

go report card MIT license GoDoc

Example
ip := net.ParseIP("8.8.8.8")
res, err := ping.Once(ip)
if err != nil {
	fmt.Println(err)
}
fmt.Println(string(res.Raw))

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Ip        net.IP
	Raw       []byte
	Meta      *ResultMeta
	Data      []*ResultData
	Statistic *ResultStatistic
}

Result struct

func Once

func Once(ip net.IP, args ...string) (r *Result, err error)

Ping the given net.IP once

Example

Example of Once function

package main

import (
	"fmt"
	"net"

	"github.com/xellio/tools/ping"
)

func main() {
	ip := net.ParseIP("8.8.8.8")
	res, err := ping.Once(ip)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(res.Meta.String())

}
Output:

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

func (*Result) String

func (r *Result) String() string

Returns r.Raw as string

type ResultData

type ResultData struct {
	IcmpSeq int
	Ttl     int
	Time    float64
	// contains filtered or unexported fields
}

Struct for storing data information in Result.Data

type ResultMeta

type ResultMeta struct {
	Host  string
	Ip    net.IP
	Bytes string
	// contains filtered or unexported fields
}

Struct for storing meta information in Result.Meta

func (*ResultMeta) String

func (m *ResultMeta) String() string

Returns r.Meta as string

type ResultStatistic

type ResultStatistic struct {
	PacketCount       int
	ReceivedCount     int
	PacketLossPercent float64
	Time              float64
	RTT               *ResultStatisticRTT
	// contains filtered or unexported fields
}

Struct for storing statistic information in Result.Statistic

func (*ResultStatistic) String

func (s *ResultStatistic) String() string

Returns r.Statistic as string

type ResultStatisticRTT

type ResultStatisticRTT struct {
	Min  float64
	Avg  float64
	Max  float64
	MDev float64
	// contains filtered or unexported fields
}

Struct for storing round trip times (RTT)

func (*ResultStatisticRTT) String

func (rtt *ResultStatisticRTT) String() string

Returns r.Statistic.RTT as string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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