@@ -778,15 +778,15 @@ func (p *ProgressBar) renderDetails() error {
778778
779779 // render the details row
780780 for _ , detail := range p .state .details {
781- b . WriteString ( fmt .Sprintf ( "\u001B [K\r %s\n " , detail ) )
781+ fmt .Fprintf ( & b , "\u001B [K\r %s\n " , detail )
782782 }
783783 // add empty lines to fill the maxDetailRow
784784 for i := len (p .state .details ); i < p .config .maxDetailRow ; i ++ {
785785 b .WriteString ("\u001B [K\n " )
786786 }
787787
788788 // move the cursor up to the start of the details row
789- b . WriteString ( fmt .Sprintf ( "\u001B [%dF" , p .config .maxDetailRow + 1 ) )
789+ fmt .Fprintf ( & b , "\u001B [%dF" , p .config .maxDetailRow + 1 )
790790
791791 _ = writeString (p .config , b .String ())
792792
@@ -1065,31 +1065,28 @@ func renderProgressBar(c config, s *state) (int, error) {
10651065 currentHumanize , currentSuffix := humanizeBytes (s .currentBytes , c .useIECUnits )
10661066 if currentSuffix == c .maxHumanizedSuffix {
10671067 if c .showTotalBytes {
1068- sb .WriteString (fmt .Sprintf ("%s/%s%s" ,
1069- currentHumanize , c .maxHumanized , c .maxHumanizedSuffix ))
1068+ fmt .Fprintf (& sb , "%s/%s%s" , currentHumanize , c .maxHumanized , c .maxHumanizedSuffix )
10701069 } else {
1071- sb .WriteString (fmt .Sprintf ("%s%s" ,
1072- currentHumanize , c .maxHumanizedSuffix ))
1070+ fmt .Fprintf (& sb , "%s%s" , currentHumanize , c .maxHumanizedSuffix )
10731071 }
10741072 } else if c .showTotalBytes {
1075- sb .WriteString (fmt .Sprintf ("%s%s/%s%s" ,
1076- currentHumanize , currentSuffix , c .maxHumanized , c .maxHumanizedSuffix ))
1073+ fmt .Fprintf (& sb , "%s%s/%s%s" , currentHumanize , currentSuffix , c .maxHumanized , c .maxHumanizedSuffix )
10771074 } else {
1078- sb . WriteString ( fmt .Sprintf ( "%s%s" , currentHumanize , currentSuffix ) )
1075+ fmt .Fprintf ( & sb , "%s%s" , currentHumanize , currentSuffix )
10791076 }
10801077 } else if c .showTotalBytes {
1081- sb . WriteString ( fmt .Sprintf ( "%.0f/%d" , s .currentBytes , c .max ) )
1078+ fmt .Fprintf ( & sb , "%.0f/%d" , s .currentBytes , c .max )
10821079 } else {
1083- sb . WriteString ( fmt .Sprintf ( "%.0f" , s .currentBytes ) )
1080+ fmt .Fprintf ( & sb , "%.0f" , s .currentBytes )
10841081 }
10851082 } else {
10861083 if c .showBytes {
10871084 currentHumanize , currentSuffix := humanizeBytes (s .currentBytes , c .useIECUnits )
1088- sb . WriteString ( fmt .Sprintf ( "%s%s" , currentHumanize , currentSuffix ) )
1085+ fmt .Fprintf ( & sb , "%s%s" , currentHumanize , currentSuffix )
10891086 } else if c .showTotalBytes {
1090- sb . WriteString ( fmt .Sprintf ( "%.0f/%s" , s .currentBytes , "-" ) )
1087+ fmt .Fprintf ( & sb , "%.0f/%s" , s .currentBytes , "-" )
10911088 } else {
1092- sb . WriteString ( fmt .Sprintf ( "%.0f" , s .currentBytes ) )
1089+ fmt .Fprintf ( & sb , "%.0f" , s .currentBytes )
10931090 }
10941091 }
10951092 }
@@ -1102,7 +1099,7 @@ func renderProgressBar(c config, s *state) (int, error) {
11021099 sb .WriteString (", " )
11031100 }
11041101 currentHumanize , currentSuffix := humanizeBytes (averageRate , c .useIECUnits )
1105- sb . WriteString ( fmt .Sprintf ( "%s%s/s" , currentHumanize , currentSuffix ) )
1102+ fmt .Fprintf ( & sb , "%s%s/s" , currentHumanize , currentSuffix )
11061103 }
11071104
11081105 // show iterations rate
@@ -1113,11 +1110,11 @@ func renderProgressBar(c config, s *state) (int, error) {
11131110 sb .WriteString (", " )
11141111 }
11151112 if averageRate > 1 {
1116- sb . WriteString ( fmt .Sprintf ( "%0.0f %s/s" , averageRate , c .iterationString ) )
1113+ fmt .Fprintf ( & sb , "%0.0f %s/s" , averageRate , c .iterationString )
11171114 } else if averageRate * 60 > 1 {
1118- sb . WriteString ( fmt .Sprintf ( "%0.0f %s/min" , 60 * averageRate , c .iterationString ) )
1115+ fmt .Fprintf ( & sb , "%0.0f %s/min" , 60 * averageRate , c .iterationString )
11191116 } else {
1120- sb . WriteString ( fmt .Sprintf ( "%0.0f %s/hr" , 3600 * averageRate , c .iterationString ) )
1117+ fmt .Fprintf ( & sb , "%0.0f %s/hr" , 3600 * averageRate , c .iterationString )
11211118 }
11221119 }
11231120 if sb .Len () > 0 {
0 commit comments