ikeikeikeike / go-sitemap-generator

go-sitemap-generator is the easiest way to generate Sitemaps in Go
https://github.com/ikeikeikeike/go-sitemap-generator
MIT License
220 stars 65 forks source link

sitemap.Add panics #48

Open march1993 opened 2 years ago

march1993 commented 2 years ago
    sm := stm.NewSitemap(1)

    sm.SetDefaultHost(someHost)

    sm.Create()

    sm.Add(stm.URL{{"loc", "/posts"}, {"changefreq", "monthly"}})
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6059b8]
goroutine 1 [running]:
net/url.(*URL).ResolveReference(0xc0002a0630, 0x0)
        /home/x/go/src/net/url/url.go:1069 +0x38
github.com/ikeikeikeike/go-sitemap-generator/v2/stm.URLJoin({0x0?, 0xc0002553b0?}, {0xc000211c00, 0x2, 0x10?})
        /home/x/projects/x/vendor/github.com/ikeikeikeike/go-sitemap-generator/v2/stm/utils.go:184 +0x10b
github.com/ikeikeikeike/go-sitemap-generator/v2/stm.URL.URLJoinBy({0xc00007d560?, 0x3, 0x4}, {0xa66ed1, 0x3}, {0xc000131a68?, 0x2?, 0xc00002e000?})
        /home/x/projects/x/vendor/github.com/ikeikeikeike/go-sitemap-generator/v2/stm/builder.go:55 +0xc5
github.com/ikeikeikeike/go-sitemap-generator/v2/stm.(*sitemapURL).XML(0xc000211be0)
        /home/x/projects/x/vendor/github.com/ikeikeikeike/go-sitemap-generator/v2/stm/builder_url.go:99 +0x12e
github.com/ikeikeikeike/go-sitemap-generator/v2/stm.(*BuilderFile).Add(0xc0002278c0, {0x9e04e0?, 0xc00029c138?})
        /home/x/projects/x/vendor/github.com/ikeikeikeike/go-sitemap-generator/v2/stm/builder_file.go:48 +0x33b
github.com/ikeikeikeike/go-sitemap-generator/v2/stm.(*Sitemap).Add(0xc00027c8a0, {0x9e04e0, 0xc00029c138})
        /home/x/projects/x/vendor/github.com/ikeikeikeike/go-sitemap-generator/v2/stm/sitemap.go:90 +0x158