![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/planitarinc/go-sitemap
A GO library for generating Sitemap XML files.
package main
import (
"bytes"
"fmt"
"io"
"time"
sitemap "github.com/PlanitarInc/go-sitemap"
)
type SitemapOutput struct {
IndexBuf bytes.Buffer
UrlsetBufs []bytes.Buffer
}
func (out *SitemapOutput) Index() io.Writer {
return &out.IndexBuf
}
func (out *SitemapOutput) Urlset() io.Writer {
out.UrlsetBufs = append(out.UrlsetBufs, bytes.Buffer{})
return &out.UrlsetBufs[len(out.UrlsetBufs)-1]
}
type ArrayInput struct {
Arr []sitemap.UrlEntry
nextIdx int
}
func (a *ArrayInput) Next() *sitemap.UrlEntry {
if a.nextIdx >= len(a.Arr) {
return nil
}
a.nextIdx++
return &a.Arr[a.nextIdx-1]
}
func (a *ArrayInput) GetUrlsetUrl(n int) string {
return fmt.Sprintf("https://goiguide.com/sitemap-%d.xml", n)
}
func main() {
entries := []sitemap.UrlEntry{
{
Loc: "http://goiguide.com/",
LastMod: time.Date(2025, time.November, 2, 11, 34, 58, 123, time.UTC),
},
{
Loc: "http://goiguide.com/test/",
Images: []string{
"http://goiguide.com/test/1.jpg",
"http://goiguide.com/test/2.jpg",
"http://goiguide.com/test/3.jpg",
},
},
}
var out SitemapOutput
err := sitemap.WriteAll(&out, &ArrayInput{Arr: entries})
if err != nil {
fmt.Printf("Error: %s\n", err)
}
for i := range out.UrlsetBufs {
fmt.Printf("\n\n::: Urlset %d\n\n", i)
fmt.Print(out.UrlsetBufs[i].String())
}
fmt.Printf("\n\n::: Index\n\n")
fmt.Print(out.IndexBuf.String())
}
The output:
::: Urlset 0
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>http://goiguide.com/</loc>
<lastmod>2025-11-02T11:34:58Z</lastmod>
</url>
<url>
<loc>http://goiguide.com/test/</loc>
<image:image>
<image:loc>http://goiguide.com/test/1.jpg</image:loc>
</image:image>
<image:image>
<image:loc>http://goiguide.com/test/2.jpg</image:loc>
</image:image>
<image:image>
<image:loc>http://goiguide.com/test/3.jpg</image:loc>
</image:image>
</url>
</urlset>
::: Index
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://goiguide.com/sitemap-0.xml</loc>
</sitemap>
</sitemapindex>
The library is trying to be smart when producing XML and keeps the allocations
constant. That is, space complexity is O(1)
-- it does not depend on the
number of entries.
$ go test -run '^$' -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/PlanitarInc/go-sitemap
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkWriteAll/1-12 1328336 945.2 ns/op 128 B/op 3 allocs/op
BenchmarkWriteAll/10-12 150031 6808 ns/op 128 B/op 3 allocs/op
BenchmarkWriteAll/100-12 17624 62340 ns/op 128 B/op 3 allocs/op
BenchmarkWriteAll/1000-12 1898 627547 ns/op 128 B/op 3 allocs/op
BenchmarkWriteAll/10000-12 192 6315018 ns/op 128 B/op 3 allocs/op
BenchmarkWriteAll/100000-12 18 62742897 ns/op 160 B/op 4 allocs/op
BenchmarkWriteAll/1000000-12 2 632302752 ns/op 736 B/op 22 allocs/op
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.