gofile

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 6 Imported by: 1

README

gofile

File and directory management libraries.


Example of use

    // determine if a file or folder exists
    gofile.IsExists("/tmp/test/")

    // get the path to program execution
    gofile.GetRunPath()

    // get all files in a directory (absolute path)
    gofile.ListFiles("/tmp/")

    // get all files in a directory by prefix (absolute path)
    gofile.ListFiles(dir, WithPrefix("READ"))

    // get all files in a directory by suffix (absolute path)
    gofile.ListFiles(dir, WithSuffix(".go"))

    // get all files in a directory based on a string (absolute path)
    gofile.ListFiles(dir, WithContain("file"))

Documentation

Overview

Package gofile is file and directory management libraries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDir added in v1.3.0

func CreateDir(dir string) error

CreateDir create dir

func FilterDirs added in v1.7.0

func FilterDirs(dirs []string, opts Option) []string

FilterDirs filter directories that meet the criteria

func FindAllSubBytes added in v1.5.1

func FindAllSubBytes(data []byte, start []byte, end []byte) [][]byte

FindAllSubBytes find all substrings, including start and end marks

func FindSubBytes

func FindSubBytes(data []byte, start []byte, end []byte) []byte

FindSubBytes find first substrings, including start and end marks

func FindSubBytesNotIn

func FindSubBytesNotIn(data []byte, start []byte, end []byte) []byte

FindSubBytesNotIn find substrings, excluding start and end tags

func FuzzyMatchFiles added in v1.2.0

func FuzzyMatchFiles(f string) []string

FuzzyMatchFiles fuzzy matching of documents, * only

func GetFileDir added in v1.3.0

func GetFileDir(filePath string) string

GetFileDir get dir

func GetFilename

func GetFilename(filePath string) string

GetFilename get file name

func GetFilenameWithoutSuffix added in v1.2.0

func GetFilenameWithoutSuffix(filePath string) string

GetFilenameWithoutSuffix get file name without suffix

func GetPathDelimiter

func GetPathDelimiter() string

GetPathDelimiter get separator by system type

func GetRunPath

func GetRunPath() string

GetRunPath get the absolute path of the program execution

func IsExists

func IsExists(f string) bool

IsExists determine if a file or folder exists

func IsWindows

func IsWindows() bool

IsWindows determining whether a window environment

func Join added in v1.2.0

func Join(elem ...string) string

Join joins any number of path elements into a single path

func ListDirs added in v1.7.0

func ListDirs(specifiedDir string) ([]string, error)

ListDirs list all sub dirs, not including itself

func ListDirsAndFiles

func ListDirsAndFiles(dirPath string) (map[string][]string, error)

ListDirsAndFiles iterates through all subdirectories of the specified directory, returning the absolute path to the file

func ListFiles

func ListFiles(dirPath string, opts ...Option) ([]string, error)

ListFiles iterates over all files in the specified directory, returning the absolute path to the file

Types

type Option

type Option func(*options)

Option set the file options.

func WithContain

func WithContain(name string) Option

WithContain set contain matching

func WithPrefix

func WithPrefix(name string) Option

WithPrefix set prefix matching

func WithSuffix

func WithSuffix(name string) Option

WithSuffix set suffix matching

Jump to

Keyboard shortcuts

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