util

package
v0.0.0-...-5972462 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDir

func ClearDir(dir string) error

ClearDir removes all files and sub dirs

func ConvertToJSON

func ConvertToJSON(val interface{}) (string, error)

ConvertToJSON convert object to json

func DeleteFile

func DeleteFile(path string) error

DeleteFile deletes a file

func DirExists

func DirExists(path string) bool

DirExists reports whether the dir exists

func EnsureDir

func EnsureDir(dirName string, mode int) (bool, error)

EnsureDir ensures that directory exists

func EnsureTrailingSlash

func EnsureTrailingSlash(dir string) string

EnsureTrailingSlash ensure there is a trailing slash

func FileExists

func FileExists(path string) bool

FileExists reports whether the named file exists

func FilterFiles

func FilterFiles(files, filters []string) []string

FilterFiles filters files list based on specific sub-strings

func InArray

func InArray(val interface{}, array interface{}) bool

InArray check if value is on array

func ListFiles

func ListFiles(basePath string) (map[string]File, error)

ListFiles lists all files inside a dir

func PathExists

func PathExists(path string) bool

PathExists reports whether the path exists

func ReadFile

func ReadFile(path string) (string, error)

ReadFile get the file content

func RemoveStartingSlash

func RemoveStartingSlash(dir string) string

RemoveStartingSlash removes any starting slash

func RemoveTrailingSlash

func RemoveTrailingSlash(dir string) string

RemoveTrailingSlash removes any trailing slash

func StoreFile

func StoreFile(path, content string) error

StoreFile stores a file content

func Unset

func Unset(a []string, i int) []string

Unset remove element at position i

Types

type File

type File struct {
	Path         string
	Ident        string
	Name         string
	Size         int64
	ModTime      time.Time
	ModTimestamp int64
}

File struct

Jump to

Keyboard shortcuts

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