style: coed cleanup and fix styling

This commit is contained in:
yusing
2025-05-10 10:46:31 +08:00
parent a06787593c
commit c05059765d
24 changed files with 161 additions and 218 deletions

View File

@@ -26,11 +26,11 @@ func AppendDuration(d time.Duration, buf []byte) []byte {
switch {
case d < time.Millisecond:
buf = strconv.AppendInt(buf, int64(d.Nanoseconds()), 10)
buf = strconv.AppendInt(buf, d.Nanoseconds(), 10)
buf = append(buf, []byte(" ns")...)
return buf
case d < time.Second:
buf = strconv.AppendInt(buf, int64(d.Milliseconds()), 10)
buf = strconv.AppendInt(buf, d.Milliseconds(), 10)
buf = append(buf, []byte(" ms")...)
return buf
}

View File

@@ -93,7 +93,7 @@ func TestFormatTime(t *testing.T) {
result := FormatTimeWithReference(tt.time, now)
if tt.expectedLength > 0 {
require.Equal(t, tt.expectedLength, len(result), result)
require.Len(t, result, tt.expectedLength)
} else {
require.Equal(t, tt.expected, result)
}
@@ -213,11 +213,8 @@ func TestFormatLastSeen(t *testing.T) {
if tt.name == "zero time" {
require.Equal(t, tt.expected, result)
} else {
// Just make sure it's not "never", the actual formatting is tested in TestFormatTime
if result == "never" {
t.Errorf("Expected non-zero time to not return 'never', got %s", result)
}
} else if result == "never" { // Just make sure it's not "never", the actual formatting is tested in TestFormatTime
t.Errorf("Expected non-zero time to not return 'never', got %s", result)
}
})
}