41 lines
600 B
Go
41 lines
600 B
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
)
|
|
|
|
/*
|
|
For server start (author's note to self):
|
|
|
|
sudo systemctl stop server.service
|
|
go build main.go
|
|
sudo systemctl start server.service
|
|
|
|
*/
|
|
|
|
type Config struct {
|
|
AssetsPath string
|
|
TemplatesPath string
|
|
TemplatesExt string
|
|
LocalIP string
|
|
ServerIP string
|
|
Port string
|
|
}
|
|
|
|
func Init() *Config {
|
|
return &Config{}
|
|
}
|
|
|
|
func (c *Config) Load(configPath string) error {
|
|
configFile, err := os.ReadFile(configPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = json.Unmarshal(configFile, c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|