util

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

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

Go to latest
Published: Sep 6, 2024 License: AGPL-3.0-or-later Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capitalize

func Capitalize(s string) string

func Check

func Check(err error, msg string, args ...interface{})

func Contains

func Contains(slice []string, s string) bool

func CreateIfNotExist

func CreateIfNotExist(docpath, content string) (bool, error)

func Eout

func Eout(err error, msg string, args ...interface{}) error

format all errors consistently, and provide context for the error using the string `msg`

func GetThreadSlug

func GetThreadSlug(threadid int, title string, threadLen int) string

func GetURLPortion

func GetURLPortion(req *http.Request, index int) (int, bool)

returns an id from a url path, and a boolean. the boolean is true if we're returning what we expect; false if the operation failed

func Hex2Base64

func Hex2Base64(s string) (string, error)

func LoadFile

func LoadFile(key, docpath, defaultContent string) ([]byte, error)

func Markup

func Markup(md string) template.HTML

Turns Markdown input into HTML

func ReadConfig

func ReadConfig(confpath string) types.Config

func RelativeTime

func RelativeTime(t time.Time) string

func SanitizeStringStrict

func SanitizeStringStrict(s string) string

func SanitizeURL

func SanitizeURL(input string) string

make a string be suitable for use as part of a url

func VerificationPrefix

func VerificationPrefix(name string) string

Types

type ErrorDescriber

type ErrorDescriber struct {
	// contains filtered or unexported fields
}

func Describe

func Describe(environ string) ErrorDescriber

parametrize Eout/Check such that error messages contain a defined context/environ

func (ErrorDescriber) Check

func (ed ErrorDescriber) Check(err error, msg string, args ...interface{})

func (ErrorDescriber) Eout

func (ed ErrorDescriber) Eout(err error, msg string, args ...interface{}) error

Jump to

Keyboard shortcuts

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