utility

package
v0.0.0-...-7b0100a Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(src string) ([]byte, error)

Decode decodes an url encoded string into a byte array

func Encode

func Encode(src []byte) string

Encode encodes a byte array into an urlencoded string

func ErrorHandler

func ErrorHandler(e error, fatal bool) bool

ErrorHandler is a utility function to handle errors so we don't have to write

if err != nil {
    // Do something here
}

func GenerateToken

func GenerateToken(len int) (string, error)

GenerateToken generates a random string of len length

func GetFlash

func GetFlash(w http.ResponseWriter, r *http.Request, name string) ([]byte, error)

GetFlash gets the cookie value set by SetFlash and removes the cookie

func IsEmailValid

func IsEmailValid(e string) bool

IsEmailValid checks if the email provided passes the required structure and length.

func SetFlash

func SetFlash(w http.ResponseWriter, name string, value []byte)

SetFlash sets a cookie which expires after the next page load

func TrimWhitespace

func TrimWhitespace(str string) string

TrimWhitespace takes a string and removes any spaces

Types

This section is empty.

Jump to

Keyboard shortcuts

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