dati

data and template interface
git clone git://git.gearsix.net/dati
Log | Files | Refs | Atom | README | LICENSE

commit 48f4adca68d4d7713ae0586c39b3c7af7864ca7a
parent 121da318adc0d135b24dba0119d4eec9e1ad484a
Author: gearsix <gearsix@tuta.io>
Date:   Tue, 27 Apr 2021 17:22:20 +0100

ran gofmt

Diffstat:
Mcmd/suti.go | 11+++++------
Mdata.go | 1-
Mfile.go | 4++--
Mfile_test.go | 10+++++-----
4 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/cmd/suti.go b/cmd/suti.go @@ -269,11 +269,11 @@ func loadFilePaths(paths ...string) (filepaths []string) { } else { err = filepath.Walk(path, func(p string, info fs.FileInfo, e error) error { - if e == nil && !info.IsDir() { - filepaths = append(filepaths, p) - } - return e - }) + if e == nil && !info.IsDir() { + filepaths = append(filepaths, p) + } + return e + }) } if err != nil { assert(err, "failed to load filepaths for '%s'", path) @@ -295,4 +295,3 @@ func mergeData(data []Data) (merged Data) { } return } - diff --git a/data.go b/data.go @@ -67,4 +67,3 @@ func LoadDataFile(path string, outp interface{}) error { return e } - diff --git a/file.go b/file.go @@ -19,10 +19,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. import ( "fmt" + "os" "path/filepath" "sort" "time" - "os" ) // SortFileList sorts `filepath` (a list of filepaths) in `order`. `order` @@ -49,7 +49,7 @@ func SortFileList(paths []string, order string) (sorted []string, err error) { return } -func sortFileListByName(direction string, paths[]string) []string { +func sortFileListByName(direction string, paths []string) []string { if direction == "desc" { sort.Slice(paths, func(i, j int) bool { return filepath.Base(paths[i]) > filepath.Base(paths[j]) diff --git a/file_test.go b/file_test.go @@ -1,17 +1,17 @@ package suti import ( - "testing" - "strconv" "os" - "time" "path/filepath" + "strconv" + "testing" + "time" ) func TestSortFileList(t *testing.T) { var err error tdir := t.TempDir() - paths := []string{tdir+"/1", tdir+"/3", tdir+"/2"} + paths := []string{tdir + "/1", tdir + "/3", tdir + "/2"} sorted := make([]string, 0, len(paths)) sorted, err = SortFileList(paths, "filename") @@ -49,7 +49,7 @@ func TestSortFileList(t *testing.T) { if err != nil { t.Error(err) } - for i, _ := range paths { + for i := range paths { if sorted[i] != paths[i] { t.Errorf("invalid order returned %s - %s", sorted, paths) }