func Marshal(urlset *URLSet) (sitemapXML []byte, err error) {
	if len(urlset.URLs) > MaxURLs {
		err = ErrExceededMaxURLs
		return
	}
	urlset.XMLNS = xmlns
	sitemapXML = []byte(preamble)
	var urlsetXML []byte
	urlsetXML, err = xml.Marshal(urlset)
	if err == nil {
		sitemapXML = append(sitemapXML, urlsetXML...)
	}
	if len(sitemapXML) > MaxFileSize {
		err = ErrExceededMaxFileSize
	}
	return
}
Marshal serializes the sitemap URLSet to XML, with the <urlset> xmlns added
and the XML preamble prepended.
package sitemap
import (
	"encoding/xml"
	"errors"
	"time"
)
const (
	MaxURLs = 50000
	MaxFileSize = 10 * 1024 * 1024
)
var (
	ErrExceededMaxURLs = errors.New("exceeded maximum number of URLs in a sitemap <urlset>")
	ErrExceededMaxFileSize = errors.New("exceeded maximum file size of a sitemap or sitemap index XML file")
)
const xmlns = "http://www.sitemaps.org/schemas/sitemap/0.9"
type URLSet struct {
	XMLName xml.Name `xml:"urlset"`
	XMLNS   string   `xml:"xmlns,attr"`
	URLs    []URL    `xml:"url"`
}
type URL struct {
	Loc        string     `xml:"loc"`
	LastMod    *time.Time `xml:"lastmod,omitempty"`
	ChangeFreq ChangeFreq `xml:"changefreq,omitempty"`
	Priority   float64    `xml:"priority,omitempty"`
}
type ChangeFreq string
const (
	Always  ChangeFreq = "always"
	Hourly  ChangeFreq = "hourly"
	Daily   ChangeFreq = "daily"
	Weekly  ChangeFreq = "weekly"
	Monthly ChangeFreq = "monthly"
	Yearly  ChangeFreq = "yearly"
	Never   ChangeFreq = "never"
)
const preamble = `<?xml version="1.0" encoding="UTF-8"?>`