first commit

This commit is contained in:
William Bouzourène 2025-11-29 21:42:30 +01:00
commit 5576528bcf
Signed by: bouzoure
GPG key ID: 423440D735B56BE2
10 changed files with 386 additions and 0 deletions

41
helpers/config.go Normal file
View file

@ -0,0 +1,41 @@
package helpers
import (
"os"
"github.com/golobby/dotenv"
)
type Config struct {
DownloadLocation string `env:"DOWNLOAD_LOCATION"`
Website struct {
Username string `env:"WEBSITE_USERNAME"`
Password string `env:"WEBSITE_PASSWORD"`
}
Debug struct {
DisableHeadless bool `env:"DEBUG_DISABLE_HEADLESS"`
}
}
var configParsed bool
var config Config
func GetConfig() (Config, error) {
if configParsed {
return config, nil
}
file, err := os.Open(".env")
if err != nil {
return config, err
}
err = dotenv.NewDecoder(file).Decode(&config)
if err != nil {
return config, err
}
configParsed = true
return config, err
}