minor: *speedFormatter as fmt.Formatter
Vladimir Bauer
1 year, 10 months ago
| 20 | 20 | // |
| 21 | 21 | // fmt.Printf("%.1f", FmtAsSpeed(SizeB1024(2048))) |
| 22 | 22 | func FmtAsSpeed(input fmt.Formatter) fmt.Formatter { |
| 23 | return speedFormatter{input} | |
| 23 | return &speedFormatter{input} | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | type speedFormatter struct { |
| 27 | 27 | fmt.Formatter |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | func (self speedFormatter) Format(st fmt.State, verb rune) { | |
| 31 | self.Formatter.Format(st, verb) | |
| 30 | func (s *speedFormatter) Format(st fmt.State, verb rune) { | |
| 31 | s.Formatter.Format(st, verb) | |
| 32 | 32 | _, err := io.WriteString(st, "/s") |
| 33 | 33 | if err != nil { |
| 34 | 34 | panic(err) |