Clean up lint in various packages - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 47fdfd5196cd24a23b30afe1d88969ffb413ab59
 (DIR) parent d45e358a0543d987091ef54b56eadd9cebda2e0f
 (HTM) Author: Cameron Moore <moorereason@gmail.com>
       Date:   Mon, 25 Sep 2017 21:25:33 -0500
       
       Clean up lint in various packages
       
       Changes fall into one of the following:
       
       - gofmt -s
       - receiver name is inconsistent
       - omit unused 2nd value from range
       - godoc comment formed incorrectly
       - err assigned and not used
       - if block ends with a return statement followed by else
       
       Diffstat:
         M helpers/pygments_test.go            |      14 +++++++-------
         M hugolib/handler_meta.go             |       2 +-
         M hugolib/page.go                     |       7 ++++---
         M hugolib/pages_related_test.go       |       2 +-
         M media/mediaType.go                  |       8 ++++----
         M output/outputFormat.go              |      16 ++++++++--------
         M related/inverted_index.go           |       2 +-
         M related/inverted_index_test.go      |      18 +++++++++---------
         M source/filesystem.go                |       4 ++--
         M tpl/collections/collections.go      |      10 +++++-----
         M tpl/fmt/fmt.go                      |       2 +-
         M tpl/images/images.go                |       1 +
       
       12 files changed, 44 insertions(+), 42 deletions(-)
       ---
 (DIR) diff --git a/helpers/pygments_test.go b/helpers/pygments_test.go
       @@ -224,13 +224,13 @@ func TestHlLinesToRanges(t *testing.T) {
                        expected  interface{}
                }{
                        {"", 1, zero},
       -                {"1 4", 1, [][2]int{[2]int{1, 1}, [2]int{4, 4}}},
       -                {"1 4", 2, [][2]int{[2]int{2, 2}, [2]int{5, 5}}},
       -                {"1-4 5-8", 1, [][2]int{[2]int{1, 4}, [2]int{5, 8}}},
       -                {" 1   4 ", 1, [][2]int{[2]int{1, 1}, [2]int{4, 4}}},
       -                {"1-4    5-8 ", 1, [][2]int{[2]int{1, 4}, [2]int{5, 8}}},
       -                {"1-4 5", 1, [][2]int{[2]int{1, 4}, [2]int{5, 5}}},
       -                {"4 5-9", 1, [][2]int{[2]int{4, 4}, [2]int{5, 9}}},
       +                {"1 4", 1, [][2]int{{1, 1}, {4, 4}}},
       +                {"1 4", 2, [][2]int{{2, 2}, {5, 5}}},
       +                {"1-4 5-8", 1, [][2]int{{1, 4}, {5, 8}}},
       +                {" 1   4 ", 1, [][2]int{{1, 1}, {4, 4}}},
       +                {"1-4    5-8 ", 1, [][2]int{{1, 4}, {5, 8}}},
       +                {"1-4 5", 1, [][2]int{{1, 4}, {5, 5}}},
       +                {"4 5-9", 1, [][2]int{{4, 4}, {5, 9}}},
                        {" 1 -4 5 - 8  ", 1, true},
                        {"a b", 1, true},
                } {
 (DIR) diff --git a/hugolib/handler_meta.go b/hugolib/handler_meta.go
       @@ -34,7 +34,7 @@ type MetaHandler interface {
                Handle() Handler
        }
        
       -// HandledResults is a channel for HandledResult.
       +// HandleResults is a channel for HandledResult.
        type HandleResults chan<- HandledResult
        
        // NewMetaHandler creates a MetaHandle for a given extensions.
 (DIR) diff --git a/hugolib/page.go b/hugolib/page.go
       @@ -65,6 +65,7 @@ const (
                KindPage = "page"
        
                // The rest are node types; home page, sections etc.
       +
                KindHome         = "home"
                KindSection      = "section"
                KindTaxonomy     = "taxonomy"
       @@ -484,10 +485,10 @@ func traverse(keys []string, m map[string]interface{}) interface{} {
                if len(rest) == 0 {
                        // That was the last key.
                        return result
       -        } else {
       -                // That was not the last key.
       -                return traverse(rest, cast.ToStringMap(result))
                }
       +
       +        // That was not the last key.
       +        return traverse(rest, cast.ToStringMap(result))
        }
        
        func (p *Page) Author() Author {
 (DIR) diff --git a/hugolib/pages_related_test.go b/hugolib/pages_related_test.go
       @@ -68,8 +68,8 @@ Content
                assert.Equal("Page 3", result[1].Title)
        
                result, err = s.RegularPages.RelatedTo(types.NewKeyValuesStrings("keywords", "bep", "rocks"))
       +        assert.NoError(err)
                assert.Len(result, 2)
                assert.Equal("Page 2", result[0].Title)
                assert.Equal("Page 3", result[1].Title)
       -
        }
 (DIR) diff --git a/media/mediaType.go b/media/mediaType.go
       @@ -189,15 +189,15 @@ func DecodeTypes(maps ...map[string]interface{}) (Types, error) {
                return m, nil
        }
        
       -func (t Type) MarshalJSON() ([]byte, error) {
       +func (m Type) MarshalJSON() ([]byte, error) {
                type Alias Type
                return json.Marshal(&struct {
                        Type   string `json:"type"`
                        String string `json:"string"`
                        Alias
                }{
       -                Type:   t.Type(),
       -                String: t.String(),
       -                Alias:  (Alias)(t),
       +                Type:   m.Type(),
       +                String: m.String(),
       +                Alias:  (Alias)(m),
                })
        }
 (DIR) diff --git a/output/outputFormat.go b/output/outputFormat.go
       @@ -150,9 +150,9 @@ func init() {
        
        type Formats []Format
        
       -func (f Formats) Len() int           { return len(f) }
       -func (f Formats) Swap(i, j int)      { f[i], f[j] = f[j], f[i] }
       -func (f Formats) Less(i, j int) bool { return f[i].Name < f[j].Name }
       +func (formats Formats) Len() int           { return len(formats) }
       +func (formats Formats) Swap(i, j int)      { formats[i], formats[j] = formats[j], formats[i] }
       +func (formats Formats) Less(i, j int) bool { return formats[i].Name < formats[j].Name }
        
        // GetBySuffix gets a output format given as suffix, e.g. "html".
        // It will return false if no format could be found, or if the suffix given
       @@ -312,17 +312,17 @@ func decode(mediaTypes media.Types, input, output interface{}) error {
                return decoder.Decode(input)
        }
        
       -func (f Format) BaseFilename() string {
       -        return f.BaseName + "." + f.MediaType.Suffix
       +func (formats Format) BaseFilename() string {
       +        return formats.BaseName + "." + formats.MediaType.Suffix
        }
        
       -func (f Format) MarshalJSON() ([]byte, error) {
       +func (formats Format) MarshalJSON() ([]byte, error) {
                type Alias Format
                return json.Marshal(&struct {
                        MediaType string
                        Alias
                }{
       -                MediaType: f.MediaType.String(),
       -                Alias:     (Alias)(f),
       +                MediaType: formats.MediaType.String(),
       +                Alias:     (Alias)(formats),
                })
        }
 (DIR) diff --git a/related/inverted_index.go b/related/inverted_index.go
       @@ -418,7 +418,7 @@ func DecodeConfig(in interface{}) (Config, error) {
                }
        
                if c.ToLower {
       -                for i, _ := range c.Indices {
       +                for i := range c.Indices {
                                c.Indices[i].ToLower = true
                        }
                }
 (DIR) diff --git a/related/inverted_index_test.go b/related/inverted_index_test.go
       @@ -27,9 +27,9 @@ type testDoc struct {
                date     time.Time
        }
        
       -func (k *testDoc) String() string {
       +func (d *testDoc) String() string {
                s := "\n"
       -        for k, v := range k.keywords {
       +        for k, v := range d.keywords {
                        s += k + ":\t\t"
                        for _, vv := range v {
                                s += "  " + vv.String()
       @@ -49,7 +49,7 @@ func newTestDoc(name string, keywords ...string) *testDoc {
                return kw
        }
        
       -func (t *testDoc) addKeywords(name string, keywords ...string) *testDoc {
       +func (d *testDoc) addKeywords(name string, keywords ...string) *testDoc {
                keywordm := createTestKeywords(name, keywords...)
        
                for k, v := range keywordm {
       @@ -57,9 +57,9 @@ func (t *testDoc) addKeywords(name string, keywords ...string) *testDoc {
                        for i := 0; i < len(v); i++ {
                                keywords[i] = StringKeyword(v[i])
                        }
       -                t.keywords[k] = keywords
       +                d.keywords[k] = keywords
                }
       -        return t
       +        return d
        }
        
        func createTestKeywords(name string, keywords ...string) map[string][]string {
       @@ -68,12 +68,12 @@ func createTestKeywords(name string, keywords ...string) map[string][]string {
                }
        }
        
       -func (k *testDoc) SearchKeywords(cfg IndexConfig) ([]Keyword, error) {
       -        return k.keywords[cfg.Name], nil
       +func (d *testDoc) SearchKeywords(cfg IndexConfig) ([]Keyword, error) {
       +        return d.keywords[cfg.Name], nil
        }
        
       -func (k *testDoc) PubDate() time.Time {
       -        return k.date
       +func (d *testDoc) PubDate() time.Time {
       +        return d.date
        }
        
        func TestSearch(t *testing.T) {
 (DIR) diff --git a/source/filesystem.go b/source/filesystem.go
       @@ -158,14 +158,14 @@ func (f *Filesystem) avoid(filePath string) bool {
                return false
        }
        
       -func (s SourceSpec) isNonProcessablePath(filePath string) bool {
       +func (sp SourceSpec) isNonProcessablePath(filePath string) bool {
                base := filepath.Base(filePath)
                if strings.HasPrefix(base, ".") ||
                        strings.HasPrefix(base, "#") ||
                        strings.HasSuffix(base, "~") {
                        return true
                }
       -        ignoreFiles := cast.ToStringSlice(s.Cfg.Get("ignoreFiles"))
       +        ignoreFiles := cast.ToStringSlice(sp.Cfg.Get("ignoreFiles"))
                if len(ignoreFiles) > 0 {
                        for _, ignorePattern := range ignoreFiles {
                                match, err := regexp.MatchString(ignorePattern, filePath)
 (DIR) diff --git a/tpl/collections/collections.go b/tpl/collections/collections.go
       @@ -503,25 +503,25 @@ func (i *intersector) appendIfNotSeen(v reflect.Value) {
                }
        }
        
       -func (ins *intersector) handleValuePair(l1vv, l2vv reflect.Value) {
       +func (i *intersector) handleValuePair(l1vv, l2vv reflect.Value) {
                switch kind := l1vv.Kind(); {
                case kind == reflect.String:
                        l2t, err := toString(l2vv)
                        if err == nil && l1vv.String() == l2t {
       -                        ins.appendIfNotSeen(l1vv)
       +                        i.appendIfNotSeen(l1vv)
                        }
                case isNumber(kind):
                        f1, err1 := numberToFloat(l1vv)
                        f2, err2 := numberToFloat(l2vv)
                        if err1 == nil && err2 == nil && f1 == f2 {
       -                        ins.appendIfNotSeen(l1vv)
       +                        i.appendIfNotSeen(l1vv)
                        }
                case kind == reflect.Ptr, kind == reflect.Struct:
                        if l1vv.Interface() == l2vv.Interface() {
       -                        ins.appendIfNotSeen(l1vv)
       +                        i.appendIfNotSeen(l1vv)
                        }
                case kind == reflect.Interface:
       -                ins.handleValuePair(reflect.ValueOf(l1vv.Interface()), l2vv)
       +                i.handleValuePair(reflect.ValueOf(l1vv.Interface()), l2vv)
                }
        }
        
 (DIR) diff --git a/tpl/fmt/fmt.go b/tpl/fmt/fmt.go
       @@ -37,7 +37,7 @@ func (ns *Namespace) Printf(format string, a ...interface{}) string {
        
        }
        
       -// Print returns string representation of the passed arguments ending with a newline.
       +// Println returns string representation of the passed arguments ending with a newline.
        func (ns *Namespace) Println(a ...interface{}) string {
                return _fmt.Sprintln(a...)
        }
 (DIR) diff --git a/tpl/images/images.go b/tpl/images/images.go
       @@ -23,6 +23,7 @@ import (
                _ "image/jpeg"
                _ "image/png"
        
       +        // Import webp codec
                _ "golang.org/x/image/webp"
        
                "github.com/gohugoio/hugo/deps"