Hi,
if you run Scan() the result will always contain the number of open ips on the specific port but always the same IP (e.g. 10.0.1.255 or 192.168.1.255).
This is caused because you dereference a variable inside a GO Routine which was referenced inside a Range Loop.
func (s *Scanner) Scan() []AddressSet {
...
// here you get a reference to the specific id
for _, ip := range s.ips {
and then
// here you use the referenced IP which is at this time the last item of the range loop
results = append(results, AddressSet{
IP: copyIP(ip),
Port: port,
Protocol: proto,
})
To fix that, you need to copy the id first into a variable and pass it into the go routine (as you did with address).
Hi,
if you run
Scan()the result will always contain the number of open ips on the specific port but always the same IP (e.g. 10.0.1.255 or 192.168.1.255).This is caused because you dereference a variable inside a GO Routine which was referenced inside a Range Loop.
and then
// here you use the referenced IP which is at this time the last item of the range loop results = append(results, AddressSet{ IP: copyIP(ip), Port: port, Protocol: proto, })To fix that, you need to copy the id first into a variable and pass it into the go routine (as you did with address).