Merge pull request #1 from fernandezvara/patch-yaml-config-windows

allow to load YAML configuration files on Windows
This commit is contained in:
Antonio Fdez 2016-11-17 17:01:27 +01:00 committed by GitHub
commit dda37c45da

View File

@ -78,6 +78,11 @@ func loadDataFrom(filePath string) ([]byte, error) {
return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath) return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath)
} }
return ioutil.ReadFile(filePath) return ioutil.ReadFile(filePath)
} else if runtime.GOOS == "windows" && strings.Contains(u.String(), "\\") {
if _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil {
return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath)
}
return ioutil.ReadFile(filePath)
} else { } else {
return nil, fmt.Errorf("unable to determine how to load from path %s", filePath) return nil, fmt.Errorf("unable to determine how to load from path %s", filePath)
} }