mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-07 16:33:40 +00:00
fix linter warnings
This commit is contained in:
parent
625df2fec3
commit
c5a97e6ec7
17
main.go
17
main.go
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user