From 6b39b2b04e037b809537ec2b6209b62b114dceaf Mon Sep 17 00:00:00 2001 From: demo Date: Thu, 28 May 2026 13:20:30 -0400 Subject: feat: add comment logging maxDepth and maxURLs inside xml output --- classic.go | 2 +- xml.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/classic.go b/classic.go index 709271f..cdf8606 100644 --- a/classic.go +++ b/classic.go @@ -76,7 +76,7 @@ loop: wg.Wait() fmt.Println("Generating sitemap...") - sitemap, err := toSitemap(seen) + sitemap, err := toSitemap(seen, maxDepth, maxURLs) if err != nil { log.Fatal(err) } diff --git a/xml.go b/xml.go index 400ae8e..51c9f93 100644 --- a/xml.go +++ b/xml.go @@ -10,6 +10,7 @@ type XMLURLset struct { XMLName xml.Name `xml:"urlset"` Xmlns string `xml:"xmlns,attr"` URLs []URL `xml:"url"` + Comment string `xml:",comment"` } type URL struct { @@ -20,7 +21,7 @@ type Loc struct { Text string `xml:",chardata"` } -func toSitemap(seen map[url.URL]int) (string, error) { +func toSitemap(seen map[url.URL]int, maxDepth, maxURLs int) (string, error) { var xmlURLs []URL for u := range seen { @@ -34,8 +35,9 @@ func toSitemap(seen map[url.URL]int) (string, error) { } set := XMLURLset{ - Xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9", - URLs: xmlURLs, + Xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9", + URLs: xmlURLs, + Comment: fmt.Sprintf("max depth: %d, max urls: %d", maxDepth, maxURLs), } output, err := xml.MarshalIndent(&set, "", "\t") -- cgit v1.2.3