utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildEnvVars added in v1.0.1

func BuildEnvVars(settings *config.Schema) []string

BuildEnvVars generates a sane base for environment variables to run shell commands with. It just includes $PATH

func DetectContentType

func DetectContentType(filePath string) (ct string, err error)

DetectContentType detect the content type of a file

func DownloadFile

func DownloadFile(folder string, url string) (filename string, 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 ExtractGzip

func ExtractGzip(filePath, outFolder string) (err error)

ExtractGzip extract a gzip file

func FileExists

func FileExists(filePath string) bool

FileExists return whenever a file exists

func GenerateRandomHash

func GenerateRandomHash() (h string, err error)

GenerateRandomHash returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GetPath

func GetPath(pieces ...string) string

GetPath build the path to a file

func Hash

func Hash(data ...interface{}) string

Hash calculate the hash of a string

func LoadJSON

func LoadJSON(filePath string, v interface{}) (err error)

LoadJSON load json from file into struct

func SearchAndMove

func SearchAndMove(root, file, targetPath string) (err error)

SearchAndMove search a file in a folder and move it to another path

func ShortHash

func ShortHash(data ...string) string

ShortHash calculate the hash of a string (10c)

func StoreJSON

func StoreJSON(filePath string, v interface{}) (err error)

StoreJSON store a struct to a json file

Types

This section is empty.

Jump to

Keyboard shortcuts

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