Skip to content

Commit 84b2737

Browse files
authored
Merge pull request #1 from stepzen-dev/go120
chore: update code to go 1.20
2 parents 31e6058 + 430bab7 commit 84b2737

File tree

10 files changed

+44
-44
lines changed

10 files changed

+44
-44
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ jobs:
44
test:
55
strategy:
66
matrix:
7-
go-version: [1.16.x]
7+
go-version: [1.20.3]
88
os: [ubuntu-latest]
99
runs-on: ${{ matrix.os }}
1010
steps:
11-
- name: Install Go
12-
uses: actions/setup-go@v2
13-
with:
14-
go-version: ${{ matrix.go-version }}
15-
- name: Checkout code
16-
uses: actions/checkout@v2
17-
- name: Install dependencies
18-
run: |
19-
go get -u honnef.co/go/tools/cmd/staticcheck@latest
20-
go get -u golang.org/x/tools/cmd/goimports
21-
- name: Run staticcheck
22-
run: staticcheck ./...
23-
- name: Check code formatting
24-
run: test -z $(goimports -l .)
25-
- name: Run Test
26-
run: go test ./...
11+
- name: Install Go
12+
uses: actions/setup-go@v3
13+
with:
14+
go-version: ${{ matrix.go-version }}
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
- name: Install dependencies
18+
run: |
19+
go install honnef.co/go/tools/cmd/staticcheck@latest
20+
go install golang.org/x/tools/cmd/goimports@latest
21+
- name: Run staticcheck
22+
run: which staticcheck ; staticcheck ./...
23+
- name: Check code formatting
24+
run: test -z $(goimports -l .)
25+
- name: Run Test
26+
run: go test ./...

example_exts_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ package jsonata_test
77
import (
88
"fmt"
99
"log"
10-
"strings"
1110

1211
jsonata "github.com/blues/jsonata-go"
12+
"golang.org/x/text/cases"
13+
"golang.org/x/text/language"
1314
)
1415

1516
//
@@ -24,7 +25,10 @@ import (
2425
// arguments (the second argument must be an error).
2526
var exts = map[string]jsonata.Extension{
2627
"titlecase": {
27-
Func: strings.Title,
28+
Func: func(v string) any {
29+
caser := cases.Title(language.English)
30+
return caser.String(v)
31+
},
2832
},
2933
}
3034

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module github.com/blues/jsonata-go
22

3-
go 1.16
3+
go 1.20
4+
5+
require golang.org/x/text v0.9.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
2+
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=

jlib/jlib.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@ package jlib
77

88
import (
99
"fmt"
10-
"math/rand"
1110
"reflect"
12-
"time"
1311

1412
"github.com/blues/jsonata-go/jtypes"
1513
)
1614

17-
func init() {
18-
// Seed random numbers for Random() and Shuffle().
19-
rand.Seed(time.Now().UnixNano())
20-
}
21-
2215
var typeBool = reflect.TypeOf((*bool)(nil)).Elem()
2316
var typeCallable = reflect.TypeOf((*jtypes.Callable)(nil)).Elem()
2417
var typeString = reflect.TypeOf((*string)(nil)).Elem()

jlib/number.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func Random() float64 {
116116
// It does this by converting back and forth to strings to
117117
// avoid floating point rounding errors, e.g.
118118
//
119-
// 4.525 * math.Pow10(2) returns 452.50000000000006
119+
// 4.525 * math.Pow10(2) returns 452.50000000000006
120120
func multByPow10(x float64, n int) float64 {
121121
if n == 0 || math.IsNaN(x) || math.IsInf(x, 0) {
122122
return x

jlib/string.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ func Join(values reflect.Value, separator jtypes.OptionalString) (string, error)
231231
// regular expression in the source string. Each object in the
232232
// array has the following fields:
233233
//
234-
// match - the substring matched by the regex
235-
// index - the starting offset of this match
236-
// groups - any captured groups for this match
234+
// match - the substring matched by the regex
235+
// index - the starting offset of this match
236+
// groups - any captured groups for this match
237237
//
238238
// The optional third argument specifies the maximum number
239239
// of matches to return. By default, Match returns all matches.

jparse/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// syntax trees. Most clients will not need to work with
77
// this package directly.
88
//
9-
// Usage
9+
// # Usage
1010
//
1111
// Call the Parse function, passing a JSONata expression as
1212
// a string. If an error occurs, it will be of type Error.

jsonata-test/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"flag"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"os"
109
"path/filepath"
1110
"reflect"
@@ -179,12 +178,13 @@ func runTest(tc testCase, dataDir string, path string) (bool, error) {
179178
// loadTestExprFile loads a jsonata expression from a file and returns the
180179
// expression
181180
// For example, one test looks like this
182-
// {
183-
// "expr-file": "case000.jsonata",
184-
// "dataset": null,
185-
// "bindings": {},
186-
// "result": 2
187-
// }
181+
//
182+
// {
183+
// "expr-file": "case000.jsonata",
184+
// "dataset": null,
185+
// "bindings": {},
186+
// "result": 2
187+
// }
188188
//
189189
// We want to load the expression from case000.jsonata so we can use it
190190
// as an expression in the test case
@@ -193,7 +193,7 @@ func loadTestExprFile(testPath string, exprFileName string) (string, error) {
193193
splitPath[len(splitPath)-1] = exprFileName
194194
exprFilePath := strings.Join(splitPath, "/")
195195

196-
content, err := ioutil.ReadFile(exprFilePath)
196+
content, err := os.ReadFile(exprFilePath)
197197
if err != nil {
198198
return "", err
199199
}
@@ -323,7 +323,7 @@ func equalResults(x, y interface{}) bool {
323323
}
324324

325325
func readJSONFile(path string, dest interface{}) error {
326-
b, err := ioutil.ReadFile(path)
326+
b, err := os.ReadFile(path)
327327
if err != nil {
328328
return fmt.Errorf("ReadFile %s: %s", path, err)
329329
}

jsonata_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11-
"io/ioutil"
1211
"math"
1312
"os"
1413
"path/filepath"
@@ -8094,9 +8093,9 @@ func must(t *testing.T, prefix string, err error) {
80948093

80958094
func readJSON(filename string) interface{} {
80968095

8097-
data, err := ioutil.ReadFile(filepath.Join("testdata", filename))
8096+
data, err := os.ReadFile(filepath.Join("testdata", filename))
80988097
if err != nil {
8099-
panicf("ioutil.ReadFile error: %s", err)
8098+
panicf("os.ReadFile error: %s", err)
81008099
}
81018100

81028101
var dest interface{}

0 commit comments

Comments
 (0)