os

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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
)

Colors

Functions

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 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 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 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 path. Overwrite if already exists

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, extensions []string, path string) string

Resolve will check paths with possible extensions until file is detected

func TemporaryFile added in v0.0.11

func TemporaryFile(file string) string

TemporaryFile return a temporary file path

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

Types

type WatchCallback

type WatchCallback func(path string) error

WatchCallback type

Jump to

Keyboard shortcuts

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