Skip to content

Commit dda37c4

Browse files
Merge pull request #1 from fernandezvara/patch-yaml-config-windows
allow to load YAML configuration files on Windows
2 parents 33bb4c1 + b5d06bd commit dda37c4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎altsrc/yaml_file_loader.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ func loadDataFrom(filePath string) ([]byte, error) {
7878
return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath)
7979
}
8080
return ioutil.ReadFile(filePath)
81+
} else if runtime.GOOS == "windows" && strings.Contains(u.String(), "\\") {
82+
if _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil {
83+
return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath)
84+
}
85+
return ioutil.ReadFile(filePath)
8186
} else {
8287
return nil, fmt.Errorf("unable to determine how to load from path %s", filePath)
8388
}

0 commit comments

Comments
 (0)