summaryrefslogtreecommitdiff
path: root/internal/template/template.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-22 23:53:31 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-22 23:53:31 +0200
commit7bfe97f3e72279a17c16803d64a16beb55944332 (patch)
treec8b09860629e2ecfbd0e6ef7382ae60c2dd80f47 /internal/template/template.go
parent9280ecb7e0b0039d6c1f4800373eb76452145078 (diff)
downloadfeed2imap-go-7bfe97f3e72279a17c16803d64a16beb55944332.tar.gz
feed2imap-go-7bfe97f3e72279a17c16803d64a16beb55944332.tar.bz2
feed2imap-go-7bfe97f3e72279a17c16803d64a16beb55944332.zip
Fix html template
Diffstat (limited to 'internal/template/template.go')
-rw-r--r--internal/template/template.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/template/template.go b/internal/template/template.go
index a239484..dd31f51 100644
--- a/internal/template/template.go
+++ b/internal/template/template.go
@@ -3,7 +3,10 @@ package template
import (
"fmt"
"html/template"
+ "strconv"
"strings"
+
+ "github.com/Necoro/feed2imap-go/internal/log"
)
func dict(v ...string) map[string]string {
@@ -29,12 +32,17 @@ func lastUrlPart(url string) string {
return split[len(split)-1]
}
-func byteCount(b int64) string {
+func byteCount(str string) string {
+ b, err := strconv.ParseUint(str, 10, 64)
+ if err != nil {
+ log.Printf("Cannot convert '%s' to byte count: %s", str, err)
+ }
+
const unit = 1024
if b < unit {
return fmt.Sprintf("%d B", b)
}
- div, exp := int64(unit), 0
+ div, exp := uint64(unit), 0
for n := b / unit; n >= unit; n /= unit {
div *= unit
exp++