utils

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Helpful utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanString

func CleanString(str string, unescape bool) string

CleanString cleans a string from new lines and caret returns, un-escapes HTML entities and trims spaces.

func DirExists

func DirExists(path string) (bool, error)

DirExists returns whether the given file or directory exists or not.

func Format

func Format(tpl *template.Template, params map[string]string) string

Format formats the template with passed string map values.

func HashPassword

func HashPassword(password string) string

HashPassword hashes a password.

func MapToSlice

func MapToSlice(boolMap map[string]bool) []string

MapToSlice will save keys of a string map into a slice.

func MustForceLocalTimezone

func MustForceLocalTimezone(date time.Time) time.Time

MustForceLocalTimezone adds current timezone to passed date, without recalculating the date.

func RemoveDuplicates

func RemoveDuplicates(slice []string) []string

RemoveDuplicates will remove duplicates from a slice of strings.

func RemoveFromSlice

func RemoveFromSlice(slice []string, item string) []string

RemoveFromSlice will remove an element from string slice by value, assuming the element is there only once.

func SliceToMap

func SliceToMap(slice []string) map[string]bool

SliceToMap will convert a string slice into a string map.

func StandardizeURL

func StandardizeURL(url string) string

StandardizeURL standardizes the url by making sure it has a schema and converting IDNA domains into ASCII.

func StripTags

func StripTags(text string) string

StripTags strips HTML tags from text.

func ToStringSlice

func ToStringSlice(elements []interface{}) []string

ToStringSlice converts arbitrary interface slice into a string slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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