compactor

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(extension Extension, processor Processor)

Add processor to the instance

func ChmodFile

func ChmodFile(filename string, perm fs.FileMode) error

ChmodFile apply permission to file

func ChownFile

func ChownFile(filename string, user int, group int) error

ChmodFile apply permission to file

func CopyFile

func CopyFile(source string, destination string) error

CopyFile copy the source file into destination

func DeleteFile

func DeleteFile(filename string) error

DeleteFile remove a file

func EnsureDirectory

func EnsureDirectory(filename string) error

EnsureDirectory makes sure directory exists from file path

func ExecCommand

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

func ExistFile

func ExistFile(filename string) bool

ExistFile check if file exists

func FindFiles

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

FindFiles retrieve files from source path

func GetPermission

func GetPermission(filename string) (fs.FileMode, error)

GetPermission retrieve file permission from filename

func ListFiles

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

ListFiles walks on filepath and return every found file

func MoveFile

func MoveFile(source string, destination string) error

MoveFile move a file to destination

func ReadFile

func ReadFile(filename string) (string, error)

ReadFile retrieve file content from filename

func ReadFileAndPermission

func ReadFileAndPermission(filename string) (string, fs.FileMode, error)

ReadFileAndPermission retrieve file content and permissions from filename

func ReadFiles

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

ReadFiles retrieve files content from file list

func RenameFile

func RenameFile(source string, destination string) error

RenameFile rename a file name

func WriteFile

func WriteFile(filename string, content string, perm fs.FileMode) error

WriteFile write content on file

Types

type Context

type Context struct {
	File        string
	Extension   string
	Path        string
	Source      string
	Destination string
	Options     Options
	Processed   bool
	Skipped     bool
}

Context struct

func Process

func Process(file, fromSource string, toDestination string, options Options) (*Context, error)

Process file

type Extension

type Extension string

Extension struct

type Instance

type Instance map[Extension]Processors

Instance struct

type Options

type Options map[string]string

Options struct

type Processor

type Processor func(context *Context) error

Processor struct

type Processors

type Processors []Processor

Processors struct

Jump to

Keyboard shortcuts

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