diff --git a/go.mod b/go.mod index 6a0e2e5..db8d094 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/blues/jsonata-go -go 1.16 +go 1.23 diff --git a/v1.5.4/.claude/settings.local.json b/v1.5.4/.claude/settings.local.json new file mode 100644 index 0000000..71100b4 --- /dev/null +++ b/v1.5.4/.claude/settings.local.json @@ -0,0 +1,10 @@ +{ + "permissions": { + "allow": [ + "Bash(ls)", + "Bash(go:*)", + "Bash(grep:*)" + ], + "deny": [] + } +} \ No newline at end of file diff --git a/callable.go b/v1.5.4/callable.go similarity index 98% rename from callable.go rename to v1.5.4/callable.go index ec08501..f681528 100644 --- a/callable.go +++ b/v1.5.4/callable.go @@ -11,9 +11,9 @@ import ( "regexp" "strings" - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jparse" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jparse" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) type callableName struct { @@ -48,7 +48,7 @@ func newGoCallableParam(typ reflect.Type) goCallableParam { t: typ, } - isOpt := reflect.PtrTo(typ).Implements(jtypes.TypeOptional) + isOpt := reflect.PointerTo(typ).Implements(jtypes.TypeOptional) if isOpt { o := reflect.New(typ).Interface().(jtypes.Optional) p := newGoCallableParam(o.Type()) @@ -294,7 +294,7 @@ func (c *goCallable) validateArgTypes(argv []reflect.Value) ([]reflect.Value, er // This is fine for most types but we need to restore // pointer type Callables. if v.Kind() == reflect.Struct && - reflect.PtrTo(v.Type()).Implements(jtypes.TypeCallable) { + reflect.PointerTo(v.Type()).Implements(jtypes.TypeCallable) { if v.CanAddr() { v = v.Addr() } diff --git a/callable_test.go b/v1.5.4/callable_test.go similarity index 99% rename from callable_test.go rename to v1.5.4/callable_test.go index 75062bc..1df5356 100644 --- a/callable_test.go +++ b/v1.5.4/callable_test.go @@ -13,8 +13,8 @@ import ( "strings" "testing" - "github.com/blues/jsonata-go/jparse" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jparse" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) var ( diff --git a/doc.go b/v1.5.4/doc.go similarity index 100% rename from doc.go rename to v1.5.4/doc.go diff --git a/env.go b/v1.5.4/env.go similarity index 98% rename from env.go rename to v1.5.4/env.go index bbbefc5..2259d65 100644 --- a/env.go +++ b/v1.5.4/env.go @@ -11,9 +11,9 @@ import ( "strings" "unicode/utf8" - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jparse" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jparse" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) type environment struct { diff --git a/error.go b/v1.5.4/error.go similarity index 99% rename from error.go rename to v1.5.4/error.go index f5d383c..8bd1bfc 100644 --- a/error.go +++ b/v1.5.4/error.go @@ -9,7 +9,7 @@ import ( "fmt" "regexp" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) // ErrUndefined is returned by the evaluation methods when diff --git a/eval.go b/v1.5.4/eval.go similarity index 99% rename from eval.go rename to v1.5.4/eval.go index a66b561..a51cfea 100644 --- a/eval.go +++ b/v1.5.4/eval.go @@ -10,9 +10,9 @@ import ( "reflect" "sort" - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jparse" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jparse" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) var undefined reflect.Value @@ -1343,7 +1343,7 @@ func (s sequence) Value() reflect.Value { var ( typeSequence = reflect.TypeOf((*sequence)(nil)).Elem() - typeSequencePtr = reflect.PtrTo(typeSequence) + typeSequencePtr = reflect.PointerTo(typeSequence) ) func asSequence(v reflect.Value) (*sequence, bool) { diff --git a/eval_test.go b/v1.5.4/eval_test.go similarity index 99% rename from eval_test.go rename to v1.5.4/eval_test.go index 80c9378..5a4e4a4 100644 --- a/eval_test.go +++ b/v1.5.4/eval_test.go @@ -11,9 +11,9 @@ import ( "strings" "testing" - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jparse" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jparse" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) type evalTestCase struct { diff --git a/example_eval_test.go b/v1.5.4/example_eval_test.go similarity index 94% rename from example_eval_test.go rename to v1.5.4/example_eval_test.go index fd35592..8e8d015 100644 --- a/example_eval_test.go +++ b/v1.5.4/example_eval_test.go @@ -9,7 +9,7 @@ import ( "fmt" "log" - jsonata "github.com/blues/jsonata-go" + jsonata "github.com/blues/jsonata-go/v1.5.4" ) const jsonString = ` diff --git a/example_exts_test.go b/v1.5.4/example_exts_test.go similarity index 65% rename from example_exts_test.go rename to v1.5.4/example_exts_test.go index 2c02e18..1ffdee6 100644 --- a/example_exts_test.go +++ b/v1.5.4/example_exts_test.go @@ -8,8 +8,9 @@ import ( "fmt" "log" "strings" + "unicode" - jsonata "github.com/blues/jsonata-go" + jsonata "github.com/blues/jsonata-go/v1.5.4" ) // @@ -17,14 +18,29 @@ import ( // custom functions. // +// titleCase returns a copy of the string s with all Unicode letters that begin words +// mapped to their Unicode title case. +func titleCase(s string) string { + // Split the string into words + words := strings.Fields(s) + for i, word := range words { + runes := []rune(word) + if len(runes) > 0 { + runes[0] = unicode.ToTitle(runes[0]) + } + words[i] = string(runes) + } + return strings.Join(words, " ") +} + // exts defines a function named "titlecase" which maps to -// the standard library function strings.Title. Any function, +// our custom titleCase function. Any function, // from the standard library or otherwise, can be used to // extend JSONata, as long as it returns either one or two // arguments (the second argument must be an error). var exts = map[string]jsonata.Extension{ "titlecase": { - Func: strings.Title, + Func: titleCase, }, } diff --git a/jlib/aggregate.go b/v1.5.4/jlib/aggregate.go similarity index 98% rename from jlib/aggregate.go rename to v1.5.4/jlib/aggregate.go index 735ff82..4cfe368 100644 --- a/jlib/aggregate.go +++ b/v1.5.4/jlib/aggregate.go @@ -8,7 +8,7 @@ import ( "fmt" "reflect" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) // Sum returns the total of an array of numbers. If the array is diff --git a/jlib/array.go b/v1.5.4/jlib/array.go similarity index 99% rename from jlib/array.go rename to v1.5.4/jlib/array.go index f16f711..f3089a6 100644 --- a/jlib/array.go +++ b/v1.5.4/jlib/array.go @@ -10,7 +10,7 @@ import ( "reflect" "sort" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) // Count (golint) diff --git a/jlib/boolean.go b/v1.5.4/jlib/boolean.go similarity index 94% rename from jlib/boolean.go rename to v1.5.4/jlib/boolean.go index b4325f4..f39528e 100644 --- a/jlib/boolean.go +++ b/v1.5.4/jlib/boolean.go @@ -7,7 +7,7 @@ package jlib import ( "reflect" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) // Boolean (golint) diff --git a/jlib/date.go b/v1.5.4/jlib/date.go similarity index 97% rename from jlib/date.go rename to v1.5.4/jlib/date.go index 70a9a2c..f1a74ce 100644 --- a/jlib/date.go +++ b/v1.5.4/jlib/date.go @@ -10,8 +10,8 @@ import ( "strconv" "time" - "github.com/blues/jsonata-go/jlib/jxpath" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib/jxpath" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) // 2006-01-02T15:04:05.000Z07:00 diff --git a/jlib/date_test.go b/v1.5.4/jlib/date_test.go similarity index 96% rename from jlib/date_test.go rename to v1.5.4/jlib/date_test.go index 7c42c62..dab8bba 100644 --- a/jlib/date_test.go +++ b/v1.5.4/jlib/date_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) func TestFromMillis(t *testing.T) { diff --git a/jlib/error.go b/v1.5.4/jlib/error.go similarity index 100% rename from jlib/error.go rename to v1.5.4/jlib/error.go diff --git a/jlib/hof.go b/v1.5.4/jlib/hof.go similarity index 98% rename from jlib/hof.go rename to v1.5.4/jlib/hof.go index 6452a3b..e604b3b 100644 --- a/jlib/hof.go +++ b/v1.5.4/jlib/hof.go @@ -8,7 +8,7 @@ import ( "fmt" "reflect" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) // Map (golint) diff --git a/jlib/jlib.go b/v1.5.4/jlib/jlib.go similarity index 90% rename from jlib/jlib.go rename to v1.5.4/jlib/jlib.go index 644a044..96eb319 100644 --- a/jlib/jlib.go +++ b/v1.5.4/jlib/jlib.go @@ -7,17 +7,13 @@ package jlib import ( "fmt" - "math/rand" "reflect" - "time" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) -func init() { - // Seed random numbers for Random() and Shuffle(). - rand.Seed(time.Now().UnixNano()) -} +// Random numbers for Random() and Shuffle() functions are automatically seeded +// in Go 1.20+ without needing to call rand.Seed var typeBool = reflect.TypeOf((*bool)(nil)).Elem() var typeCallable = reflect.TypeOf((*jtypes.Callable)(nil)).Elem() diff --git a/jlib/jxpath/formatdate.go b/v1.5.4/jlib/jxpath/formatdate.go similarity index 100% rename from jlib/jxpath/formatdate.go rename to v1.5.4/jlib/jxpath/formatdate.go diff --git a/jlib/jxpath/formatdate_test.go b/v1.5.4/jlib/jxpath/formatdate_test.go similarity index 100% rename from jlib/jxpath/formatdate_test.go rename to v1.5.4/jlib/jxpath/formatdate_test.go diff --git a/jlib/jxpath/formatnumber.go b/v1.5.4/jlib/jxpath/formatnumber.go similarity index 100% rename from jlib/jxpath/formatnumber.go rename to v1.5.4/jlib/jxpath/formatnumber.go diff --git a/jlib/jxpath/formatnumber_test.go b/v1.5.4/jlib/jxpath/formatnumber_test.go similarity index 100% rename from jlib/jxpath/formatnumber_test.go rename to v1.5.4/jlib/jxpath/formatnumber_test.go diff --git a/jlib/jxpath/language.go b/v1.5.4/jlib/jxpath/language.go similarity index 100% rename from jlib/jxpath/language.go rename to v1.5.4/jlib/jxpath/language.go diff --git a/jlib/number.go b/v1.5.4/jlib/number.go similarity index 97% rename from jlib/number.go rename to v1.5.4/jlib/number.go index 8cb0e46..27f5e0c 100644 --- a/jlib/number.go +++ b/v1.5.4/jlib/number.go @@ -13,7 +13,7 @@ import ( "strconv" "strings" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) var reNumber = regexp.MustCompile(`^-?(([0-9]+))(\.[0-9]+)?([Ee][-+]?[0-9]+)?$`) @@ -116,7 +116,7 @@ func Random() float64 { // It does this by converting back and forth to strings to // avoid floating point rounding errors, e.g. // -// 4.525 * math.Pow10(2) returns 452.50000000000006 +// 4.525 * math.Pow10(2) returns 452.50000000000006 func multByPow10(x float64, n int) float64 { if n == 0 || math.IsNaN(x) || math.IsInf(x, 0) { return x diff --git a/jlib/number_test.go b/v1.5.4/jlib/number_test.go similarity index 96% rename from jlib/number_test.go rename to v1.5.4/jlib/number_test.go index 51b422f..bf7a275 100644 --- a/jlib/number_test.go +++ b/v1.5.4/jlib/number_test.go @@ -8,8 +8,8 @@ import ( "fmt" "testing" - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) func TestRound(t *testing.T) { diff --git a/jlib/object.go b/v1.5.4/jlib/object.go similarity index 99% rename from jlib/object.go rename to v1.5.4/jlib/object.go index ca43f8d..79fe20a 100644 --- a/jlib/object.go +++ b/v1.5.4/jlib/object.go @@ -8,7 +8,7 @@ import ( "fmt" "reflect" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) // typeInterfaceMap is the reflect.Type for map[string]interface{}. diff --git a/jlib/object_test.go b/v1.5.4/jlib/object_test.go similarity index 99% rename from jlib/object_test.go rename to v1.5.4/jlib/object_test.go index e2e8dc7..c40f5ce 100644 --- a/jlib/object_test.go +++ b/v1.5.4/jlib/object_test.go @@ -12,8 +12,8 @@ import ( "strings" "testing" - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) type eachTest struct { diff --git a/jlib/string.go b/v1.5.4/jlib/string.go similarity index 98% rename from jlib/string.go rename to v1.5.4/jlib/string.go index cd49c6f..3ffe032 100644 --- a/jlib/string.go +++ b/v1.5.4/jlib/string.go @@ -17,8 +17,8 @@ import ( "strings" "unicode/utf8" - "github.com/blues/jsonata-go/jlib/jxpath" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib/jxpath" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) // String converts a JSONata value to a string. Values that are @@ -231,9 +231,9 @@ func Join(values reflect.Value, separator jtypes.OptionalString) (string, error) // regular expression in the source string. Each object in the // array has the following fields: // -// match - the substring matched by the regex -// index - the starting offset of this match -// groups - any captured groups for this match +// match - the substring matched by the regex +// index - the starting offset of this match +// groups - any captured groups for this match // // The optional third argument specifies the maximum number // of matches to return. By default, Match returns all matches. diff --git a/jlib/string_test.go b/v1.5.4/jlib/string_test.go similarity index 99% rename from jlib/string_test.go rename to v1.5.4/jlib/string_test.go index 21a91c6..8b1186c 100644 --- a/jlib/string_test.go +++ b/v1.5.4/jlib/string_test.go @@ -13,8 +13,8 @@ import ( "testing" "unicode/utf8" - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) var typereplaceCallable = reflect.TypeOf((*replaceCallable)(nil)).Elem() @@ -28,7 +28,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if !reflect.PtrTo(typeMatchCallable).Implements(typeCallable) { + if !reflect.PointerTo(typeMatchCallable).Implements(typeCallable) { fmt.Fprintln(os.Stderr, "*matchCallable is not a Callable. Aborting...") os.Exit(1) } diff --git a/jparse/doc.go b/v1.5.4/jparse/doc.go similarity index 97% rename from jparse/doc.go rename to v1.5.4/jparse/doc.go index 22826d6..c352f34 100644 --- a/jparse/doc.go +++ b/v1.5.4/jparse/doc.go @@ -6,7 +6,7 @@ // syntax trees. Most clients will not need to work with // this package directly. // -// Usage +// # Usage // // Call the Parse function, passing a JSONata expression as // a string. If an error occurs, it will be of type Error. diff --git a/jparse/error.go b/v1.5.4/jparse/error.go similarity index 100% rename from jparse/error.go rename to v1.5.4/jparse/error.go diff --git a/jparse/jparse.go b/v1.5.4/jparse/jparse.go similarity index 100% rename from jparse/jparse.go rename to v1.5.4/jparse/jparse.go diff --git a/jparse/jparse_test.go b/v1.5.4/jparse/jparse_test.go similarity index 99% rename from jparse/jparse_test.go rename to v1.5.4/jparse/jparse_test.go index f0874e5..91fe085 100644 --- a/jparse/jparse_test.go +++ b/v1.5.4/jparse/jparse_test.go @@ -12,7 +12,7 @@ import ( "testing" "unicode/utf8" - "github.com/blues/jsonata-go/jparse" + "github.com/blues/jsonata-go/v1.5.4/jparse" ) type testCase struct { diff --git a/jparse/lexer.go b/v1.5.4/jparse/lexer.go similarity index 100% rename from jparse/lexer.go rename to v1.5.4/jparse/lexer.go diff --git a/jparse/lexer_test.go b/v1.5.4/jparse/lexer_test.go similarity index 100% rename from jparse/lexer_test.go rename to v1.5.4/jparse/lexer_test.go diff --git a/jparse/node.go b/v1.5.4/jparse/node.go similarity index 100% rename from jparse/node.go rename to v1.5.4/jparse/node.go diff --git a/jsonata-server/.gitignore b/v1.5.4/jsonata-server/.gitignore similarity index 100% rename from jsonata-server/.gitignore rename to v1.5.4/jsonata-server/.gitignore diff --git a/jsonata-server/README.md b/v1.5.4/jsonata-server/README.md similarity index 100% rename from jsonata-server/README.md rename to v1.5.4/jsonata-server/README.md diff --git a/jsonata-server/bench.go b/v1.5.4/jsonata-server/bench.go similarity index 98% rename from jsonata-server/bench.go rename to v1.5.4/jsonata-server/bench.go index 925ecfc..0caadab 100644 --- a/jsonata-server/bench.go +++ b/v1.5.4/jsonata-server/bench.go @@ -10,7 +10,7 @@ import ( "encoding/json" - jsonata "github.com/blues/jsonata-go" + jsonata "github.com/blues/jsonata-go/v1.5.4" ) var ( diff --git a/jsonata-server/exts.go b/v1.5.4/jsonata-server/exts.go similarity index 92% rename from jsonata-server/exts.go rename to v1.5.4/jsonata-server/exts.go index 117beb6..97c6eab 100644 --- a/jsonata-server/exts.go +++ b/v1.5.4/jsonata-server/exts.go @@ -5,8 +5,8 @@ package main import ( - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) // Default format for dates: e.g. 2006-01-02 15:04 MST diff --git a/jsonata-server/main.go b/v1.5.4/jsonata-server/main.go similarity index 96% rename from jsonata-server/main.go rename to v1.5.4/jsonata-server/main.go index 73ebea0..def3a99 100644 --- a/jsonata-server/main.go +++ b/v1.5.4/jsonata-server/main.go @@ -14,8 +14,8 @@ import ( _ "net/http/pprof" "strings" - jsonata "github.com/blues/jsonata-go" - "github.com/blues/jsonata-go/jtypes" + jsonata "github.com/blues/jsonata-go/v1.5.4" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) func init() { diff --git a/jsonata-server/site/assets/css/codemirror.min.css b/v1.5.4/jsonata-server/site/assets/css/codemirror.min.css similarity index 100% rename from jsonata-server/site/assets/css/codemirror.min.css rename to v1.5.4/jsonata-server/site/assets/css/codemirror.min.css diff --git a/jsonata-server/site/assets/css/normalize.min.css b/v1.5.4/jsonata-server/site/assets/css/normalize.min.css similarity index 100% rename from jsonata-server/site/assets/css/normalize.min.css rename to v1.5.4/jsonata-server/site/assets/css/normalize.min.css diff --git a/jsonata-server/site/assets/css/styles.css b/v1.5.4/jsonata-server/site/assets/css/styles.css similarity index 100% rename from jsonata-server/site/assets/css/styles.css rename to v1.5.4/jsonata-server/site/assets/css/styles.css diff --git a/jsonata-server/site/assets/js/codemirror.min.js b/v1.5.4/jsonata-server/site/assets/js/codemirror.min.js similarity index 100% rename from jsonata-server/site/assets/js/codemirror.min.js rename to v1.5.4/jsonata-server/site/assets/js/codemirror.min.js diff --git a/jsonata-server/site/assets/js/javascript.min.js b/v1.5.4/jsonata-server/site/assets/js/javascript.min.js similarity index 100% rename from jsonata-server/site/assets/js/javascript.min.js rename to v1.5.4/jsonata-server/site/assets/js/javascript.min.js diff --git a/jsonata-server/site/assets/js/jsonata-codemirror.js b/v1.5.4/jsonata-server/site/assets/js/jsonata-codemirror.js similarity index 100% rename from jsonata-server/site/assets/js/jsonata-codemirror.js rename to v1.5.4/jsonata-server/site/assets/js/jsonata-codemirror.js diff --git a/jsonata-server/site/assets/js/split.min.js b/v1.5.4/jsonata-server/site/assets/js/split.min.js similarity index 100% rename from jsonata-server/site/assets/js/split.min.js rename to v1.5.4/jsonata-server/site/assets/js/split.min.js diff --git a/jsonata-server/site/favicon.ico b/v1.5.4/jsonata-server/site/favicon.ico similarity index 100% rename from jsonata-server/site/favicon.ico rename to v1.5.4/jsonata-server/site/favicon.ico diff --git a/jsonata-server/site/index.html b/v1.5.4/jsonata-server/site/index.html similarity index 100% rename from jsonata-server/site/index.html rename to v1.5.4/jsonata-server/site/index.html diff --git a/jsonata-test/.gitignore b/v1.5.4/jsonata-test/.gitignore similarity index 100% rename from jsonata-test/.gitignore rename to v1.5.4/jsonata-test/.gitignore diff --git a/jsonata-test/README.md b/v1.5.4/jsonata-test/README.md similarity index 100% rename from jsonata-test/README.md rename to v1.5.4/jsonata-test/README.md diff --git a/jsonata-test/main.go b/v1.5.4/jsonata-test/main.go similarity index 96% rename from jsonata-test/main.go rename to v1.5.4/jsonata-test/main.go index 937e07e..2aa9fd1 100644 --- a/jsonata-test/main.go +++ b/v1.5.4/jsonata-test/main.go @@ -5,15 +5,14 @@ import ( "flag" "fmt" "io" - "io/ioutil" "os" "path/filepath" "reflect" "regexp" "strings" - jsonata "github.com/blues/jsonata-go" - types "github.com/blues/jsonata-go/jtypes" + jsonata "github.com/blues/jsonata-go/v1.5.4" + types "github.com/blues/jsonata-go/v1.5.4/jtypes" ) type testCase struct { @@ -179,12 +178,13 @@ func runTest(tc testCase, dataDir string, path string) (bool, error) { // loadTestExprFile loads a jsonata expression from a file and returns the // expression // For example, one test looks like this -// { -// "expr-file": "case000.jsonata", -// "dataset": null, -// "bindings": {}, -// "result": 2 -// } +// +// { +// "expr-file": "case000.jsonata", +// "dataset": null, +// "bindings": {}, +// "result": 2 +// } // // We want to load the expression from case000.jsonata so we can use it // as an expression in the test case @@ -193,7 +193,7 @@ func loadTestExprFile(testPath string, exprFileName string) (string, error) { splitPath[len(splitPath)-1] = exprFileName exprFilePath := strings.Join(splitPath, "/") - content, err := ioutil.ReadFile(exprFilePath) + content, err := os.ReadFile(exprFilePath) if err != nil { return "", err } @@ -323,7 +323,7 @@ func equalResults(x, y interface{}) bool { } func readJSONFile(path string, dest interface{}) error { - b, err := ioutil.ReadFile(path) + b, err := os.ReadFile(path) if err != nil { return fmt.Errorf("ReadFile %s: %s", path, err) } diff --git a/jsonata-test/main_test.go b/v1.5.4/jsonata-test/main_test.go similarity index 100% rename from jsonata-test/main_test.go rename to v1.5.4/jsonata-test/main_test.go diff --git a/jsonata.go b/v1.5.4/jsonata.go similarity index 98% rename from jsonata.go rename to v1.5.4/jsonata.go index 7277b6e..2477a76 100644 --- a/jsonata.go +++ b/v1.5.4/jsonata.go @@ -12,9 +12,9 @@ import ( "time" "unicode" - "github.com/blues/jsonata-go/jlib" - "github.com/blues/jsonata-go/jparse" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jlib" + "github.com/blues/jsonata-go/v1.5.4/jparse" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) var ( diff --git a/jsonata_test.go b/v1.5.4/jsonata_test.go similarity index 99% rename from jsonata_test.go rename to v1.5.4/jsonata_test.go index 3267918..6530b9b 100644 --- a/jsonata_test.go +++ b/v1.5.4/jsonata_test.go @@ -8,7 +8,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "math" "os" "path/filepath" @@ -19,8 +18,8 @@ import ( "time" "unicode/utf8" - "github.com/blues/jsonata-go/jparse" - "github.com/blues/jsonata-go/jtypes" + "github.com/blues/jsonata-go/v1.5.4/jparse" + "github.com/blues/jsonata-go/v1.5.4/jtypes" ) type testCase struct { @@ -8094,9 +8093,9 @@ func must(t *testing.T, prefix string, err error) { func readJSON(filename string) interface{} { - data, err := ioutil.ReadFile(filepath.Join("testdata", filename)) + data, err := os.ReadFile(filepath.Join("testdata", filename)) if err != nil { - panicf("ioutil.ReadFile error: %s", err) + panicf("os.ReadFile error: %s", err) } var dest interface{} diff --git a/jtypes/funcs.go b/v1.5.4/jtypes/funcs.go similarity index 94% rename from jtypes/funcs.go rename to v1.5.4/jtypes/funcs.go index fdbc89b..ebbc168 100644 --- a/jtypes/funcs.go +++ b/v1.5.4/jtypes/funcs.go @@ -44,7 +44,7 @@ func IsNumber(v reflect.Value) bool { func IsCallable(v reflect.Value) bool { v = Resolve(v) return v.IsValid() && - (v.Type().Implements(TypeCallable) || reflect.PtrTo(v.Type()).Implements(TypeCallable)) + (v.Type().Implements(TypeCallable) || reflect.PointerTo(v.Type()).Implements(TypeCallable)) } // IsArray (golint) @@ -128,7 +128,7 @@ func AsCallable(v reflect.Value) (Callable, bool) { return v.Interface().(Callable), true } - if v.IsValid() && reflect.PtrTo(v.Type()).Implements(TypeCallable) && v.CanAddr() && v.Addr().CanInterface() { + if v.IsValid() && reflect.PointerTo(v.Type()).Implements(TypeCallable) && v.CanAddr() && v.Addr().CanInterface() { return v.Addr().Interface().(Callable), true } diff --git a/jtypes/types.go b/v1.5.4/jtypes/types.go similarity index 100% rename from jtypes/types.go rename to v1.5.4/jtypes/types.go diff --git a/testdata/account.json b/v1.5.4/testdata/account.json similarity index 100% rename from testdata/account.json rename to v1.5.4/testdata/account.json diff --git a/testdata/account2.json b/v1.5.4/testdata/account2.json similarity index 100% rename from testdata/account2.json rename to v1.5.4/testdata/account2.json diff --git a/testdata/account3.json b/v1.5.4/testdata/account3.json similarity index 100% rename from testdata/account3.json rename to v1.5.4/testdata/account3.json diff --git a/testdata/account4.json b/v1.5.4/testdata/account4.json similarity index 100% rename from testdata/account4.json rename to v1.5.4/testdata/account4.json diff --git a/testdata/account5.json b/v1.5.4/testdata/account5.json similarity index 100% rename from testdata/account5.json rename to v1.5.4/testdata/account5.json diff --git a/testdata/account6.json b/v1.5.4/testdata/account6.json similarity index 100% rename from testdata/account6.json rename to v1.5.4/testdata/account6.json diff --git a/testdata/account7.json b/v1.5.4/testdata/account7.json similarity index 100% rename from testdata/account7.json rename to v1.5.4/testdata/account7.json diff --git a/testdata/address.json b/v1.5.4/testdata/address.json similarity index 100% rename from testdata/address.json rename to v1.5.4/testdata/address.json diff --git a/testdata/foobar.json b/v1.5.4/testdata/foobar.json similarity index 100% rename from testdata/foobar.json rename to v1.5.4/testdata/foobar.json diff --git a/testdata/foobar2.json b/v1.5.4/testdata/foobar2.json similarity index 100% rename from testdata/foobar2.json rename to v1.5.4/testdata/foobar2.json diff --git a/testdata/library.json b/v1.5.4/testdata/library.json similarity index 100% rename from testdata/library.json rename to v1.5.4/testdata/library.json diff --git a/testdata/nest1.json b/v1.5.4/testdata/nest1.json similarity index 100% rename from testdata/nest1.json rename to v1.5.4/testdata/nest1.json diff --git a/testdata/nest2.json b/v1.5.4/testdata/nest2.json similarity index 100% rename from testdata/nest2.json rename to v1.5.4/testdata/nest2.json diff --git a/testdata/nest3.json b/v1.5.4/testdata/nest3.json similarity index 100% rename from testdata/nest3.json rename to v1.5.4/testdata/nest3.json