Skip to content

Commit 5be8d4d

Browse files
committed
add Value.String()
1 parent 9b85616 commit 5be8d4d

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
go tool cover -html=coverage.out -o=coveragereport.html.out
4545
4646
- name: Publish code coverage badge (and optional report)
47-
uses: linkdata/gitcoverage@v1
47+
uses: linkdata/gitcoverage@v3
4848
with:
4949
coverage: ${{ steps.coverage.outputs.coverage }}
5050
report: "coveragereport.html.out"

value.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import (
77

88
type Value float32
99

10+
func (v Value) String() string {
11+
return fmt.Sprint(v)
12+
}
13+
1014
func (v Value) Format(f fmt.State, verb rune) {
1115
var wid, prec int
1216
var scale rune

value_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ func TestValue_Format(t *testing.T) {
8383
})
8484
}
8585
}
86+
87+
func TestValue_String(t *testing.T) {
88+
want := "1.95kB"
89+
got := N(2000).String()
90+
if got != want {
91+
t.Errorf("want %q got %q", want, got)
92+
}
93+
}

0 commit comments

Comments
 (0)