vutils

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTPBaseCookie http.Cookie

HTTPBaseCookie defines the base cookie setup for vcago

View Source
var Logger string

Logger defines the Logger type. Can set to IO for StdOut and NATS for nats logging

Functions

func Env added in v1.0.1

func Env()

Env load the environment variables for vcago

Types

type LoadEnv added in v1.0.1

type LoadEnv []bool

LoadEnv used for loading environment variables.

func (LoadEnv) GetEnvBool added in v1.0.1

func (l LoadEnv) GetEnvBool(key string, lvl string, dVal bool) (bool, LoadEnv)

GetEnvBool load a key from environment variables as bool.

func (LoadEnv) GetEnvInt added in v1.0.1

func (l LoadEnv) GetEnvInt(key string, lvl string, dVal int) (int, LoadEnv)

GetEnvInt loads a key from enviroment variables as int. The lvl param defines the log level. For warnings set "w" and for error set "e". If the variable is not used or can be ignored use n for do nothing. The default value can be set by the dVal param.

func (LoadEnv) GetEnvString added in v1.0.1

func (l LoadEnv) GetEnvString(key string, lvl string, dVal string) (string, LoadEnv)

GetEnvString loads a key from enviroment variables as string. The lvl param defines the log level. For warnings set "w" and for error set "e". If the variable is not used or can be ignored use n for do nothing. The default value can be set by the dVal param.

func (LoadEnv) GetEnvStringList added in v1.0.1

func (l LoadEnv) GetEnvStringList(key string, lvl string, dVal []string) ([]string, LoadEnv)

GetEnvStringList as

func (LoadEnv) Validate added in v1.0.1

func (l LoadEnv) Validate()

Validate check if LoadEnv is valid and log.Fatal if on entry is false.

type Mongo added in v1.0.1

type Mongo struct {
	Host   string
	Port   string
	DBName string
	DB     *mongo.Database
}

Mongo represents the initial struct for an Mongo connection.

func (*Mongo) Connect added in v1.0.1

func (i *Mongo) Connect(dbName string) (r *Mongo)

Connect connects to mongoDB and return an mongo.Database.

func (*Mongo) CreateIndex added in v1.0.1

func (i *Mongo) CreateIndex(collection string, field string, unique bool)

func (*Mongo) FindOne added in v1.0.2

func (i *Mongo) FindOne(ctx context.Context, collection string, value bson.M, result interface{}) (err error)

func (Mongo) InsertOne added in v1.0.1

func (i Mongo) InsertOne(ctx context.Context, collection string, value interface{}) (err error)

func (*Mongo) LoadEnv added in v1.0.1

func (i *Mongo) LoadEnv() *Mongo

LoadEnv loads the Host and Port From .env file. Host can be set via NATS_HOST Port can be set via NATS_PORT

type MongoError added in v1.0.1

type MongoError struct {
	Err        string      `json:"error" bson:"error"`
	Value      interface{} `json:"value" bson:"value"`
	Database   string      `json:"database" bson:"database"`
	Collection string      `json:"collection" bson:"collection"`
}

func NewMongoError added in v1.0.1

func NewMongoError(err error, value interface{}, database string, collection string) *MongoError

func (*MongoError) Error added in v1.0.1

func (i *MongoError) Error() string

type Nats added in v1.0.1

type Nats struct {
	Host string
	Port string
}

Nats represents the initial struct for an nats connection.

func (*Nats) Connect added in v1.0.1

func (i *Nats) Connect() (r *nats.EncodedConn)

Connect connects nats client to server. The client is using the Nats.Host and Nats.Port parameters.

func (*Nats) LoadEnv added in v1.0.1

func (i *Nats) LoadEnv() *Nats

LoadEnv loads the Host and Port From .env file. Host can be set via NATS_HOST Port can be set via NATS_PORT

Jump to

Keyboard shortcuts

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