From 5276f2ba6fa72e0fb8fb2f4be9fc578416488836 Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Tue, 11 Apr 2023 17:35:14 +0200 Subject: [PATCH] improve fmt part, using consistant size --- internal/epub/core.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/epub/core.go b/internal/epub/core.go index b6d7b1c..da0ff2c 100644 --- a/internal/epub/core.go +++ b/internal/epub/core.go @@ -247,7 +247,9 @@ func (e *ePub) Write() error { ext := filepath.Ext(e.Output) suffix := "" if totalParts > 1 { - suffix = fmt.Sprintf(" Part %02d of %02d", i+1, totalParts) + fmtLen := len(fmt.Sprint(totalParts)) + fmtPart := fmt.Sprintf(" Part %%0%dd of %%0%dd", fmtLen, fmtLen) + suffix = fmt.Sprintf(fmtPart, i+1, totalParts) } path := fmt.Sprintf("%s%s%s", e.Output[0:len(e.Output)-len(ext)], suffix, ext)