core

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Buffer2Struct

func Buffer2Struct(buf *bytes.Buffer, i interface{}) error

Parse a buffer to an interface

func GetFirebase

func GetFirebase() *firebase.App

func GetToday

func GetToday() time.Time

func IndexOf

func IndexOf(values []string, value string) int

func IndexOfWithField added in v0.2.8

func IndexOfWithField(values interface{}, value interface{}, key string) int

func IndexOfWithFunction added in v0.2.8

func IndexOfWithFunction(values interface{}, value interface{}, compareFunction func(interface{}, interface{}) bool) int

func InitFirebase

func InitFirebase(credentialsFile string) error

func LoadConfig

func LoadConfig(filename string, doc interface{}) error

Load yaml from a file to a struct

func Map2Struct

func Map2Struct(v map[string]interface{}, i interface{}) error

From map to struct using json.Marshal() and json json.Unmarshal()

func NewInstance

func NewInstance(t reflect.Type) interface{}

func Now

func Now() *time.Time

func SetInterval

func SetInterval(callback func(), interval time.Duration, async bool) chan bool

func SetTimeout

func SetTimeout(callback func(), milliseconds int)

func Struct2Map

func Struct2Map(v interface{}) (map[string]interface{}, error)

From struct to map[string]interface{} using json.Marshal() and json json.Unmarshal()

func TypeOf

func TypeOf(i interface{}) reflect.Type

func WriteConfig

func WriteConfig(filename string, doc interface{}) error

Write config file

Types

type Auth

type Auth struct {
	UserName string
	Password string
}

Use login auth instead of PlainAuth that was support by golang

func (*Auth) Next

func (a *Auth) Next(fromServer []byte, more bool) ([]byte, error)

func (*Auth) Start

func (a *Auth) Start(server *smtp.ServerInfo) (string, []byte, error)

type Emitter added in v0.2.11

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

func (*Emitter) Clear added in v0.2.11

func (e *Emitter) Clear()

func (*Emitter) Emit added in v0.2.11

func (e *Emitter) Emit(event string)

func (*Emitter) Has added in v0.2.11

func (e *Emitter) Has(event string) bool

func (*Emitter) Init added in v0.2.11

func (e *Emitter) Init()

func (*Emitter) Off added in v0.2.11

func (e *Emitter) Off(event string, handler func())

func (*Emitter) On added in v0.2.11

func (e *Emitter) On(event string, handler func())

type Error added in v0.2.11

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

add code into error

func NewError added in v0.2.11

func NewError(code int, message string, params interface{}) *Error

func (*Error) Code added in v0.2.11

func (e *Error) Code() int

func (*Error) Error added in v0.2.11

func (e *Error) Error() string

type IDTokenResp

type IDTokenResp struct {
	Token        string `json:"idToken"`
	RefreshToken string `json:"refreshToken"`
	IsNewUser    bool   `json:"isNewUser"`
}

func GetFirebaseIDToken

func GetFirebaseIDToken(apiKey, customToken string) (*IDTokenResp, error)

type SMTP

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

func GetSMTP

func GetSMTP() *SMTP

Singleton pattern

func (*SMTP) Init

func (s *SMTP) Init(config SMTPConfig)

func (*SMTP) LoginAuth

func (s *SMTP) LoginAuth(username, password string) smtp.Auth

func (*SMTP) Send

func (s *SMTP) Send(from string, subject, body string, to string, toAddressess []string) error

Connect to the server, authenticate, set the sender and recipient, and send the email all in one step

type SMTPConfig

type SMTPConfig struct {
	Username string `yaml:"user"`
	Password string `yaml:"password"`
	Server   string `yaml:"server"`
	Port     int    `yaml:"port"`
}

Config for SMTP

Jump to

Keyboard shortcuts

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