filesystem

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(path, filter string) []fs.DirEntry

Just like ls command, in the path, list all files in array of fs.DisEntry It will return an array of fs.DirEntry Example: files := filesystem.Dir("/home/user", ".txt") It will return all files in the directory /home/user with .txt extension If filter is empty or "*", it will return all files in the directory Output: [file1.txt file2.txt file3.txt]

func DirFileExist

func DirFileExist(path string, directory bool) bool

Check if file or directory exist. if directory=true then check if exist AND also if it's a dir Example: exist := filesystem.DirFileExist("/home/user/test.txt", false) It will return true if the file "test.txt" exist exist = filesystem.DirFileExist("/home/user/test", true) It will return true if the directory "test" exist

func DirPath

func DirPath(completefilename string) string

Return the directory name (everything beside the filename) DirPath will return the directory name of the complete path Example: dir := filesystem.DirPath("/home/user/test.txt") It will return "/home/user"

func FileExists

func FileExists(path string) bool

Check if file exists

func FileName

func FileName(completefilename string) string

This is a simple way to get the filename from a complete path It will return the filename only, without the path Example: filename := filesystem.Base("/home/user/test.txt") It will return "test.txt"

func More

func More(filename string) []string

Only for textfile, this will read the file and return as array of string per line This is a simple way to read a file line by line It will return an array of string, each line is a string It will return an empty array if the file is not found or error Example: content := filesystem.More("test.txt")

Types

This section is empty.

Jump to

Keyboard shortcuts

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