go fmt
This commit is contained in:
@@ -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 = `<!DOCTYPE html>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>`
|
||||
</html>`
|
||||
|
||||
Reference in New Issue
Block a user