40 lines
758 B
Go
40 lines
758 B
Go
|
package config
|
||
|
|
||
|
type Environment string
|
||
|
|
||
|
const (
|
||
|
Dev Environment = "dev"
|
||
|
Staging = "staging"
|
||
|
Production = "prod"
|
||
|
)
|
||
|
|
||
|
// Config holds all configuration values
|
||
|
type Config struct {
|
||
|
ConfigPath string `toml:"-"`
|
||
|
|
||
|
SavePath string `toml:"savePath"`
|
||
|
|
||
|
BaseUrl string `toml:"base_url"`
|
||
|
Port int `toml:"port"`
|
||
|
}
|
||
|
|
||
|
// New returns a pointer to a default configuration with all empty values
|
||
|
func New() *Config {
|
||
|
return &Config{
|
||
|
ConfigPath: "",
|
||
|
Port: 0,
|
||
|
SavePath: "",
|
||
|
BaseUrl: "",
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Default returns a pointer to a default configuration
|
||
|
func Default() *Config {
|
||
|
return &Config{
|
||
|
ConfigPath: "./config.toml",
|
||
|
BaseUrl: "http://localhost:8080",
|
||
|
Port: 8080,
|
||
|
SavePath: "./storage",
|
||
|
}
|
||
|
}
|