From 21fb29d0eec71f3dd7c12e260af5925d452b238f Mon Sep 17 00:00:00 2001 From: Alexander Kavon Date: Mon, 27 Nov 2023 17:52:06 -0500 Subject: template files for registration page, updated cwd handling, included cwd and config file path in conf struct --- src/conf/conf.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/conf/conf.go') diff --git a/src/conf/conf.go b/src/conf/conf.go index 8abb8a8..969332a 100644 --- a/src/conf/conf.go +++ b/src/conf/conf.go @@ -9,6 +9,8 @@ import ( type ( Conf struct { + cwd string + path string Db Db `toml:"database"` Server Server `toml:"server"` } @@ -28,20 +30,22 @@ type ( func NewConf() *Conf { - workingdir, err := os.Getwd() + cwd, err := os.Getwd() if err != nil { log.Fatal(err) } filepath := os.Getenv("NEWSSTAND_CONFIG_PATH") if filepath == "" { - filepath = workingdir + "/.newsstandrc.toml" + filepath = cwd + "/.newsstandrc.toml" } log.Printf("Config file path: %s", filepath) c := Conf{ + cwd, + filepath, Db{}, Server{ - TemplatePath: workingdir + "/views", + TemplatePath: cwd + "/ui", }, } _, err = toml.DecodeFile(filepath, &c) @@ -52,3 +56,11 @@ func NewConf() *Conf { return &c } + +func (c *Conf) GetCwd() string { + return c.cwd +} + +func (c *Conf) GetPath() string { + return c.path +} -- cgit v1.2.3