27 lines
511 B
Go
27 lines
511 B
Go
package config
|
|
|
|
import (
|
|
"github.com/akyaiy/GSfass/core/config"
|
|
)
|
|
|
|
type ServerConfig struct {
|
|
Port int `mapstructure:"port"`
|
|
Addr string `mapstructure:"address"`
|
|
}
|
|
|
|
type Config struct {
|
|
Server ServerConfig `mapstructure:"server"`
|
|
}
|
|
|
|
func LoadConfig(path string) (*Config, error) {
|
|
var cfg Config
|
|
err := config.Read().Config().FilePath(path).SetBy(&cfg).SetDefaults(map[string]any{
|
|
"server.port": 8080,
|
|
"server.address": "127.0.0.0",
|
|
}).End()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &cfg, nil
|
|
}
|