Browse Source

Merge pull request #1977 from slingamn/deps

upgrade dependencies for v2.11 release cycle
tags/v2.11.0-rc1
Shivaram Lingamneni 1 year ago
parent
commit
26e0dae11d
No account linked to committer's email address

+ 5
- 5
go.mod View File

@@ -17,10 +17,10 @@ require (
17 17
 	github.com/onsi/ginkgo v1.12.0 // indirect
18 18
 	github.com/onsi/gomega v1.9.0 // indirect
19 19
 	github.com/stretchr/testify v1.4.0 // indirect
20
-	github.com/tidwall/buntdb v1.2.7
20
+	github.com/tidwall/buntdb v1.2.9
21 21
 	github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208
22 22
 	github.com/xdg-go/scram v1.0.2
23
-	golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8
23
+	golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
24 24
 	golang.org/x/text v0.3.7
25 25
 	gopkg.in/yaml.v2 v2.4.0
26 26
 )
@@ -28,9 +28,9 @@ require (
28 28
 require github.com/gofrs/flock v0.8.1
29 29
 
30 30
 require (
31
-	github.com/tidwall/btree v0.6.1 // indirect
32
-	github.com/tidwall/gjson v1.10.2 // indirect
33
-	github.com/tidwall/grect v0.1.3 // indirect
31
+	github.com/tidwall/btree v1.1.0 // indirect
32
+	github.com/tidwall/gjson v1.12.1 // indirect
33
+	github.com/tidwall/grect v0.1.4 // indirect
34 34
 	github.com/tidwall/match v1.1.1 // indirect
35 35
 	github.com/tidwall/pretty v1.2.0 // indirect
36 36
 	github.com/tidwall/rtred v0.1.2 // indirect

+ 11
- 0
go.sum View File

@@ -47,12 +47,20 @@ github.com/tidwall/assert v0.1.0 h1:aWcKyRBUAdLoVebxo95N7+YZVTFF/ASTr7BN4sLP6XI=
47 47
 github.com/tidwall/assert v0.1.0/go.mod h1:QLYtGyeqse53vuELQheYl9dngGCJQ+mTtlxcktb+Kj8=
48 48
 github.com/tidwall/btree v0.6.1 h1:75VVgBeviiDO+3g4U+7+BaNBNhNINxB0ULPT3fs9pMY=
49 49
 github.com/tidwall/btree v0.6.1/go.mod h1:TzIRzen6yHbibdSfK6t8QimqbUnoxUSrZfeW7Uob0q4=
50
+github.com/tidwall/btree v1.1.0 h1:5P+9WU8ui5uhmcg3SoPyTwoI0mVyZ1nps7YQzTZFkYM=
51
+github.com/tidwall/btree v1.1.0/go.mod h1:TzIRzen6yHbibdSfK6t8QimqbUnoxUSrZfeW7Uob0q4=
50 52
 github.com/tidwall/buntdb v1.2.7 h1:SIyObKAymzLyGhDeIhVk2Yc1/EwfCC75Uyu77CHlVoA=
51 53
 github.com/tidwall/buntdb v1.2.7/go.mod h1:b6KvZM27x/8JLI5hgRhRu60pa3q0Tz9c50TyD46OHUM=
54
+github.com/tidwall/buntdb v1.2.9 h1:XVz684P7X6HCTrdr385yDZWB1zt/n20ZNG3M1iGyFm4=
55
+github.com/tidwall/buntdb v1.2.9/go.mod h1:IwyGSvvDg6hnKSIhtdZ0AqhCZGH8ukdtCAzaP8fI1X4=
52 56
 github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo=
53 57
 github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
58
+github.com/tidwall/gjson v1.12.1 h1:ikuZsLdhr8Ws0IdROXUS1Gi4v9Z4pGqpX/CvJkxvfpo=
59
+github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
54 60
 github.com/tidwall/grect v0.1.3 h1:z9YwQAMUxVSBde3b7Sl8Da37rffgNfZ6Fq6h9t6KdXE=
55 61
 github.com/tidwall/grect v0.1.3/go.mod h1:8GMjwh3gPZVpLBI/jDz9uslCe0dpxRpWDdtN0lWAS/E=
62
+github.com/tidwall/grect v0.1.4 h1:dA3oIgNgWdSspFzn1kS4S/RDpZFLrIxAZOdJKjYapOg=
63
+github.com/tidwall/grect v0.1.4/go.mod h1:9FBsaYRaR0Tcy4UwefBX/UDcDcDy9V5jUcxHzv2jd5Q=
56 64
 github.com/tidwall/lotsa v1.0.2 h1:dNVBH5MErdaQ/xd9s769R31/n2dXavsQ0Yf4TMEHHw8=
57 65
 github.com/tidwall/lotsa v1.0.2/go.mod h1:X6NiU+4yHA3fE3Puvpnn1XMDrFZrE9JO2/w+UMuqgR8=
58 66
 github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
@@ -71,9 +79,12 @@ github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyh
71 79
 github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
72 80
 golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8 h1:5QRxNnVsaJP6NAse0UdkRgL3zHMvCRRkrDVLNdNpdy4=
73 81
 golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
82
+golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM=
83
+golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
74 84
 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
75 85
 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
76 86
 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
87
+golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
77 88
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
78 89
 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
79 90
 golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

+ 3
- 1
vendor/github.com/tidwall/btree/PATH_HINT.md View File

@@ -26,7 +26,7 @@ Take the first example image. The item 9 is at path “1/0”. The item 16 is at
26 26
 
27 27
 A Path Hint is a predefined path that is provided to B-tree operations. It’s just a hint that says, “Hey B-tree, instead of starting your binary search with the middle index, start with what I provide you. My path may be wrong, and if so please provide me with the correct path so I get it right the next time.”
28 28
 
29
-I’ve found using path hints can lead to a little performance increase of 150% - 300%. This is because in real-world cases the items that I’m working with are usually nearby each other in the tree. 
29
+I’ve found using path hints can lead to a little performance increase of 150% - 300%. This is because in real-world cases the items that I’m working with are usually nearby each other in the tree.
30 30
 
31 31
 Take for example inserting a group of timeseries points. They may often be received as chucks of near-contiguous items.  
32 32
 Or, I'm sequentially inserting an ordered group of rows somewhere in the middle of a table.  
@@ -37,6 +37,8 @@ While I may see a 3x boost in when the path hint is right on, I'll only see arou
37 37
 
38 38
 ## Using a Path Hint
39 39
 
40
+All of the functions that take in a path hint argument mutate the path hint argument.
41
+
40 42
 For single-threaded programs, it’s possible to use one shared path hint per B-tree for the life of the program.  
41 43
 For multi-threaded programs, I find it best to use one path hint per B-tree , per thread.  
42 44
 For server-client programs, one path hint per B-tree, per client should suffice.  

+ 30
- 20
vendor/github.com/tidwall/btree/README.md View File

@@ -4,6 +4,8 @@
4 4
 
5 5
 An [efficient](#performance) [B-tree](https://en.wikipedia.org/wiki/B-tree) implementation in Go. 
6 6
 
7
+*Check out the [generics branch](https://github.com/tidwall/btree/tree/generics) if you want to try out btree with generic support for Go 1.18+*
8
+
7 9
 ## Features
8 10
 
9 11
 - `Copy()` method with copy-on-write support.
@@ -116,10 +118,10 @@ func main() {
116 118
 ### Basic
117 119
 
118 120
 ```
119
-Len()                   # return the number of items in the btree
120
-Set(item)               # insert or replace an existing item
121 121
 Get(item)               # get an existing item
122
+Set(item)               # insert or replace an existing item
122 123
 Delete(item)            # delete an item
124
+Len()                   # return the number of items in the btree
123 125
 ```
124 126
 
125 127
 ### Iteration
@@ -127,6 +129,7 @@ Delete(item)            # delete an item
127 129
 ```
128 130
 Ascend(pivot, iter)     # scan items in ascending order starting at pivot.
129 131
 Descend(pivot, iter)    # scan items in descending order starting at pivot.
132
+Iter()                  # returns a read-only iterator for for-loops.
130 133
 ```
131 134
 
132 135
 ### Queues
@@ -151,11 +154,18 @@ GetHint(item, *hint)    # get an existing item
151 154
 DeleteHint(item, *hint) # delete an item
152 155
 ```
153 156
 
157
+### Array-like operations
158
+
159
+```
160
+GetAt(index)     # returns the value at index
161
+DeleteAt(index)  # deletes the item at index
162
+```
163
+
154 164
 ## Performance
155 165
 
156 166
 This implementation was designed with performance in mind. 
157 167
 
158
-The following benchmarks were run on my 2019 Macbook Pro (2.4 GHz 8-Core Intel Core i9) using Go 1.16.5. The items are simple 8-byte ints. 
168
+The following benchmarks were run on my 2019 Macbook Pro (2.4 GHz 8-Core Intel Core i9) using Go 1.17.3. The items are simple 8-byte ints. 
159 169
 
160 170
 - `google`: The [google/btree](https://github.com/google/btree) package
161 171
 - `tidwall`: The [tidwall/btree](https://github.com/tidwall/btree) package
@@ -163,29 +173,29 @@ The following benchmarks were run on my 2019 Macbook Pro (2.4 GHz 8-Core Intel C
163 173
 
164 174
 ```
165 175
 ** sequential set **
166
-google:  set-seq        1,000,000 ops in 163ms, 6,140,597/sec, 162 ns/op, 30.9 MB, 32 bytes/op
167
-tidwall: set-seq        1,000,000 ops in 141ms, 7,075,240/sec, 141 ns/op, 36.6 MB, 38 bytes/op
168
-tidwall: set-seq-hint   1,000,000 ops in 79ms, 12,673,902/sec, 78 ns/op, 36.6 MB, 38 bytes/op
169
-tidwall: load-seq       1,000,000 ops in 40ms, 24,887,293/sec, 40 ns/op, 36.6 MB, 38 bytes/op
170
-go-arr:  append         1,000,000 ops in 51ms, 19,617,269/sec, 50 ns/op
176
+google:  set-seq        1,000,000 ops in 178ms, 5,618,049/sec, 177 ns/op, 39.0 MB, 40 bytes/op
177
+tidwall: set-seq        1,000,000 ops in 156ms, 6,389,837/sec, 156 ns/op, 23.5 MB, 24 bytes/op
178
+tidwall: set-seq-hint   1,000,000 ops in 78ms, 12,895,355/sec, 77 ns/op, 23.5 MB, 24 bytes/op
179
+tidwall: load-seq       1,000,000 ops in 53ms, 18,937,400/sec, 52 ns/op, 23.5 MB, 24 bytes/op
180
+go-arr:  append         1,000,000 ops in 78ms, 12,843,432/sec, 77 ns/op
171 181
 
172 182
 ** random set **
173
-google:  set-rand       1,000,000 ops in 666ms, 1,501,583/sec, 665 ns/op, 21.5 MB, 22 bytes/op
174
-tidwall: set-rand       1,000,000 ops in 569ms, 1,756,845/sec, 569 ns/op, 26.7 MB, 27 bytes/op
175
-tidwall: set-rand-hint  1,000,000 ops in 670ms, 1,491,637/sec, 670 ns/op, 26.4 MB, 27 bytes/op
176
-tidwall: set-again      1,000,000 ops in 488ms, 2,050,667/sec, 487 ns/op, 27.1 MB, 28 bytes/op
177
-tidwall: set-after-copy 1,000,000 ops in 494ms, 2,022,980/sec, 494 ns/op, 27.9 MB, 29 bytes/op
178
-tidwall: load-rand      1,000,000 ops in 594ms, 1,682,937/sec, 594 ns/op, 26.1 MB, 27 bytes/op
183
+google:  set-rand       1,000,000 ops in 555ms, 1,803,133/sec, 554 ns/op, 29.7 MB, 31 bytes/op
184
+tidwall: set-rand       1,000,000 ops in 545ms, 1,835,818/sec, 544 ns/op, 29.6 MB, 31 bytes/op
185
+tidwall: set-rand-hint  1,000,000 ops in 670ms, 1,493,473/sec, 669 ns/op, 29.6 MB, 31 bytes/op
186
+tidwall: set-again      1,000,000 ops in 681ms, 1,469,038/sec, 680 ns/op
187
+tidwall: set-after-copy 1,000,000 ops in 670ms, 1,493,230/sec, 669 ns/op
188
+tidwall: load-rand      1,000,000 ops in 569ms, 1,756,187/sec, 569 ns/op, 29.6 MB, 31 bytes/op
179 189
 
180 190
 ** sequential get **
181
-google:  get-seq        1,000,000 ops in 141ms, 7,078,690/sec, 141 ns/op
182
-tidwall: get-seq        1,000,000 ops in 124ms, 8,075,925/sec, 123 ns/op
183
-tidwall: get-seq-hint   1,000,000 ops in 40ms, 25,142,979/sec, 39 ns/op
191
+google:  get-seq        1,000,000 ops in 165ms, 6,048,307/sec, 165 ns/op
192
+tidwall: get-seq        1,000,000 ops in 144ms, 6,940,120/sec, 144 ns/op
193
+tidwall: get-seq-hint   1,000,000 ops in 78ms, 12,815,243/sec, 78 ns/op
184 194
 
185 195
 ** random get **
186
-google:  get-rand       1,000,000 ops in 152ms, 6,593,518/sec, 151 ns/op
187
-tidwall: get-rand       1,000,000 ops in 128ms, 7,783,293/sec, 128 ns/op
188
-tidwall: get-rand-hint  1,000,000 ops in 135ms, 7,403,823/sec, 135 ns/op
196
+google:  get-rand       1,000,000 ops in 701ms, 1,427,507/sec, 700 ns/op
197
+tidwall: get-rand       1,000,000 ops in 679ms, 1,473,531/sec, 678 ns/op
198
+tidwall: get-rand-hint  1,000,000 ops in 824ms, 1,213,805/sec, 823 ns/op
189 199
 ```
190 200
 
191 201
 *You can find the benchmark utility at [tidwall/btree-benchmark](https://github.com/tidwall/btree-benchmark)*

+ 117
- 782
vendor/github.com/tidwall/btree/btree.go
File diff suppressed because it is too large
View File


+ 1275
- 0
vendor/github.com/tidwall/btree/internal/btree.go
File diff suppressed because it is too large
View File


+ 1
- 0
vendor/github.com/tidwall/buntdb/README.md View File

@@ -137,6 +137,7 @@ All keys/value pairs are ordered in the database by the key. To iterate over the
137 137
 err := db.View(func(tx *buntdb.Tx) error {
138 138
 	err := tx.Ascend("", func(key, value string) bool {
139 139
 		fmt.Printf("key: %s, value: %s\n", key, value)
140
+		return true // continue iteration
140 141
 	})
141 142
 	return err
142 143
 })

+ 3
- 1
vendor/github.com/tidwall/gjson/README.md View File

@@ -4,7 +4,9 @@
4 4
     width="240" height="78" border="0" alt="GJSON">
5 5
 <br>
6 6
 <a href="https://godoc.org/github.com/tidwall/gjson"><img src="https://img.shields.io/badge/api-reference-blue.svg?style=flat-square" alt="GoDoc"></a>
7
-<a href="http://tidwall.com/gjson-play"><img src="https://img.shields.io/badge/%F0%9F%8F%90-playground-9900cc.svg?style=flat-square" alt="GJSON Playground"></a>
7
+<a href="https://tidwall.com/gjson-play"><img src="https://img.shields.io/badge/%F0%9F%8F%90-playground-9900cc.svg?style=flat-square" alt="GJSON Playground"></a>
8
+<a href="SYNTAX.md"><img src="https://img.shields.io/badge/{}-syntax-33aa33.svg?style=flat-square" alt="GJSON Syntax"></a>
9
+	
8 10
 </p>
9 11
 
10 12
 <p align="center">get json values quickly</a></p>

+ 23
- 3
vendor/github.com/tidwall/gjson/SYNTAX.md View File

@@ -13,11 +13,11 @@ This document is designed to explain the structure of a GJSON Path through examp
13 13
 - [Dot vs Pipe](#dot-vs-pipe)
14 14
 - [Modifiers](#modifiers)
15 15
 - [Multipaths](#multipaths)
16
+- [Literals](#literals)
16 17
 
17 18
 The definitive implemenation is [github.com/tidwall/gjson](https://github.com/tidwall/gjson).  
18 19
 Use the [GJSON Playground](https://gjson.dev) to experiment with the syntax online.
19 20
 
20
-
21 21
 ## Path structure
22 22
 
23 23
 A GJSON Path is intended to be easily expressed as a series of components seperated by a `.` character. 
@@ -296,7 +296,7 @@ Starting with v1.3.0, GJSON added the ability to join multiple paths together
296 296
 to form new documents. Wrapping comma-separated paths between `[...]` or
297 297
 `{...}` will result in a new array or object, respectively.
298 298
 
299
-For example, using the given multipath 
299
+For example, using the given multipath:
300 300
 
301 301
 ```
302 302
 {name.first,age,"the_murphys":friends.#(last="Murphy")#.first}
@@ -312,8 +312,28 @@ determined, then "_" is used.
312 312
 
313 313
 This results in
314 314
 
315
-```
315
+```json
316 316
 {"first":"Tom","age":37,"the_murphys":["Dale","Jane"]}
317 317
 ```
318 318
 
319
+### Literals
320
+
321
+Starting with v1.12.0, GJSON added support of json literals, which provides a way for constructing static blocks of json. This is can be particularly useful when constructing a new json document using [multipaths](#multipaths).  
322
+
323
+A json literal begins with the '!' declaration character. 
324
+
325
+For example, using the given multipath:
326
+
327
+```
328
+{name.first,age,"company":!"Happysoft","employed":!true}
329
+```
330
+
331
+Here we selected the first name and age. Then add two new fields, "company" and "employed".
332
+
333
+This results in 
334
+
335
+```json
336
+{"first":"Tom","age":37,"company":"Happysoft","employed":true}
337
+```
319 338
 
339
+*See issue [#249](https://github.com/tidwall/gjson/issues/249) for additional context on JSON Literals.*

+ 291
- 50
vendor/github.com/tidwall/gjson/gjson.go View File

@@ -229,17 +229,19 @@ func (t Result) ForEach(iterator func(key, value Result) bool) {
229 229
 		return
230 230
 	}
231 231
 	json := t.Raw
232
-	var keys bool
232
+	var obj bool
233 233
 	var i int
234 234
 	var key, value Result
235 235
 	for ; i < len(json); i++ {
236 236
 		if json[i] == '{' {
237 237
 			i++
238 238
 			key.Type = String
239
-			keys = true
239
+			obj = true
240 240
 			break
241 241
 		} else if json[i] == '[' {
242 242
 			i++
243
+			key.Type = Number
244
+			key.Num = -1
243 245
 			break
244 246
 		}
245 247
 		if json[i] > ' ' {
@@ -249,8 +251,9 @@ func (t Result) ForEach(iterator func(key, value Result) bool) {
249 251
 	var str string
250 252
 	var vesc bool
251 253
 	var ok bool
254
+	var idx int
252 255
 	for ; i < len(json); i++ {
253
-		if keys {
256
+		if obj {
254 257
 			if json[i] != '"' {
255 258
 				continue
256 259
 			}
@@ -265,7 +268,9 @@ func (t Result) ForEach(iterator func(key, value Result) bool) {
265 268
 				key.Str = str[1 : len(str)-1]
266 269
 			}
267 270
 			key.Raw = str
268
-			key.Index = s
271
+			key.Index = s + t.Index
272
+		} else {
273
+			key.Num += 1
269 274
 		}
270 275
 		for ; i < len(json); i++ {
271 276
 			if json[i] <= ' ' || json[i] == ',' || json[i] == ':' {
@@ -278,10 +283,17 @@ func (t Result) ForEach(iterator func(key, value Result) bool) {
278 283
 		if !ok {
279 284
 			return
280 285
 		}
281
-		value.Index = s
286
+		if t.Indexes != nil {
287
+			if idx < len(t.Indexes) {
288
+				value.Index = t.Indexes[idx]
289
+			}
290
+		} else {
291
+			value.Index = s + t.Index
292
+		}
282 293
 		if !iterator(key, value) {
283 294
 			return
284 295
 		}
296
+		idx++
285 297
 	}
286 298
 }
287 299
 
@@ -298,7 +310,15 @@ func (t Result) Map() map[string]Result {
298 310
 // Get searches result for the specified path.
299 311
 // The result should be a JSON array or object.
300 312
 func (t Result) Get(path string) Result {
301
-	return Get(t.Raw, path)
313
+	r := Get(t.Raw, path)
314
+	if r.Indexes != nil {
315
+		for i := 0; i < len(r.Indexes); i++ {
316
+			r.Indexes[i] += t.Index
317
+		}
318
+	} else {
319
+		r.Index += t.Index
320
+	}
321
+	return r
302 322
 }
303 323
 
304 324
 type arrayOrMapResult struct {
@@ -389,6 +409,8 @@ func (t Result) arrayOrMap(vc byte, valueize bool) (r arrayOrMapResult) {
389 409
 			value.Raw, value.Str = tostr(json[i:])
390 410
 			value.Num = 0
391 411
 		}
412
+		value.Index = i + t.Index
413
+
392 414
 		i += len(value.Raw) - 1
393 415
 
394 416
 		if r.vc == '{' {
@@ -415,6 +437,17 @@ func (t Result) arrayOrMap(vc byte, valueize bool) (r arrayOrMapResult) {
415 437
 		}
416 438
 	}
417 439
 end:
440
+	if t.Indexes != nil {
441
+		if len(t.Indexes) != len(r.a) {
442
+			for i := 0; i < len(r.a); i++ {
443
+				r.a[i].Index = 0
444
+			}
445
+		} else {
446
+			for i := 0; i < len(r.a); i++ {
447
+				r.a[i].Index = t.Indexes[i]
448
+			}
449
+		}
450
+	}
418 451
 	return
419 452
 }
420 453
 
@@ -426,7 +459,8 @@ end:
426 459
 // use the Valid function first.
427 460
 func Parse(json string) Result {
428 461
 	var value Result
429
-	for i := 0; i < len(json); i++ {
462
+	i := 0
463
+	for ; i < len(json); i++ {
430 464
 		if json[i] == '{' || json[i] == '[' {
431 465
 			value.Type = JSON
432 466
 			value.Raw = json[i:] // just take the entire raw
@@ -436,16 +470,20 @@ func Parse(json string) Result {
436 470
 			continue
437 471
 		}
438 472
 		switch json[i] {
439
-		default:
440
-			if (json[i] >= '0' && json[i] <= '9') || json[i] == '-' {
473
+		case '+', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
474
+			'i', 'I', 'N':
475
+			value.Type = Number
476
+			value.Raw, value.Num = tonum(json[i:])
477
+		case 'n':
478
+			if i+1 < len(json) && json[i+1] != 'u' {
479
+				// nan
441 480
 				value.Type = Number
442 481
 				value.Raw, value.Num = tonum(json[i:])
443 482
 			} else {
444
-				return Result{}
483
+				// null
484
+				value.Type = Null
485
+				value.Raw = tolit(json[i:])
445 486
 			}
446
-		case 'n':
447
-			value.Type = Null
448
-			value.Raw = tolit(json[i:])
449 487
 		case 't':
450 488
 			value.Type = True
451 489
 			value.Raw = tolit(json[i:])
@@ -455,9 +493,14 @@ func Parse(json string) Result {
455 493
 		case '"':
456 494
 			value.Type = String
457 495
 			value.Raw, value.Str = tostr(json[i:])
496
+		default:
497
+			return Result{}
458 498
 		}
459 499
 		break
460 500
 	}
501
+	if value.Exists() {
502
+		value.Index = i
503
+	}
461 504
 	return value
462 505
 }
463 506
 
@@ -531,20 +574,12 @@ func tonum(json string) (raw string, num float64) {
531 574
 				return
532 575
 			}
533 576
 			// could be a '+' or '-'. let's assume so.
534
-			continue
535
-		}
536
-		if json[i] < ']' {
537
-			// probably a valid number
538
-			continue
539
-		}
540
-		if json[i] == 'e' || json[i] == 'E' {
541
-			// allow for exponential numbers
542
-			continue
577
+		} else if json[i] == ']' || json[i] == '}' {
578
+			// break on ']' or '}'
579
+			raw = json[:i]
580
+			num, _ = strconv.ParseFloat(raw, 64)
581
+			return
543 582
 		}
544
-		// likely a ']' or '}'
545
-		raw = json[:i]
546
-		num, _ = strconv.ParseFloat(raw, 64)
547
-		return
548 583
 	}
549 584
 	raw = json
550 585
 	num, _ = strconv.ParseFloat(raw, 64)
@@ -1513,7 +1548,6 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
1513 1548
 							}
1514 1549
 							if idx < len(c.json) && c.json[idx] != ']' {
1515 1550
 								_, res, ok := parseAny(c.json, idx, true)
1516
-								parentIndex := res.Index
1517 1551
 								if ok {
1518 1552
 									res := res.Get(rp.alogkey)
1519 1553
 									if res.Exists() {
@@ -1525,8 +1559,7 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
1525 1559
 											raw = res.String()
1526 1560
 										}
1527 1561
 										jsons = append(jsons, []byte(raw)...)
1528
-										indexes = append(indexes,
1529
-											res.Index+parentIndex)
1562
+										indexes = append(indexes, res.Index)
1530 1563
 										k++
1531 1564
 									}
1532 1565
 								}
@@ -1699,7 +1732,7 @@ type subSelector struct {
1699 1732
 // first character in path is either '[' or '{', and has already been checked
1700 1733
 // prior to calling this function.
1701 1734
 func parseSubSelectors(path string) (sels []subSelector, out string, ok bool) {
1702
-	modifer := 0
1735
+	modifier := 0
1703 1736
 	depth := 1
1704 1737
 	colon := 0
1705 1738
 	start := 1
@@ -1714,6 +1747,7 @@ func parseSubSelectors(path string) (sels []subSelector, out string, ok bool) {
1714 1747
 		}
1715 1748
 		sels = append(sels, sel)
1716 1749
 		colon = 0
1750
+		modifier = 0
1717 1751
 		start = i + 1
1718 1752
 	}
1719 1753
 	for ; i < len(path); i++ {
@@ -1721,11 +1755,11 @@ func parseSubSelectors(path string) (sels []subSelector, out string, ok bool) {
1721 1755
 		case '\\':
1722 1756
 			i++
1723 1757
 		case '@':
1724
-			if modifer == 0 && i > 0 && (path[i-1] == '.' || path[i-1] == '|') {
1725
-				modifer = i
1758
+			if modifier == 0 && i > 0 && (path[i-1] == '.' || path[i-1] == '|') {
1759
+				modifier = i
1726 1760
 			}
1727 1761
 		case ':':
1728
-			if modifer == 0 && colon == 0 && depth == 1 {
1762
+			if modifier == 0 && colon == 0 && depth == 1 {
1729 1763
 				colon = i
1730 1764
 			}
1731 1765
 		case ',':
@@ -1778,7 +1812,7 @@ func isSimpleName(component string) bool {
1778 1812
 			return false
1779 1813
 		}
1780 1814
 		switch component[i] {
1781
-		case '[', ']', '{', '}', '(', ')', '#', '|':
1815
+		case '[', ']', '{', '}', '(', ')', '#', '|', '!':
1782 1816
 			return false
1783 1817
 		}
1784 1818
 	}
@@ -1842,23 +1876,25 @@ type parseContext struct {
1842 1876
 // use the Valid function first.
1843 1877
 func Get(json, path string) Result {
1844 1878
 	if len(path) > 1 {
1845
-		if !DisableModifiers {
1846
-			if path[0] == '@' {
1847
-				// possible modifier
1848
-				var ok bool
1849
-				var npath string
1850
-				var rjson string
1879
+		if (path[0] == '@' && !DisableModifiers) || path[0] == '!' {
1880
+			// possible modifier
1881
+			var ok bool
1882
+			var npath string
1883
+			var rjson string
1884
+			if path[0] == '@' && !DisableModifiers {
1851 1885
 				npath, rjson, ok = execModifier(json, path)
1852
-				if ok {
1853
-					path = npath
1854
-					if len(path) > 0 && (path[0] == '|' || path[0] == '.') {
1855
-						res := Get(rjson, path[1:])
1856
-						res.Index = 0
1857
-						res.Indexes = nil
1858
-						return res
1859
-					}
1860
-					return Parse(rjson)
1886
+			} else if path[0] == '!' {
1887
+				npath, rjson, ok = execStatic(json, path)
1888
+			}
1889
+			if ok {
1890
+				path = npath
1891
+				if len(path) > 0 && (path[0] == '|' || path[0] == '.') {
1892
+					res := Get(rjson, path[1:])
1893
+					res.Index = 0
1894
+					res.Indexes = nil
1895
+					return res
1861 1896
 				}
1897
+				return Parse(rjson)
1862 1898
 			}
1863 1899
 		}
1864 1900
 		if path[0] == '[' || path[0] == '{' {
@@ -2527,8 +2563,40 @@ func safeInt(f float64) (n int64, ok bool) {
2527 2563
 	return int64(f), true
2528 2564
 }
2529 2565
 
2566
+// execStatic parses the path to find a static value.
2567
+// The input expects that the path already starts with a '!'
2568
+func execStatic(json, path string) (pathOut, res string, ok bool) {
2569
+	name := path[1:]
2570
+	if len(name) > 0 {
2571
+		switch name[0] {
2572
+		case '{', '[', '"', '+', '-', '0', '1', '2', '3', '4', '5', '6', '7',
2573
+			'8', '9':
2574
+			_, res = parseSquash(name, 0)
2575
+			pathOut = name[len(res):]
2576
+			return pathOut, res, true
2577
+		}
2578
+	}
2579
+	for i := 1; i < len(path); i++ {
2580
+		if path[i] == '|' {
2581
+			pathOut = path[i:]
2582
+			name = path[1:i]
2583
+			break
2584
+		}
2585
+		if path[i] == '.' {
2586
+			pathOut = path[i:]
2587
+			name = path[1:i]
2588
+			break
2589
+		}
2590
+	}
2591
+	switch strings.ToLower(name) {
2592
+	case "true", "false", "null", "nan", "inf":
2593
+		return pathOut, name, true
2594
+	}
2595
+	return pathOut, res, false
2596
+}
2597
+
2530 2598
 // execModifier parses the path to find a matching modifier function.
2531
-// then input expects that the path already starts with a '@'
2599
+// The input expects that the path already starts with a '@'
2532 2600
 func execModifier(json, path string) (pathOut, res string, ok bool) {
2533 2601
 	name := path[1:]
2534 2602
 	var hasArgs bool
@@ -2971,3 +3039,176 @@ func stringBytes(s string) []byte {
2971 3039
 func bytesString(b []byte) string {
2972 3040
 	return *(*string)(unsafe.Pointer(&b))
2973 3041
 }
3042
+
3043
+func revSquash(json string) string {
3044
+	// reverse squash
3045
+	// expects that the tail character is a ']' or '}' or ')' or '"'
3046
+	// squash the value, ignoring all nested arrays and objects.
3047
+	i := len(json) - 1
3048
+	var depth int
3049
+	if json[i] != '"' {
3050
+		depth++
3051
+	}
3052
+	if json[i] == '}' || json[i] == ']' || json[i] == ')' {
3053
+		i--
3054
+	}
3055
+	for ; i >= 0; i-- {
3056
+		switch json[i] {
3057
+		case '"':
3058
+			i--
3059
+			for ; i >= 0; i-- {
3060
+				if json[i] == '"' {
3061
+					esc := 0
3062
+					for i > 0 && json[i-1] == '\\' {
3063
+						i--
3064
+						esc++
3065
+					}
3066
+					if esc%2 == 1 {
3067
+						continue
3068
+					}
3069
+					i += esc
3070
+					break
3071
+				}
3072
+			}
3073
+			if depth == 0 {
3074
+				if i < 0 {
3075
+					i = 0
3076
+				}
3077
+				return json[i:]
3078
+			}
3079
+		case '}', ']', ')':
3080
+			depth++
3081
+		case '{', '[', '(':
3082
+			depth--
3083
+			if depth == 0 {
3084
+				return json[i:]
3085
+			}
3086
+		}
3087
+	}
3088
+	return json
3089
+}
3090
+
3091
+func (t Result) Paths(json string) []string {
3092
+	if t.Indexes == nil {
3093
+		return nil
3094
+	}
3095
+	paths := make([]string, 0, len(t.Indexes))
3096
+	t.ForEach(func(_, value Result) bool {
3097
+		paths = append(paths, value.Path(json))
3098
+		return true
3099
+	})
3100
+	if len(paths) != len(t.Indexes) {
3101
+		return nil
3102
+	}
3103
+	return paths
3104
+}
3105
+
3106
+// Path returns the original GJSON path for Result.
3107
+// The json param must be the original JSON used when calling Get.
3108
+func (t Result) Path(json string) string {
3109
+	var path []byte
3110
+	var comps []string // raw components
3111
+	i := t.Index - 1
3112
+	if t.Index+len(t.Raw) > len(json) {
3113
+		// JSON cannot safely contain Result.
3114
+		goto fail
3115
+	}
3116
+	if !strings.HasPrefix(json[t.Index:], t.Raw) {
3117
+		// Result is not at the JSON index as exepcted.
3118
+		goto fail
3119
+	}
3120
+	for ; i >= 0; i-- {
3121
+		if json[i] <= ' ' {
3122
+			continue
3123
+		}
3124
+		if json[i] == ':' {
3125
+			// inside of object, get the key
3126
+			for ; i >= 0; i-- {
3127
+				if json[i] != '"' {
3128
+					continue
3129
+				}
3130
+				break
3131
+			}
3132
+			raw := revSquash(json[:i+1])
3133
+			i = i - len(raw)
3134
+			comps = append(comps, raw)
3135
+			// key gotten, now squash the rest
3136
+			raw = revSquash(json[:i+1])
3137
+			i = i - len(raw)
3138
+			i++ // increment the index for next loop step
3139
+		} else if json[i] == '{' {
3140
+			// Encountered an open object. The original result was probably an
3141
+			// object key.
3142
+			goto fail
3143
+		} else if json[i] == ',' || json[i] == '[' {
3144
+			// inside of an array, count the position
3145
+			var arrIdx int
3146
+			if json[i] == ',' {
3147
+				arrIdx++
3148
+				i--
3149
+			}
3150
+			for ; i >= 0; i-- {
3151
+				if json[i] == ':' {
3152
+					// Encountered an unexpected colon. The original result was
3153
+					// probably an object key.
3154
+					goto fail
3155
+				} else if json[i] == ',' {
3156
+					arrIdx++
3157
+				} else if json[i] == '[' {
3158
+					comps = append(comps, strconv.Itoa(arrIdx))
3159
+					break
3160
+				} else if json[i] == ']' || json[i] == '}' || json[i] == '"' {
3161
+					raw := revSquash(json[:i+1])
3162
+					i = i - len(raw) + 1
3163
+				}
3164
+			}
3165
+		}
3166
+	}
3167
+	if len(comps) == 0 {
3168
+		if DisableModifiers {
3169
+			goto fail
3170
+		}
3171
+		return "@this"
3172
+	}
3173
+	for i := len(comps) - 1; i >= 0; i-- {
3174
+		rcomp := Parse(comps[i])
3175
+		if !rcomp.Exists() {
3176
+			goto fail
3177
+		}
3178
+		comp := escapeComp(rcomp.String())
3179
+		path = append(path, '.')
3180
+		path = append(path, comp...)
3181
+	}
3182
+	if len(path) > 0 {
3183
+		path = path[1:]
3184
+	}
3185
+	return string(path)
3186
+fail:
3187
+	return ""
3188
+}
3189
+
3190
+// isSafePathKeyChar returns true if the input character is safe for not
3191
+// needing escaping.
3192
+func isSafePathKeyChar(c byte) bool {
3193
+	return c <= ' ' || c > '~' || c == '_' || c == '-' || c == ':' ||
3194
+		(c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
3195
+		(c >= '0' && c <= '9')
3196
+}
3197
+
3198
+// escapeComp escaped a path compontent, making it safe for generating a
3199
+// path for later use.
3200
+func escapeComp(comp string) string {
3201
+	for i := 0; i < len(comp); i++ {
3202
+		if !isSafePathKeyChar(comp[i]) {
3203
+			ncomp := []byte(comp[:i])
3204
+			for ; i < len(comp); i++ {
3205
+				if !isSafePathKeyChar(comp[i]) {
3206
+					ncomp = append(ncomp, '\\')
3207
+				}
3208
+				ncomp = append(ncomp, comp[i])
3209
+			}
3210
+			return string(ncomp)
3211
+		}
3212
+	}
3213
+	return comp
3214
+}

+ 1
- 1
vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go View File

@@ -32,7 +32,7 @@ import (
32 32
 // can get a derived key for e.g. AES-256 (which needs a 32-byte key) by
33 33
 // doing:
34 34
 //
35
-// 	dk := pbkdf2.Key([]byte("some password"), salt, 4096, 32, sha1.New)
35
+//	dk := pbkdf2.Key([]byte("some password"), salt, 4096, 32, sha1.New)
36 36
 //
37 37
 // Remember to get a good random salt. At least 8 bytes is recommended by the
38 38
 // RFC.

+ 4
- 8
vendor/golang.org/x/crypto/sha3/doc.go View File

@@ -8,8 +8,7 @@
8 8
 // Both types of hash function use the "sponge" construction and the Keccak
9 9
 // permutation. For a detailed specification see http://keccak.noekeon.org/
10 10
 //
11
-//
12
-// Guidance
11
+// # Guidance
13 12
 //
14 13
 // If you aren't sure what function you need, use SHAKE256 with at least 64
15 14
 // bytes of output. The SHAKE instances are faster than the SHA3 instances;
@@ -19,8 +18,7 @@
19 18
 // secret key to the input, hash with SHAKE256 and read at least 32 bytes of
20 19
 // output.
21 20
 //
22
-//
23
-// Security strengths
21
+// # Security strengths
24 22
 //
25 23
 // The SHA3-x (x equals 224, 256, 384, or 512) functions have a security
26 24
 // strength against preimage attacks of x bits. Since they only produce "x"
@@ -31,8 +29,7 @@
31 29
 // is used.  Requesting more than 64 or 32 bytes of output, respectively, does
32 30
 // not increase the collision-resistance of the SHAKE functions.
33 31
 //
34
-//
35
-// The sponge construction
32
+// # The sponge construction
36 33
 //
37 34
 // A sponge builds a pseudo-random function from a public pseudo-random
38 35
 // permutation, by applying the permutation to a state of "rate + capacity"
@@ -50,8 +47,7 @@
50 47
 // Since the KeccakF-1600 permutation is 1600 bits (200 bytes) wide, this means
51 48
 // that the security strength of a sponge instance is equal to (1600 - bitrate) / 2.
52 49
 //
53
-//
54
-// Recommendations
50
+// # Recommendations
55 51
 //
56 52
 // The SHAKE functions are recommended for most new uses. They can produce
57 53
 // output of arbitrary length. SHAKE256, with an output length of at least

+ 1
- 1
vendor/golang.org/x/crypto/sha3/sha3.go View File

@@ -86,7 +86,7 @@ func (d *state) permute() {
86 86
 		d.buf = d.storage.asBytes()[:0]
87 87
 		keccakF1600(&d.a)
88 88
 	case spongeSqueezing:
89
-		// If we're squeezing, we need to apply the permutatin before
89
+		// If we're squeezing, we need to apply the permutation before
90 90
 		// copying more output.
91 91
 		keccakF1600(&d.a)
92 92
 		d.buf = d.storage.asBytes()[:d.rate]

+ 2
- 0
vendor/golang.org/x/crypto/sha3/sha3_s390x.go View File

@@ -34,11 +34,13 @@ const (
34 34
 
35 35
 // kimd is a wrapper for the 'compute intermediate message digest' instruction.
36 36
 // src must be a multiple of the rate for the given function code.
37
+//
37 38
 //go:noescape
38 39
 func kimd(function code, chain *[200]byte, src []byte)
39 40
 
40 41
 // klmd is a wrapper for the 'compute last message digest' instruction.
41 42
 // src padding is handled by the instruction.
43
+//
42 44
 //go:noescape
43 45
 func klmd(function code, chain *[200]byte, dst, src []byte)
44 46
 

+ 6
- 5
vendor/modules.txt View File

@@ -45,16 +45,17 @@ github.com/okzk/sdnotify
45 45
 ## explicit
46 46
 # github.com/stretchr/testify v1.4.0
47 47
 ## explicit
48
-# github.com/tidwall/btree v0.6.1
48
+# github.com/tidwall/btree v1.1.0
49 49
 ## explicit; go 1.16
50 50
 github.com/tidwall/btree
51
-# github.com/tidwall/buntdb v1.2.7
51
+github.com/tidwall/btree/internal
52
+# github.com/tidwall/buntdb v1.2.9
52 53
 ## explicit; go 1.16
53 54
 github.com/tidwall/buntdb
54
-# github.com/tidwall/gjson v1.10.2
55
+# github.com/tidwall/gjson v1.12.1
55 56
 ## explicit; go 1.12
56 57
 github.com/tidwall/gjson
57
-# github.com/tidwall/grect v0.1.3
58
+# github.com/tidwall/grect v0.1.4
58 59
 ## explicit; go 1.15
59 60
 github.com/tidwall/grect
60 61
 # github.com/tidwall/match v1.1.1
@@ -79,7 +80,7 @@ github.com/xdg-go/pbkdf2
79 80
 # github.com/xdg-go/scram v1.0.2 => github.com/ergochat/scram v1.0.2-ergo1
80 81
 ## explicit; go 1.11
81 82
 github.com/xdg-go/scram
82
-# golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8
83
+# golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
83 84
 ## explicit; go 1.17
84 85
 golang.org/x/crypto/bcrypt
85 86
 golang.org/x/crypto/blowfish

Loading…
Cancel
Save