Format method on speedFormatter value receiver
Vladimir Bauer
3 years ago
| 19 | 19 | // |
| 20 | 20 | // fmt.Printf("%.1f", FmtAsSpeed(SizeB1024(2048))) |
| 21 | 21 | func FmtAsSpeed(input fmt.Formatter) fmt.Formatter { |
| 22 | return &speedFormatter{input} | |
| 22 | return speedFormatter{input} | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | type speedFormatter struct { |
| 26 | 26 | fmt.Formatter |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | func (self *speedFormatter) Format(st fmt.State, verb rune) { | |
| 29 | func (self speedFormatter) Format(st fmt.State, verb rune) { | |
| 30 | 30 | self.Formatter.Format(st, verb) |
| 31 | 31 | _, err := st.Write([]byte("/s")) |
| 32 | 32 | if err != nil { |