utils

package module
v0.0.0-...-b2b82d6 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 16 Imported by: 2

README

utils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskForConfirmation

func AskForConfirmation(s string) bool

AskForConfirmation asks the user for confirmation. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user.

func BodyToString

func BodyToString(body io.Reader) (string, error)

BodyToString returns the pure json-string data to screen

func DoesFileExist

func DoesFileExist(filename string) (fileok bool)

func EnvVariable

func EnvVariable(exportedName string) (variable string, err error)

func PrettyJson

func PrettyJson(i interface{}) (string, error)

PrettyJson returns pretty converted json

func ReadWholeFile

func ReadWholeFile(path string) (body string, err error)

ReadWholeFile opens and reads whole file and return a body of this file Note that this function should not be used for big files!

func ResolveEnv

func ResolveEnv(envName, def string) string

ResolveEnv check the env with the provived name and if doesn't exist it will create it and set value to the provided one

func SliceContains

func SliceContains(slice []string, needle string) bool

func SlicesDiff

func SlicesDiff(oldSlice, newSlice []string) (removed, added []string)

SlicesDiff comparef two slices together and returns two slices of the difference The first slice contains what's been removed, opposite to the other slice Note: First passed slice should be the old/previous/base one, second the new/current one

func StructToMap

func StructToMap(entry interface{}) (retval map[string]interface{})

func Untar

func Untar(path string, destinationpath string) error

Untar function unpacking an archive to destination directory Returns nil if everything goes just fine, otherwise error is sent

Types

type File

type File struct {
	Filepath string
	Name     string
	Time     time.Time
	Size     int64
}

func FilesFromDirectory

func FilesFromDirectory(directory string, mustCompile string) (result []*File, err error)

FilesFromDirectory returns a list of files in passed directory. If mustCompile variable passed, only the files that pass the regexp will be returned

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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