@@ 16,27 16,12 @@ var (
Addr string
)
-// Loads the application configuration, reads options from the command line,
-// and initializes some internals based on these results.
-func LoadConfig(defaultAddr string) ini.File {
- Addr = defaultAddr
+// Just loads the config files
+func LoadFiles() ini.File {
var (
config ini.File
err error
)
- opts, _, err := getopt.Getopts(os.Args, "b:d")
- if err != nil {
- panic(err)
- }
-
- for _, opt := range opts {
- switch opt.Option {
- case 'b':
- Addr = opt.Value
- case 'd':
- Debug = true
- }
- }
// Only loads from one of these locations
for _, path := range []string{
@@ 68,7 53,29 @@ func LoadConfig(defaultAddr string) ini.File {
if err != nil {
log.Fatalf("Failed to load config file: %v", err)
}
+ return config
+}
+
+// Loads the application configuration, reads options from the command line,
+// and initializes some internals based on these results.
+func LoadConfig(defaultAddr string) ini.File {
+ Addr = defaultAddr
+
+ opts, _, err := getopt.Getopts(os.Args, "b:d")
+ if err != nil {
+ panic(err)
+ }
+
+ for _, opt := range opts {
+ switch opt.Option {
+ case 'b':
+ Addr = opt.Value
+ case 'd':
+ Debug = true
+ }
+ }
+ config := LoadFiles()
crypto.InitCrypto(config)
return config
}