utils

package
v0.0.0-...-c3bab1b Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: MIT Imports: 5 Imported by: 0

README

Utils

This package contains different utilities used within the library

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(data string) (st interface{}, err error)

Parse is a wrapper around json.Unmarshal

func Stringify

func Stringify(data interface{}) (d string, err error)

Stringify is a wrapper around json.Marshal

Types

type ConfigHelper

type ConfigHelper struct {
	File string // File token will be read from
}

ConfigHelper loads token from txt file

func NewConfigHelper

func NewConfigHelper(file string) (*ConfigHelper, error)

NewConfigHelper creates a new ConfigHelper

func (*ConfigHelper) Token

func (c *ConfigHelper) Token() (token string, err error)

Token reads token from a file

type EventEmitter

type EventEmitter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Utility structure used for event management

func NewEventEmitter

func NewEventEmitter() *EventEmitter

func (*EventEmitter) Emit

func (e *EventEmitter) Emit(name string, data ...interface{})

Emit an event

func (*EventEmitter) On

func (e *EventEmitter) On(name string, handler interface{})

Add an event handler

type Flags

type Flags struct {
	Flags int // Bitfield
}

Flags represents a bitfield

func (*Flags) Add

func (f *Flags) Add(flags ...int)

Add adds a new bit

func (*Flags) Has

func (f *Flags) Has(flag int) bool

Has checks if a bit equals one

Jump to

Keyboard shortcuts

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