os

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: MIT Imports: 13 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 retrieve 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 Clean added in v0.1.1

func Clean(path string, root string) string

Clean return the cleaned relative path from root

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 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(base string, target string) string

Relative return the relative path from root to the target path

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 Server added in v0.1.0

func Server(root string, port string, onRequest RequestCallback) error

Server start a file server with given path and port

func TemporaryFile added in v0.0.11

func TemporaryFile(file string) string

TemporaryFile return a temporary file path

func Watch

func Watch(root string, onChange WatchCallback) error

Watch will check if there is any change in the files inside path

func WatchCheckFile added in v0.1.0

func WatchCheckFile(file string, onChange WatchCallback) error

WatchCheckFile will check if file has been changed and run callback once necessary

func Write

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

Write content on file

Types

type RequestCallback added in v0.1.0

type RequestCallback func(uri string) error

RequestCallback type

type WatchCallback

type WatchCallback func(path string, action string) error

WatchCallback type

Jump to

Keyboard shortcuts

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