Documentation
¶
Overview ¶
Package helpers are a sub-section of function from defense-unicorn pkg helpers package
Index ¶
- Constants
- func CreateDirectory(path string, mode os.FileMode) error
- func CreateFile(filepath string) error
- func CreateParentDirectory(destination string) error
- func CreatePathAndCopy(source string, destination string) error
- func ExtractBasePathFromURL(urlStr string) (string, error)
- func GetCryptoHash(data io.ReadCloser, hashName crypto.Hash) (string, error)
- func GetSHA256Hash(data io.ReadCloser) (string, error)
- func GetSHA256OfFile(filePath string) (string, error)
- func InvalidPath(path string) bool
- func IsDir(path string) bool
- func IsURL(source string) bool
- func SHAsMatch(path, expected string) error
- func Unique[T comparable](s []T) (r []T)
Constants ¶
const ( // ReadUser is used for any internal file to be read only ReadUser = 0400 // ReadWriteUser is used for any internal file not normally used by the end user or containing sensitive data ReadWriteUser = 0600 // ReadAllWriteUser is used for any non sensitive file intended to be consumed by the end user ReadAllWriteUser = 0644 // ReadWriteExecuteUser is used for any directory or executable not normally used by the end user or containing sensitive data ReadWriteExecuteUser = 0700 // ReadExecuteAllWriteUser is used for any non sensitive directory or executable intended to be consumed by the end user ReadExecuteAllWriteUser = 0755 )
Variables ¶
This section is empty.
Functions ¶
func CreateDirectory ¶
CreateDirectory creates a directory for the given path and file mode.
func CreateFile ¶
CreateFile creates an empty file at the given path.
func CreateParentDirectory ¶
CreateParentDirectory creates the parent directory for the given file path.
func CreatePathAndCopy ¶
CreatePathAndCopy creates the parent directory for the given file path and copies the source file to the destination.
func ExtractBasePathFromURL ¶
ExtractBasePathFromURL returns filename from URL string
func GetCryptoHash ¶
GetCryptoHash returns the computed SHA256 Sum of a given file
func GetSHA256Hash ¶
func GetSHA256Hash(data io.ReadCloser) (string, error)
GetSHA256Hash returns the computed SHA256 Sum of a given file
func GetSHA256OfFile ¶
GetSHA256OfFile returns the SHA256 hash of the provided file.
func InvalidPath ¶
InvalidPath checks if the given path is valid (if it is a permissions error it is there we just don't have access)
func SHAsMatch ¶
SHAsMatch returns an error if the SHA256 hash of the provided file does not match the expected hash.
func Unique ¶
func Unique[T comparable](s []T) (r []T)
Unique returns a new slice with only unique elements.
Types ¶
This section is empty.