summaryrefslogtreecommitdiff
path: root/xml.go
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-28 13:25:42 -0400
committerdemo <demo@antix1>2026-05-28 13:25:42 -0400
commiteae74f26ada313c15057013a1df6b81b50d94a90 (patch)
tree031a9bd07c2f099b1ea42ceeb45333418d387097 /xml.go
parentc679e48964a6fa2bc2bc54fa6541c113e41ca672 (diff)
feat: prettify stats when figure was passed in as 0
The code understands 0 as "no limit", but I want to convey the no-limit concept to readers of the file who don't have a notion of how the program works. So I convert 0 to ∞ in the string output here.
Diffstat (limited to 'xml.go')
-rw-r--r--xml.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/xml.go b/xml.go
index e1a253f..74ecc0d 100644
--- a/xml.go
+++ b/xml.go
@@ -37,7 +37,7 @@ func toSitemap(seen map[url.URL]int, maxDepth, maxURLs int) (string, error) {
set := XMLURLset{
Xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9",
URLs: xmlURLs,
- Comment: fmt.Sprintf("max depth: %d, max urls: %d", maxDepth, maxURLs),
+ Comment: fmt.Sprintf("max depth: %s, max urls: %s", toSymbol(maxDepth), toSymbol(maxURLs)),
}
output, err := xml.MarshalIndent(&set, "", "\t")
@@ -48,3 +48,11 @@ func toSitemap(seen map[url.URL]int, maxDepth, maxURLs int) (string, error) {
withHeader := fmt.Sprintf("%s\n%s", xml.Header, output)
return withHeader, nil
}
+
+func toSymbol(figure int) string {
+ if figure == 0 {
+ return "∞"
+ }
+
+ return fmt.Sprintf("%d", figure)
+}