mirror of
https://github.com/nxshock/gallery.git
synced 2024-11-28 00:21:01 +05:00
31 lines
566 B
Go
31 lines
566 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"path/filepath"
|
||
|
|
||
|
"github.com/ilyakaznacheev/cleanenv"
|
||
|
)
|
||
|
|
||
|
type Config struct {
|
||
|
WorkingDirectory string `env-default:"."`
|
||
|
Crf uint64 `env-default:"40"`
|
||
|
ProcessCount uint64 `env-default:"4"`
|
||
|
}
|
||
|
|
||
|
func loadConfig(path string) (*Config, error) {
|
||
|
var config Config
|
||
|
|
||
|
err := cleanenv.ReadConfig("gallery.toml", &config)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
workingDirectory, err := filepath.Abs(config.WorkingDirectory)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
config.WorkingDirectory = workingDirectory
|
||
|
|
||
|
return &config, nil
|
||
|
}
|