utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir added in v0.2.0

func CopyDir(srcPath, dstPath string) error

CopyDir recursively copies files from one directory to another

func GenerateUUID

func GenerateUUID(name string) uuid.UUID

GenerateUUID generates a new uuid for a minion

func SameContent added in v0.2.0

func SameContent(src, dst string) (bool, error)

SameContent returns a boolean indicating whether two files have the same content

func WalkPath added in v0.2.0

func WalkPath(root string, skip []string) ([]string, error)

WalkPath walks a path and returns a slice of file names that were found during path traversing

Types

type ConcurrentMap added in v0.2.0

type ConcurrentMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConcurrentMap is a map type that can be safely shared between goroutines that require read/write access to a map

func NewConcurrentMap

func NewConcurrentMap() *ConcurrentMap

NewConcurrentMap creates a new concurrent map

func (*ConcurrentMap) Get added in v0.2.0

func (cm *ConcurrentMap) Get(key string) (interface{}, bool)

Get retrieves the value for a concurrent map item

func (*ConcurrentMap) Iter added in v0.2.0

func (cm *ConcurrentMap) Iter() <-chan ConcurrentMapItem

Iter iterates over the items in a concurrent map Each item is sent over a channel, so that we can iterate over the map using the builtin range keyword

func (*ConcurrentMap) Set added in v0.2.0

func (cm *ConcurrentMap) Set(key string, value interface{})

Set adds an item to a concurrent map

type ConcurrentMapItem

type ConcurrentMapItem struct {
	Key   string
	Value interface{}
}

ConcurrentMapItem contains a key/value pair item of a concurrent map

type ConcurrentSlice added in v0.2.0

type ConcurrentSlice struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConcurrentSlice type that can be safely shared between goroutines

func NewConcurrentSlice

func NewConcurrentSlice() *ConcurrentSlice

NewConcurrentSlice creates a new concurrent slice

func (*ConcurrentSlice) Append added in v0.2.0

func (cs *ConcurrentSlice) Append(item interface{})

Append adds an item to the concurrent slice

func (*ConcurrentSlice) Iter added in v0.2.0

func (cs *ConcurrentSlice) Iter() <-chan ConcurrentSliceItem

Iter iterates over the items in the concurrent slice Each item is sent over a channel, so that we can iterate over the slice using the builin range keyword

type ConcurrentSliceItem

type ConcurrentSliceItem struct {
	Index int
	Value interface{}
}

ConcurrentSliceItem contains the index/value pair of an item in a concurrent slice

type FileOwner added in v0.2.0

type FileOwner struct {
	*user.User
	*user.Group
}

FileOwner type provides details about the user and group that owns a file

type FileUtil added in v0.2.0

type FileUtil struct {
	// Path to the file we manage
	Path string
}

FileUtil type

func NewFileUtil added in v0.2.0

func NewFileUtil(path string) *FileUtil

NewFileUtil creates a file utility from the given path

func (*FileUtil) Abs added in v0.2.0

func (fu *FileUtil) Abs() (string, error)

Abs returns the absolute path for the file

func (*FileUtil) Chmod added in v0.2.0

func (fu *FileUtil) Chmod(perm os.FileMode) error

Chmod changes the permissions of the file

func (*FileUtil) CopyFrom added in v0.2.0

func (fu *FileUtil) CopyFrom(srcPath string, overwrite bool) error

CopyFrom copies contents from another source to the current file

func (*FileUtil) Exists added in v0.2.0

func (fu *FileUtil) Exists() bool

Exists returns a boolean indicating whether the file exists or not

func (*FileUtil) Md5 added in v0.2.0

func (fu *FileUtil) Md5() (string, error)

Md5 returns the md5 checksum of the file's contents

func (*FileUtil) Mode added in v0.2.0

func (fu *FileUtil) Mode() (os.FileMode, error)

Mode returns the file permission bits

func (*FileUtil) Owner added in v0.2.0

func (fu *FileUtil) Owner() (*FileOwner, error)

Owner retrieves the owner and group for the file

func (*FileUtil) Remove added in v0.2.0

func (fu *FileUtil) Remove() error

Remove removes the file

func (*FileUtil) SameContentWith added in v0.2.0

func (fu *FileUtil) SameContentWith(dst string) (bool, error)

SameContentWith returns a boolean indicating whether the content of the current file is the same as the destination

func (*FileUtil) SetOwner added in v0.2.0

func (fu *FileUtil) SetOwner(owner, group string) error

SetOwner sets the ownership for the file

func (*FileUtil) Sha1 added in v0.2.0

func (fu *FileUtil) Sha1() (string, error)

Sha1 returns the sha1 checksum of the file's contents

func (*FileUtil) Sha256 added in v0.2.0

func (fu *FileUtil) Sha256() (string, error)

Sha256 returns the sha256 checksum of the file's contents

Jump to

Keyboard shortcuts

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