From f8d9841a68e696f01be289e60ed9c3412aadb70f Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Tue, 2 Dec 2025 23:50:07 +0100 Subject: [PATCH] go fmt --- internal/indexgen/indexgen.go | 68 +++++++++++++-------------- internal/indexgen/indexgen_test.go | 2 +- internal/indexgen/integration_test.go | 2 +- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/internal/indexgen/indexgen.go b/internal/indexgen/indexgen.go index 340c1a3..45143fa 100644 --- a/internal/indexgen/indexgen.go +++ b/internal/indexgen/indexgen.go @@ -158,28 +158,28 @@ var ExtensionTypes = map[string]string{ } type Options struct { - TopDir string - Filter string - OutputFile string - DirAppend bool - Recursive bool - IncludeHidden bool - ExcludeRegex *regexp.Regexp - Verbose bool + TopDir string + Filter string + OutputFile string + DirAppend bool + Recursive bool + IncludeHidden bool + ExcludeRegex *regexp.Regexp + Verbose bool } type FileEntry struct { - Name string - Path string - IsDir bool - IsSymlink bool - Size int64 - ModTime time.Time - IconType string - CSSClass string - SizePretty string - ModTimeISO string - ModTimeHuman string + Name string + Path string + IsDir bool + IsSymlink bool + Size int64 + ModTime time.Time + IconType string + CSSClass string + SizePretty string + ModTimeISO string + ModTimeHuman string } func ProcessDir(topDir string, opts *Options) error { @@ -193,7 +193,7 @@ func ProcessDir(topDir string, opts *Options) error { } indexPath := filepath.Join(absPath, opts.OutputFile) - + file, err := os.Create(indexPath) if err != nil { return fmt.Errorf("cannot create file %s: %w", indexPath, err) @@ -201,7 +201,7 @@ func ProcessDir(topDir string, opts *Options) error { defer file.Close() dirName := filepath.Base(absPath) - + entries, err := ReadDirEntries(absPath, opts) if err != nil { return fmt.Errorf("failed to read directory: %w", err) @@ -215,14 +215,14 @@ func ProcessDir(topDir string, opts *Options) error { }) templateData := struct { - DirName string - Entries []FileEntry - DirAppend bool + DirName string + Entries []FileEntry + DirAppend bool OutputFile string }{ - DirName: dirName, - Entries: entries, - DirAppend: opts.DirAppend, + DirName: dirName, + Entries: entries, + DirAppend: opts.DirAppend, OutputFile: opts.OutputFile, } @@ -270,7 +270,7 @@ func ReadDirEntries(dirPath string, opts *Options) ([]FileEntry, error) { } fullPath := filepath.Join(dirPath, fileName) - + info, err := file.Info() if err != nil { fmt.Printf("*** WARNING *** entry %s is not accessible! SKIPPING! Error: %v\n", fullPath, err) @@ -282,9 +282,9 @@ func ReadDirEntries(dirPath string, opts *Options) ([]FileEntry, error) { } entry := FileEntry{ - Name: fileName, - Path: fileName, - IsDir: file.IsDir(), + Name: fileName, + Path: fileName, + IsDir: file.IsDir(), ModTime: info.ModTime(), } @@ -330,11 +330,11 @@ func GetIconType(fileName string) string { if iconType, exists := ExtensionTypes[ext]; exists { return iconType } - + if iconType, exists := ExtensionTypes[fileName]; exists { return iconType } - + return "generic" } @@ -972,4 +972,4 @@ const htmlTemplateString = ` -` \ No newline at end of file +` diff --git a/internal/indexgen/indexgen_test.go b/internal/indexgen/indexgen_test.go index ccb9afb..9877bd9 100644 --- a/internal/indexgen/indexgen_test.go +++ b/internal/indexgen/indexgen_test.go @@ -382,4 +382,4 @@ func TestFileEntryProperties(t *testing.T) { if entry.SizePretty != PrettySize(int64(len(content))) { t.Errorf("Size pretty mismatch") } -} \ No newline at end of file +} diff --git a/internal/indexgen/integration_test.go b/internal/indexgen/integration_test.go index 7fcfe38..2798fb7 100644 --- a/internal/indexgen/integration_test.go +++ b/internal/indexgen/integration_test.go @@ -351,4 +351,4 @@ func TestProcessDirWithSymlinks(t *testing.T) { if !strings.Contains(htmlContent, "#symlink") { t.Error("index.html should contain symlink icon for symlinked file") } -} \ No newline at end of file +}