From 48120ccfd2138ff2b308081cd7cb9cee033db691 Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Thu, 9 Mar 2017 18:18:12 +0500 Subject: [PATCH] all: Fix some govet complaints --- commands/convert.go | 8 ++++---- config/configProvider.go | 4 ---- deps/deps.go | 2 +- hugofs/fs.go | 2 +- hugolib/hugo_sites.go | 1 - hugolib/page.go | 4 ++-- hugolib/page_test.go | 2 +- hugolib/site.go | 1 - tpl/tplimpl/template.go | 3 +++ 9 files changed, 12 insertions(+), 15 deletions(-) diff --git a/commands/convert.go b/commands/convert.go index c24282550..034d5bf55 100644 --- a/commands/convert.go +++ b/commands/convert.go @@ -123,14 +123,14 @@ func convertContents(mark rune) error { // better handling of dates in formats that don't have support for them if mark == parser.FormatToLeadRune("json") || mark == parser.FormatToLeadRune("yaml") || mark == parser.FormatToLeadRune("toml") { - newmetadata := cast.ToStringMap(metadata) - for k, v := range newmetadata { + newMetadata := cast.ToStringMap(metadata) + for k, v := range newMetadata { switch vv := v.(type) { case time.Time: - newmetadata[k] = vv.Format(time.RFC3339) + newMetadata[k] = vv.Format(time.RFC3339) } } - metadata = newmetadata + metadata = newMetadata } page.SetDir(filepath.Join(contentDir, file.Dir())) diff --git a/config/configProvider.go b/config/configProvider.go index 7f306fa0e..870341f7f 100644 --- a/config/configProvider.go +++ b/config/configProvider.go @@ -11,10 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package helpers implements general utility functions that work with -// and on content. The helper functions defined here lay down the -// foundation of how Hugo works with files and filepaths, and perform -// string operations on content. package config // Provider provides the configuration settings for Hugo. diff --git a/deps/deps.go b/deps/deps.go index de1b955cb..3e97ffd93 100644 --- a/deps/deps.go +++ b/deps/deps.go @@ -45,7 +45,7 @@ type Deps struct { translationProvider ResourceProvider } -// Used to create and refresh, and clone resources needed. +// ResourceProvider is used to create and refresh, and clone resources needed. type ResourceProvider interface { Update(deps *Deps) error Clone(deps *Deps) error diff --git a/hugofs/fs.go b/hugofs/fs.go index 1ddb98214..f79c927db 100644 --- a/hugofs/fs.go +++ b/hugofs/fs.go @@ -44,7 +44,7 @@ func NewDefault(cfg config.Provider) *Fs { return newFs(fs, cfg) } -// NewDefault creates a new Fs with the MemMapFs +// NewMem creates a new Fs with the MemMapFs // as source and destination file systems. // Useful for testing. func NewMem(cfg config.Provider) *Fs { diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index 49dd51cd6..0e7aafe96 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -302,7 +302,6 @@ func (h *HugoSites) createMissingPages() error { var newPages Pages for _, s := range h.Sites { - if s.isEnabled(KindHome) { // home pages home := s.findPagesByKind(KindHome) diff --git a/hugolib/page.go b/hugolib/page.go index 3169e123a..dcfffa666 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -254,8 +254,8 @@ type Position struct { type Pages []*Page -func (p Pages) String() string { - return fmt.Sprintf("Pages(%d)", len(p)) +func (ps Pages) String() string { + return fmt.Sprintf("Pages(%d)", len(ps)) } func (ps Pages) FindPagePosByFilePath(inPath string) int { diff --git a/hugolib/page_test.go b/hugolib/page_test.go index d80516ddd..ab6087647 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -1361,7 +1361,7 @@ func TestPageParams(t *testing.T) { for i, c := range pagesParamsTemplate { p, err := s.NewPageFrom(strings.NewReader(c), "content/post/params.md") require.NoError(t, err, "err during parse", "#%d", i) - for key, _ := range wantedMap { + for key := range wantedMap { assert.Equal(t, wantedMap[key], p.Params[key], "#%d", key) } } diff --git a/hugolib/site.go b/hugolib/site.go index 933f4db04..007ad4246 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -546,7 +546,6 @@ type whatChanged struct { // reBuild partially rebuilds a site given the filesystem events. // It returns whetever the content source was changed. func (s *Site) reProcess(events []fsnotify.Event) (whatChanged, error) { - s.Log.DEBUG.Printf("Rebuild for events %q", events) s.timerStep("initialize rebuild") diff --git a/tpl/tplimpl/template.go b/tpl/tplimpl/template.go index 012319104..b625f570b 100644 --- a/tpl/tplimpl/template.go +++ b/tpl/tplimpl/template.go @@ -452,6 +452,7 @@ func (t *GoHTMLTemplate) loadTemplates(absPath string, prefix string) { if err != nil { return nil } + t.Log.DEBUG.Println("Template path", path) if fi.Mode()&os.ModeSymlink == os.ModeSymlink { link, err := filepath.EvalSymlinks(absPath) @@ -459,11 +460,13 @@ func (t *GoHTMLTemplate) loadTemplates(absPath string, prefix string) { t.Log.ERROR.Printf("Cannot read symbolic link '%s', error was: %s", absPath, err) return nil } + linkfi, err := t.Fs.Source.Stat(link) if err != nil { t.Log.ERROR.Printf("Cannot stat '%s', error was: %s", link, err) return nil } + if !linkfi.Mode().IsRegular() { t.Log.ERROR.Printf("Symbolic links for directories not supported, skipping '%s'", absPath) }