From 20bfdc2e73af67f478bf5ddbc6733b969d8966af Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 10 Sep 2014 16:54:22 +0100 Subject: [PATCH] refactor --- connection_maker.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/connection_maker.go b/connection_maker.go index 2354c851..0776e4f3 100644 --- a/connection_maker.go +++ b/connection_maker.go @@ -161,11 +161,13 @@ func (cm *ConnectionMaker) addToTargets(address string) { func (cm *ConnectionMaker) status() string { var buf bytes.Buffer for address, target := range cm.targets { + var fmtStr string if target.attempting { - buf.WriteString(fmt.Sprintf("%s (%v attempts, trying since %v)\n", address, target.attemptCount, target.tryAfter)) + fmtStr = "%s (%v attempts, trying since %v)\n" } else { - buf.WriteString(fmt.Sprintf("%s (%v attempts, next at %v)\n", address, target.attemptCount, target.tryAfter)) + fmtStr = "%s (%v attempts, next at %v)\n" } + buf.WriteString(fmt.Sprintf(fmtStr, address, target.attemptCount, target.tryAfter)) } return buf.String() }