docs: add godoc for formatInt in activity package
Explains the integer-to-string conversion behavior: - Direct rune conversion for single digits (efficiency) - Iterative digit extraction for larger numbers - Avoids strconv import for simple formatting
This commit is contained in:
@@ -92,6 +92,10 @@ func formatDays(d time.Duration) string {
|
|||||||
return formatInt(days) + "d"
|
return formatInt(days) + "d"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// formatInt converts a non-negative integer to its decimal string representation.
|
||||||
|
// For single digits (0-9), it uses direct rune conversion for efficiency.
|
||||||
|
// For larger numbers, it extracts digits iteratively from least to most significant.
|
||||||
|
// This avoids importing strconv for simple integer formatting in the activity package.
|
||||||
func formatInt(n int) string {
|
func formatInt(n int) string {
|
||||||
if n < 10 {
|
if n < 10 {
|
||||||
return string(rune('0'+n))
|
return string(rune('0'+n))
|
||||||
|
|||||||
Reference in New Issue
Block a user