aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers/path.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-12-02 13:23:25 +0100
committerBjørn Erik Pedersen <[email protected]>2020-12-03 13:12:58 +0100
commitd90e37e0c6e812f9913bf256c9c81aa05b7a08aa (patch)
tree7b1b14464eefec1188ca2eed53c64e4823453cc9 /helpers/path.go
parent32471b57bde51c55a15dbf1db75d6e5f7232c347 (diff)
downloadhugo-d90e37e0c6e812f9913bf256c9c81aa05b7a08aa.tar.gz
hugo-d90e37e0c6e812f9913bf256c9c81aa05b7a08aa.zip
all: Format code with gofumpt
See https://github.com/mvdan/gofumpt
Diffstat (limited to 'helpers/path.go')
-rw-r--r--helpers/path.go16
1 files changed, 2 insertions, 14 deletions
diff --git a/helpers/path.go b/helpers/path.go
index 01c452607..abc73d081 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -36,10 +36,8 @@ import (
"github.com/spf13/afero"
)
-var (
- // ErrThemeUndefined is returned when a theme has not be defined by the user.
- ErrThemeUndefined = errors.New("no theme set")
-)
+// ErrThemeUndefined is returned when a theme has not be defined by the user.
+var ErrThemeUndefined = errors.New("no theme set")
// filepathPathBridge is a bridge for common functionality in filepath vs path
type filepathPathBridge interface {
@@ -169,7 +167,6 @@ func ReplaceExtension(path string, newExt string) string {
}
func makePathRelative(inPath string, possibleDirectories ...string) (string, error) {
-
for _, currentPath := range possibleDirectories {
if strings.HasPrefix(inPath, currentPath) {
return strings.TrimPrefix(inPath, currentPath), nil
@@ -281,7 +278,6 @@ func fileAndExt(in string, b filepathPathBridge) (name string, ext string) {
}
func extractFilename(in, ext, base, pathSeparator string) (name string) {
-
// No file name cases. These are defined as:
// 1. any "in" path that ends in a pathSeparator
// 2. any "base" consisting of just an pathSeparator
@@ -299,7 +295,6 @@ func extractFilename(in, ext, base, pathSeparator string) (name string) {
name = base
}
return
-
}
// GetRelativePath returns the relative path of a given path.
@@ -474,21 +469,18 @@ func ExtractRootPaths(paths []string) []string {
r[i] = root
}
return r
-
}
// FindCWD returns the current working directory from where the Hugo
// executable is run.
func FindCWD() (string, error) {
serverFile, err := filepath.Abs(os.Args[0])
-
if err != nil {
return "", fmt.Errorf("can't get absolute path for executable: %v", err)
}
path := filepath.Dir(serverFile)
realFile, err := filepath.EvalSymlinks(serverFile)
-
if err != nil {
if _, err = os.Stat(serverFile + ".exe"); err == nil {
realFile = filepath.Clean(serverFile + ".exe")
@@ -516,7 +508,6 @@ func SymbolicWalk(fs afero.Fs, root string, walker hugofs.WalkFunc) error {
})
return w.Walk()
-
}
// LstatIfPossible can be used to call Lstat if possible, else Stat.
@@ -555,7 +546,6 @@ func OpenFilesForWriting(fs afero.Fs, filenames ...string) (io.WriteCloser, erro
}
return hugio.NewMultiWriteCloser(writeClosers...), nil
-
}
// OpenFileForWriting opens or creates the given file. If the target directory
@@ -598,7 +588,6 @@ func GetCacheDir(fs afero.Fs, cfg config.Provider) (string, error) {
// Fall back to a cache in /tmp.
return GetTempDir("hugo_cache", fs), nil
-
}
func getCacheDir(cfg config.Provider) string {
@@ -614,7 +603,6 @@ func getCacheDir(cfg config.Provider) string {
// is this project:
// https://github.com/philhawksworth/content-shards/blob/master/gulpfile.js
return "/opt/build/cache/hugo_cache/"
-
}
// This will fall back to an hugo_cache folder in the tmp dir, which should work fine for most CI