From 282fbd9382095337dabd5d8af71f209ad1d36f0c Mon Sep 17 00:00:00 2001 From: Tizian Date: Wed, 4 Sep 2024 16:02:34 +0200 Subject: [PATCH] Moved progress declaration into for loop (#133) --- nmap.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nmap.go b/nmap.go index 328717c..d95604c 100644 --- a/nmap.go +++ b/nmap.go @@ -176,7 +176,6 @@ func (s *Scanner) Run() (result *Run, warnings *[]string, err error) { type progress struct { TaskProgress []TaskProgress `xml:"taskprogress" json:"task_progress"` } - p := &progress{} for { select { case <-doneProgress: @@ -184,7 +183,8 @@ func (s *Scanner) Run() (result *Run, warnings *[]string, err error) { return default: time.Sleep(time.Millisecond * 100) - _ = xml.Unmarshal(stdout.Bytes(), p) + var p progress + _ = xml.Unmarshal(stdout.Bytes(), &p) progressIndex := len(p.TaskProgress) - 1 if progressIndex >= 0 { s.liveProgress <- p.TaskProgress[progressIndex].Percent