utils

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFile

func DeleteFile(filepath string) error

DeleteFile will delete filepath permanently. Returns an error in case there's any.

func GetFile

func GetFile(filepath string) (*os.File, error)

GetFile will open filepath. Returns a tuple with a file and an error in case there's any.

func SafeReadTomlFile

func SafeReadTomlFile(filename string, v interface{}) error

SafeReadTomlFile will try to acquire a lock on the file and then read its content afterwards. Returns an error in case there's any.

func SafeWriteTomlFile

func SafeWriteTomlFile(v interface{}, filename string) error

SafeWriteTomlFile will try to acquire a lock on the file and then write to it. Returns an error in case there's any.

func WriteFile

func WriteFile(filepath string, b []byte) error

WriteFile will write the info on array of bytes b to filepath. It will set the file permission mode to 0660 Returns an error in case there's any.

Types

type FileMutex

type FileMutex struct {
	// contains filtered or unexported fields
}

FileMutex is a wrapper used to create lock on files.

func MakeFileMutex

func MakeFileMutex(filename string) *FileMutex

MakeFileMutex will create a FileMutex intance. Returns a FileMutex instance.

func (*FileMutex) Lock

func (fMutex *FileMutex) Lock()

Lock will try to acquire a lock on the file.

func (*FileMutex) Unlock

func (fMutex *FileMutex) Unlock()

Unlock will try to release a lock on a file.

Jump to

Keyboard shortcuts

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