utils

package
v0.0.0-...-cec39cb Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: MIT Imports: 20 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidFunc func(cacheKey string)

Functions

func ArrayContains

func ArrayContains(val interface{}, array interface{}) (exists bool, index int)

func ArrayContainsRe

func ArrayContainsRe(itr []string, value string) bool

func ClearFeaturedCache

func ClearFeaturedCache(gameshort string)

func ClearGameCache

func ClearGameCache(gameshort string, version string)

func ClearModCache

func ClearModCache(gameshort string, modid uint)

func ClearModListCache

func ClearModListCache(gameshort string, listid uint)

func ClearPublisherCache

func ClearPublisherCache(pubid uint)

func ClearUserCache

func ClearUserCache(userid uint)

func CurrentGoroutineID

func CurrentGoroutineID() uint64

This function is terrible and I should feel bad. Borrowed from https://github.com/bradfitz/http2/blob/dc0c5c000ec33e263612939744d51a3b68b9cece/gotrack.go

func DumpJSON

func DumpJSON(data interface{}) string

func EditObject

func EditObject(value interface{}, data map[string]interface{}) int

Return codes:

0: Everything is ok
1: Tried to edit a field that is locked
2: Tried to patch a field that doesnt exist
3: Invalid type

func Format

func Format(format string, p map[string]interface{}) string

func FromMap

func FromMap(data interface{}, values map[string]interface{}) error

func GetFullJSON

func GetFullJSON(ctx *iris.Context) map[string]interface{}

func GetJSON

func GetJSON(ctx *iris.Context, key string) interface{}

func InvalidateCache

func InvalidateCache(url string, values ...interface{})

func LoadJSON

func LoadJSON(data string) map[string]interface{}

func RandomHex

func RandomHex(n int) (string, error)

func ReadField

func ReadField(value *interface{}, field string) interface{}

func RegisterDataTransformer

func RegisterDataTransformer(transformer DataTransformerFunc)

func SendAutoUpdateNotification

func SendAutoUpdateNotification(followers []string, changelog string, username string, friendly_version string, modname string, modID uint, modURL string, gamename string, gameversion string)

func SendConfirmation

func SendConfirmation(userConfirmation string, userUsername string, userEmail string, followMod string)

func SendGrantNotice

func SendGrantNotice(userUsername string, modUsername string, modName string, modID uint, userEmail string, modURL string)

func SendMail

func SendMail(sender string, recipients []string, subject string, message string, important bool)

func SendReset

func SendReset(userUsername string, userPasswordReset string, userEmail string)

func SendUpdateNotification

func SendUpdateNotification(followers []string, changelog string, username string, friendly_version string, modname string, modID uint, modURL string, gamename string, gameversion string)

func Ternary

func Ternary(condition bool, tVal interface{}, fVal interface{}) interface{}

Stupidly simple, but I want to inline conditions

func ToMap

func ToMap(data interface{}) map[string]interface{}

func WriteJSON

func WriteJSON(ctx *iris.Context, status int, v interface{}) error

Types

type DataTransformerFunc

type DataTransformerFunc func(interface{}, map[string]interface{})

type ErrorMessage

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

func Error

func Error(reasons ...string) ErrorMessage

func (ErrorMessage) Code

func (error ErrorMessage) Code(codes ...int) iris.Map

Jump to

Keyboard shortcuts

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