Initial commit

This commit is contained in:
Ivan 2025-06-16 13:50:33 +05:00
commit e3da3b9c7a
Signed by: landlord
GPG key ID: 416A03BC4ADA4CD7
9 changed files with 929 additions and 0 deletions

41
README.md Normal file
View file

@ -0,0 +1,41 @@
# Sitemap
Sitemap library for golang.
## Usage
```go
package main
import (
"log/slog"
"net/http"
"time"
"code.app-house.ru/go/sitemap"
)
var (
urlset = []sitemap.URL{
sitemap.URL{
Loc: "https://example.com/",
LastMod: time.Date(2025, time.June, 1, 0, 0, 0, 0, time.Local),
ChangeFreq: sitemap.ChangeFreqMonthly,
Priority: 1.0,
},
}
)
func main() {
http.HandleFunc("/sitemap.xml", sitemapHandler)
http.ListenAndServe(":8080", nil)
}
func sitemapHandler(w http.ResponseWriter, r *http.Request) {
err := sitemap.Execute(w, urlset)
if err != nil {
slog.Error("can't render sitemap", "err", err)
}
}
```