config

package
v0.0.0-...-55ee965 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config provides types and functions for parsing config file, environment variables and command-line flags.

Index

Constants

View Source
const (
	DBTypeSQLite   string = "sqlite"
	DBTypePostgres string = "postgres"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HTTP     HTTP     `mapstructure:"http"`
	Logger   Log      `mapstructure:"log"`
	Database Database `mapstructure:"database"`
	Version  string
	Build    string
}

Config represents the config file.

func New

func New(version, build string) (*Config, error)

New make and return a new config. Parse config file, environment variables and flags to config struct.

type Database

type Database struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	Name     string `mapstructure:"name"`
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
	Timeout  int    `mapstructure:"timeout"`
	MaxConns int32  `mapstructure:"max_conns"`
	DBType   string `mapstructure:"db_type"`
}

Database represents database section in config file.

type HTTP

type HTTP struct {
	Address         string        `mapstructure:"address"`
	Timeout         HTTPTimeout   `mapstructure:"timeout"`
	ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout"`
}

HTTP represents HTTP section in config file.

type HTTPTimeout

type HTTPTimeout struct {
	Read  int `mapstructure:"read"`
	Write int `mapstructure:"write"`
}

HTTPTimeout represents HTTP timeout section in config file.

type Log

type Log struct {
	Level  string `mapstructure:"level"`
	Format string `mapstructure:"format"`
}

Log represents log section in config file.

Jump to

Keyboard shortcuts

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