fix linter warnings

This commit is contained in:
Kirill Zhuravlev 2023-02-26 01:23:27 +01:00 committed by Avelino
parent 625df2fec3
commit c5a97e6ec7
No known key found for this signature in database
GPG Key ID: B345B4D52E98180A
2 changed files with 12 additions and 9 deletions

17
main.go
View File

@ -1,3 +1,4 @@
/* Package main contains code for generate static site. */
package main package main
import ( import (
@ -16,12 +17,14 @@ import (
"github.com/avelino/awesome-go/pkg/slug" "github.com/avelino/awesome-go/pkg/slug"
) )
// Link contains info about awesome url
type Link struct { type Link struct {
Title string Title string
Url string URL string
Description string Description string
} }
// Category describe link category
type Category struct { type Category struct {
Title string Title string
Slug string Slug string
@ -251,7 +254,7 @@ func extractCategory(doc *goquery.Document, selector string) (*Category, error)
// FIXME(kazhuravlev): Title contains only title but // FIXME(kazhuravlev): Title contains only title but
// description contains Title + description // description contains Title + description
Description: selLi.Text(), Description: selLi.Text(),
Url: url, URL: url,
} }
links = append(links, link) links = append(links, link)
}) })
@ -297,14 +300,14 @@ func rewriteLinksInIndex(doc *goquery.Document, categories map[string]Category)
return true return true
} }
linkUrl, err := url.Parse(href) linkURL, err := url.Parse(href)
if err != nil { if err != nil {
iterErr = err iterErr = err
return false return false
} }
if linkUrl.Fragment != "" && linkUrl.Fragment != "contents" { if linkURL.Fragment != "" && linkURL.Fragment != "contents" {
s.SetAttr("href", linkUrl.Fragment) s.SetAttr("href", linkURL.Fragment)
} }
return true return true
@ -315,12 +318,12 @@ func rewriteLinksInIndex(doc *goquery.Document, categories map[string]Category)
} }
fmt.Printf("Rewrite links in Index file: %s\n", outIndexFile) fmt.Printf("Rewrite links in Index file: %s\n", outIndexFile)
resultHtml, err := doc.Html() resultHTML, err := doc.Html()
if err != nil { if err != nil {
return fmt.Errorf("render html: %w", err) return fmt.Errorf("render html: %w", err)
} }
if err := os.WriteFile(outIndexFile, []byte(resultHtml), 0644); err != nil { if err := os.WriteFile(outIndexFile, []byte(resultHTML), 0644); err != nil {
return fmt.Errorf("rewrite index file: %w", err) return fmt.Errorf("rewrite index file: %w", err)
} }

View File

@ -115,6 +115,6 @@ h1 > a img {
line-height: 1; line-height: 1;
} }
td{ td {
padding: 6px; padding: 6px;
} }