config

package
v0.0.0-...-431252f Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: BSL-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

Variables

View Source
var Available = func() string {
	ret := make([]string, len(FormatMap))
	i := 0
	for k := range FormatMap {
		ret[i] = k
		i++
	}
	return strings.Join(ret, " ")
}()

Available is string implementation of all formats. Can be used with flag package Example:

'json toml yaml'
View Source
var FormatMap = map[string]Format{
	"json": JSON,
	"toml": TOML,
	"yaml": YAML,
}

FormatMap is a map implementation of all formats Can be used with flag package

Functions

func FlagString

func FlagString(format *Format) func(string) error

Types

type Config

type Config struct {
	MySQL MySQL
	Redis Redis
	Host  Host
	SMTP  Email
}

func ReadConfig

func ReadConfig(filename string, format Format) (Config, error)

ReadConfig reads and parses config using available formats (JSON, TOML, YAML) Example:

config.ReadConfig("config.json",config.JSON)

type Email

type Email struct {
	Mail     string
	Password string
	Hostname string
	Port     int
}

type Format

type Format int

type Host

type Host struct {
	Port string
	HTTP bool   // Start server in http mode
	Key  string // Path to TLS key
	Cert string // Path to TLS key
}

type MySQL

type MySQL struct {
	Login    string
	Pass     string
	DbName   string // 'mysql'
	IP       string
	Port     string
	Protocol string
}

type Redis

type Redis struct {
	Addr string
	Pass string // Optional
	DB   int
}

Jump to

Keyboard shortcuts

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