aboutsummaryrefslogtreecommitdiff
path: root/config/config.go
diff options
context:
space:
mode:
authorJulien Dessaux2020-12-23 12:01:05 +0100
committerJulien Dessaux2020-12-23 12:01:05 +0100
commit484734ab36b06a9e6d35348e357312d99522302c (patch)
treecb8e57bd56316b1a111ab7a3f13444344deeca2f /config/config.go
parentInitial import (diff)
downloadshell-game-launcher-484734ab36b06a9e6d35348e357312d99522302c.tar.gz
shell-game-launcher-484734ab36b06a9e6d35348e357312d99522302c.tar.bz2
shell-game-launcher-484734ab36b06a9e6d35348e357312d99522302c.zip
Implemented the configuration file format
Diffstat (limited to 'config/config.go')
-rw-r--r--config/config.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go
new file mode 100644
index 0000000..2c94dbe
--- /dev/null
+++ b/config/config.go
@@ -0,0 +1,31 @@
+package config
+
+import (
+ "os"
+
+ "gopkg.in/yaml.v2"
+)
+
+type Config struct {
+ // AppConfig is the application level configuration entries
+ App App `yaml:"App"`
+ // Menus is the list of menus. The first one is the default menu for an anonymous user, the second one is the default menu for an authenticated user
+ Menus []Menu `yaml:"Menus"`
+ // Games is the list of games.
+ Games map[string]Game `yaml:"Games"`
+}
+
+// LoadFile loads the config from a given file
+func LoadFile(path string) (config Config, err error) {
+ var f *os.File
+ f, err = os.Open(path)
+ if err != nil {
+ return
+ }
+ defer f.Close()
+ decoder := yaml.NewDecoder(f)
+ if err = decoder.Decode(&config); err != nil {
+ return
+ }
+ return
+}