config

package
v0.0.0-...-b8b0e3c Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: MIT Imports: 7 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 {
	Database DBConfig
	Server   ServerConfig
	Log      LogConfig
}

Config is the application config

func Read

func Read(path string) (*Config, error)

Read the config file

func (*Config) Validate

func (c *Config) Validate() error

Validate the config

type DBConfig

type DBConfig struct {
	// The SQL dialect we support
	// One of mysql, postgres, mssql, sqlite3
	Type string `default:"sqlite3"`

	// The database connection options
	Host     string `default:"localhost"`
	Port     uint
	Name     string `default:"ghz"`
	User     string
	Password string
	SSLMode  string `default:"disable"`

	// Optionally full connection string in which case the above are ignored
	Connection string

	// Path to db for sqlite
	Path string `default:"ghz.db"`
}

DBConfig database configs

func (*DBConfig) GetConnectionString

func (db *DBConfig) GetConnectionString() string

GetConnectionString returns the database connection string

func (*DBConfig) GetDialect

func (db *DBConfig) GetDialect() string

GetDialect gets compatible GORM dialect

func (*DBConfig) Validate

func (db *DBConfig) Validate() error

Validate the database config

type Info

type Info struct {
	Version   string
	GOVersion string
	StartTime time.Time
}

Info represents some app level info

type LogConfig

type LogConfig struct {
	Level string `default:"info"`
	Path  string
}

LogConfig log settings

func (*LogConfig) Validate

func (lc *LogConfig) Validate() error

Validate validates the config settings

type ServerConfig

type ServerConfig struct {
	RootURL string
	Address string `default:"localhost"`
	Port    uint   `default:"3000"`
}

ServerConfig is server config

func (*ServerConfig) GetHostPort

func (s *ServerConfig) GetHostPort() string

GetHostPort returns host:port

Jump to

Keyboard shortcuts

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