From 2dfc019ddcee54f974216be3e6fb94b9982db2ff Mon Sep 17 00:00:00 2001 From: Thijs Nijman Date: Fri, 14 Sep 2018 13:48:17 +0200 Subject: [PATCH] Fix golint issues and cleanup --- microdata.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/microdata.go b/microdata.go index 8198518..569b1fe 100644 --- a/microdata.go +++ b/microdata.go @@ -18,12 +18,12 @@ import ( "golang.org/x/net/html/atom" ) -type ValueList []interface{} -type PropertyMap map[string]ValueList +type valueList []interface{} +type propertyMap map[string]valueList // Item represents a microdata item type Item struct { - Properties PropertyMap `json:"properties"` + Properties propertyMap `json:"properties"` Types []string `json:"type,omitempty"` ID string `json:"id,omitempty"` } @@ -31,7 +31,7 @@ type Item struct { // NewItem creates a new microdata item func NewItem() *Item { return &Item{ - Properties: make(PropertyMap, 0), + Properties: make(propertyMap, 0), Types: make([]string, 0), } } @@ -132,11 +132,10 @@ func (p *Parser) Parse() (*Microdata, error) { } // itemid only valid when itemscope and itemtype are both present if itemid, exists := getAttr("itemid", node); exists { - if parsedUrl, err := p.base.Parse(itemid); err == nil { - item.ID = parsedUrl.String() + if parsedURL, err := p.base.Parse(itemid); err == nil { + item.ID = parsedURL.String() } } - } if itemrefs, exists := getAttr("itemref", node); exists { @@ -198,15 +197,14 @@ func (p *Parser) readItem(item *Item, node *html.Node) { } case atom.Audio, atom.Embed, atom.Iframe, atom.Img, atom.Source, atom.Track, atom.Video: if urlValue, exists := getAttr("src", node); exists { - if parsedUrl, err := p.base.Parse(urlValue); err == nil { - propertyValue = parsedUrl.String() + if parsedURL, err := p.base.Parse(urlValue); err == nil { + propertyValue = parsedURL.String() } - } case atom.A, atom.Area, atom.Link: if urlValue, exists := getAttr("href", node); exists { - if parsedUrl, err := p.base.Parse(urlValue); err == nil { - propertyValue = parsedUrl.String() + if parsedURL, err := p.base.Parse(urlValue); err == nil { + propertyValue = parsedURL.String() } } case atom.Object: