Only replace \ with / on Windows

This commit is contained in:
Steve Streeting 2016-07-15 16:52:44 +01:00
parent ee5df4971f
commit 40318ddaa0

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"os"
"runtime"
"strings"
"testing"
@ -24,8 +25,11 @@ func NewSchemaValidator(t *testing.T, schemaName string, got interface{}) *Schem
if err != nil {
t.Fatal(err)
}
// Platform compatibility: use "/" separators always for file://
dir = strings.Replace(dir, "\\", "/", -1)
if runtime.GOOS == "windows" {
// Platform compatibility: use "/" separators always for file://
dir = strings.Replace(dir, "\\", "/", -1)
}
schema := gojsonschema.NewReferenceLoader(fmt.Sprintf(
"file:///%s/schema/%s", dir, schemaName),