diff --git a/plugin.go b/plugin.go index 25fd899..9d7d454 100644 --- a/plugin.go +++ b/plugin.go @@ -40,7 +40,7 @@ type ( ) func (p Plugin) log(host string, message ...interface{}) { - if len(host) == 0 { + if count := len(p.Config.Host); count == 1 { fmt.Printf("%s", fmt.Sprintln(message...)) } else { fmt.Printf("%s: %s", host, fmt.Sprintln(message...)) @@ -65,9 +65,8 @@ func (p Plugin) Exec() error { wg.Add(len(p.Config.Host)) errChannel := make(chan error, 1) finished := make(chan bool, 1) - countHosts := len(p.Config.Host) for _, host := range p.Config.Host { - go func(host string, counts int) { + go func(host string) { // Create MakeConfig instance with remote username, server address and path to private key. ssh := &easyssh.MakeConfig{ Server: host, @@ -96,10 +95,6 @@ func (p Plugin) Exec() error { // read from the output channel until the done signal is passed stillGoing := true isTimeout := true - // hide host in log if only single host in config. - if counts == 1 { - host = "" - } for stillGoing { select { case isTimeout = <-doneChan: @@ -124,7 +119,7 @@ func (p Plugin) Exec() error { } wg.Done() - }(host, countHosts) + }(host) } go func() {