utils

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChownFileUsername

func ChownFileUsername(filename, username string) error

ChownFileUsername executes chown username:username filename.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Otherise, attempt to create a hard link between the two files. If that fail, copy the file contents from src to dst.

func CreateFile

func CreateFile(path string) error

CreateFile will create an empty file.

func DeleteDirContent added in v0.0.4

func DeleteDirContent(dir string) error

DeleteDirContent delete all files from a folder without deleting the parent directory.

func DeleteFile added in v0.0.3

func DeleteFile(path string) error

DeleteFile delete a file.

func Download added in v0.0.2

func Download(client *minio.Client, bucketName, filePath, objectName string) (
	[]byte, error)

Download downloads an object from a bucket.

func ExecCommand

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

ExecCommand runs cmd on file.

func Exists added in v0.0.5

func Exists(name string) bool

Exists reports whether the named file or directory exists.

func GetCurrentTime

func GetCurrentTime() time.Time

GetCurrentTime as Time object in UTC.

func GetFileSize

func GetFileSize(FilePath string) int64

GetFileSize returns file size in bytes.

func GetRootProjectDir

func GetRootProjectDir() string

GetRootProjectDir retrieves `saferwall` root src project directory.

func Getwd

func Getwd() (string, error)

Getwd returns the directory where the process is running from.

func IsDirectory

func IsDirectory(path string) (bool, error)

IsDirectory returns true if path is a directory.

func ReadAll

func ReadAll(filePath string) ([]byte, error)

ReadAll reads the entire file into memory.

func SliceContainsString

func SliceContainsString(a string, list []string) bool

SliceContainsString returns if slice contains substring.

func StartCommand

func StartCommand(name string, args ...string) error

StartCommand will execute a command in background.

func StringInSlice

func StringInSlice(a string, list []string) bool

StringInSlice returns whether or not a string exists in a slice.

func UniqueSlice

func UniqueSlice(slice []string) []string

UniqueSlice delete duplicate strings from an array of strings.

func WalkAllFilesInDir

func WalkAllFilesInDir(dir string) ([]string, error)

WalkAllFilesInDir returns list of files in directory.

func WriteBytesFile

func WriteBytesFile(filename string, r io.Reader) (int, error)

WriteBytesFile write Bytes to a File.

func ZipDecrypt added in v0.0.2

func ZipDecrypt(zipFilepath string, password string) error

ZipDecrypt compresses binary data to zip using a password.

func ZipEncrypt added in v0.0.2

func ZipEncrypt(filename string, password string, contents io.Reader) (
	string, error)

ZipEncrypt compresses binary data to zip using a password.

Types

This section is empty.

Jump to

Keyboard shortcuts

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