Files
efsldap/config/config.go
Shin'ya Minazuki e4d9b92061 * Rename fsldap to efsldap
* Use gopkg.in/ini.v1 over github.com/joho/godotenv
* Fix typos

Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
2026-01-07 19:42:00 -03:00

44 lines
748 B
Go

package config
import (
"errors"
"log"
"os"
"gopkg.in/ini.v1"
)
var Config struct {
LDAPBase string
LDAPUID string
SMTPDomain string
SMTPHost string
SMTPPort string
}
var (
ConfigPath string
)
func ConfInit() {
if _, err := os.Stat(ConfigPath); errors.Is(err, os.ErrNotExist) {
log.Fatal(err)
}
Parse(ConfigPath)
}
func Parse(fn string) error {
cfg, err := ini.Load(fn)
if err != nil {
return err
}
Config.LDAPBase = cfg.Section("").Key("ldap_base").String()
Config.LDAPUID = cfg.Section("").Key("ldap_uid").String()
Config.SMTPDomain = cfg.Section("").Key("smtp_domain").String()
Config.SMTPHost = cfg.Section("").Key("smtp_host").String()
Config.SMTPPort = cfg.Section("").Key("smtp_port").String()
return nil
}