gofile

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 6 Imported by: 0

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

func CreateDir(dir string) error

CreateDir create dir

func FindAllSubBytes

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

func FuzzyMatchFiles(f string) []string

FuzzyMatchFiles fuzzy matching of documents, * only

func GetFileDir

func GetFileDir(filePath string) string

GetFileDir get dir

func GetFilename

func GetFilename(filePath string) string

GetFilename get file name

func GetFilenameWithoutSuffix

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

func Join(elem ...string) string

Join joins any number of path elements into a single path

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