Skip to content

Commit dea676c

Browse files
committed
fix unwanted trailing-space
1 parent 1bae6ba commit dea676c

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ a maximum of six characters while still showing as much precision as possible.
2020
The highest byte count printable is 268435440QB (Quetta-bytes, 10³⁰),
2121
exceeding this will print `+InfQB`.
2222

23+
`bytecount.Value` stores values as `float32`. Exact integer precision is therefore limited
24+
to 24 bits (16,777,216). Above that, neighboring integer byte counts may format identically.
25+
2326
If the formatting verb is `d` (e.g. `"%d"`), the divisor is 1000 rather than 1024.
2427

2528
If the formatting verb is `b` (e.g. `"%b"`), the value is multiplied by 8 and the

value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (v Value) Format(f fmt.State, verb rune) {
7373
}
7474
buf = buf[1:]
7575
}
76-
if f.Flag(' ') {
76+
if f.Flag(' ') && (scale != 0 || unit != 0) {
7777
buf = append(buf, ' ')
7878
}
7979
if scale != 0 {

value_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ func TestValue_Format(t *testing.T) {
5555
f: "%#-5.1v",
5656
v: 1,
5757
},
58+
{
59+
name: "1",
60+
f: "% #v",
61+
v: 1,
62+
},
5863
{
5964
name: "-01B",
6065
f: "%04v",

0 commit comments

Comments
 (0)