mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 06:30:33 +03:00
helpers: apply some Golint rules
This commit is contained in:
parent
e685dfc0c6
commit
bd2b679eaf
4 changed files with 39 additions and 46 deletions
|
@ -28,7 +28,7 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// Bridge for common functionality in filepath vs path
|
||||
// FilepathPathBridge is a bridge for common functionality in filepath vs path
|
||||
type FilepathPathBridge interface {
|
||||
Base(in string) string
|
||||
Clean(in string) string
|
||||
|
@ -149,9 +149,8 @@ func IsEmpty(path string, fs afero.Fs) (bool, error) {
|
|||
list, err := f.Readdir(-1)
|
||||
// f.Close() - see bug fix above
|
||||
return len(list) == 0, nil
|
||||
} else {
|
||||
return fi.Size() == 0, nil
|
||||
}
|
||||
return fi.Size() == 0, nil
|
||||
}
|
||||
|
||||
// Check if a file or directory exists.
|
||||
|
@ -317,9 +316,8 @@ func GuessSection(in string) string {
|
|||
if parts[0] == "content" {
|
||||
if len(parts) > 2 {
|
||||
return parts[1]
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
return parts[0]
|
||||
|
@ -328,9 +326,8 @@ func GuessSection(in string) string {
|
|||
func PathPrep(ugly bool, in string) string {
|
||||
if ugly {
|
||||
return Uglify(in)
|
||||
} else {
|
||||
return PrettifyPath(in)
|
||||
}
|
||||
return PrettifyPath(in)
|
||||
}
|
||||
|
||||
// Same as PrettifyUrlPath() but for file paths.
|
||||
|
@ -348,16 +345,14 @@ func PrettiyPath(in string, b FilepathPathBridge) string {
|
|||
return b.Separator()
|
||||
}
|
||||
return b.Join(b.Clean(in), "index.html")
|
||||
} else {
|
||||
name, ext := FileAndExt(in, b)
|
||||
if name == "index" {
|
||||
// /section/name/index.html -> /section/name/index.html
|
||||
return b.Clean(in)
|
||||
} else {
|
||||
// /section/name.html -> /section/name/index.html
|
||||
return b.Join(b.Dir(in), name, "index"+ext)
|
||||
}
|
||||
}
|
||||
name, ext := FileAndExt(in, b)
|
||||
if name == "index" {
|
||||
// /section/name/index.html -> /section/name/index.html
|
||||
return b.Clean(in)
|
||||
}
|
||||
// /section/name.html -> /section/name/index.html
|
||||
return b.Join(b.Dir(in), name, "index"+ext)
|
||||
}
|
||||
|
||||
// FindCWD returns the current working directory from where the Hugo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue