From 38364646a73a5e666f2db6a34025e2a5a0e3999a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 23 Mar 2018 23:39:17 +0200 Subject: Refactoring and documentation --- config/config.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'config') diff --git a/config/config.go b/config/config.go index 5c1d87c..4ad6793 100644 --- a/config/config.go +++ b/config/config.go @@ -26,6 +26,7 @@ import ( "maunium.net/go/gomuks/ui/debug" ) +// Config contains the main config of gomuks. type Config struct { UserID string `yaml:"mxid"` HS string `yaml:"homeserver"` @@ -35,6 +36,7 @@ type Config struct { Session *Session `yaml:"-"` } +// NewConfig creates a config that loads data from the given directory. func NewConfig(dir string) *Config { return &Config{ Dir: dir, @@ -42,6 +44,7 @@ func NewConfig(dir string) *Config { } } +// Clear clears the session cache and removes all history. func (config *Config) Clear() { if config.Session != nil { config.Session.Clear() @@ -49,6 +52,7 @@ func (config *Config) Clear() { os.RemoveAll(config.HistoryDir) } +// Load loads the config from config.yaml in the directory given to the config struct. func (config *Config) Load() { os.MkdirAll(config.Dir, 0700) os.MkdirAll(config.HistoryDir, 0700) @@ -70,6 +74,7 @@ func (config *Config) Load() { } } +// Save saves this config to config.yaml in the directory given to the config struct. func (config *Config) Save() { os.MkdirAll(config.Dir, 0700) data, err := yaml.Marshal(&config) -- cgit v1.2.3