all: Fix some govet complaints

This commit is contained in:
Albert Nigmatzianov 2017-03-09 18:18:12 +05:00 committed by Bjørn Erik Pedersen
parent 560ed6e686
commit 48120ccfd2
9 changed files with 12 additions and 15 deletions

View file

@ -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()))

View file

@ -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.

2
deps/deps.go vendored
View file

@ -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

View file

@ -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 {

View file

@ -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)

View file

@ -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 {

View file

@ -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)
}
}

View file

@ -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")

View file

@ -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)
}