diff options
| author | demo <demo@antix1> | 2026-05-28 13:25:42 -0400 |
|---|---|---|
| committer | demo <demo@antix1> | 2026-05-28 13:25:42 -0400 |
| commit | eae74f26ada313c15057013a1df6b81b50d94a90 (patch) | |
| tree | 031a9bd07c2f099b1ea42ceeb45333418d387097 | |
| parent | c679e48964a6fa2bc2bc54fa6541c113e41ca672 (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.
| -rw-r--r-- | xml.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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) +} |
