improve readability of the web package

This commit is contained in:
2026-02-13 21:48:21 -08:00
parent 332460b90d
commit 5c5b295961
7 changed files with 719 additions and 658 deletions

26
web/utils.go Normal file
View File

@@ -0,0 +1,26 @@
package web
// Functions used in the HTML templates
import (
"fmt"
)
// Subtracts two integers
func sub(a int, b int) int {
return a - b
}
// Adds two integers
func add(a int, b int) int {
return a + b
}
// Put a comma in the thousands place, ten-thousands place etc.
func formatInt(n int) string {
if n < 1000 {
return fmt.Sprintf("%d", n)
} else {
return formatInt(n/1000) + "," + fmt.Sprintf("%03d", n%1000)
}
}