From 00eaee6896acb4ea1c46545caab44fb4ad3f2a5e Mon Sep 17 00:00:00 2001 From: nitper Date: Wed, 6 Mar 2019 15:40:58 -0500 Subject: [PATCH] fix Scan() to output the correct IP and Port pass copies of `ip` and `port` into the goroutine fixes #4 --- pkg/scanner/scanner.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/scanner/scanner.go b/pkg/scanner/scanner.go index 38d8ee4..2929e65 100644 --- a/pkg/scanner/scanner.go +++ b/pkg/scanner/scanner.go @@ -109,7 +109,7 @@ func (s *Scanner) Scan() []AddressSet { addr := fmt.Sprintf("%s:%d", ip, port) wg.Add(1) - go func(proto, addr string) { + go func(proto, addr string, ip net.IP, port int) { defer wg.Done() guard <- struct{}{} @@ -125,7 +125,7 @@ func (s *Scanner) Scan() []AddressSet { }) resultsMutex.Unlock() } - }(proto, addr) + }(proto, addr, ip, port) } } }