Skip to content

Commit

Permalink
fix format 0 duration
Browse files Browse the repository at this point in the history
  • Loading branch information
mkideal committed Aug 18, 2024
1 parent 9ff9ad8 commit 19749b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func (d *Duration) Deref() time.Duration {
func formatDuration(d time.Duration) string {
var sb strings.Builder
if d == 0 {
return "0"
return "0s"
}
if d < 0 {
sb.WriteByte('-')
Expand Down
1 change: 1 addition & 0 deletions types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func TestFormatDuration(t *testing.T) {
d time.Duration
str string
}{
{0, "0s"},
{5 * time.Second, "5s"},
{5 * time.Minute, "5m"},
{5 * time.Hour, "5h"},
Expand Down

0 comments on commit 19749b3

Please sign in to comment.