Skip to content

Pinger.TimeOut cause nil pointer error #137

Open
@gaorongfu

Description

@gaorongfu

code :

pinger, err := probing.NewPinger(ip)
if err != nil {
fmt.Printf("%s : %s", allIp[idx], err.Error())
return
}
pinger.SetPrivileged(true)
pinger.Timeout = time.Second
pinger.Count = 3

            err := pinger.Run() // Blocks until finished.
		if err != nil {
			panic(err)
		}

error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0xf0 pc=0xbb5fff]

goroutine 1 [running]:
github.com/prometheus-community/pro-bing.(*Pinger).RunWithContext(0xc5d220?, {0xc5e250?, 0xdbf6e0?})
E:/goProjects/pkg/mod/github.com/prometheus-community/[email protected]/ping.go:520 +0x3f
github.com/prometheus-community/pro-bing.(*Pinger).Run(...)
E:/goProjects/pkg/mod/github.com/prometheus-community/[email protected]/ping.go:511
main.main()
E:/goProjects/src/fping/main.go:44 +0x3d6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions