filelist

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2023 License: MIT Imports: 4 Imported by: 0

README

File List

Returns a list of files.

Installation
go get github.com/matt9mg/go-filelist
Examples

OS Filesystem

fileList := filelist.NewFileList()

fl, err := fileList.ListFromLocation("/path/to/base_directory")

if err != nil {
    log.Fatalln(err)
}

log.Println(fl)

Embed Filesystem

//go:embed a_dir
var files embed.FS

fileList := filelist.NewFileList()

fl, err := fileList.ListFromFS(files, ".")

if err != nil {
    log.Fatalln(err)
}

log.Println(fl)
LICENSE

This project is licensed under the MIT License - see the LICENSE.md file for details

Disclaimer

We take no legal responsibility for anything this code is used for.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileList

type FileList struct {
}

func NewFileList

func NewFileList() *FileList

func (*FileList) ListFromFS

func (f *FileList) ListFromFS(fileSystem embed.FS, startingDIR string) ([]string, error)

ListFromFS reads the embed.FS directory recursively and returns a list of files and their locations in an unsorted order. If an error occurs during the list generation, all files before the error are returned including the error itself

func (*FileList) ListFromLocation

func (f *FileList) ListFromLocation(dir string) ([]string, error)

ListFromLocation reads the named directory recursively and returns a list of files and their locations in an unsorted order. If an error occurs during the list generation, all files before the error are returned including the error itself

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL