aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 20:52:04 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 20:52:04 +0800
commitb4b0d966340ad9c892f8b8912eebc6118eed7482 (patch)
tree0512a6dd5cfc21fbd91a07d31f972aa2a1cf844d /config.go
parentgit2c: git2c.go -> client.go, a more sensible name (diff)
downloadforge-b4b0d966340ad9c892f8b8912eebc6118eed7482.tar.gz
forge-b4b0d966340ad9c892f8b8912eebc6118eed7482.tar.zst
forge-b4b0d966340ad9c892f8b8912eebc6118eed7482.zip
Use cmd/forge for the entry point
Diffstat (limited to 'config.go')
-rw-r--r--config.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/config.go b/config.go
index ec8daf8..84633ea 100644
--- a/config.go
+++ b/config.go
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
-package main
+package forge
import (
"bufio"
@@ -67,7 +67,7 @@ type Config struct {
} `scfg:"db"`
}
-// loadConfig loads a configuration file from the specified path and unmarshals
+// LoadConfig loads a configuration file from the specified path and unmarshals
// it to the global [config] struct. This may race with concurrent reads from
// [config]; additional synchronization is necessary if the configuration is to
// be made reloadable.
@@ -76,7 +76,7 @@ type Config struct {
// configuration patterns, but silently ignores fields in the [config] struct
// that is not present in the user's configuration file. We would prefer the
// exact opposite behavior.
-func (s *server) loadConfig(path string) (err error) {
+func (s *Server) LoadConfig(path string) (err error) {
var configFile *os.File
if configFile, err = os.Open(path); err != nil {
return err
@@ -84,19 +84,19 @@ func (s *server) loadConfig(path string) (err error) {
defer configFile.Close()
decoder := scfg.NewDecoder(bufio.NewReader(configFile))
- if err = decoder.Decode(&s.config); err != nil {
+ if err = decoder.Decode(&s.Config); err != nil {
return err
}
- if s.config.DB.Type != "postgres" {
+ if s.Config.DB.Type != "postgres" {
return errors.New("unsupported database type")
}
- if s.database, err = pgxpool.New(context.Background(), s.config.DB.Conn); err != nil {
+ if s.Database, err = pgxpool.New(context.Background(), s.Config.DB.Conn); err != nil {
return err
}
- s.globalData["forge_title"] = s.config.General.Title
+ s.GlobalData["forge_title"] = s.Config.General.Title
return nil
}