ref: fbfefb8a8ff1f16001604332a22086c7c11c7dcf
parent: 52b9d00a556b0a743ac2195c8b2029f5408f3f3b
author: penny <penny@limitedideas.org>
date: Tue Sep 30 18:20:55 EDT 2025
use \~/.hell.conf for the config
--- a/config.go
+++ b/config.go
@@ -9,7 +9,7 @@
"strings"
)
-const configFileName = "config.json"
+const configFileName = ".hell.conf"
type Hellprefs struct {Apidelay float32 `json:"apidelay"`
@@ -75,8 +75,17 @@
func loadConfig() (*account, error) { config := &account{}+ homedir, err := os.UserHomeDir()
+ var configpath string
+ if err == nil {+ configpath = homedir + "/" + configFileName
+ } else {+ //If go can't find us a home dir just use the current dir
+ //Probably not a normal multiuser system
+ configpath = configFileName
+ }
// Check if the config file exists
- if _, err := os.Stat(configFileName); os.IsNotExist(err) {+ if _, err = os.Stat(configpath); os.IsNotExist(err) {// no config, create account
client := ConfigureClient()
config.URL = "https://eldritch.cafe"
@@ -91,7 +100,7 @@
return nil, fmt.Errorf("error marshalling config: %w", err)}
- err = ioutil.WriteFile(configFileName, data, 0644)
+ err = ioutil.WriteFile(configpath, data, 0644)
if err != nil { return nil, fmt.Errorf("error writing config file: %w", err)}
@@ -99,7 +108,7 @@
}
// File exists, load it
- data, err := ioutil.ReadFile(configFileName)
+ data, err := ioutil.ReadFile(configpath)
if err != nil { return nil, fmt.Errorf("error reading config file: %w", err)}
@@ -118,7 +127,7 @@
return nil, fmt.Errorf("error marshalling config: %w", err)}
- err = ioutil.WriteFile(configFileName, data, 0644)
+ err = ioutil.WriteFile(configpath, data, 0644)
if err != nil { return nil, fmt.Errorf("error writing config file: %w", err)}
--
⑨