While testing port scanner with go1.6 I discovered that it fails with initialising PortScanner struct. It throws such error:
combor/port-scanner/PortScanner.go:27: too few values in struct initializer
combor/port-scanner/PortScanner.go:50: cannot use h.timeout (type int) as type time.Duration in argument to net.DialTimeout
combor/port-scanner/PortScanner.go:82: cannot use h.timeout (type int) as type time.Duration in argument to net.DialTimeout
Additionaly there is a wrong type returned in openConn method:
combor/port-scanner/PortScanner.go:90: cannot use conn (type net.Conn) as type *net.TCPConn in return argument: need type assertion
How to test
Run the code from README but with modified call to NewPortScanner :
timeout := 100 * time.Millisecond
ps := portscanner.NewPortScanner(host, timeout)
// get opened port
fmt.Printf("scanning port %d-%d...\n", 20, 65535)
openedPorts := ps.GetOpenedPort(20, 30000)
for i := 0; i < len(openedPorts); i++ {
port := openedPorts[i]
fmt.Print(" ", port, " [open]")
fmt.Println(" --> ", ps.DescribePort(port))
}
What
While testing port scanner with go1.6 I discovered that it fails with initialising
PortScanner
struct. It throws such error:Additionaly there is a wrong type returned in
openConn
method:How to test
Run the code from README but with modified call to
NewPortScanner
: