utils

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src, dest string, opt ...CopyOption) error

Copy copies src to dest, doesn't matter if src is a directory or a file.

func DownloadFile

func DownloadFile(url string) (f *os.File, err error)

DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.

func GitClone added in v0.0.2

func GitClone(repo string, outDir string) (err error)

GitClone clones a repo with depth 1

func IsEmpty

func IsEmpty(name string) (bool, error)

IsEmpty checks if a directory is empty

func PathExists

func PathExists(name string) bool

PathExists checks if a file exists

func Unzip

func Unzip(src string, dest string) ([]string, error)

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).

Types

type CopyOption added in v0.0.2

type CopyOption func(*Options)

CopyOption define a function type that handle optional actions.

type Options

type Options struct {
	// OnSymlink can specify what to do on symlink
	OnSymlink func(src string) SymlinkAction
	// Skip can specify which files should be skipped
	Skip func(src string) bool
	// AddPermission to every entities,
	// NO MORE THAN 0777
	AddPermission os.FileMode
	// Sync file after copy.
	// Useful in case when file must be on the disk
	// (in case crash happens, for example),
	// at the expense of some performance penalty
	Sync bool
}

Options specifies optional actions on copying.

type SymlinkAction

type SymlinkAction int

SymlinkAction represents what to do on symlink.

const (
	// Deep creates hard-copy of contents.
	Deep SymlinkAction = iota
	// Shallow creates new symlink to the dest of symlink.
	Shallow
	// Skip does nothing with symlink.
	Skip
)

Jump to

Keyboard shortcuts

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