1
0
Fork 0
mirror of https://github.com/avelino/awesome-go.git synced 2024-11-13 11:14:37 -05:00

handle errors on render sitemap

This commit is contained in:
Kirill Zhuravlev 2023-02-15 00:05:31 +01:00 committed by Avelino
parent 3f3e953ef0
commit 9bb5084a96
No known key found for this signature in database
GPG key ID: B345B4D52E98180A

18
main.go
View file

@ -108,7 +108,9 @@ func renderAll() error {
return fmt.Errorf("unable to rewrite links in index: %w", err)
}
makeSitemap(objs)
if err := renderSitemap(objs); err != nil {
return fmt.Errorf("unable to render sitemap: %w", err)
}
for _, srcFilename := range staticFiles {
dstFilename := filepath.Join(outDir, filepath.Base(srcFilename))
@ -181,12 +183,20 @@ func renderCategories(objs map[string]Object) error {
return nil
}
func makeSitemap(objs map[string]Object) {
func renderSitemap(objs map[string]Object) error {
// FIXME: handle error
f, _ := os.Create(outSitemapFile)
f, err := os.Create(outSitemapFile)
if err != nil {
return fmt.Errorf("unable to create sitemap file `%s`: %w", outSitemapFile, err)
}
fmt.Printf("Render Sitemap to: %s\n", outSitemapFile)
_ = tplSitemap.Execute(f, objs)
if err := tplSitemap.Execute(f, objs); err != nil {
return fmt.Errorf("unable to render sitemap: %w", err)
}
return nil
}
func makeObjByID(selector string, s *goquery.Selection) (*Object, error) {