config

package
v0.0.0-...-078eab7 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package config contains app config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromEnv

func LoadFromEnv(ctx context.Context, cfg *Config)

LoadFromEnv load config from env.

func ParseFlags

func ParseFlags(cfg *Config)

ParseFlags parse flags.

func ToPrettyString

func ToPrettyString(cfg any) string

ToPrettyString convert any config to pretty string.

Types

type Config

type Config struct {
	ServerAddress   string `env:"SERVER_ADDRESS,default=localhost:8080" flag:"server-address a" desc:"(env SERVER_ADDRESS) server address"`
	BaseURL         string `env:"BASE_URL,default=http://localhost:8080" flag:"base-url b" desc:"(env BASE_URL) base url"`
	StorageFilePath string `env:"FILE_STORAGE_PATH" flag:"storage-file-path f" desc:"(env FILE_STORAGE_PATH) storage file path"`
	UserCookieName  string `env:"USER_COOKIE_NAME,default=kkk" flag:"user-cookie-name" desc:"(env USER_COOKIE_NAME) user cookie name"`
	SecretKey       string `env:"SECRET_KEY" flag:"secret-key" desc:"(env SECRET_KEY) server secret key"`
	DatabaseDsn     string `env:"DATABASE_DSN" flag:"database-dsn d" desc:"(env DATABASE_DSN) database dsn"`
	// contains filtered or unexported fields
}

Config is main app config struct.

func (*Config) GetSecretKey

func (cfg *Config) GetSecretKey() (ret []byte, err error)

GetSecretKey get secret key.

func (*Config) GetStorage

func (cfg *Config) GetStorage() storage.Storage

GetStorage get storage.

func (*Config) SetStorage

func (cfg *Config) SetStorage(stg storage.Storage)

SetStorage set storage.

Jump to

Keyboard shortcuts

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