utils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExtensionNotAccepted = errors.New("ErrExtensionNotAccepted")
View Source
var ErrFileDoesNotExist = errors.New("ErrFileDoesNotExist")

Functions

func AnyEquals

func AnyEquals[T comparable](list []T, value T) bool

func BoolToString

func BoolToString(value bool) string

func ExtensionMatches

func ExtensionMatches(extensionList []string, filePath string) bool

func FileExists

func FileExists(filePath string) bool

func FilePathToPageName

func FilePathToPageName(allowedExtensions []string, filePath string) string

func FormatPageNameInput

func FormatPageNameInput(pageName string) string

func GetFileExtension

func GetFileExtension(filePath string) string

func GetNthWord

func GetNthWord(str, divisor string, index int, fallback string) string

func MapValueSearch

func MapValueSearch[TMapKey comparable, TMapValue comparable](
	subject map[TMapKey]TMapValue,
	valueToBeSearched TMapValue,
	fallback TMapKey,
) TMapKey

func RegexTest

func RegexTest(regex string, subject string) bool

func RegexTestAny

func RegexTestAny(regexList []string, subject string) bool

func RemoveNth

func RemoveNth[T interface{}](list []T, iToRemove int) []T

func ReplaceRegex added in v0.2.0

func ReplaceRegex(subject string, find []string, replaceWith string) string

func StringToBool

func StringToBool(str string) bool

func TrimEmptyLines added in v0.2.1

func TrimEmptyLines(text string) string

func ValidateFiles

func ValidateFiles(filePaths []string, acceptedExtensions []string) map[string]error

func Wget

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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