config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvProduction = "production"
	EnvLocal      = "local"
)

Variables

View Source
var (
	// Env global environment accessible from anywhere
	Env string
)

Functions

func Local

func Local() bool

func Production

func Production() bool

Types

type API

type API struct {
	PORT            int    `env:"API_PORT" envDefault:"9000"`
	SecretKey       string `env:"API_SECRET_KEY" envDefault:"PBU_gha4zfk!rwj8axv"`
	TokenExpiryHour int    `env:"API_TOKEN_EXPIRY_HOUR" envDefault:"24"`
}

type Config

type Config struct {
	Env      string `env:"ENV" envDefault:"local"`
	Database Database
	Log      LogConfig
	API      API
}

func Parse

func Parse() (*Config, error)

type ConnectionType

type ConnectionType string
const (
	MySQL    ConnectionType = "mysql"
	Postgres ConnectionType = "postgresql"
	SQLite   ConnectionType = "sqlite"
)

type Database

type Database struct {
	DSN         string         `env:"DATABASE_DSN" envDefault:"fitWave.db"`
	Type        ConnectionType `env:"DATABASE_TYPE" envDefault:"sqlite"`
	AutoMigrate bool           `env:"DATABASE_AUTO_MIGRATE" envDefault:"true"`
}

type LogConfig

type LogConfig struct {
	Level  string `env:"LOG_LEVEL" envDefault:"debug"`
	Output string `env:"LOG_OUTPUT" envDefault:"stdout"`
}

Jump to

Keyboard shortcuts

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