Add configurable sequence numbering command

This commit is contained in:
2025-11-03 10:59:15 +08:00
parent 843c51e347
commit e6a5c6499b
34 changed files with 1920 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
package sequence
import (
"fmt"
"strconv"
)
// formatNumber zero-pads the provided value using the requested width and returns
// both the padded number string and the width that was ultimately used.
func formatNumber(value, requestedWidth int) (string, int) {
if value < 0 {
value = 0
}
digitCount := len(strconv.Itoa(value))
width := requestedWidth
if width <= 0 || width < digitCount {
width = digitCount
}
return fmt.Sprintf("%0*d", width, value), width
}