utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileCopy

func FileCopy(fs afero.Fs, sourcePath string, destPath string) error

func FileCopyRecursively

func FileCopyRecursively(fs afero.Fs, sourcePath string, destPath string) error

FileCopyRecursively copies recursively files from one directory to other, being similar to a `cp -R` command. Based on walk function https://github.com/spf13/afero/blob/master/path.go

func FileListRecursively

func FileListRecursively(fs afero.Fs, path string) ([]string, error)

FileListRecursively list recursively all files inside a directory. The result list is alphanumerically ordered

func FileListRecursivelyWithoutDirs

func FileListRecursivelyWithoutDirs(fs afero.Fs, path string) ([]string, error)

FileListRecursivelyWithoutDirs list recursively all files inside a directory, excluding directories. The result list is alphanumerically ordered

func FindString

func FindString(slice []string, val string) (int, bool)

FindString takes a slice and looks for a string in it. If found it will return it's key, otherwise it will return nil and a bool of false.

func HTTPDownloadFile

func HTTPDownloadFile(fs afero.Fs, file afero.File, url string) error

HTTPDownloadFile downloads a url and store it in local filepath. Based on https://progolang.com/how-to-download-files-in-go/

func NewDirectoryWithKeep

func NewDirectoryWithKeep(fs afero.Fs, path string) error

NewDirectoryWithKeep creates a directory and an empty .keep file to maintain filetree in git

func NewFileIfNotExist

func NewFileIfNotExist(fs afero.Fs, path string) error

NewFileIfNotExist creates a empty file if is not present, or do nothing if file already exists

func NewFileWithContentIfNotExist

func NewFileWithContentIfNotExist(fs afero.Fs, path string, content string) error

NewFileWithContentIfNotExist creates a file with a speficied content only if file doesn't exist

func RemoveDuplicatedStrings

func RemoveDuplicatedStrings(slice []string) []string

RemoveDuplicatedStrings returns a string slice without duplicated elements. Order is NOT preserved

Types

This section is empty.

Jump to

Keyboard shortcuts

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