Files
photodisk/internal/config/app.go
Artem Mamonov acf9b43671 Initial commit
2025-02-06 02:36:10 +01:00

41 lines
669 B
Go

package config
import (
"gopkg.in/yaml.v3"
"os"
"time"
)
var app App
type App struct {
Data string `yaml:"data"`
Db string `yaml:"db"`
Static string `yaml:"static"`
Watermark string `yaml:"watermark"`
SessionTtl time.Duration `yaml:"session_ttl"`
AlbumTtl time.Duration `yaml:"album_ttl"`
}
func ReadConfig(filename string) error {
// read config from yaml file
file, err := os.Open(filename)
if err != nil {
return err
}
defer file.Close()
// decode yaml
decoder := yaml.NewDecoder(file)
err = decoder.Decode(&app)
if err != nil {
return err
}
return nil
}
func Get() App {
return app
}