Skip to content
Snippets Groups Projects
Commit de330d65 authored by ale's avatar ale
Browse files

ensure that the config directory exists

parent 170fce01
No related branches found
No related tags found
No related merge requests found
......@@ -13,11 +13,15 @@ type FileConfig struct {
}
func NewFileConfig(rootDir string) *FileConfig {
os.Mkdir(rootDir, 0700)
return &FileConfig{rootDir: rootDir}
}
func (fc *FileConfig) Set(key string, value string) error {
// Ignore errors if the directory already exists.
os.Mkdir(fc.rootDir, 0700)
// Dump the value to file.
data := fmt.Sprintf("%s\n", value)
return ioutil.WriteFile(
filepath.Join(fc.rootDir, key),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment