utils

package
v0.26.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(arr []string, val string) bool

Contains Returns true of array contains the given string

func CopyDir

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

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

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

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

func DirectoryExists

func DirectoryExists(directory string) bool

DirectoryExists Returns true if the given path is a directory, and it exists.

func ExpandPath

func ExpandPath(pathToExpand string) string

ExpandPath Expands the given path to an absolute directory

func FileExists

func FileExists(file string) bool

FileExists Returns true if the given path is a file, and it exists.

func GetChildDirectories

func GetChildDirectories(path string) ([]string, error)

GetChildDirectories Gets child directories in the given directory

func GetFileLines

func GetFileLines(path string) ([]string, error)

GetFileLines Get all the lines from a file

func NewID

func NewID() string

NewID generates a new identifier for use where random identifiers with low collision probability are required.

With the parameters in this package, the generated identifier will provide ~129 bits of entropy encoded with base36. Leading padding is added if the string is less 25 bytes. We do not intend to maintain this interface, so identifiers should be treated opaquely.

func RemoveDuplicates

func RemoveDuplicates(elements []string) []string

RemoveDuplicates Remove duplicate items from an array.

func Reverse

func Reverse(elements []string) []string

Reverse Reverses the array

Types

This section is empty.

Jump to

Keyboard shortcuts

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