First commit, nothing here really

This commit is contained in:
2025-07-12 23:18:36 +01:00
commit a56a277463
60 changed files with 11526 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
package config
import (
"gopkg.in/yaml.v2"
"log"
"os"
"sync"
)
type Configuration struct {
AssetsDir string `yaml:"assets"`
}
var (
instance *Configuration
once sync.Once
confPath string
)
func GetInstance() *Configuration {
once.Do(func() {
instance = &Configuration{}
instance.loadConfiguration()
})
return instance
}
func SetConfig(path string) {
confPath = path
}
func (c *Configuration) loadConfiguration() {
file, err := os.ReadFile(confPath)
if err != nil {
log.Fatalf("Unable to open configuration file [%s]: %s", confPath,
err.Error())
}
err = yaml.Unmarshal(file, &instance)
if err != nil {
log.Fatalf("Error parsing JSON: %s", err.Error())
}
}