Skip to content

Commit d9b3d51

Browse files
committed
Fix default path loading under windows
1 parent f4d111b commit d9b3d51

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

beehive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func main() {
110110
if err != nil {
111111
log.Fatalf("Error loading configuration file from %s. err: %v", config.URL(), err)
112112
}
113-
log.Infof("Loading configuration from %s", config.URL())
113+
log.Infof("Loading configuration from %s", config.URL().Raw)
114114
} else { // try to load default config from user paths
115115
path := cfg.Lookup()
116116
if path == "" {

cfg/config.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"path/filepath"
77
"regexp"
88
"runtime"
9+
"strings"
910

1011
"github.com/muesli/beehive/bees"
1112
gap "github.com/muesli/go-app-paths"
@@ -157,7 +158,7 @@ func DefaultPath() string {
157158
return cfgFileName
158159
}
159160

160-
return path
161+
return fixWindowsPath(path)
161162
}
162163

163164
// Lookup tries to find the config file.
@@ -201,3 +202,13 @@ func exist(file string) bool {
201202
_, err := os.Stat(file)
202203
return err == nil
203204
}
205+
206+
// Replace backward slashes in Windows paths with /, to make them suitable
207+
// for Go URL parsing.
208+
func fixWindowsPath(path string) string {
209+
if runtime.GOOS == "windows" {
210+
return strings.Replace(path, `\`, "/", -1)
211+
}
212+
213+
return path
214+
}

cfg/helpers_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,8 @@ import (
44
"io/ioutil"
55
"os"
66
"path/filepath"
7-
"runtime"
8-
"strings"
97
)
108

11-
// Replace backward slashes in Windows paths with /, to make them suitable
12-
// for Go URL parsing.
13-
func fixWindowsPath(path string) string {
14-
if runtime.GOOS == "windows" {
15-
return strings.Replace(path, `\`, "/", -1)
16-
}
17-
18-
return path
19-
}
20-
219
func encryptedConfPath() string {
2210
cwd, _ := os.Getwd()
2311
return fixWindowsPath(filepath.Join(cwd, "testdata", "beehive-crypto.conf"))

0 commit comments

Comments
 (0)