utils

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64DecodeSegment

func Base64DecodeSegment(seg string) ([]byte, error)

func ByteCountIEC

func ByteCountIEC(b int64) string

func CheckErr

func CheckErr(e error, cmd *cobra.Command)

CheckErr prints the msg with the prefix 'Error:' and exits with error code 1. If the msg is nil, it does nothing.

func ChunkSliceOfInt

func ChunkSliceOfInt(slice []int, chunkSize int) [][]int

func ChunkString

func ChunkString(s string, chunkSize int) []string

func CreateDirectoryIfNotExists

func CreateDirectoryIfNotExists(directoryPath string)

func CreateDirectoryIfNotExistsInHome

func CreateDirectoryIfNotExistsInHome(directoryPath string)

func CreateFileIfNotExists

func CreateFileIfNotExists(filePath string) error

func CreateFileIfNotExistsInHome

func CreateFileIfNotExistsInHome(filePath string) error

func CreateRangeOfInt

func CreateRangeOfInt(min, max int) []int

func DifferenceStrings

func DifferenceStrings(a, b []string) []string

DifferenceStrings returns the elements that are in A, but not in B

func DownloadFile

func DownloadFile(url, filename string) error

func DuplicateStrings

func DuplicateStrings(arr []string) []string

func Ellipsis

func Ellipsis(s string, max int) string

func ExecuteCommandAndGetOutput

func ExecuteCommandAndGetOutput(command string, flags ...string) (string, error)

func ExtractTAR

func ExtractTAR(src, dst string) error

ExtractTAR takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dst' along the way, and writing any files

func ExtractZIP

func ExtractZIP(src, dst string) error

ExtractZIP takes a destination path and a reader; a tar reader loops over the zip file creating the file structure at 'dst' along the way, and writing any files

func FileExists

func FileExists(filePath string) bool

func FileExistsInHome

func FileExistsInHome(filePath string) bool

func FileHasTarExtension

func FileHasTarExtension(filename string) bool

func FileHasZIPExtension

func FileHasZIPExtension(filename string) bool

func FormatCommas

func FormatCommas(num int) string

func GetFromAPI

func GetFromAPI(url string) ([]byte, error)

func GetPermissions

func GetPermissions(filename string) (string, error)

func GetRealSizeOf

func GetRealSizeOf(v interface{}) (int, error)

func IsOnPath

func IsOnPath(tool string) string

func IsValidJSON

func IsValidJSON(s string) bool

func MakeFileExecutable

func MakeFileExecutable(path string) error

func MoveFile

func MoveFile(file, target string) error

func OpenURL

func OpenURL(url string)

func ParseInterfaceIntoJSON

func ParseInterfaceIntoJSON(yourThing interface{}) []byte

func ParseJSON

func ParseJSON(bytes []byte) interface{}

func ParseJSONIntoArray

func ParseJSONIntoArray(bytes []byte) []interface{}

func ParseJSONIntoMap

func ParseJSONIntoMap(bytes []byte) map[string]interface{}

func Percentage

func Percentage(partialValue, totalValue int) int

func PrintAndReturnError

func PrintAndReturnError(text string) error

func PrintJSON

func PrintJSON(withColor bool, body []byte) error

func PrintJSONString

func PrintJSONString(withColor bool, body string) error

func PrintYAML

func PrintYAML(s string) error

func RemoveDirectory

func RemoveDirectory(path string) error

func RemoveFile

func RemoveFile(path string) error

func StringAfter

func StringAfter(s, substring string) string

func TarWithoutExtension

func TarWithoutExtension(fileName string) string

func Unique

func Unique(strings []string) []string

Unique returns the unique element that are in a slice of strings

func ZIPWithoutExtension

func ZIPWithoutExtension(fileName string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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