config

package
v0.0.0-...-3778cc8 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Log      Log      `envconfig:"log"      required:"true"`
	Server   Server   `envconfig:"server"   required:"true"`
	Postgres Postgres `envconfig:"postgres" required:"true"`
	Redis    Redis    `envconfig:"redis"    required:"true"`
	Version  string   `envconfig:"version"  required:"true"`
}

func Init

func Init() (Config, error)

Init - initializes config from .env file.

type Log

type Log struct {
	Level string `envconfig:"level" required:"true"`
}

type Postgres

type Postgres struct {
	User     string `envconfig:"USER"     required:"true"`
	Password string `envconfig:"PASSWORD" required:"true"`
	Host     string `envconfig:"HOST"     required:"true"`
	Port     string `envconfig:"PORT"     required:"true"`
	Database string `envconfig:"DATABASE" required:"true"`

	WithDebug bool `default:"false" envconfig:"WITH_DEBUG"`
}

func (Postgres) ConnString

func (p Postgres) ConnString() string

type Redis

type Redis struct {
	Host string `envconfig:"host" required:"true"`
	Port string `envconfig:"port" required:"true"`
	Pass string `envconfig:"pass"`
	DB   int    `default:"0"      envconfig:"db"`
}

func (*Redis) BuildAddressString

func (v *Redis) BuildAddressString() string

type Server

type Server struct {
	Host            string        `envconfig:"host"       required:"true"`
	Port            string        `envconfig:"port"       required:"true"`
	BodyLimit       int           `envconfig:"body_limit" required:"true"`
	ReadTimeout     time.Duration `default:"30s"          envconfig:"read_timeout"`
	WriteTimeout    time.Duration `default:"30s"          envconfig:"write_timeout"`
	ShutdownTimeout time.Duration `default:"30s"          envconfig:"shutdown_timeout"`
	Mode            string        `envconfig:"mode"       required:"true"`
}

Jump to

Keyboard shortcuts

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