v0.0.15 Latest Latest

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

Go to latest
Published: May 1, 2022 License: MIT Imports: 16 Imported by: 0




This section is empty.


View Source
var (
	Reset   = "\033[0m"
	Red     = "\033[31m"
	Green   = "\033[32m"
	Yellow  = "\033[33m"
	Blue    = "\033[34m"
	Purple  = "\033[35m"
	Cyan    = "\033[36m"
	Gray    = "\033[37m"
	White   = "\033[97m"
	Notice  = Cyan
	Warn    = Yellow
	Fatal   = Red
	Success = Green



func Checksum

func Checksum(content string) (string, error)

Checksum retrive the checksum for given content

func Chmod

func Chmod(file string, perm fs.FileMode) error

Chmod apply permissions to file

func Chown

func Chown(file string, user int, group int) error

Chown apply user and group ownership to file

func Copy

func Copy(origin string, destination string) error

Copy the origin file into destination

func Delete

func Delete(file string) error

Delete remove a file

func Dir

func Dir(path string) string

Dir return the clean directory path for file

func EnsureDirectory

func EnsureDirectory(file string) error

EnsureDirectory makes sure directory exists from file path

func Exec

func Exec(cmd string, args ...string) (string, error)

Exec run command with given arguments

func Exist

func Exist(path string) bool

Exist check if file or directory exists

func Extension

func Extension(file string) string

Extension return the clean file extension, with dot

func File

func File(path string) string

File return the clean file name for path, with extension

func Find

func Find(root string, names []string) ([]string, error)

Find retrieve files from path that exactly match names

func FindMatch

func FindMatch(root string, patterns []string) ([]string, error)

FindMatch retrieve files from path that match patterns

func Info

func Info(file string) (string, string, fs.FileMode)

Info read and return file information: content, checksum and permissions

func List

func List(root string) ([]string, error)

List walks on path and return every found file

func Move

func Move(origin string, destination string) error

Move a file to destination

func Name

func Name(path string) string

Name return the clean file name for path, without extension

func NoColor added in v0.0.8

func NoColor() bool

NoColor check if should avoid color output on console

func NodeRequire added in v0.0.5

func NodeRequire(command string, pkg string) error

NodeRequire check if node package command exists, otherwise, try to install the package

func Permissions

func Permissions(path string) (fs.FileMode, error)

Permissions retrieve permissions for file or directory

func Printf

func Printf(color string, format string, args ...interface{})

Printf displays a info to standard output

func RandomString added in v0.0.11

func RandomString(n int) string

RandomString generates a random string from give size

func Read

func Read(file string) (string, error)

Read retrieve content from file

func ReadMany

func ReadMany(files []string) (string, error)

ReadMany retrieve merged content from file list

func Relative added in v0.0.15

func Relative(path string, root string) string

Relative return the relative path from root

func Rename

func Rename(origin string, destination string) error

Rename a file name

func Replace added in v0.0.11

func Replace(file string, search string, replace string) error

Replace content inside file

func Resolve added in v0.0.15

func Resolve(file string, path string) string

Resolve will check paths until file is detected

func TemporaryFile added in v0.0.11

func TemporaryFile(file string) string

TemporaryFile return a temporary file path

func Walk

func Walk(root string, callback WalkCallback) error

Walk find files in path and process callback for every result

func Watch

func Watch(path string, interval time.Duration, onChange WatchCallback, onDelete WatchCallback)

Watch check for changes on path files and trigger events on change or on delete file

func Write

func Write(file string, content string, perm fs.FileMode) error

Write content on file


type WalkCallback

type WalkCallback func(path string) error

WalkCallback type

type WatchCallback

type WatchCallback func(path string) error

WalkCallback type

Jump to

Keyboard shortcuts

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