diff --git a/go.mod b/go.mod index 3ebcef25..82757da8 100644 --- a/go.mod +++ b/go.mod @@ -19,18 +19,18 @@ require ( github.com/pires/go-proxyproto v0.8.1 github.com/sirupsen/logrus v1.9.3 github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 - github.com/skycoin/skycoin v0.28.1-0.20251109152000-9018c9f37372 //DO NOT MODIFY OR UPDATE v0.28.1-0.20251109152000-9018c9f37372 + github.com/skycoin/skycoin v0.28.1-0.20251215160458-f84f07154eae //MUST TRACK COBRA-CLI BRANCH FOR NOW v0.28.1-0.20251215160458-f84f07154eae github.com/skycoin/skywire v1.3.32-0.20251108143835-4a7d00a050e1 - github.com/spf13/cobra v1.10.1 + github.com/spf13/cobra v1.10.2 github.com/stretchr/testify v1.11.1 - golang.org/x/net v0.47.0 - golang.org/x/sys v0.38.0 - golang.org/x/term v0.37.0 + golang.org/x/net v0.48.0 + golang.org/x/sys v0.39.0 + golang.org/x/term v0.38.0 ) require ( github.com/docker/docker v28.5.2+incompatible - github.com/xtaci/smux v1.5.44 + github.com/xtaci/smux v1.5.47 ) require ( @@ -51,17 +51,17 @@ require ( github.com/docker/go-units v0.4.0 // indirect github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/gabriel-vasile/mimetype v1.4.11 // indirect + github.com/gabriel-vasile/mimetype v1.4.12 // indirect github.com/gin-contrib/sse v1.1.0 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.28.0 // indirect + github.com/go-playground/validator/v10 v10.29.0 // indirect github.com/goccy/go-json v0.10.5 // indirect github.com/goccy/go-yaml v1.19.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/itchyny/gojq v0.12.17 // indirect + github.com/itchyny/gojq v0.12.18 // indirect github.com/itchyny/timefmt-go v0.1.7 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect @@ -93,10 +93,10 @@ require ( go.opentelemetry.io/otel/metric v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect golang.org/x/arch v0.23.0 // indirect - golang.org/x/crypto v0.45.0 // indirect - golang.org/x/text v0.31.0 // indirect + golang.org/x/crypto v0.46.0 // indirect + golang.org/x/text v0.32.0 // indirect golang.org/x/time v0.14.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect + google.golang.org/protobuf v1.36.11 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.2 // indirect mvdan.cc/sh/v3 v3.12.0 // indirect @@ -115,7 +115,7 @@ require ( // Below should reflect current versions of the following deps // To update deps to specific commit hash: // 1) Uncomment one of the following lines and substituite version with desired commit hash: -//replace github.com/skycoin/skycoin => github.com/skycoin/skycoin v0.28.1-0.20251022232932-b3a844043898 +//replace github.com/skycoin/skycoin => github.com/skycoin/skycoin v0.28.1-0.20251215160458-f84f07154eae //replace github.com/skycoin/skywire => github.com/skycoin/skywire v1.3.32-0.20251108143835-4a7d00a050e1 // 2) Run `go mod tidy && go mod vendor` // 3) Copy the populated version string to the correct place in require(...) above - replacing the specified version string diff --git a/go.sum b/go.sum index e604944e..9e44488d 100644 --- a/go.sum +++ b/go.sum @@ -59,8 +59,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2 github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/gabriel-vasile/mimetype v1.4.11 h1:AQvxbp830wPhHTqc1u7nzoLT+ZFxGY7emj5DR5DYFik= -github.com/gabriel-vasile/mimetype v1.4.11/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= +github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw= +github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w= github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM= github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk= @@ -78,8 +78,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688= -github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU= +github.com/go-playground/validator/v10 v10.29.0 h1:lQlF5VNJWNlRbRZNeOIkWElR+1LL/OuHcc0Kp14w1xk= +github.com/go-playground/validator/v10 v10.29.0/go.mod h1:D6QxqeMlgIPuT02L66f2ccrZ7AGgHkzKmmTMZhk/Kc4= github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= @@ -100,8 +100,8 @@ github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/itchyny/gojq v0.12.17 h1:8av8eGduDb5+rvEdaOO+zQUjA04MS0m3Ps8HiD+fceg= -github.com/itchyny/gojq v0.12.17/go.mod h1:WBrEMkgAfAGO1LUcGOckBl5O726KPp+OlkKug0I/FEY= +github.com/itchyny/gojq v0.12.18 h1:gFGHyt/MLbG9n6dqnvlliiya2TaMMh6FFaR2b1H6Drc= +github.com/itchyny/gojq v0.12.18/go.mod h1:4hPoZ/3lN9fDL1D+aK7DY1f39XZpY9+1Xpjz8atrEkg= github.com/itchyny/timefmt-go v0.1.7 h1:xyftit9Tbw+Dc/huSSPJaEmX1TVL8lw5vxjJLK4GMMA= github.com/itchyny/timefmt-go v0.1.7/go.mod h1:5E46Q+zj7vbTgWY8o5YkMeYb4I6GeWLFnetPy5oBrAI= github.com/ivanpirog/coloredcobra v1.0.1 h1:aURSdEmlR90/tSiWS0dMjdwOvCVUeYLfltLfbgNxrN4= @@ -170,13 +170,13 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 h1:1Nc5EBY6pjfw1kwW0duwyG+7WliWz5u9kgk1h5MnLuA= github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:UXghlricA7J3aRD/k7p/zBObQfmBawwCxIVPVjz2Q3o= -github.com/skycoin/skycoin v0.28.1-0.20251109152000-9018c9f37372 h1:vLfM8PLmmIAc5CJej52lFCRM3EeCh/DMPw5JkqX9cGc= -github.com/skycoin/skycoin v0.28.1-0.20251109152000-9018c9f37372/go.mod h1:UV52f79oGvWNYIC9JU+PjFu1cQwAN6Vb+SgZenBly/8= +github.com/skycoin/skycoin v0.28.1-0.20251215160458-f84f07154eae h1:CjmnI6mIcmel4hGr8zi/X0yl2uLIfhRnggwwU/NapcM= +github.com/skycoin/skycoin v0.28.1-0.20251215160458-f84f07154eae/go.mod h1:ZMRZ/7/4rNnisdkZjWNsAHEDtRCG5o8YN7Xe8GtHs6s= github.com/skycoin/skywire v1.3.32-0.20251108143835-4a7d00a050e1 h1:+S3Hr+EVnsj79ku9gPFxr1F8wiIwzJXwG94J1KQf5RU= github.com/skycoin/skywire v1.3.32-0.20251108143835-4a7d00a050e1/go.mod h1:EwDfO34iivOLo4C8QmPT7g4Q1qDpM2k+anOIrxID/ss= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= -github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= -github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= @@ -201,8 +201,8 @@ github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ= github.com/valyala/histogram v1.2.0 h1:wyYGAZZt3CpwUiIb9AU/Zbllg1llXyrtApRS815OLoQ= github.com/valyala/histogram v1.2.0/go.mod h1:Hb4kBwb4UxsaNbbbh+RRz8ZR6pdodR57tzWUS3BUzXY= -github.com/xtaci/smux v1.5.44 h1:7T61zLfFX1jokXj6d+lPaxHnVwgYiJ7EN94DAudKqpg= -github.com/xtaci/smux v1.5.44/go.mod h1:IGQ9QYrBphmb/4aTnLEcJby0TNr3NV+OslIOMrX825Q= +github.com/xtaci/smux v1.5.47 h1:VzvwiCt7P2Y1eA7FR2ViwAUns8DG/wQMyMBVOCRNbys= +github.com/xtaci/smux v1.5.47/go.mod h1:IGQ9QYrBphmb/4aTnLEcJby0TNr3NV+OslIOMrX825Q= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18= @@ -225,12 +225,13 @@ go.opentelemetry.io/proto/otlp v1.7.1 h1:gTOMpGDb0WTBOP8JaO72iL3auEZhVmAQg4ipjOV go.opentelemetry.io/proto/otlp v1.7.1/go.mod h1:b2rVh6rfI/s2pHWNlB7ILJcRALpcNDzKhACevjI+ZnE= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/arch v0.23.0 h1:lKF64A2jF6Zd8L0knGltUnegD62JMFBiCPBmQpToHhg= golang.org/x/arch v0.23.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A= -golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= -golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= -golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= -golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= +golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200428200454-593003d681fa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -238,24 +239,24 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= -golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= -golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= -golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= -golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q= +golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= -golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= -golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= +golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY= google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5/go.mod h1:j3QtIyytwqGr1JUDtYXwtMXWPKsEa5LtzIFN1Wn5WvE= google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE= google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc= google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4= google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ= -google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= -google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= +google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/vendor/github.com/gabriel-vasile/mimetype/.golangci.yml b/vendor/github.com/gabriel-vasile/mimetype/.golangci.yml index f2058ccc..5b30cd61 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/.golangci.yml +++ b/vendor/github.com/gabriel-vasile/mimetype/.golangci.yml @@ -1,5 +1,41 @@ version: "2" + +run: + timeout: 5m + linters: exclusions: presets: - std-error-handling + enable: + - gosec # Detects security problems. + # Keep all extras disabled for now to focus on the integer overflow problem. + # TODO: enable these and other good linters + - dogsled # Detects assignments with too many blank identifiers. + - errcheck + - errchkjson # Detects unsupported types passed to json encoding functions and reports if checks for the returned error can be omitted. + - exhaustive # Detects missing options in enum switch statements. + - gocyclo + - govet + - ineffassign + - makezero # Finds slice declarations with non-zero initial length. + - misspell # Detects commonly misspelled English words in comments. + - nakedret # Detects uses of naked returns. + - prealloc # Detects slice declarations that could potentially be pre-allocated. + - predeclared # Detects code that shadows one of Go's predeclared identifiers. + - reassign # Detects reassigning a top-level variable in another package. + - staticcheck + - thelper # Detects test helpers without t.Helper(). + - tparallel # Detects inappropriate usage of t.Parallel(). + - unconvert # Detects unnecessary type conversions. + - unused + - usestdlibvars # Detects the possibility to use variables/constants from the Go standard library. + - usetesting # Reports uses of functions with replacement inside the testing package. + settings: + govet: + disable: + - stdversion + gosec: + excludes: + - G404 # Weak random number generator used in tests. + - G304 # File inclusion diff --git a/vendor/github.com/gabriel-vasile/mimetype/README.md b/vendor/github.com/gabriel-vasile/mimetype/README.md index ea5c89a9..9fe71ac9 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/README.md +++ b/vendor/github.com/gabriel-vasile/mimetype/README.md @@ -70,13 +70,13 @@ If increasing the limit does not help, please ## Tests In addition to unit tests, [mimetype_tests](https://github.com/gabriel-vasile/mimetype_tests) compares the -library with the [Unix file utility](https://en.wikipedia.org/wiki/File_(command)) +library with [libmagic](https://en.wikipedia.org/wiki/File_(command)) for around 50 000 sample files. Check the latest comparison results [here](https://github.com/gabriel-vasile/mimetype_tests/actions). ## Benchmarks -Benchmarks for each file format are performed when a PR is open. The results can -be seen on the [workflows page](https://github.com/gabriel-vasile/mimetype/actions/workflows/benchmark.yml). +Benchmarks are performed when a PR is open. The results can be seen on the +[workflows page](https://github.com/gabriel-vasile/mimetype/actions/workflows/benchmark.yml). Performance improvements are welcome but correctness is prioritized. ## Structure diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/json/parser.go b/vendor/github.com/gabriel-vasile/mimetype/internal/json/parser.go index d11c0a88..fc3c7720 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/json/parser.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/json/parser.go @@ -94,20 +94,6 @@ func eq(path1, path2 [][]byte) bool { return true } -// LooksLikeObjectOrArray reports if first non white space character from raw -// is either { or [. Parsing raw as JSON is a heavy operation. When receiving some -// text input we can skip parsing if the input does not even look like JSON. -func LooksLikeObjectOrArray(raw []byte) bool { - for i := range raw { - if isSpace(raw[i]) { - continue - } - return raw[i] == '{' || raw[i] == '[' - } - - return false -} - // Parse will take out a parser from the pool depending on queryType and tries // to parse raw bytes as JSON. func Parse(queryType string, raw []byte) (parsed, inspected, firstToken int, querySatisfied bool) { diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/archive.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/archive.go index 8a0c8499..0b4c62f1 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/archive.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/archive.go @@ -106,10 +106,10 @@ func CRX(raw []byte, limit uint32) bool { if len(raw) < minHeaderLen || !bytes.HasPrefix(raw, []byte("Cr24")) { return false } - pubkeyLen := binary.LittleEndian.Uint32(raw[8:12]) - sigLen := binary.LittleEndian.Uint32(raw[12:16]) + pubkeyLen := int64(binary.LittleEndian.Uint32(raw[8:12])) + sigLen := int64(binary.LittleEndian.Uint32(raw[12:16])) zipOffset := minHeaderLen + pubkeyLen + sigLen - if uint32(len(raw)) < zipOffset { + if zipOffset < 0 || int64(len(raw)) < zipOffset { return false } return Zip(raw[zipOffset:], limit) @@ -209,3 +209,13 @@ func tarChksum(b []byte) (unsigned, signed int64) { } return unsigned, signed } + +// Zlib matches zlib compressed files. +func Zlib(raw []byte, _ uint32) bool { + // https://www.ietf.org/rfc/rfc6713.txt + // This check has one fault: ASCII code can satisfy it; for ex: []byte("x ") + zlib := len(raw) > 1 && + raw[0] == 'x' && binary.BigEndian.Uint16(raw)%31 == 0 + // Check that the file is not a regular text to avoid false positives. + return zlib && !Text(raw, 0) +} diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/meteo.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/meteo.go new file mode 100644 index 00000000..da77d0b0 --- /dev/null +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/meteo.go @@ -0,0 +1,12 @@ +package magic + +import "bytes" + +// GRIB matches a GRIdded Binary meteorological file. +// https://www.nco.ncep.noaa.gov/pmb/docs/on388/ +// https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/ +func GRIB(raw []byte, _ uint32) bool { + return len(raw) > 7 && + bytes.HasPrefix(raw, []byte("GRIB")) && + (raw[7] == 1 || raw[7] == 2) +} diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/ms_office.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/ms_office.go index bd4a0c36..e689e92a 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/ms_office.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/ms_office.go @@ -192,7 +192,8 @@ func matchOleClsid(in []byte, clsid []byte) bool { // Expected offset of CLSID for root storage object. clsidOffset := sectorLength*(1+firstSecID) + 80 - if len(in) <= clsidOffset+16 { + // #731 offset is outside in or wrapped around due to integer overflow. + if len(in) <= clsidOffset+16 || clsidOffset < 0 { return false } diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/text.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/text.go index fb84e854..82f6c670 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/text.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/text.go @@ -283,7 +283,7 @@ func Shell(raw []byte, _ uint32) bool { // Text matches a plain text file. // // TODO: This function does not parse BOM-less UTF16 and UTF32 files. Not really -// sure it should. Linux file utility also requires a BOM for UTF16 and UTF32. +// sure it should. libmagic also requires a BOM for UTF16 and UTF32. func Text(raw []byte, _ uint32) bool { // First look for BOM. if cset := charset.FromBOM(raw); cset != "" { @@ -352,13 +352,20 @@ func GLTF(raw []byte, limit uint32) bool { return jsonHelper(raw, limit, json.QueryGLTF, json.TokObject) } -func jsonHelper(raw []byte, limit uint32, q string, wantTok int) bool { - if !json.LooksLikeObjectOrArray(raw) { +func jsonHelper(raw scan.Bytes, limit uint32, q string, wantToks ...int) bool { + firstNonWS := raw.FirstNonWS() + + hasTargetTok := false + for _, t := range wantToks { + hasTargetTok = hasTargetTok || (t&json.TokArray > 0 && firstNonWS == '[') + hasTargetTok = hasTargetTok || (t&json.TokObject > 0 && firstNonWS == '{') + } + if !hasTargetTok { return false } lraw := len(raw) - parsed, inspected, firstToken, querySatisfied := json.Parse(q, raw) - if !querySatisfied || firstToken&wantTok == 0 { + parsed, inspected, _, querySatisfied := json.Parse(q, raw) + if !querySatisfied { return false } @@ -369,7 +376,7 @@ func jsonHelper(raw []byte, limit uint32, q string, wantTok int) bool { // If a section of the file was provided, check if all of it was inspected. // In other words, check that if there was a problem parsing, that problem - // occured at the last byte in the input. + // occurred at the last byte in the input. return inspected == lraw && lraw > 0 } @@ -536,3 +543,57 @@ func Vtt(raw []byte, limit uint32) bool { return bytes.Equal(raw, []byte{0xEF, 0xBB, 0xBF, 0x57, 0x45, 0x42, 0x56, 0x54, 0x54}) || // UTF-8 BOM and "WEBVTT" bytes.Equal(raw, []byte{0x57, 0x45, 0x42, 0x56, 0x54, 0x54}) // "WEBVTT" } + +type rfc822Hint struct { + h []byte + matchFlags scan.Flags +} + +// The hints come from libmagic, but the implementation is bit different. libmagic +// only checks if the file starts with the hint, while we additionally look for +// a secondary hint in the first few lines of input. +func RFC822(raw []byte, limit uint32) bool { + b := scan.Bytes(raw) + + // Keep hints here to avoid instantiating them several times in lineHasRFC822Hint. + // The alternative is to make them a package level var, but then they'd go + // on the heap. + // Some of the hints are IgnoreCase, some not. I selected based on what libmagic + // does and based on personal observations from sample files. + hints := []rfc822Hint{ + {[]byte("From: "), 0}, + {[]byte("To: "), 0}, + {[]byte("CC: "), scan.IgnoreCase}, + {[]byte("Date: "), 0}, + {[]byte("Subject: "), 0}, + {[]byte("Received: "), 0}, + {[]byte("Relay-Version: "), 0}, + {[]byte("#! rnews"), 0}, + {[]byte("N#! rnews"), 0}, + {[]byte("Forward to"), 0}, + {[]byte("Pipe to"), 0}, + {[]byte("DELIVERED-TO: "), scan.IgnoreCase}, + {[]byte("RETURN-PATH: "), scan.IgnoreCase}, + {[]byte("Content-Type: "), 0}, + {[]byte("Content-Transfer-Encoding: "), 0}, + } + if !lineHasRFC822Hint(b.Line(), hints) { + return false + } + for i := 0; i < 20; i++ { + if lineHasRFC822Hint(b.Line(), hints) { + return true + } + } + + return false +} + +func lineHasRFC822Hint(b scan.Bytes, hints []rfc822Hint) bool { + for _, h := range hints { + if b.Match(h.h, h.matchFlags) > -1 { + return true + } + } + return false +} diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/video.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/video.go index 830c5ed2..23e30da2 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/video.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/video.go @@ -69,9 +69,9 @@ func isFileTypeNamePresent(in []byte, flType string) bool { // vintWidth parses the variable-integer width in matroska containers func vintWidth(v int) int { - mask, max, num := 128, 8, 1 - for num < max && v&mask == 0 { - mask = mask >> 1 + mask, nTimes, num := 128, 8, 1 + for num < nTimes && v&mask == 0 { + mask >>= 1 num++ } return num diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/zip.go b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/zip.go index 31f42482..f3bfa2ac 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/magic/zip.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/magic/zip.go @@ -85,10 +85,14 @@ func Zip(raw []byte, limit uint32) bool { // (instead of relying on offsets told by the file.) func Jar(raw []byte, limit uint32) bool { return executableJar(raw) || + // First entry must be an empty META-INF directory or the manifest. + // There is no specification saying that, but the jar reader and writer + // implementations from Java do it that way. + // https://github.com/openjdk/jdk/blob/88c4678eed818cbe9380f35352e90883fed27d33/src/java.base/share/classes/java/util/jar/JarInputStream.java#L170-L173 zipHas(raw, zipEntries{{ - name: []byte("META-INF/MANIFEST.MF"), - }, { name: []byte("META-INF/"), + }, { + name: []byte("META-INF/MANIFEST.MF"), }}, 1) } @@ -127,11 +131,14 @@ type zipEntries []struct { func (z zipEntries) match(file []byte) bool { for i := range z { - if z[i].dir && bytes.HasPrefix(file, z[i].name) { - return true - } - if bytes.Equal(file, z[i].name) { - return true + if z[i].dir { + if bytes.HasPrefix(file, z[i].name) { + return true + } + } else { + if bytes.Equal(file, z[i].name) { + return true + } } } return false diff --git a/vendor/github.com/gabriel-vasile/mimetype/internal/scan/bytes.go b/vendor/github.com/gabriel-vasile/mimetype/internal/scan/bytes.go index b19a9492..552b4ead 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/internal/scan/bytes.go +++ b/vendor/github.com/gabriel-vasile/mimetype/internal/scan/bytes.go @@ -35,6 +35,19 @@ func (b *Bytes) TrimRWS() { } } +// FirstNonWS returns the first non-whitespace character from b, +// or 0x00 if no such character is found. +func (b Bytes) FirstNonWS() byte { + for i := range b { + if ByteIsWS(b[i]) { + continue + } + return b[i] + } + + return 0x00 +} + // Peek one byte from b or 0x00 if b is empty. func (b *Bytes) Peek() byte { if len(*b) > 0 { @@ -63,8 +76,8 @@ func (b *Bytes) PopN(n int) []byte { return nil } -// PopUntil will advance b until, but not including, the first occurence of stopAt -// character. If no occurence is found, then it will advance until the end of b. +// PopUntil will advance b until, but not including, the first occurrence of stopAt +// character. If no occurrence is found, then it will advance until the end of b. // The returned Bytes is a slice of all the bytes that we're advanced over. func (b *Bytes) PopUntil(stopAt ...byte) Bytes { if len(*b) == 0 { @@ -77,7 +90,7 @@ func (b *Bytes) PopUntil(stopAt ...byte) Bytes { prefix := (*b)[:i] *b = (*b)[i:] - return Bytes(prefix) + return prefix } // ReadSlice is the same as PopUntil, but the returned value includes stopAt as well. @@ -94,7 +107,7 @@ func (b *Bytes) ReadSlice(stopAt byte) Bytes { prefix := (*b)[:i] *b = (*b)[i:] - return Bytes(prefix) + return prefix } // Line returns the first line from b and advances b with the length of the @@ -117,7 +130,7 @@ func (b *Bytes) Line() Bytes { // If b length is less than readLimit, it means we received an incomplete file // and proceed with dropping the last line. func (b *Bytes) DropLastLine(readLimit uint32) { - if readLimit == 0 || uint32(len(*b)) < readLimit { + if readLimit == 0 || uint64(len(*b)) < uint64(readLimit) { return } @@ -151,7 +164,7 @@ const ( FullWord ) -// Search for occurences of pattern p inside b at any index. +// Search for occurrences of pattern p inside b at any index. // It returns the index where p was found in b and how many bytes were needed // for matching the pattern. func (b Bytes) Search(p []byte, flags Flags) (i int, l int) { diff --git a/vendor/github.com/gabriel-vasile/mimetype/mime.go b/vendor/github.com/gabriel-vasile/mimetype/mime.go index ec2bc5bf..3dadf720 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/mime.go +++ b/vendor/github.com/gabriel-vasile/mimetype/mime.go @@ -2,6 +2,7 @@ package mimetype import ( "mime" + "slices" "strings" "github.com/gabriel-vasile/mimetype/internal/charset" @@ -58,10 +59,8 @@ func (m *MIME) Is(expectedMIME string) bool { return true } - for _, alias := range m.aliases { - if alias == expectedMIME { - return true - } + if slices.Contains(m.aliases, expectedMIME) { + return true } return false @@ -180,10 +179,8 @@ func (m *MIME) lookup(mime string) *MIME { if mime == m.mime { return m } - for _, n := range m.aliases { - if n == mime { - return m - } + if slices.Contains(m.aliases, mime) { + return m } for _, c := range m.children { diff --git a/vendor/github.com/gabriel-vasile/mimetype/supported_mimes.md b/vendor/github.com/gabriel-vasile/mimetype/supported_mimes.md index 241a81f4..45de7b9e 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/supported_mimes.md +++ b/vendor/github.com/gabriel-vasile/mimetype/supported_mimes.md @@ -1,4 +1,4 @@ -## 192 Supported MIME types +## 195 Supported MIME types This file is automatically generated when running tests. Do not edit manually. Extension | MIME type
Aliases | Hierarchy @@ -152,6 +152,8 @@ Extension | MIME type
Aliases | Hierarchy **.chm** | **application/vnd.ms-htmlhelp** | chm>root **.wpd** | **application/vnd.wordperfect** | wpd>root **.dxf** | **image/vnd.dxf** | dxf>root +**.grb** | **application/grib** | grb>root +**n/a** | **application/zlib** | zlib>root **.txt** | **text/plain** | txt>root **.svg** | **image/svg+xml** | svg>txt>root **.html** | **text/html** | html>txt>root @@ -195,3 +197,4 @@ Extension | MIME type
Aliases | Hierarchy **.pgm** | **image/x-portable-graymap** | pgm>txt>root **.ppm** | **image/x-portable-pixmap** | ppm>txt>root **.pam** | **image/x-portable-arbitrarymap** | pam>txt>root +**.eml** | **message/rfc822** | eml>txt>root diff --git a/vendor/github.com/gabriel-vasile/mimetype/tree.go b/vendor/github.com/gabriel-vasile/mimetype/tree.go index 21b70d5c..29ef820b 100644 --- a/vendor/github.com/gabriel-vasile/mimetype/tree.go +++ b/vendor/github.com/gabriel-vasile/mimetype/tree.go @@ -24,7 +24,7 @@ var root = newMIME("application/octet-stream", "", woff2, otf, ttc, eot, wasm, shx, dbf, dcm, rar, djvu, mobi, lit, bpg, cbor, sqlite3, dwg, nes, lnk, macho, qcp, icns, hdr, mrc, mdb, accdb, zstd, cab, rpm, xz, lzip, torrent, cpio, tzif, xcf, pat, gbr, glb, cabIS, jxr, parquet, - oneNote, chm, wpd, dxf, + oneNote, chm, wpd, dxf, grib, zlib, // Keep text last because it is the slowest check. text, ) @@ -82,7 +82,7 @@ var ( alias("application/x-ogg") oggAudio = newMIME("audio/ogg", ".oga", magic.OggAudio) oggVideo = newMIME("video/ogg", ".ogv", magic.OggVideo) - text = newMIME("text/plain", ".txt", magic.Text, svg, html, xml, php, js, lua, perl, python, ruby, json, ndJSON, rtf, srt, tcl, csv, tsv, vCard, iCalendar, warc, vtt, shell, netpbm, netpgm, netppm, netpam) + text = newMIME("text/plain", ".txt", magic.Text, svg, html, xml, php, js, lua, perl, python, ruby, json, ndJSON, rtf, srt, tcl, csv, tsv, vCard, iCalendar, warc, vtt, shell, netpbm, netpgm, netppm, netpam, rfc822) xml = newMIME("text/xml", ".xml", magic.XML, rss, atom, x3d, kml, xliff, collada, gml, gpx, tcx, amf, threemf, xfdf, owl2, xhtml). alias("application/xml") xhtml = newMIME("application/xhtml+xml", ".html", magic.XHTML) @@ -287,4 +287,7 @@ var ( chm = newMIME("application/vnd.ms-htmlhelp", ".chm", magic.CHM) wpd = newMIME("application/vnd.wordperfect", ".wpd", magic.WPD) dxf = newMIME("image/vnd.dxf", ".dxf", magic.DXF) + rfc822 = newMIME("message/rfc822", ".eml", magic.RFC822) + grib = newMIME("application/grib", ".grb", magic.GRIB) + zlib = newMIME("application/zlib", "", magic.Zlib) ) diff --git a/vendor/github.com/go-playground/validator/v10/.golangci.yaml b/vendor/github.com/go-playground/validator/v10/.golangci.yaml index dd9c05cc..96337d6c 100644 --- a/vendor/github.com/go-playground/validator/v10/.golangci.yaml +++ b/vendor/github.com/go-playground/validator/v10/.golangci.yaml @@ -32,6 +32,7 @@ linters: - maintidx - misspell - mnd + - modernize - nakedret - nestif - nilnil diff --git a/vendor/github.com/go-playground/validator/v10/README.md b/vendor/github.com/go-playground/validator/v10/README.md index cb5d4194..16b16d8d 100644 --- a/vendor/github.com/go-playground/validator/v10/README.md +++ b/vendor/github.com/go-playground/validator/v10/README.md @@ -137,6 +137,7 @@ validate := validator.New(validator.WithRequiredStructEnabled()) | alpha | Alpha Only | | alphaspace | Alpha Space | | alphanum | Alphanumeric | +| alphanumspace | Alphanumeric Space | | alphanumunicode | Alphanumeric Unicode | | alphaunicode | Alpha Unicode | | ascii | ASCII | @@ -164,7 +165,8 @@ validate := validator.New(validator.WithRequiredStructEnabled()) | base64 | Base64 String | | base64url | Base64URL String | | base64rawurl | Base64RawURL String | -| bic | Business Identifier Code (ISO 9362) | +| bic_iso_9362_2014 | Business Identifier Code (ISO 9362:2014) | +| bic | Business Identifier Code (ISO 9362:2022) | | bcp47_language_tag | Language tag (BCP 47) | | btc_addr | Bitcoin Address | | btc_addr_bech32 | Bitcoin Bech32 Address (segwit) | diff --git a/vendor/github.com/go-playground/validator/v10/baked_in.go b/vendor/github.com/go-playground/validator/v10/baked_in.go index 8fd55e77..e90c98e4 100644 --- a/vendor/github.com/go-playground/validator/v10/baked_in.go +++ b/vendor/github.com/go-playground/validator/v10/baked_in.go @@ -120,6 +120,7 @@ var ( "alpha": isAlpha, "alphaspace": isAlphaSpace, "alphanum": isAlphanum, + "alphanumspace": isAlphaNumericSpace, "alphaunicode": isAlphaUnicode, "alphanumunicode": isAlphanumUnicode, "boolean": isBoolean, @@ -237,7 +238,8 @@ var ( "bcp47_language_tag": isBCP47LanguageTag, "postcode_iso3166_alpha2": isPostcodeByIso3166Alpha2, "postcode_iso3166_alpha2_field": isPostcodeByIso3166Alpha2Field, - "bic": isIsoBicFormat, + "bic_iso_9362_2014": isIsoBic2014Format, + "bic": isIsoBic2022Format, "semver": isSemverFormat, "dns_rfc1035_label": isDnsRFC1035LabelFormat, "credit_card": isCreditCard, @@ -533,12 +535,20 @@ func hasMultiByteCharacter(fl FieldLevel) bool { // isPrintableASCII is the validation function for validating if the field's value is a valid printable ASCII character. func isPrintableASCII(fl FieldLevel) bool { - return printableASCIIRegex().MatchString(fl.Field().String()) + field := fl.Field() + if field.Kind() == reflect.String { + return printableASCIIRegex().MatchString(field.String()) + } + return false } // isASCII is the validation function for validating if the field's value is a valid ASCII character. func isASCII(fl FieldLevel) bool { - return aSCIIRegex().MatchString(fl.Field().String()) + field := fl.Field() + if field.Kind() == reflect.String { + return aSCIIRegex().MatchString(field.String()) + } + return false } // isUUID5 is the validation function for validating if the field's value is a valid v5 UUID. @@ -1773,6 +1783,11 @@ func isAlphaSpace(fl FieldLevel) bool { return alphaSpaceRegex().MatchString(fl.Field().String()) } +// isAlphaNumericSpace is the validation function for validating if the current field's value is a valid alphanumeric value with spaces. +func isAlphaNumericSpace(fl FieldLevel) bool { + return alphanNumericSpaceRegex().MatchString(fl.Field().String()) +} + // isAlphaUnicode is the validation function for validating if the current field's value is a valid alpha unicode value. func isAlphaUnicode(fl FieldLevel) bool { return alphaUnicodeRegex().MatchString(fl.Field().String()) @@ -1974,11 +1989,12 @@ func excludedUnless(fl FieldLevel) bool { panic(fmt.Sprintf("Bad param number for excluded_unless %s", fl.FieldName())) } for i := 0; i < len(params); i += 2 { - if !requireCheckFieldValue(fl, params[i], params[i+1], false) { - return !hasValue(fl) + if requireCheckFieldValue(fl, params[i], params[i+1], false) { + return true } } - return true + + return !hasValue(fl) } // excludedWith is the validation function @@ -2943,11 +2959,18 @@ func isBCP47LanguageTag(fl FieldLevel) bool { panic(fmt.Sprintf("Bad field type %s", field.Type())) } -// isIsoBicFormat is the validation function for validating if the current field's value is a valid Business Identifier Code (SWIFT code), defined in ISO 9362 -func isIsoBicFormat(fl FieldLevel) bool { +// isIsoBic2014Format is the validation function for validating if the current field's value is a valid Business Identifier Code (SWIFT code), defined in ISO 9362 2014 +func isIsoBic2014Format(fl FieldLevel) bool { + bicString := fl.Field().String() + + return bic2014Regex().MatchString(bicString) +} + +// isIsoBic2022Format is the validation function for validating if the current field's value is a valid Business Identifier Code (SWIFT code), defined in ISO 9362 2022 +func isIsoBic2022Format(fl FieldLevel) bool { bicString := fl.Field().String() - return bicRegex().MatchString(bicString) + return bic2022Regex().MatchString(bicString) } // isSemverFormat is the validation function for validating if the current field's value is a valid semver version, defined in Semantic Versioning 2.0.0 diff --git a/vendor/github.com/go-playground/validator/v10/currency_codes.go b/vendor/github.com/go-playground/validator/v10/currency_codes.go index d0317f89..83b67290 100644 --- a/vendor/github.com/go-playground/validator/v10/currency_codes.go +++ b/vendor/github.com/go-playground/validator/v10/currency_codes.go @@ -10,33 +10,33 @@ var iso4217 = map[string]struct{}{ "BIF": {}, "CVE": {}, "KHR": {}, "XAF": {}, "CAD": {}, "KYD": {}, "CLP": {}, "CLF": {}, "CNY": {}, "COP": {}, "COU": {}, "KMF": {}, "CDF": {}, "NZD": {}, "CRC": {}, - "HRK": {}, "CUP": {}, "CUC": {}, "ANG": {}, "CZK": {}, - "DKK": {}, "DJF": {}, "DOP": {}, "EGP": {}, "SVC": {}, - "ERN": {}, "SZL": {}, "ETB": {}, "FKP": {}, "FJD": {}, - "XPF": {}, "GMD": {}, "GEL": {}, "GHS": {}, "GIP": {}, - "GTQ": {}, "GBP": {}, "GNF": {}, "GYD": {}, "HTG": {}, - "HNL": {}, "HKD": {}, "HUF": {}, "ISK": {}, "IDR": {}, - "XDR": {}, "IRR": {}, "IQD": {}, "ILS": {}, "JMD": {}, - "JPY": {}, "JOD": {}, "KZT": {}, "KES": {}, "KPW": {}, - "KRW": {}, "KWD": {}, "KGS": {}, "LAK": {}, "LBP": {}, - "LSL": {}, "ZAR": {}, "LRD": {}, "LYD": {}, "CHF": {}, - "MOP": {}, "MKD": {}, "MGA": {}, "MWK": {}, "MYR": {}, - "MVR": {}, "MRU": {}, "MUR": {}, "XUA": {}, "MXN": {}, - "MXV": {}, "MDL": {}, "MNT": {}, "MAD": {}, "MZN": {}, - "MMK": {}, "NAD": {}, "NPR": {}, "NIO": {}, "NGN": {}, - "OMR": {}, "PKR": {}, "PAB": {}, "PGK": {}, "PYG": {}, - "PEN": {}, "PHP": {}, "PLN": {}, "QAR": {}, "RON": {}, - "RUB": {}, "RWF": {}, "SHP": {}, "WST": {}, "STN": {}, - "SAR": {}, "RSD": {}, "SCR": {}, "SLL": {}, "SGD": {}, - "XSU": {}, "SBD": {}, "SOS": {}, "SSP": {}, "LKR": {}, - "SDG": {}, "SRD": {}, "SEK": {}, "CHE": {}, "CHW": {}, - "SYP": {}, "TWD": {}, "TJS": {}, "TZS": {}, "THB": {}, - "TOP": {}, "TTD": {}, "TND": {}, "TRY": {}, "TMT": {}, - "UGX": {}, "UAH": {}, "AED": {}, "USN": {}, "UYU": {}, - "UYI": {}, "UYW": {}, "UZS": {}, "VUV": {}, "VES": {}, - "VND": {}, "YER": {}, "ZMW": {}, "ZWL": {}, "XBA": {}, - "XBB": {}, "XBC": {}, "XBD": {}, "XTS": {}, "XXX": {}, - "XAU": {}, "XPD": {}, "XPT": {}, "XAG": {}, + "CUP": {}, "CZK": {}, "DKK": {}, "DJF": {}, "DOP": {}, + "EGP": {}, "SVC": {}, "ERN": {}, "SZL": {}, "ETB": {}, + "FKP": {}, "FJD": {}, "XPF": {}, "GMD": {}, "GEL": {}, + "GHS": {}, "GIP": {}, "GTQ": {}, "GBP": {}, "GNF": {}, + "GYD": {}, "HTG": {}, "HNL": {}, "HKD": {}, "HUF": {}, + "ISK": {}, "IDR": {}, "XDR": {}, "IRR": {}, "IQD": {}, + "ILS": {}, "JMD": {}, "JPY": {}, "JOD": {}, "KZT": {}, + "KES": {}, "KPW": {}, "KRW": {}, "KWD": {}, "KGS": {}, + "LAK": {}, "LBP": {}, "LSL": {}, "ZAR": {}, "LRD": {}, + "LYD": {}, "CHF": {}, "MOP": {}, "MKD": {}, "MGA": {}, + "MWK": {}, "MYR": {}, "MVR": {}, "MRU": {}, "MUR": {}, + "XUA": {}, "MXN": {}, "MXV": {}, "MDL": {}, "MNT": {}, + "MAD": {}, "MZN": {}, "MMK": {}, "NAD": {}, "NPR": {}, + "NIO": {}, "NGN": {}, "OMR": {}, "PKR": {}, "PAB": {}, + "PGK": {}, "PYG": {}, "PEN": {}, "PHP": {}, "PLN": {}, + "QAR": {}, "RON": {}, "RUB": {}, "RWF": {}, "SHP": {}, + "WST": {}, "STN": {}, "SAR": {}, "RSD": {}, "SCR": {}, + "SLE": {}, "SGD": {}, "XSU": {}, "SBD": {}, "SOS": {}, + "SSP": {}, "LKR": {}, "SDG": {}, "SRD": {}, "SEK": {}, + "CHE": {}, "CHW": {}, "SYP": {}, "TWD": {}, "TJS": {}, + "TZS": {}, "THB": {}, "TOP": {}, "TTD": {}, "TND": {}, + "TRY": {}, "TMT": {}, "UGX": {}, "UAH": {}, "AED": {}, + "USN": {}, "UYU": {}, "UYI": {}, "UYW": {}, "UZS": {}, + "VUV": {}, "VES": {}, "VED": {}, "VND": {}, "YER": {}, + "ZMW": {}, "ZWG": {}, "XBA": {}, "XBB": {}, "XBC": {}, + "XBD": {}, "XCG": {}, "XTS": {}, "XXX": {}, "XAU": {}, + "XPD": {}, "XPT": {}, "XAG": {}, } var iso4217_numeric = map[int]struct{}{ @@ -45,35 +45,35 @@ var iso4217_numeric = map[int]struct{}{ 64: {}, 68: {}, 72: {}, 84: {}, 90: {}, 96: {}, 104: {}, 108: {}, 116: {}, 124: {}, 132: {}, 136: {}, 144: {}, 152: {}, 156: {}, - 170: {}, 174: {}, 188: {}, 191: {}, 192: {}, - 203: {}, 208: {}, 214: {}, 222: {}, 230: {}, - 232: {}, 238: {}, 242: {}, 262: {}, 270: {}, - 292: {}, 320: {}, 324: {}, 328: {}, 332: {}, - 340: {}, 344: {}, 348: {}, 352: {}, 356: {}, - 360: {}, 364: {}, 368: {}, 376: {}, 388: {}, - 392: {}, 398: {}, 400: {}, 404: {}, 408: {}, - 410: {}, 414: {}, 417: {}, 418: {}, 422: {}, - 426: {}, 430: {}, 434: {}, 446: {}, 454: {}, - 458: {}, 462: {}, 480: {}, 484: {}, 496: {}, - 498: {}, 504: {}, 512: {}, 516: {}, 524: {}, - 532: {}, 533: {}, 548: {}, 554: {}, 558: {}, - 566: {}, 578: {}, 586: {}, 590: {}, 598: {}, - 600: {}, 604: {}, 608: {}, 634: {}, 643: {}, - 646: {}, 654: {}, 682: {}, 690: {}, 694: {}, - 702: {}, 704: {}, 706: {}, 710: {}, 728: {}, - 748: {}, 752: {}, 756: {}, 760: {}, 764: {}, - 776: {}, 780: {}, 784: {}, 788: {}, 800: {}, - 807: {}, 818: {}, 826: {}, 834: {}, 840: {}, - 858: {}, 860: {}, 882: {}, 886: {}, 901: {}, - 927: {}, 928: {}, 929: {}, 930: {}, 931: {}, - 932: {}, 933: {}, 934: {}, 936: {}, 938: {}, - 940: {}, 941: {}, 943: {}, 944: {}, 946: {}, - 947: {}, 948: {}, 949: {}, 950: {}, 951: {}, - 952: {}, 953: {}, 955: {}, 956: {}, 957: {}, - 958: {}, 959: {}, 960: {}, 961: {}, 962: {}, - 963: {}, 964: {}, 965: {}, 967: {}, 968: {}, - 969: {}, 970: {}, 971: {}, 972: {}, 973: {}, - 975: {}, 976: {}, 977: {}, 978: {}, 979: {}, - 980: {}, 981: {}, 984: {}, 985: {}, 986: {}, - 990: {}, 994: {}, 997: {}, 999: {}, + 170: {}, 174: {}, 188: {}, 192: {}, 203: {}, + 208: {}, 214: {}, 222: {}, 230: {}, 232: {}, + 238: {}, 242: {}, 262: {}, 270: {}, 292: {}, + 320: {}, 324: {}, 328: {}, 332: {}, 340: {}, + 344: {}, 348: {}, 352: {}, 356: {}, 360: {}, + 364: {}, 368: {}, 376: {}, 388: {}, 392: {}, + 398: {}, 400: {}, 404: {}, 408: {}, 410: {}, + 414: {}, 417: {}, 418: {}, 422: {}, 426: {}, + 430: {}, 434: {}, 446: {}, 454: {}, 458: {}, + 462: {}, 480: {}, 484: {}, 496: {}, 498: {}, + 504: {}, 512: {}, 516: {}, 524: {}, 532: {}, + 533: {}, 548: {}, 554: {}, 558: {}, 566: {}, + 578: {}, 586: {}, 590: {}, 598: {}, 600: {}, + 604: {}, 608: {}, 634: {}, 643: {}, 646: {}, + 654: {}, 682: {}, 690: {}, 702: {}, 704: {}, + 706: {}, 710: {}, 728: {}, 748: {}, 752: {}, + 756: {}, 760: {}, 764: {}, 776: {}, 780: {}, + 784: {}, 788: {}, 800: {}, 807: {}, 818: {}, + 826: {}, 834: {}, 840: {}, 858: {}, 860: {}, + 882: {}, 886: {}, 901: {}, 924: {}, 925: {}, + 926: {}, 927: {}, 928: {}, 929: {}, 930: {}, + 933: {}, 934: {}, 936: {}, 938: {}, 940: {}, + 941: {}, 943: {}, 944: {}, 946: {}, 947: {}, + 948: {}, 949: {}, 950: {}, 951: {}, 952: {}, + 953: {}, 955: {}, 956: {}, 957: {}, 958: {}, + 959: {}, 960: {}, 961: {}, 962: {}, 963: {}, + 964: {}, 965: {}, 967: {}, 968: {}, 969: {}, + 970: {}, 971: {}, 972: {}, 973: {}, 975: {}, + 976: {}, 977: {}, 978: {}, 979: {}, 980: {}, + 981: {}, 984: {}, 985: {}, 986: {}, 990: {}, + 994: {}, 997: {}, 999: {}, } diff --git a/vendor/github.com/go-playground/validator/v10/doc.go b/vendor/github.com/go-playground/validator/v10/doc.go index 52918e40..612bcf55 100644 --- a/vendor/github.com/go-playground/validator/v10/doc.go +++ b/vendor/github.com/go-playground/validator/v10/doc.go @@ -789,6 +789,12 @@ This validates that a string value contains ASCII alphanumeric characters only Usage: alphanum +# Alphanumeric Space + +This validates that a string value contains ASCII alphanumeric characters and spaces only + + Usage: alphanumspace + # Alpha Unicode This validates that a string value contains unicode alpha characters only @@ -1378,13 +1384,20 @@ More information on https://pkg.go.dev/golang.org/x/text/language Usage: bcp47_language_tag -BIC (SWIFT code) +BIC (SWIFT code - 2022 standard) -This validates that a string value is a valid Business Identifier Code (SWIFT code), defined in ISO 9362. -More information on https://www.iso.org/standard/60390.html +This validates that a string value is a valid Business Identifier Code (SWIFT code), defined in ISO 9362:2022. +More information on https://www.iso.org/standard/84108.html Usage: bic +BIC (SWIFT code - 2014 standard) + +This validates that a string value is a valid Business Identifier Code (SWIFT code), defined in ISO 9362:2014. +More information on https://www.iso.org/standard/60390.html + + Usage: bic_iso_9362_2014 + # RFC 1035 label This validates that a string value is a valid dns RFC 1035 label, defined in RFC 1035. @@ -1519,7 +1532,7 @@ This package panics when bad input is provided, this is by design, bad code like that should not make it to production. type Test struct { - TestField string `validate:"nonexistantfunction=1"` + TestField string `validate:"nonexistentfunction=1"` } t := &Test{ diff --git a/vendor/github.com/go-playground/validator/v10/regexes.go b/vendor/github.com/go-playground/validator/v10/regexes.go index 0b3615f5..6b564b6f 100644 --- a/vendor/github.com/go-playground/validator/v10/regexes.go +++ b/vendor/github.com/go-playground/validator/v10/regexes.go @@ -9,6 +9,7 @@ const ( alphaRegexString = "^[a-zA-Z]+$" alphaSpaceRegexString = "^[a-zA-Z ]+$" alphaNumericRegexString = "^[a-zA-Z0-9]+$" + alphaNumericSpaceRegexString = "^[a-zA-Z0-9 ]+$" alphaUnicodeRegexString = "^[\\p{L}]+$" alphaUnicodeNumericRegexString = "^[\\p{L}\\p{N}]+$" numericRegexString = "^[-+]?[0-9]+(?:\\.[0-9]+)?$" @@ -20,7 +21,7 @@ const ( hslRegexString = "^hsl\\(\\s*(?:0|[1-9]\\d?|[12]\\d\\d|3[0-5]\\d|360)\\s*,\\s*(?:(?:0|[1-9]\\d?|100)%)\\s*,\\s*(?:(?:0|[1-9]\\d?|100)%)\\s*\\)$" hslaRegexString = "^hsla\\(\\s*(?:0|[1-9]\\d?|[12]\\d\\d|3[0-5]\\d|360)\\s*,\\s*(?:(?:0|[1-9]\\d?|100)%)\\s*,\\s*(?:(?:0|[1-9]\\d?|100)%)\\s*,\\s*(?:(?:0.[1-9]*)|[01])\\s*\\)$" emailRegexString = "^(?:(?:(?:(?:[a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+(?:\\.([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+)*)|(?:(?:\\x22)(?:(?:(?:(?:\\x20|\\x09)*(?:\\x0d\\x0a))?(?:\\x20|\\x09)+)?(?:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}]))))*(?:(?:(?:\\x20|\\x09)*(?:\\x0d\\x0a))?(\\x20|\\x09)+)?(?:\\x22))))@(?:(?:(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])(?:[a-zA-Z]|\\d|-|\\.|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.)+(?:(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])(?:[a-zA-Z]|\\d|-|\\.|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.?$" - e164RegexString = "^\\+[1-9]?[0-9]{7,14}$" + e164RegexString = "^\\+?[1-9]\\d{1,14}$" base32RegexString = "^(?:[A-Z2-7]{8})*(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}=|[A-Z2-7]{8})$" base64RegexString = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$" base64URLRegexString = "^(?:[A-Za-z0-9-_]{4})*(?:[A-Za-z0-9-_]{2}==|[A-Za-z0-9-_]{3}=|[A-Za-z0-9-_]{4})$" @@ -68,7 +69,8 @@ const ( hTMLRegexString = `<[/]?([a-zA-Z]+).*?>` jWTRegexString = "^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$" splitParamsRegexString = `'[^']*'|\S+` - bicRegexString = `^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$` + bic2014RegexString = `^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$` + bic2022RegexString = `^[A-Z0-9]{4}[A-Z]{2}[A-Z0-9]{2}(?:[A-Z0-9]{3})?$` semverRegexString = `^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$` // numbered capture groups https://semver.org/ dnsRegexStringRFC1035Label = "^[a-z]([-a-z0-9]*[a-z0-9])?$" cveRegexString = `^CVE-(1999|2\d{3})-(0[^0]\d{2}|0\d[^0]\d{1}|0\d{2}[^0]|[1-9]{1}\d{3,})$` // CVE Format Id https://cve.mitre.org/cve/identifiers/syntaxchange.html @@ -95,6 +97,7 @@ func lazyRegexCompile(str string) func() *regexp.Regexp { var ( alphaRegex = lazyRegexCompile(alphaRegexString) alphaSpaceRegex = lazyRegexCompile(alphaSpaceRegexString) + alphanNumericSpaceRegex = lazyRegexCompile(alphaNumericSpaceRegexString) alphaNumericRegex = lazyRegexCompile(alphaNumericRegexString) alphaUnicodeRegex = lazyRegexCompile(alphaUnicodeRegexString) alphaUnicodeNumericRegex = lazyRegexCompile(alphaUnicodeNumericRegexString) @@ -153,7 +156,8 @@ var ( hTMLRegex = lazyRegexCompile(hTMLRegexString) jWTRegex = lazyRegexCompile(jWTRegexString) splitParamsRegex = lazyRegexCompile(splitParamsRegexString) - bicRegex = lazyRegexCompile(bicRegexString) + bic2014Regex = lazyRegexCompile(bic2014RegexString) + bic2022Regex = lazyRegexCompile(bic2022RegexString) semverRegex = lazyRegexCompile(semverRegexString) dnsRegexRFC1035Label = lazyRegexCompile(dnsRegexStringRFC1035Label) cveRegex = lazyRegexCompile(cveRegexString) diff --git a/vendor/github.com/itchyny/gojq/CHANGELOG.md b/vendor/github.com/itchyny/gojq/CHANGELOG.md index a10c4858..d2acbff0 100644 --- a/vendor/github.com/itchyny/gojq/CHANGELOG.md +++ b/vendor/github.com/itchyny/gojq/CHANGELOG.md @@ -1,4 +1,18 @@ # Changelog +## [v0.12.18](https://github.com/itchyny/gojq/compare/v0.12.17..v0.12.18) (2025-12-02) +* implement `trimstr/1`, `toboolean/0` function +* fix `last/1` to be included in `builtins/0` +* fix `--indent 0` to preserve newlines +* fix string repetition to emit error when the result is too large +* increase the array index limit to 536870912 (`2^29`) +* stop numeric normalization for concurrent execution (see 1ace748d08df) +* support binding expressions with binary operators (`1 + 2 as $x | -$x`) +* improve `gojq.NewIter` to be a generic function +* improve logic for getting file contents on JSON parse error +* improve JSON parsing to preserve the precision of floating-point numbers +* improve YAML parsing performance and preserve the precision of large integers +* improve performance and reduce memory allocation of long-running queries + ## [v0.12.17](https://github.com/itchyny/gojq/compare/v0.12.16..v0.12.17) (2024-12-01) * implement `add/1`, `skip/2` functions * implement `--library-path` option as the alias of `-L` option diff --git a/vendor/github.com/itchyny/gojq/Dockerfile b/vendor/github.com/itchyny/gojq/Dockerfile index 96a14e99..cf6a9a35 100644 --- a/vendor/github.com/itchyny/gojq/Dockerfile +++ b/vendor/github.com/itchyny/gojq/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.23 AS builder +FROM golang:1.25 AS builder WORKDIR /app COPY go.* ./ diff --git a/vendor/github.com/itchyny/gojq/LICENSE b/vendor/github.com/itchyny/gojq/LICENSE index fe590040..5eeaeebb 100644 --- a/vendor/github.com/itchyny/gojq/LICENSE +++ b/vendor/github.com/itchyny/gojq/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019-2024 itchyny +Copyright (c) 2019-2025 itchyny Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/github.com/itchyny/gojq/Makefile b/vendor/github.com/itchyny/gojq/Makefile index 15ace7d7..e91f2c6d 100644 --- a/vendor/github.com/itchyny/gojq/Makefile +++ b/vendor/github.com/itchyny/gojq/Makefile @@ -89,9 +89,8 @@ clean: .PHONY: update update: export GOPROXY=direct update: - go get -u ./... && go mod tidy - go mod edit -modfile=go.dev.mod -droprequire=github.com/itchyny/{astgen,timefmt}-go - go get -u -modfile=go.dev.mod github.com/itchyny/{astgen,timefmt}-go && go generate + go get -u ./... && go get github.com/itchyny/go-yaml@gojq && go mod tidy + rm go.dev.sum && go get -u -modfile=go.dev.mod github.com/itchyny/{astgen,timefmt}-go && go generate .PHONY: bump bump: $(GOBIN)/gobump diff --git a/vendor/github.com/itchyny/gojq/README.md b/vendor/github.com/itchyny/gojq/README.md index 7b34f93c..98709ee0 100644 --- a/vendor/github.com/itchyny/gojq/README.md +++ b/vendor/github.com/itchyny/gojq/README.md @@ -74,12 +74,11 @@ docker run -i --rm ghcr.io/itchyny/gojq ## Difference to jq - gojq is purely implemented with Go language and is completely portable. jq depends on the C standard library so the availability of math functions depends on the library. jq also depends on the regular expression library and it makes build scripts complex. -- gojq implements nice error messages for invalid query and JSON input. The error message of jq is sometimes difficult to tell where to fix the query. - gojq does not keep the order of object keys. I understand this might cause problems for some scripts but basically, we should not rely on the order of object keys. Due to this limitation, gojq does not have `keys_unsorted` function and `--sort-keys` (`-S`) option. I would implement when ordered map is implemented in the standard library of Go but I'm less motivated. - gojq supports arbitrary-precision integer calculation while jq does not; jq loses the precision of large integers when calculation is involved. Note that even with gojq, all mathematical functions, including `floor` and `round`, convert integers to floating-point numbers; only addition, subtraction, multiplication, modulo, and division operators (when divisible) keep the integer precision. To calculate floor division of integers without losing the precision, use `def idivide($n): (. - . % $n) / $n;`. To round down floating-point numbers to integers, use `def ifloor: floor | tostring | tonumber;`, but note that this function does not work with large floating-point numbers and also loses the precision of large integers. -- gojq behaves differently than jq in some features, hoping that jq will fix the behaviors in the future. gojq consistently counts by characters (not by bytes) in `index`, `rindex`, and `indices` functions; `"12345" | .[index("3"):]` results in `"345"` ([jq#1430](https://github.com/jqlang/jq/issues/1430), [jq#1624](https://github.com/jqlang/jq/issues/1624)). gojq supports string indexing; `"abcde"[2]` ([jq#1520](https://github.com/jqlang/jq/issues/1520)). gojq fixes handling files with no newline characters at the end ([jq#2374](https://github.com/jqlang/jq/issues/2374)). gojq consistently truncates down floating-point number indices both in indexing (`[0] | .[0.5]` results in `0`), and slicing (`[0,1,2] | .[0.5:1.5]` results in `[0]`). gojq parses unary operators with higher precedence than variable binding (`[-1 as $x | 1,$x]` results in `[1,-1]` not `[-1,-1]`) ([jq#3053](https://github.com/jqlang/jq/pull/3053)). gojq fixes `@base64d` to allow binary string as the decoded string ([jq#1931](https://github.com/jqlang/jq/issues/1931)). gojq improves time formatting and parsing; deals with `%f` in `strftime` and `strptime` ([jq#1409](https://github.com/jqlang/jq/issues/1409)), parses timezone offsets with `fromdate` and `fromdateiso8601` ([jq#1053](https://github.com/jqlang/jq/issues/1053)), supports timezone name/offset with `%Z`/`%z` in `strptime` ([jq#929](https://github.com/jqlang/jq/issues/929), [jq#2195](https://github.com/jqlang/jq/issues/2195)), and looks up correct timezone during daylight saving time on formatting with `%Z` ([jq#1912](https://github.com/jqlang/jq/issues/1912)). gojq supports nanoseconds in date and time functions. -- gojq does not support some functions intentionally; `get_jq_origin`, `get_prog_origin`, `get_search_list` (unstable, not listed in jq document), `input_line_number`, `$__loc__` (performance issue). gojq does not support some flags; `--ascii-output, -a` (performance issue), `--seq` (not used commonly), `--sort-keys, -S` (sorts by default because `map[string]any` does not keep the order), `--unbuffered` (unbuffered by default). gojq does not parse JSON extensions supported by jq; `NaN`, `Infinity`, and `[000]`. gojq normalizes floating-point numbers to fit to double-precision floating-point numbers. gojq does not support some regular expression metacharacters, backreferences, look-around assertions, and some flags (regular expression engine differences). gojq does not support BOM (`encoding/json` does not support this). gojq disallows using keywords for function names (`def true: .; true` is a confusing query), and module name prefixes in function declarations (using module prefixes like `def m::f: .;` is undocumented). -- gojq supports reading from YAML input (`--yaml-input`) while jq does not. gojq also supports YAML output (`--yaml-output`). gojq supports `@urid` format string ([jq#798](https://github.com/jqlang/jq/issues/798), [jq#2261](https://github.com/jqlang/jq/issues/2261)). +- gojq behaves differently than jq in some features, expecting jq to fix its behavior in the future. gojq supports string indexing; `"abcde"[2]` ([jq#1520](https://github.com/jqlang/jq/issues/1520)). gojq fixes handling files with no newline characters at the end ([jq#2374](https://github.com/jqlang/jq/issues/2374)). gojq fixes `@base64d` to allow binary string as the decoded string ([jq#1931](https://github.com/jqlang/jq/issues/1931)). gojq improves time formatting and parsing; deals with `%f` in `strftime` and `strptime` ([jq#1409](https://github.com/jqlang/jq/issues/1409)), parses timezone offsets with `fromdate` and `fromdateiso8601` ([jq#1053](https://github.com/jqlang/jq/issues/1053)), supports timezone name/offset with `%Z`/`%z` in `strptime` ([jq#929](https://github.com/jqlang/jq/issues/929), [jq#2195](https://github.com/jqlang/jq/issues/2195)). gojq supports nanoseconds in date and time functions. +- gojq does not support some functions intentionally; `get_jq_origin`, `get_prog_origin`, `get_search_list` (unstable, not listed in jq document), `input_line_number`, `$__loc__` (performance issue). gojq does not support some flags; `--ascii-output, -a` (performance issue), `--seq` (not used commonly), `--sort-keys, -S` (sorts by default because `map[string]any` does not keep the order), `--unbuffered` (unbuffered by default). gojq does not parse JSON extensions supported by jq; `NaN`, `Infinity`, and `[000]`. gojq does not support some regular expression metacharacters, backreferences, look-around assertions, and some flags (regular expression engine differences). gojq does not support BOM (`encoding/json` does not support this). gojq disallows using keywords for function names (`def true: .; true` is a confusing query), and module name prefixes in function declarations (using module prefixes like `def m::f: .;` is undocumented). +- gojq supports reading from YAML input (`--yaml-input`) while jq does not. gojq also supports YAML output (`--yaml-output`). ### Color configuration The gojq command automatically disables coloring output when the output is not a tty. @@ -130,7 +129,7 @@ func main() { - Use [`gojq.ParseError`](https://pkg.go.dev/github.com/itchyny/gojq#ParseError) to get the error position and token of the parsing error. - Secondly, get the result iterator - using [`query.Run`](https://pkg.go.dev/github.com/itchyny/gojq#Query.Run) or [`query.RunWithContext`](https://pkg.go.dev/github.com/itchyny/gojq#Query.RunWithContext) - - or alternatively, compile the query using [`gojq.Compile`](https://pkg.go.dev/github.com/itchyny/gojq#Compile) and then [`code.Run`](https://pkg.go.dev/github.com/itchyny/gojq#Code.Run) or [`code.RunWithContext`](https://pkg.go.dev/github.com/itchyny/gojq#Code.RunWithContext). You can reuse the `*Code` against multiple inputs to avoid compilation of the same query. But for arguments of `code.Run`, do not give values sharing same data between multiple calls. + - or alternatively, compile the query using [`gojq.Compile`](https://pkg.go.dev/github.com/itchyny/gojq#Compile) and then [`code.Run`](https://pkg.go.dev/github.com/itchyny/gojq#Code.Run) or [`code.RunWithContext`](https://pkg.go.dev/github.com/itchyny/gojq#Code.RunWithContext). You can reuse the `*Code` against multiple inputs to avoid compilation of the same query. - In either case, you cannot use custom type values as the query input. The type should be `[]any` for an array and `map[string]any` for a map (just like decoded to an `any` using the [encoding/json](https://golang.org/pkg/encoding/json/) package). You can't use `[]int` or `map[string]string`, for example. If you want to query your custom struct, marshal to JSON, unmarshal to `any` and use it as the query input. - Thirdly, iterate through the results using [`iter.Next() (any, bool)`](https://pkg.go.dev/github.com/itchyny/gojq#Iter). The iterator can emit an error so make sure to handle it. The method returns `true` with results, and `false` when the iterator terminates. - The return type is not `(any, error)` because the iterator may emit multiple errors. The `jq` and `gojq` commands stop the iteration on the first error, but the library user can choose to stop the iteration on errors, or to continue until it terminates. diff --git a/vendor/github.com/itchyny/gojq/builtin.go b/vendor/github.com/itchyny/gojq/builtin.go index 8ae4666c..01344834 100644 --- a/vendor/github.com/itchyny/gojq/builtin.go +++ b/vendor/github.com/itchyny/gojq/builtin.go @@ -4,67 +4,68 @@ package gojq func init() { builtinFuncDefs = map[string][]*FuncDef{ - "IN": {{Name: "IN", Args: []string{"s"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "any", Args: []*Query{{Left: &Query{Func: "s"}, Op: OpEq, Right: &Query{Func: "."}}, {Func: "."}}}}}}, {Name: "IN", Args: []string{"src", "s"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "any", Args: []*Query{{Left: &Query{Func: "src"}, Op: OpEq, Right: &Query{Func: "s"}}, {Func: "."}}}}}}}, - "INDEX": {{Name: "INDEX", Args: []string{"stream", "idx_expr"}, Body: &Query{Term: &Term{Type: TermTypeReduce, Reduce: &Reduce{Query: &Query{Func: "stream"}, Pattern: &Pattern{Name: "$row"}, Start: &Query{Term: &Term{Type: TermTypeObject, Object: &Object{}}}, Update: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Left: &Query{Func: "$row"}, Op: OpPipe, Right: &Query{Left: &Query{Func: "idx_expr"}, Op: OpPipe, Right: &Query{Func: "tostring"}}}}}}, Op: OpAssign, Right: &Query{Func: "$row"}}}}}}, {Name: "INDEX", Args: []string{"idx_expr"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "INDEX", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, {Func: "idx_expr"}}}}}}}, - "JOIN": {{Name: "JOIN", Args: []string{"$idx", "idx_expr"}, Body: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Func: "."}, Op: OpComma, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$idx"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Func: "idx_expr"}}}}}}}}}}}}}}}, {Name: "JOIN", Args: []string{"$idx", "stream", "idx_expr"}, Body: &Query{Left: &Query{Func: "stream"}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Func: "."}, Op: OpComma, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$idx"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Func: "idx_expr"}}}}}}}}}}}}, {Name: "JOIN", Args: []string{"$idx", "stream", "idx_expr", "join_expr"}, Body: &Query{Left: &Query{Func: "stream"}, Op: OpPipe, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Func: "."}, Op: OpComma, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$idx"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Func: "idx_expr"}}}}}}}}}}, Op: OpPipe, Right: &Query{Func: "join_expr"}}}}}, + "IN": {{Name: "IN", Args: []string{"s"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "any", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "s"}}}, Right: &Query{Term: &Term{Type: TermTypeIdentity}}, Op: OpEq}, {Term: &Term{Type: TermTypeIdentity}}}}}}}, {Name: "IN", Args: []string{"src", "s"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "any", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "src"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "s"}}}, Op: OpEq}, {Term: &Term{Type: TermTypeIdentity}}}}}}}}, + "INDEX": {{Name: "INDEX", Args: []string{"stream", "idx_expr"}, Body: &Query{Term: &Term{Type: TermTypeReduce, Reduce: &Reduce{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "stream"}}}, Pattern: &Pattern{Name: "$row"}, Start: &Query{Term: &Term{Type: TermTypeObject, Object: &Object{}}}, Update: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$row"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "idx_expr"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "tostring"}}}, Op: OpPipe}, Op: OpPipe}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$row"}}}, Op: OpAssign}}}}}, {Name: "INDEX", Args: []string{"idx_expr"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "INDEX", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "idx_expr"}}}}}}}}}, + "JOIN": {{Name: "JOIN", Args: []string{"$idx", "idx_expr"}, Body: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$idx"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "idx_expr"}}}}}}}}, Op: OpComma}}}}, Op: OpPipe}}}}}, {Name: "JOIN", Args: []string{"$idx", "stream", "idx_expr"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "stream"}}}, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$idx"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "idx_expr"}}}}}}}}, Op: OpComma}}}}, Op: OpPipe}}, {Name: "JOIN", Args: []string{"$idx", "stream", "idx_expr", "join_expr"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "stream"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$idx"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "idx_expr"}}}}}}}}, Op: OpComma}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "join_expr"}}}, Op: OpPipe}, Op: OpPipe}}}, "_assign": {}, + "_last": {}, "_modify": {}, - "add": {{Name: "add", Args: []string{"f"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Func: "f"}}}}, Op: OpPipe, Right: &Query{Func: "add"}}}}, - "all": {{Name: "all", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "all", Args: []*Query{{Func: "."}}}}}}, {Name: "all", Args: []string{"y"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "all", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, {Func: "y"}}}}}}, {Name: "all", Args: []string{"g", "y"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "isempty", Args: []*Query{{Left: &Query{Func: "g"}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "y"}, Op: OpPipe, Right: &Query{Func: "not"}}}}}}}}}}}}}, - "any": {{Name: "any", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "any", Args: []*Query{{Func: "."}}}}}}, {Name: "any", Args: []string{"y"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "any", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, {Func: "y"}}}}}}, {Name: "any", Args: []string{"g", "y"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "isempty", Args: []*Query{{Left: &Query{Func: "g"}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Func: "y"}}}}}}}}}}, Op: OpPipe, Right: &Query{Func: "not"}}}}, - "arrays": {{Name: "arrays", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "type"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "array"}}}}}}}}}}, - "booleans": {{Name: "booleans", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "type"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "boolean"}}}}}}}}}}, - "capture": {{Name: "capture", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "capture", Args: []*Query{{Func: "$re"}, {Func: "null"}}}}}}, {Name: "capture", Args: []string{"$re", "$flags"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "match", Args: []*Query{{Func: "$re"}, {Func: "$flags"}}}}}, Op: OpPipe, Right: &Query{Func: "_capture"}}}}, - "combinations": {{Name: "combinations", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Func: "length"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, Then: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}, Else: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, SuffixList: []*Suffix{{Iter: true}, {Bind: &Bind{Patterns: []*Pattern{{Name: "$x"}}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Func: "$x"}}}}, Op: OpAdd, Right: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "1"}}, IsSlice: true}}}, Op: OpPipe, Right: &Query{Func: "combinations"}}}}}}}}}}}}}}, {Name: "combinations", Args: []string{"n"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "limit", Args: []*Query{{Func: "n"}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "repeat", Args: []*Query{{Func: "."}}}}}}}}}}}}, Op: OpPipe, Right: &Query{Func: "combinations"}}}}, - "del": {{Name: "del", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "delpaths", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Func: "f"}}}}}}}}}}}}}}, - "finites": {{Name: "finites", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Func: "isfinite"}}}}}}}, - "first": {{Name: "first", Body: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}}}}, {Name: "first", Args: []string{"g"}, Body: &Query{Term: &Term{Type: TermTypeLabel, Label: &Label{Ident: "$out", Body: &Query{Left: &Query{Func: "g"}, Op: OpPipe, Right: &Query{Left: &Query{Func: "."}, Op: OpComma, Right: &Query{Term: &Term{Type: TermTypeBreak, Break: "$out"}}}}}}}}}, - "fromdate": {{Name: "fromdate", Body: &Query{Func: "fromdateiso8601"}}}, - "fromdateiso8601": {{Name: "fromdateiso8601", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "strptime", Args: []*Query{{Term: &Term{Type: TermTypeString, Str: &String{Str: "%Y-%m-%dT%H:%M:%S%z"}}}}}}}, Op: OpPipe, Right: &Query{Func: "mktime"}}}}, - "fromstream": {{Name: "fromstream", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeForeach, Foreach: &Foreach{Query: &Query{Func: "f"}, Pattern: &Pattern{Name: "$pv"}, Start: &Query{Func: "null"}, Update: &Query{Left: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "e"}}}, Then: &Query{Func: "null"}}}}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$pv"}, SuffixList: []*Suffix{{Bind: &Bind{Patterns: []*Pattern{{Array: []*Pattern{{Name: "$p"}, {Name: "$v"}}}}, Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Func: "$pv"}, Op: OpPipe, Right: &Query{Left: &Query{Func: "length"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "2"}}}}, Then: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "setpath", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "v"}}}}}}, Op: OpAdd, Right: &Query{Func: "$p"}}, {Func: "$v"}}}}}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "setpath", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "e"}}}}}}, {Left: &Query{Func: "$p"}, Op: OpPipe, Right: &Query{Left: &Query{Func: "length"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}}}}}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "setpath", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "e"}}}}}}, {Left: &Query{Func: "$p"}, Op: OpPipe, Right: &Query{Left: &Query{Func: "length"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "1"}}}}}}}}}}}}}}}}}, Extract: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "e"}}}, Then: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "v"}}}, Else: &Query{Func: "empty"}}}}}}}}}, - "group_by": {{Name: "group_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_group_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Func: "f"}}}}}}}}}}}}}}, - "gsub": {{Name: "gsub", Args: []string{"$re", "str"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "sub", Args: []*Query{{Func: "$re"}, {Func: "str"}, {Term: &Term{Type: TermTypeString, Str: &String{Str: "g"}}}}}}}}, {Name: "gsub", Args: []string{"$re", "str", "$flags"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "sub", Args: []*Query{{Func: "$re"}, {Func: "str"}, {Left: &Query{Func: "$flags"}, Op: OpAdd, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "g"}}}}}}}}}}, - "in": {{Name: "in", Args: []string{"xs"}, Body: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Bind: &Bind{Patterns: []*Pattern{{Name: "$x"}}, Body: &Query{Left: &Query{Func: "xs"}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "has", Args: []*Query{{Func: "$x"}}}}}}}}}}}}}, - "inputs": {{Name: "inputs", Body: &Query{Term: &Term{Type: TermTypeTry, Try: &Try{Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "repeat", Args: []*Query{{Func: "input"}}}}}, Catch: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Func: "."}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "break"}}}}, Then: &Query{Func: "empty"}, Else: &Query{Func: "error"}}}}}}}}}, - "inside": {{Name: "inside", Args: []string{"xs"}, Body: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Bind: &Bind{Patterns: []*Pattern{{Name: "$x"}}, Body: &Query{Left: &Query{Func: "xs"}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "contains", Args: []*Query{{Func: "$x"}}}}}}}}}}}}}, - "isempty": {{Name: "isempty", Args: []string{"g"}, Body: &Query{Term: &Term{Type: TermTypeLabel, Label: &Label{Ident: "$out", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Func: "g"}, Op: OpPipe, Right: &Query{Left: &Query{Func: "false"}, Op: OpComma, Right: &Query{Term: &Term{Type: TermTypeBreak, Break: "$out"}}}}}}, Op: OpComma, Right: &Query{Func: "true"}}}}}}}, - "iterables": {{Name: "iterables", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "type"}, Op: OpPipe, Right: &Query{Left: &Query{Left: &Query{Func: "."}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "array"}}}}, Op: OpOr, Right: &Query{Left: &Query{Func: "."}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "object"}}}}}}}}}}}}, - "last": {{Name: "last", Body: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeUnary, Unary: &Unary{Op: OpSub, Term: &Term{Type: TermTypeNumber, Number: "1"}}}}}}}}}, - "limit": {{Name: "limit", Args: []string{"$n", "g"}, Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Func: "$n"}, Op: OpGt, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, Then: &Query{Term: &Term{Type: TermTypeLabel, Label: &Label{Ident: "$out", Body: &Query{Term: &Term{Type: TermTypeForeach, Foreach: &Foreach{Query: &Query{Func: "g"}, Pattern: &Pattern{Name: "$item"}, Start: &Query{Func: "$n"}, Update: &Query{Left: &Query{Func: "."}, Op: OpSub, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "1"}}}, Extract: &Query{Left: &Query{Func: "$item"}, Op: OpComma, Right: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Func: "."}, Op: OpLe, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, Then: &Query{Term: &Term{Type: TermTypeBreak, Break: "$out"}}, Else: &Query{Func: "empty"}}}}}}}}}}}, Elif: []*IfElif{{Cond: &Query{Left: &Query{Func: "$n"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, Then: &Query{Func: "empty"}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "error", Args: []*Query{{Term: &Term{Type: TermTypeString, Str: &String{Str: "limit doesn't support negative count"}}}}}}}}}}}}, - "map": {{Name: "map", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, Op: OpPipe, Right: &Query{Func: "f"}}}}}}}, - "map_values": {{Name: "map_values", Args: []string{"f"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, Op: OpModify, Right: &Query{Func: "f"}}}}, - "match": {{Name: "match", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "match", Args: []*Query{{Func: "$re"}, {Func: "null"}}}}}}, {Name: "match", Args: []string{"$re", "$flags"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_match", Args: []*Query{{Func: "$re"}, {Func: "$flags"}, {Func: "false"}}}, SuffixList: []*Suffix{{Iter: true}}}}}}, - "max_by": {{Name: "max_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_max_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Func: "f"}}}}}}}}}}}}}}, - "min_by": {{Name: "min_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_min_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Func: "f"}}}}}}}}}}}}}}, - "normals": {{Name: "normals", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Func: "isnormal"}}}}}}}, - "not": {{Name: "not", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Func: "."}, Then: &Query{Func: "false"}, Else: &Query{Func: "true"}}}}}}, - "nth": {{Name: "nth", Args: []string{"$n"}, Body: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Func: "$n"}}}}}, {Name: "nth", Args: []string{"$n", "g"}, Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Func: "$n"}, Op: OpGe, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "first", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "skip", Args: []*Query{{Func: "$n"}, {Func: "g"}}}}}}}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "error", Args: []*Query{{Term: &Term{Type: TermTypeString, Str: &String{Str: "nth doesn't support negative index"}}}}}}}}}}}}, - "nulls": {{Name: "nulls", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "."}, Op: OpEq, Right: &Query{Func: "null"}}}}}}}}, - "numbers": {{Name: "numbers", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "type"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "number"}}}}}}}}}}, - "objects": {{Name: "objects", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "type"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "object"}}}}}}}}}}, - "paths": {{Name: "paths", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Func: ".."}}}}}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "."}, Op: OpNe, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}}}}}}}}, {Name: "paths", Args: []string{"f"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Left: &Query{Func: ".."}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Func: "f"}}}}}}}}}}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "."}, Op: OpNe, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}}}}}}}}}, - "pick": {{Name: "pick", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Bind: &Bind{Patterns: []*Pattern{{Name: "$v"}}, Body: &Query{Term: &Term{Type: TermTypeReduce, Reduce: &Reduce{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Func: "f"}}}}}, Pattern: &Pattern{Name: "$p"}, Start: &Query{Func: "null"}, Update: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "setpath", Args: []*Query{{Func: "$p"}, {Left: &Query{Func: "$v"}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "getpath", Args: []*Query{{Func: "$p"}}}}}}}}}}}}}}}}}}}}, - "range": {{Name: "range", Args: []string{"$end"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_range", Args: []*Query{{Term: &Term{Type: TermTypeNumber, Number: "0"}}, {Func: "$end"}, {Term: &Term{Type: TermTypeNumber, Number: "1"}}}}}}}, {Name: "range", Args: []string{"$start", "$end"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_range", Args: []*Query{{Func: "$start"}, {Func: "$end"}, {Term: &Term{Type: TermTypeNumber, Number: "1"}}}}}}}, {Name: "range", Args: []string{"$start", "$end", "$step"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_range", Args: []*Query{{Func: "$start"}, {Func: "$end"}, {Func: "$step"}}}}}}}, - "recurse": {{Name: "recurse", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "recurse", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}, {Optional: true}}}}}}}}}, {Name: "recurse", Args: []string{"f"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "r", Body: &Query{Left: &Query{Func: "."}, Op: OpComma, Right: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Func: "f"}, Op: OpPipe, Right: &Query{Func: "r"}}}}}}}, Func: "r"}}, {Name: "recurse", Args: []string{"f", "cond"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "r", Body: &Query{Left: &Query{Func: "."}, Op: OpComma, Right: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Func: "f"}, Op: OpPipe, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Func: "cond"}}}}}, Op: OpPipe, Right: &Query{Func: "r"}}}}}}}}, Func: "r"}}}, - "repeat": {{Name: "repeat", Args: []string{"f"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "_repeat", Body: &Query{Left: &Query{Func: "f"}, Op: OpComma, Right: &Query{Func: "_repeat"}}}}, Func: "_repeat"}}}, - "scalars": {{Name: "scalars", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "type"}, Op: OpPipe, Right: &Query{Left: &Query{Left: &Query{Func: "."}, Op: OpNe, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "array"}}}}, Op: OpAnd, Right: &Query{Left: &Query{Func: "."}, Op: OpNe, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "object"}}}}}}}}}}}}, - "scan": {{Name: "scan", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "scan", Args: []*Query{{Func: "$re"}, {Func: "null"}}}}}}, {Name: "scan", Args: []string{"$re", "$flags"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "match", Args: []*Query{{Func: "$re"}, {Left: &Query{Func: "$flags"}, Op: OpAdd, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "g"}}}}}}}}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "captures"}}}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}}, Then: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "string"}}}, Else: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "captures"}, SuffixList: []*Suffix{{Iter: true}, {Index: &Index{Name: "string"}}}}}}}}}}}}}}, - "select": {{Name: "select", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Func: "f"}, Then: &Query{Func: "."}, Else: &Query{Func: "empty"}}}}}}, - "skip": {{Name: "skip", Args: []string{"$n", "g"}, Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Func: "$n"}, Op: OpGt, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, Then: &Query{Term: &Term{Type: TermTypeForeach, Foreach: &Foreach{Query: &Query{Func: "g"}, Pattern: &Pattern{Name: "$item"}, Start: &Query{Func: "$n"}, Update: &Query{Left: &Query{Func: "."}, Op: OpSub, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "1"}}}, Extract: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Func: "."}, Op: OpLt, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, Then: &Query{Func: "$item"}, Else: &Query{Func: "empty"}}}}}}}, Elif: []*IfElif{{Cond: &Query{Left: &Query{Func: "$n"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, Then: &Query{Func: "g"}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "error", Args: []*Query{{Term: &Term{Type: TermTypeString, Str: &String{Str: "skip doesn't support negative count"}}}}}}}}}}}}, - "sort_by": {{Name: "sort_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_sort_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Func: "f"}}}}}}}}}}}}}}, - "splits": {{Name: "splits", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "splits", Args: []*Query{{Func: "$re"}, {Func: "null"}}}}}}, {Name: "splits", Args: []string{"$re", "$flags"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "split", Args: []*Query{{Func: "$re"}, {Func: "$flags"}}}, SuffixList: []*Suffix{{Iter: true}}}}}}, - "strings": {{Name: "strings", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "type"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "string"}}}}}}}}}}, - "sub": {{Name: "sub", Args: []string{"$re", "str"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "sub", Args: []*Query{{Func: "$re"}, {Func: "str"}, {Func: "null"}}}}}}, {Name: "sub", Args: []string{"$re", "str", "$flags"}, Body: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Bind: &Bind{Patterns: []*Pattern{{Name: "$str"}}, Body: &Query{FuncDefs: []*FuncDef{{Name: "_sub", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "matches"}}}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}}, Then: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$str"}, SuffixList: []*Suffix{{Index: &Index{End: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "offset"}}}, IsSlice: true}}}}}, Op: OpAdd, Right: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "string"}}}}, Else: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "matches"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Term: &Term{Type: TermTypeUnary, Unary: &Unary{Op: OpSub, Term: &Term{Type: TermTypeNumber, Number: "1"}}}}}}, {Bind: &Bind{Patterns: []*Pattern{{Name: "$r"}}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeObject, Object: &Object{KeyVals: []*ObjectKeyVal{{Key: "string", Val: &Query{Left: &Query{Left: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Func: "$r"}, Op: OpPipe, Right: &Query{Left: &Query{Func: "_capture"}, Op: OpPipe, Right: &Query{Func: "str"}}}}}, Op: OpAdd, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$str"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$r"}, SuffixList: []*Suffix{{Index: &Index{Name: "offset"}}}}}, Op: OpAdd, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$r"}, SuffixList: []*Suffix{{Index: &Index{Name: "length"}}}}}}, End: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "offset"}}}, IsSlice: true}}}}}}, Op: OpAdd, Right: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "string"}}}}}, {Key: "offset", Val: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$r"}, SuffixList: []*Suffix{{Index: &Index{Name: "offset"}}}}}}, {Key: "matches", Val: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "matches"}, SuffixList: []*Suffix{{Index: &Index{End: &Query{Term: &Term{Type: TermTypeUnary, Unary: &Unary{Op: OpSub, Term: &Term{Type: TermTypeNumber, Number: "1"}}}}, IsSlice: true}}}}}}}}}}, Op: OpPipe, Right: &Query{Func: "_sub"}}}}}}}}}}}}, Left: &Query{Term: &Term{Type: TermTypeObject, Object: &Object{KeyVals: []*ObjectKeyVal{{Key: "string", Val: &Query{Term: &Term{Type: TermTypeString, Str: &String{}}}}, {Key: "matches", Val: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "match", Args: []*Query{{Func: "$re"}, {Func: "$flags"}}}}}}}}}}}}}, Op: OpPipe, Right: &Query{Func: "_sub"}}}}}}}}}, - "test": {{Name: "test", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "test", Args: []*Query{{Func: "$re"}, {Func: "null"}}}}}}, {Name: "test", Args: []string{"$re", "$flags"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_match", Args: []*Query{{Func: "$re"}, {Func: "$flags"}, {Func: "true"}}}}}}}, - "todate": {{Name: "todate", Body: &Query{Func: "todateiso8601"}}}, + "add": {{Name: "add", Args: []string{"f"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "add"}}}, Op: OpPipe}}}, + "all": {{Name: "all", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "all", Args: []*Query{{Term: &Term{Type: TermTypeIdentity}}}}}}}, {Name: "all", Args: []string{"y"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "all", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "y"}}}}}}}}, {Name: "all", Args: []string{"g", "y"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "isempty", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "g"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "y"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "not"}}}, Op: OpPipe}}}}}, Op: OpPipe}}}}}}}, + "any": {{Name: "any", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "any", Args: []*Query{{Term: &Term{Type: TermTypeIdentity}}}}}}}, {Name: "any", Args: []string{"y"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "any", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "y"}}}}}}}}, {Name: "any", Args: []string{"g", "y"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "isempty", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "g"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "y"}}}}}}}, Op: OpPipe}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "not"}}}, Op: OpPipe}}}, + "arrays": {{Name: "arrays", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "type"}}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "array"}}}, Op: OpEq}}}}}}}, + "booleans": {{Name: "booleans", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "type"}}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "boolean"}}}, Op: OpEq}}}}}}}, + "capture": {{Name: "capture", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "capture", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeNull}}}}}}}, {Name: "capture", Args: []string{"$re", "$flags"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "match", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$flags"}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_capture"}}}, Op: OpPipe}}}, + "combinations": {{Name: "combinations", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "length"}}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}, Op: OpEq}, Then: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}, Else: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}, SuffixList: []*Suffix{{Iter: true}}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$x"}}}}}}, Right: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "1"}}, IsSlice: true}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "combinations"}}}, Op: OpPipe}}}, Op: OpAdd}, Patterns: []*Pattern{{Name: "$x"}}, Op: OpPipe}}}}}, {Name: "combinations", Args: []string{"n"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "limit", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "n"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "repeat", Args: []*Query{{Term: &Term{Type: TermTypeIdentity}}}}}}}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "combinations"}}}, Op: OpPipe}}}, + "del": {{Name: "del", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "delpaths", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}}}}}}}}}}}, + "finites": {{Name: "finites", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "isfinite"}}}}}}}}}, + "first": {{Name: "first", Body: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}}}}, {Name: "first", Args: []string{"g"}, Body: &Query{Term: &Term{Type: TermTypeLabel, Label: &Label{Ident: "$out", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "g"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeBreak, Break: "$out"}}, Op: OpComma}, Op: OpPipe}}}}}}, + "fromdate": {{Name: "fromdate", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "fromdateiso8601"}}}}}, + "fromdateiso8601": {{Name: "fromdateiso8601", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "strptime", Args: []*Query{{Term: &Term{Type: TermTypeString, Str: &String{Str: "%Y-%m-%dT%H:%M:%S%z"}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "mktime"}}}, Op: OpPipe}}}, + "fromstream": {{Name: "fromstream", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeForeach, Foreach: &Foreach{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}, Pattern: &Pattern{Name: "$pv"}, Start: &Query{Term: &Term{Type: TermTypeNull}}, Update: &Query{Left: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "e"}}}, Then: &Query{Term: &Term{Type: TermTypeNull}}}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$pv"}}}, Right: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$pv"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "length"}}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "2"}}, Op: OpEq}, Op: OpPipe}, Then: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "setpath", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "v"}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$p"}}}, Op: OpAdd}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$v"}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "setpath", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "e"}}}}}}, {Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$p"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "length"}}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}, Op: OpEq}, Op: OpPipe}}}}}, Op: OpPipe}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "setpath", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "e"}}}}}}, {Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$p"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "length"}}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "1"}}, Op: OpEq}, Op: OpPipe}}}}}}}}, Patterns: []*Pattern{{Array: []*Pattern{{Name: "$p"}, {Name: "$v"}}}}, Op: OpPipe}, Op: OpPipe}, Extract: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "e"}}}, Then: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "v"}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "empty"}}}}}}}}}}}, + "group_by": {{Name: "group_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_group_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}}}}}}}}}}}, + "gsub": {{Name: "gsub", Args: []string{"$re", "str"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "sub", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "str"}}}, {Term: &Term{Type: TermTypeString, Str: &String{Str: "g"}}}}}}}}, {Name: "gsub", Args: []string{"$re", "str", "$flags"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "sub", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "str"}}}, {Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$flags"}}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "g"}}}, Op: OpAdd}}}}}}}, + "in": {{Name: "in", Args: []string{"xs"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "xs"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "has", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$x"}}}}}}}, Op: OpPipe}, Patterns: []*Pattern{{Name: "$x"}}, Op: OpPipe}}}, + "inputs": {{Name: "inputs", Body: &Query{Term: &Term{Type: TermTypeTry, Try: &Try{Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "repeat", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "input"}}}}}}}, Catch: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "break"}}}, Op: OpEq}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "empty"}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "error"}}}}}}}}}}}, + "inside": {{Name: "inside", Args: []string{"xs"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "xs"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "contains", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$x"}}}}}}}, Op: OpPipe}, Patterns: []*Pattern{{Name: "$x"}}, Op: OpPipe}}}, + "isempty": {{Name: "isempty", Args: []string{"g"}, Body: &Query{Term: &Term{Type: TermTypeLabel, Label: &Label{Ident: "$out", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "g"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFalse}}, Right: &Query{Term: &Term{Type: TermTypeBreak, Break: "$out"}}, Op: OpComma}, Op: OpPipe}}}, Right: &Query{Term: &Term{Type: TermTypeTrue}}, Op: OpComma}}}}}}, + "iterables": {{Name: "iterables", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "type"}}}, Right: &Query{Left: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "array"}}}, Op: OpEq}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "object"}}}, Op: OpEq}, Op: OpOr}, Op: OpPipe}}}}}}}, + "last": {{Name: "last", Body: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeUnary, Unary: &Unary{Op: OpSub, Term: &Term{Type: TermTypeNumber, Number: "1"}}}}}}}}, {Name: "last", Args: []string{"g"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_last", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "g"}}}}}}}}}, + "limit": {{Name: "limit", Args: []string{"$n", "g"}, Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}, Op: OpGt}, Then: &Query{Term: &Term{Type: TermTypeLabel, Label: &Label{Ident: "$out", Body: &Query{Term: &Term{Type: TermTypeForeach, Foreach: &Foreach{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "g"}}}, Pattern: &Pattern{Name: "$item"}, Start: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, Update: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "1"}}, Op: OpSub}, Extract: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$item"}}}, Right: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}, Op: OpLe}, Then: &Query{Term: &Term{Type: TermTypeBreak, Break: "$out"}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "empty"}}}}}}, Op: OpComma}}}}}}}, Elif: []*IfElif{{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}, Op: OpEq}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "empty"}}}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "error", Args: []*Query{{Term: &Term{Type: TermTypeString, Str: &String{Str: "limit doesn't support negative count"}}}}}}}}}}}}, + "map": {{Name: "map", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}, Op: OpPipe}}}}}}, + "map_values": {{Name: "map_values", Args: []string{"f"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}, Op: OpModify}}}, + "match": {{Name: "match", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "match", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeNull}}}}}}}, {Name: "match", Args: []string{"$re", "$flags"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_match", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$flags"}}}, {Term: &Term{Type: TermTypeFalse}}}}, SuffixList: []*Suffix{{Iter: true}}}}}}, + "max_by": {{Name: "max_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_max_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}}}}}}}}}}}, + "min_by": {{Name: "min_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_min_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}}}}}}}}}}}, + "normals": {{Name: "normals", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "isnormal"}}}}}}}}}, + "not": {{Name: "not", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Term: &Term{Type: TermTypeIdentity}}, Then: &Query{Term: &Term{Type: TermTypeFalse}}, Else: &Query{Term: &Term{Type: TermTypeTrue}}}}}}}, + "nth": {{Name: "nth", Args: []string{"$n"}, Body: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}}}}}, {Name: "nth", Args: []string{"$n", "g"}, Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}, Op: OpGe}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "first", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "skip", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "g"}}}}}}}}}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "error", Args: []*Query{{Term: &Term{Type: TermTypeString, Str: &String{Str: "nth doesn't support negative index"}}}}}}}}}}}}, + "nulls": {{Name: "nulls", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeNull}}, Op: OpEq}}}}}}}, + "numbers": {{Name: "numbers", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "type"}}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "number"}}}, Op: OpEq}}}}}}}, + "objects": {{Name: "objects", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "type"}}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "object"}}}, Op: OpEq}}}}}}}, + "paths": {{Name: "paths", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Term: &Term{Type: TermTypeRecurse}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}, Op: OpNe}}}}}, Op: OpPipe}}, {Name: "paths", Args: []string{"f"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeRecurse}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}}, Op: OpPipe}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}, Op: OpNe}}}}}, Op: OpPipe}}}, + "pick": {{Name: "pick", Args: []string{"f"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeReduce, Reduce: &Reduce{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}}, Pattern: &Pattern{Name: "$p"}, Start: &Query{Term: &Term{Type: TermTypeNull}}, Update: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "setpath", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$p"}}}, {Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$v"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "getpath", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$p"}}}}}}}, Op: OpPipe}}}}}}}}, Patterns: []*Pattern{{Name: "$v"}}, Op: OpPipe}}}, + "range": {{Name: "range", Args: []string{"$end"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_range", Args: []*Query{{Term: &Term{Type: TermTypeNumber, Number: "0"}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$end"}}}, {Term: &Term{Type: TermTypeNumber, Number: "1"}}}}}}}, {Name: "range", Args: []string{"$start", "$end"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_range", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$start"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$end"}}}, {Term: &Term{Type: TermTypeNumber, Number: "1"}}}}}}}, {Name: "range", Args: []string{"$start", "$end", "$step"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_range", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$start"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$end"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$step"}}}}}}}}}, + "recurse": {{Name: "recurse", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "recurse", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}, {Optional: true}}}}}}}}}, {Name: "recurse", Args: []string{"f"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "r", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "r"}}}, Op: OpPipe}}}, Op: OpComma}}}, Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "r"}}}}, {Name: "recurse", Args: []string{"f", "cond"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "r", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "cond"}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "r"}}}, Op: OpPipe}, Op: OpPipe}}}, Op: OpComma}}}, Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "r"}}}}}, + "repeat": {{Name: "repeat", Args: []string{"f"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "_repeat", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_repeat"}}}, Op: OpComma}}}, Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_repeat"}}}}}, + "scalars": {{Name: "scalars", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "type"}}}, Right: &Query{Left: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "array"}}}, Op: OpNe}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "object"}}}, Op: OpNe}, Op: OpAnd}, Op: OpPipe}}}}}}}, + "scan": {{Name: "scan", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "scan", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeNull}}}}}}}, {Name: "scan", Args: []string{"$re", "$flags"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "match", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$flags"}}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "g"}}}, Op: OpAdd}}}}}, Right: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "captures"}}}, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}, Op: OpEq}, Then: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "string"}}}, Else: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "captures"}, SuffixList: []*Suffix{{Iter: true}, {Index: &Index{Name: "string"}}}}}}}}}}}, Op: OpPipe}}}, + "select": {{Name: "select", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}, Then: &Query{Term: &Term{Type: TermTypeIdentity}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "empty"}}}}}}}}, + "skip": {{Name: "skip", Args: []string{"$n", "g"}, Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}, Op: OpGt}, Then: &Query{Term: &Term{Type: TermTypeForeach, Foreach: &Foreach{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "g"}}}, Pattern: &Pattern{Name: "$item"}, Start: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, Update: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "1"}}, Op: OpSub}, Extract: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}, Op: OpLt}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$item"}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "empty"}}}}}}}}}, Elif: []*IfElif{{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, Right: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}, Op: OpEq}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "g"}}}}}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "error", Args: []*Query{{Term: &Term{Type: TermTypeString, Str: &String{Str: "skip doesn't support negative count"}}}}}}}}}}}}, + "sort_by": {{Name: "sort_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_sort_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}}}}}}}}}}}, + "splits": {{Name: "splits", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "splits", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeNull}}}}}}}, {Name: "splits", Args: []string{"$re", "$flags"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "split", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$flags"}}}}}, SuffixList: []*Suffix{{Iter: true}}}}}}, + "strings": {{Name: "strings", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "type"}}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "string"}}}, Op: OpEq}}}}}}}, + "sub": {{Name: "sub", Args: []string{"$re", "str"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "sub", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "str"}}}, {Term: &Term{Type: TermTypeNull}}}}}}}, {Name: "sub", Args: []string{"$re", "str", "$flags"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{FuncDefs: []*FuncDef{{Name: "_sub", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "matches"}}}, Right: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{}}}, Op: OpEq}, Then: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$str"}, SuffixList: []*Suffix{{Index: &Index{End: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "offset"}}}, IsSlice: true}}}}}, Right: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "string"}}}, Op: OpAdd}, Else: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "matches"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Term: &Term{Type: TermTypeUnary, Unary: &Unary{Op: OpSub, Term: &Term{Type: TermTypeNumber, Number: "1"}}}}}}}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeObject, Object: &Object{KeyVals: []*ObjectKeyVal{{Key: "string", Val: &Query{Left: &Query{Left: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$r"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_capture"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "str"}}}, Op: OpPipe}, Op: OpPipe}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$str"}, SuffixList: []*Suffix{{Index: &Index{Start: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$r"}, SuffixList: []*Suffix{{Index: &Index{Name: "offset"}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$r"}, SuffixList: []*Suffix{{Index: &Index{Name: "length"}}}}}, Op: OpAdd}, End: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "offset"}}}, IsSlice: true}}}}}, Op: OpAdd}, Right: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "string"}}}, Op: OpAdd}}, {Key: "offset", Val: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$r"}, SuffixList: []*Suffix{{Index: &Index{Name: "offset"}}}}}}, {Key: "matches", Val: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Name: "matches"}, SuffixList: []*Suffix{{Index: &Index{End: &Query{Term: &Term{Type: TermTypeUnary, Unary: &Unary{Op: OpSub, Term: &Term{Type: TermTypeNumber, Number: "1"}}}}, IsSlice: true}}}}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_sub"}}}, Op: OpPipe}, Patterns: []*Pattern{{Name: "$r"}}, Op: OpPipe}}}}}}, Left: &Query{Term: &Term{Type: TermTypeObject, Object: &Object{KeyVals: []*ObjectKeyVal{{Key: "string", Val: &Query{Term: &Term{Type: TermTypeString, Str: &String{}}}}, {Key: "matches", Val: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "match", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$flags"}}}}}}}}}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_sub"}}}, Op: OpPipe}, Patterns: []*Pattern{{Name: "$str"}}, Op: OpPipe}}}, + "test": {{Name: "test", Args: []string{"$re"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "test", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeNull}}}}}}}, {Name: "test", Args: []string{"$re", "$flags"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_match", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$re"}}}, {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$flags"}}}, {Term: &Term{Type: TermTypeTrue}}}}}}}}, + "todate": {{Name: "todate", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "todateiso8601"}}}}}, "todateiso8601": {{Name: "todateiso8601", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "strftime", Args: []*Query{{Term: &Term{Type: TermTypeString, Str: &String{Str: "%Y-%m-%dT%H:%M:%SZ"}}}}}}}}}, - "tostream": {{Name: "tostream", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{FuncDefs: []*FuncDef{{Name: "r", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}, {Optional: true}}}}, Op: OpPipe, Right: &Query{Func: "r"}}}}, Op: OpComma, Right: &Query{Func: "."}}}}, Func: "r"}}}, SuffixList: []*Suffix{{Bind: &Bind{Patterns: []*Pattern{{Name: "$p"}}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "getpath", Args: []*Query{{Func: "$p"}}}}}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeReduce, Reduce: &Reduce{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}, {Optional: true}}}}}}}}, Pattern: &Pattern{Name: "$q"}, Start: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Func: "$p"}, Op: OpComma, Right: &Query{Func: "."}}}}}, Update: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Func: "$p"}, Op: OpAdd, Right: &Query{Func: "$q"}}}}}}}}}}}}}}}}, - "truncate_stream": {{Name: "truncate_stream", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Bind: &Bind{Patterns: []*Pattern{{Name: "$n"}}, Body: &Query{Left: &Query{Func: "null"}, Op: OpPipe, Right: &Query{Left: &Query{Func: "f"}, Op: OpPipe, Right: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}}}, Op: OpPipe, Right: &Query{Left: &Query{Func: "length"}, Op: OpGt, Right: &Query{Func: "$n"}}}, Then: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}}}, Op: OpModify, Right: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Func: "$n"}, IsSlice: true}}}}, Else: &Query{Func: "empty"}}}}}}}}}}}}}, - "unique_by": {{Name: "unique_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_unique_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Func: "f"}}}}}}}}}}}}}}, - "until": {{Name: "until", Args: []string{"cond", "next"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "_until", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Func: "cond"}, Then: &Query{Func: "."}, Else: &Query{Left: &Query{Func: "next"}, Op: OpPipe, Right: &Query{Func: "_until"}}}}}}}, Func: "_until"}}}, - "values": {{Name: "values", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Func: "."}, Op: OpNe, Right: &Query{Func: "null"}}}}}}}}, - "walk": {{Name: "walk", Args: []string{"f"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "_walk", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Func: "type"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "array"}}}}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Func: "_walk"}}}}}, Elif: []*IfElif{{Cond: &Query{Left: &Query{Func: "type"}, Op: OpEq, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "object"}}}}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map_values", Args: []*Query{{Func: "_walk"}}}}}}}}}}, Op: OpPipe, Right: &Query{Func: "f"}}}}, Func: "_walk"}}}, - "while": {{Name: "while", Args: []string{"cond", "update"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "_while", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Func: "cond"}, Then: &Query{Left: &Query{Func: "."}, Op: OpComma, Right: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Func: "update"}, Op: OpPipe, Right: &Query{Func: "_while"}}}}}, Else: &Query{Func: "empty"}}}}}}, Func: "_while"}}}, - "with_entries": {{Name: "with_entries", Args: []string{"f"}, Body: &Query{Left: &Query{Func: "to_entries"}, Op: OpPipe, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Func: "f"}}}}}, Op: OpPipe, Right: &Query{Func: "from_entries"}}}}}, + "tostream": {{Name: "tostream", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{FuncDefs: []*FuncDef{{Name: "r", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}, {Optional: true}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "r"}}}, Op: OpPipe}}}, Right: &Query{Term: &Term{Type: TermTypeIdentity}}, Op: OpComma}}}, Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "r"}}}}}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "getpath", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$p"}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeReduce, Reduce: &Reduce{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "path", Args: []*Query{{Term: &Term{Type: TermTypeIdentity, SuffixList: []*Suffix{{Iter: true}, {Optional: true}}}}}}}}, Pattern: &Pattern{Name: "$q"}, Start: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$p"}}}, Right: &Query{Term: &Term{Type: TermTypeIdentity}}, Op: OpComma}}}}, Update: &Query{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$p"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$q"}}}, Op: OpAdd}}}}}}}, Op: OpPipe}, Patterns: []*Pattern{{Name: "$p"}}, Op: OpPipe}}}, + "truncate_stream": {{Name: "truncate_stream", Args: []string{"f"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeNull}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}, Right: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "length"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, Op: OpGt}, Op: OpPipe}, Then: &Query{Left: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeNumber, Number: "0"}}}}}, Right: &Query{Term: &Term{Type: TermTypeIndex, Index: &Index{Start: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "$n"}}}, IsSlice: true}}}, Op: OpModify}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "empty"}}}}}}, Op: OpPipe}, Op: OpPipe}, Patterns: []*Pattern{{Name: "$n"}}, Op: OpPipe}}}, + "unique_by": {{Name: "unique_by", Args: []string{"f"}, Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_unique_by", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeArray, Array: &Array{Query: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}}}}}}}}}}}, + "until": {{Name: "until", Args: []string{"cond", "next"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "_until", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "cond"}}}, Then: &Query{Term: &Term{Type: TermTypeIdentity}}, Else: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "next"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_until"}}}, Op: OpPipe}}}}}}, Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_until"}}}}}, + "values": {{Name: "values", Body: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "select", Args: []*Query{{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeNull}}, Op: OpNe}}}}}}}, + "walk": {{Name: "walk", Args: []string{"f"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "_walk", Body: &Query{Left: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "type"}}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "array"}}}, Op: OpEq}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_walk"}}}}}}}, Elif: []*IfElif{{Cond: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "type"}}}, Right: &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: "object"}}}, Op: OpEq}, Then: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map_values", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_walk"}}}}}}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}, Op: OpPipe}}}, Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_walk"}}}}}, + "while": {{Name: "while", Args: []string{"cond", "update"}, Body: &Query{FuncDefs: []*FuncDef{{Name: "_while", Body: &Query{Term: &Term{Type: TermTypeIf, If: &If{Cond: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "cond"}}}, Then: &Query{Left: &Query{Term: &Term{Type: TermTypeIdentity}}, Right: &Query{Term: &Term{Type: TermTypeQuery, Query: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "update"}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_while"}}}, Op: OpPipe}}}, Op: OpComma}, Else: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "empty"}}}}}}}}, Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "_while"}}}}}, + "with_entries": {{Name: "with_entries", Args: []string{"f"}, Body: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "to_entries"}}}, Right: &Query{Left: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "map", Args: []*Query{{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "f"}}}}}}}, Right: &Query{Term: &Term{Type: TermTypeFunc, Func: &Func{Name: "from_entries"}}}, Op: OpPipe}, Op: OpPipe}}}, } } diff --git a/vendor/github.com/itchyny/gojq/builtin.jq b/vendor/github.com/itchyny/gojq/builtin.jq index 987e4192..a7049216 100644 --- a/vendor/github.com/itchyny/gojq/builtin.jq +++ b/vendor/github.com/itchyny/gojq/builtin.jq @@ -59,6 +59,7 @@ def walk(f): def first: .[0]; def first(g): label $out | g | ., break $out; def last: .[-1]; +def last(g): _last(g); def isempty(g): label $out | (g | false, break $out), true; def all: all(.); def all(y): all(.[]; y); diff --git a/vendor/github.com/itchyny/gojq/compare.go b/vendor/github.com/itchyny/gojq/compare.go index 9791e9dc..533c9760 100644 --- a/vendor/github.com/itchyny/gojq/compare.go +++ b/vendor/github.com/itchyny/gojq/compare.go @@ -1,6 +1,8 @@ package gojq import ( + "cmp" + "encoding/json" "math" "math/big" ) @@ -10,8 +12,8 @@ import ( // This comparison is used by built-in operators and functions. func Compare(l, r any) int { return binopTypeSwitch(l, r, - compareInt, - func(l, r float64) any { + cmp.Compare, + func(l, r float64) int { switch { case l < r || math.IsNaN(l): return -1 @@ -21,28 +23,17 @@ func Compare(l, r any) int { return 1 } }, - func(l, r *big.Int) any { - return l.Cmp(r) - }, - func(l, r string) any { - switch { - case l < r: - return -1 - case l == r: - return 0 - default: - return 1 - } - }, - func(l, r []any) any { - for i, n := 0, min(len(l), len(r)); i < n; i++ { + (*big.Int).Cmp, + cmp.Compare, + func(l, r []any) int { + for i := range min(len(l), len(r)) { if cmp := Compare(l[i], r[i]); cmp != 0 { return cmp } } - return compareInt(len(l), len(r)) + return cmp.Compare(len(l), len(r)) }, - func(l, r map[string]any) any { + func(l, r map[string]any) int { lk, rk := funcKeys(l), funcKeys(r) if cmp := Compare(lk, rk); cmp != 0 { return cmp @@ -54,21 +45,10 @@ func Compare(l, r any) int { } return 0 }, - func(l, r any) any { - return compareInt(typeIndex(l), typeIndex(r)) + func(l, r any) int { + return cmp.Compare(typeIndex(l), typeIndex(r)) }, - ).(int) -} - -func compareInt(l, r int) any { - switch { - case l < r: - return -1 - case l == r: - return 0 - default: - return 1 - } + ) } func typeIndex(v any) int { @@ -80,7 +60,7 @@ func typeIndex(v any) int { return 1 } return 2 - case int, float64, *big.Int: + case int, float64, *big.Int, json.Number: return 3 case string: return 4 diff --git a/vendor/github.com/itchyny/gojq/compiler.go b/vendor/github.com/itchyny/gojq/compiler.go index cea452e3..3a193848 100644 --- a/vendor/github.com/itchyny/gojq/compiler.go +++ b/vendor/github.com/itchyny/gojq/compiler.go @@ -34,7 +34,6 @@ type Code struct { // a result iterator. // // It is safe to call this method in goroutines, to reuse a compiled [*Code]. -// But for arguments, do not give values sharing same data between goroutines. func (c *Code) Run(v any, values ...any) Iter { return c.RunWithContext(context.Background(), v, values...) } @@ -46,10 +45,7 @@ func (c *Code) RunWithContext(ctx context.Context, v any, values ...any) Iter { } else if len(values) < len(c.variables) { return NewIter(&expectedVariableError{c.variables[len(values)]}) } - for i, v := range values { - values[i] = normalizeNumbers(v) - } - return newEnv(ctx).execute(c, normalizeNumbers(v), values...) + return newEnv(ctx).execute(c, v, values...) } type scopeinfo struct { @@ -160,7 +156,6 @@ func (c *compiler) compileImport(i *Import) error { } else { return fmt.Errorf("module not found: %q", path) } - vals = normalizeNumbers(vals) c.append(&code{op: oppush, v: vals}) c.append(&code{op: opstore, v: c.pushVariable(alias)}) c.append(&code{op: oppush, v: vals}) @@ -379,28 +374,16 @@ func (c *compiler) compileQuery(e *Query) error { return err } } - if e.Func != "" { - switch e.Func { - case ".": - return c.compileTerm(&Term{Type: TermTypeIdentity}) - case "..": - return c.compileTerm(&Term{Type: TermTypeRecurse}) - case "null": - return c.compileTerm(&Term{Type: TermTypeNull}) - case "true": - return c.compileTerm(&Term{Type: TermTypeTrue}) - case "false": - return c.compileTerm(&Term{Type: TermTypeFalse}) - default: - return c.compileFunc(&Func{Name: e.Func}) - } - } else if e.Term != nil { + if e.Term != nil { return c.compileTerm(e.Term) } switch e.Op { case Operator(0): return errors.New(`missing query (try ".")`) case OpPipe: + if len(e.Patterns) > 0 { + return c.compileBind(e.Left, e.Right, e.Patterns) + } if err := c.compileQuery(e.Left); err != nil { return err } @@ -529,7 +512,7 @@ func (c *compiler) compileQueryUpdate(l, r *Query, op Operator) error { Name: op.getFunc(), Args: []*Query{ {Term: &Term{Type: TermTypeIdentity}}, - {Func: name}, + {Term: &Term{Type: TermTypeFunc, Func: &Func{Name: name}}}, }, }, }}, @@ -539,19 +522,19 @@ func (c *compiler) compileQueryUpdate(l, r *Query, op Operator) error { } } -func (c *compiler) compileBind(e *Term, b *Bind) error { +func (c *compiler) compileBind(l, r *Query, patterns []*Pattern) error { defer c.newScopeDepth()() c.append(&code{op: opdup}) c.append(&code{op: opexpbegin}) - if err := c.compileTerm(e); err != nil { + if err := c.compileQuery(l); err != nil { return err } var pc int var vs [][2]int - for i, p := range b.Patterns { + for i, p := range patterns { var pcc int var err error - if i < len(b.Patterns)-1 { + if i < len(patterns)-1 { defer c.lazy(func() *code { return &code{op: opforkalt, v: pcc} })() @@ -565,22 +548,22 @@ func (c *compiler) compileBind(e *Term, b *Bind) error { if vs, err = c.compilePattern(vs[:0], p); err != nil { return err } - if i < len(b.Patterns)-1 { + if i < len(patterns)-1 { defer c.lazy(func() *code { return &code{op: opjump, v: pc} })() pcc = len(c.codes) } } - if len(b.Patterns) > 1 { + if len(patterns) > 1 { pc = len(c.codes) } - if len(b.Patterns) == 1 && c.codes[len(c.codes)-2].op == opexpbegin { + if len(patterns) == 1 && c.codes[len(c.codes)-2].op == opexpbegin { c.codes[len(c.codes)-2].op = opnop } else { c.append(&code{op: opexpend}) } - return c.compileQuery(b.Body) + return c.compileQuery(r) } func (c *compiler) compilePattern(vs [][2]int, p *Pattern) ([][2]int, error) { @@ -953,7 +936,7 @@ func (c *compiler) compileFunc(e *Func) error { c.compileAssign() case "_modify": c.compileModify() - case "last": + case "_last": c.compileLast() } } @@ -1145,7 +1128,7 @@ func (c *compiler) compileModify() { // Appends the compiled code for the `last/1` function to // maximize performance avoiding unnecessary boxing. func (c *compiler) compileLast() { - defer c.appendBuiltin("last", 1)() + defer c.appendBuiltin("_last", 1)() scope := c.newScope() v, g, x := [2]int{scope.id, 0}, [2]int{scope.id, 1}, [2]int{scope.id, 2} c.appends( @@ -1218,7 +1201,7 @@ func (c *compiler) funcInput(any, []any) any { if !ok { return errors.New("break") } - return normalizeNumbers(v) + return v } func (c *compiler) funcModulemeta(v any, _ []any) any { @@ -1317,7 +1300,7 @@ func (c *compiler) compileObject(e *Object) error { if pc+l*3+1 != len(c.codes) { return nil } - for i := 0; i < l; i++ { + for i := range l { if c.codes[pc+i*3].op != oppush || c.codes[pc+i*3+1].op != opload || c.codes[pc+i*3+2].op != opconst { @@ -1325,7 +1308,7 @@ func (c *compiler) compileObject(e *Object) error { } } w := make(map[string]any, l) - for i := 0; i < l; i++ { + for i := range l { w[c.codes[pc+i*3].v.(string)] = c.codes[pc+i*3+2].v } c.codes[pc-1] = &code{op: opconst, v: w} @@ -1417,7 +1400,7 @@ func (c *compiler) compileArray(e *Array) error { return nil } l := (len(c.codes) - pc - 3) / 3 - for i := 0; i < l; i++ { + for i := range l { if c.codes[pc+i].op != opfork || c.codes[pc+i*2+l].op != opconst || (i < l-1 && c.codes[pc+i*2+l+1].op != opjump) { @@ -1425,7 +1408,7 @@ func (c *compiler) compileArray(e *Array) error { } } v := make([]any, l) - for i := 0; i < l; i++ { + for i := range l { v[i] = c.codes[pc+i*2+l].v } c.codes[pc-2] = &code{op: opconst, v: v} @@ -1536,8 +1519,6 @@ func (c *compiler) compileTermSuffix(e *Term, s *Suffix) error { } } return c.compileTry(&Try{Body: &Query{Term: e}}) - } else if s.Bind != nil { - return c.compileBind(e, s.Bind) } else { return fmt.Errorf("invalid suffix: %s", s) } @@ -1656,33 +1637,33 @@ func (c *compiler) optimizeTailRec() { var pcs []int scopes := map[int]bool{} L: - for i, l := 0, len(c.codes); i < l; i++ { - switch c.codes[i].op { + for i, code := range c.codes { + switch code.op { case opscope: pcs = append(pcs, i) - if v := c.codes[i].v.([3]int); v[2] == 0 { + if v := code.v.([3]int); v[2] == 0 { scopes[i] = v[1] == 0 } case opcall: var canjump bool - if j, ok := c.codes[i].v.(int); !ok || + if j, ok := code.v.(int); !ok || len(pcs) == 0 || pcs[len(pcs)-1] != j { break } else if canjump, ok = scopes[j]; !ok { break } - for j := i + 1; j < l; { + for j := i + 1; j < len(c.codes); { switch c.codes[j].op { case opjump: j = c.codes[j].v.(int) case opret: if canjump { - c.codes[i].op = opjump - c.codes[i].v = pcs[len(pcs)-1] + 1 + code.op = opjump + code.v = pcs[len(pcs)-1] + 1 } else { - c.codes[i].op = opcallrec + code.op = opcallrec } - continue L + fallthrough default: continue L } diff --git a/vendor/github.com/itchyny/gojq/encoder.go b/vendor/github.com/itchyny/gojq/encoder.go index 518904d7..cc44c95b 100644 --- a/vendor/github.com/itchyny/gojq/encoder.go +++ b/vendor/github.com/itchyny/gojq/encoder.go @@ -2,6 +2,7 @@ package gojq import ( "bytes" + "encoding/json" "fmt" "io" "math" @@ -15,12 +16,12 @@ import ( // Marshal returns the jq-flavored JSON encoding of v. // // This method accepts only limited types (nil, bool, int, float64, *big.Int, -// string, []any, and map[string]any) because these are the possible types a -// gojq iterator can emit. This method marshals NaN to null, truncates -// infinities to (+|-) math.MaxFloat64, uses \b and \f in strings, and does not -// escape '<', '>', '&', '\u2028', and '\u2029'. These behaviors are based on -// the marshaler of jq command, and different from json.Marshal in the Go -// standard library. Note that the result is not safe to embed in HTML. +// json.Number, string, []any, and map[string]any) because these are the +// possible types a gojq iterator can emit. This method marshals NaN to null, +// truncates infinities to (+|-) math.MaxFloat64, uses \b and \f in strings, +// and does not escape '<', '>', '&', '\u2028', and '\u2029'. These behaviors +// are based on the marshaler of jq command, and different from json.Marshal in +// the Go standard library. Note that the result is not safe to embed in HTML. func Marshal(v any) ([]byte, error) { var b bytes.Buffer (&encoder{w: &b}).encode(v) @@ -62,6 +63,8 @@ func (e *encoder) encode(v any) { e.encodeFloat64(v) case *big.Int: e.w.Write(v.Append(e.buf[:0], 10)) + case json.Number: + e.w.WriteString(v.String()) case string: e.encodeString(v) case []any: diff --git a/vendor/github.com/itchyny/gojq/env.go b/vendor/github.com/itchyny/gojq/env.go index bf058eda..3ba44ad1 100644 --- a/vendor/github.com/itchyny/gojq/env.go +++ b/vendor/github.com/itchyny/gojq/env.go @@ -44,5 +44,6 @@ type fork struct { scopelimit int pathindex int pathlimit int + offset int expdepth int } diff --git a/vendor/github.com/itchyny/gojq/error.go b/vendor/github.com/itchyny/gojq/error.go index 18b06b1c..743fa9f6 100644 --- a/vendor/github.com/itchyny/gojq/error.go +++ b/vendor/github.com/itchyny/gojq/error.go @@ -51,6 +51,15 @@ func (err *arrayIndexTooLargeError) Error() string { return "array index too large: " + Preview(err.v) } +type repeatStringTooLargeError struct { + s string + n float64 +} + +func (err *repeatStringTooLargeError) Error() string { + return "repeat string result too large: " + Preview(err.s) + " * " + Preview(err.n) +} + type objectKeyNotStringError struct { v any } diff --git a/vendor/github.com/itchyny/gojq/execute.go b/vendor/github.com/itchyny/gojq/execute.go index 344d8a3c..3b7eab2b 100644 --- a/vendor/github.com/itchyny/gojq/execute.go +++ b/vendor/github.com/itchyny/gojq/execute.go @@ -59,7 +59,7 @@ loop: } n := code.v.(int) m := make(map[string]any, n) - for i := 0; i < n; i++ { + for range n { v, k := env.pop(), env.pop() s, ok := k.(string) if !ok { @@ -180,7 +180,7 @@ loop: case [3]any: argcnt := v[1].(int) x, args := env.pop(), env.args[:argcnt] - for i := 0; i < argcnt; i++ { + for i := range argcnt { args[i] = env.pop() } w := v[0].(func(any, []any) any)(x, args) @@ -238,8 +238,7 @@ loop: callpc, saveindex = env.popscope() } } else { - saveindex, _ = env.scopes.save() - env.scopes.index = index + saveindex = env.scopes.index } if outerindex = index; outerindex >= 0 { if s := env.scopes.data[outerindex].value; s.id == xs[0] { @@ -377,7 +376,7 @@ func (env *env) popscope() (int, int) { } func (env *env) pushfork(pc int) { - f := fork{pc: pc, expdepth: env.expdepth} + f := fork{pc: pc, offset: env.offset, expdepth: env.expdepth} f.stackindex, f.stacklimit = env.stack.save() f.scopeindex, f.scopelimit = env.scopes.save() f.pathindex, f.pathlimit = env.paths.save() @@ -388,7 +387,8 @@ func (env *env) pushfork(pc int) { func (env *env) popfork() int { f := env.forks[len(env.forks)-1] env.debugForks(f.pc, "<<<") - env.forks, env.expdepth = env.forks[:len(env.forks)-1], f.expdepth + env.forks, env.offset, env.expdepth = + env.forks[:len(env.forks)-1], f.offset, f.expdepth env.stack.restore(f.stackindex, f.stacklimit) env.scopes.restore(f.scopeindex, f.scopelimit) env.paths.restore(f.pathindex, f.pathlimit) diff --git a/vendor/github.com/itchyny/gojq/func.go b/vendor/github.com/itchyny/gojq/func.go index dcfaa5d5..b7d7a346 100644 --- a/vendor/github.com/itchyny/gojq/func.go +++ b/vendor/github.com/itchyny/gojq/func.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "maps" "math" "math/big" "net/url" @@ -60,6 +61,7 @@ func init() { "to_entries": argFunc0(funcToEntries), "from_entries": argFunc0(funcFromEntries), "add": argFunc0(funcAdd), + "toboolean": argFunc0(funcToBoolean), "tonumber": argFunc0(funcToNumber), "tostring": argFunc0(funcToString), "type": argFunc0(funcType), @@ -72,6 +74,7 @@ func init() { "endswith": argFunc1(funcEndsWith), "ltrimstr": argFunc1(funcLtrimstr), "rtrimstr": argFunc1(funcRtrimstr), + "trimstr": argFunc1(funcTrimstr), "ltrim": argFunc0(funcLtrim), "rtrim": argFunc0(funcRtrim), "trim": argFunc0(funcTrim), @@ -293,6 +296,11 @@ func funcAbs(v any) any { return v } return new(big.Int).Abs(v) + case json.Number: + if !strings.HasPrefix(v.String(), "-") { + return v + } + return v[1:] default: return &func0TypeError{"abs", v} } @@ -314,6 +322,11 @@ func funcLength(v any) any { return v } return new(big.Int).Abs(v) + case json.Number: + if !strings.HasPrefix(v.String(), "-") { + return v + } + return v[1:] case string: return len([]rune(v)) case []any: @@ -487,16 +500,10 @@ func funcAdd(v any) any { case map[string]any: switch w := v.(type) { case nil: - m := make(map[string]any, len(x)) - for k, e := range x { - m[k] = e - } - v = m + v = maps.Clone(x) continue case map[string]any: - for k, e := range x { - w[k] = e - } + maps.Copy(w, x) continue } } @@ -514,9 +521,27 @@ func funcAdd(v any) any { return v } +func funcToBoolean(v any) any { + switch v := v.(type) { + case bool: + return v + case string: + switch v { + case "true": + return true + case "false": + return false + default: + return &func0WrapError{"toboolean", v, errors.New("invalid boolean")} + } + default: + return &func0TypeError{"toboolean", v} + } +} + func funcToNumber(v any) any { switch v := v.(type) { - case int, float64, *big.Int: + case int, float64, *big.Int, json.Number: return v case string: if !newLexer(v).validNumber() { @@ -529,7 +554,7 @@ func funcToNumber(v any) any { } func toNumber(v string) any { - return normalizeNumber(json.Number(v)) + return parseNumber(json.Number(v)) } func funcToString(v any) any { @@ -602,7 +627,7 @@ func indices(vs, xs []any) any { if len(xs) == 0 { return rs } - for i := 0; i <= len(vs)-len(xs); i++ { + for i := range len(vs) - len(xs) + 1 { if Compare(vs[i:i+len(xs)], xs) == 0 { rs = append(rs, i) } @@ -615,7 +640,7 @@ func funcIndex(v, x any) any { if len(xs) == 0 { return nil } - for i := 0; i <= len(vs)-len(xs); i++ { + for i := range len(vs) - len(xs) + 1 { if Compare(vs[i:i+len(xs)], xs) == 0 { return i } @@ -707,6 +732,18 @@ func funcRtrimstr(v, x any) any { return strings.TrimSuffix(s, t) } +func funcTrimstr(v, x any) any { + s, ok := v.(string) + if !ok { + return &func1TypeError{"trimstr", v, x} + } + t, ok := x.(string) + if !ok { + return &func1TypeError{"trimstr", v, x} + } + return strings.TrimSuffix(strings.TrimPrefix(s, t), t) +} + func funcLtrim(v any) any { s, ok := v.(string) if !ok { @@ -848,7 +885,7 @@ func funcFromJSON(v any) any { if _, err := dec.Token(); err != io.EOF { return &func0TypeError{"fromjson", v} } - return normalizeNumbers(w) + return w } func funcFormat(v, x any) any { @@ -997,7 +1034,7 @@ func funcIndex2(_, v, x any) any { default: return &expectedObjectError{v} } - case int, float64, *big.Int: + case int, float64, *big.Int, json.Number: i, _ := toInt(x) switch v := v.(type) { case nil: @@ -1087,7 +1124,7 @@ func slice(vs []any, e, s any) any { } } if e != nil { - if i, ok := toInt(e); ok { + if i, ok := toIntCeil(e); ok { end = clampIndex(i, start, len(vs)) } else { return &arrayIndexNotNumberError{e} @@ -1109,7 +1146,7 @@ func sliceString(v string, e, s any) any { } } if e != nil { - if i, ok := toInt(e); ok { + if i, ok := toIntCeil(e); ok { end = clampIndex(i, start, l) } else { return &stringIndexNotNumberError{e} @@ -1140,16 +1177,16 @@ func sliceString(v string, e, s any) any { return v[start:end] } -func clampIndex(i, min, max int) int { +func clampIndex(i, minimum, maximum int) int { if i < 0 { - i += max + i += maximum } - if i < min { - return min - } else if i < max { + if i < minimum { + return minimum + } else if i < maximum { return i } else { - return max + return maximum } } @@ -1200,7 +1237,7 @@ func (iter *rangeIter) Next() (any, bool) { func funcRange(_ any, xs []any) any { for _, x := range xs { switch x.(type) { - case int, float64, *big.Int: + case int, float64, *big.Int, json.Number: default: return &func0TypeError{"range", x} } @@ -1380,7 +1417,7 @@ func funcJoin(v, x any) any { } else { ss[i] = "false" } - case int, float64, *big.Int: + case int, float64, *big.Int, json.Number: ss[i] = jsonMarshal(v) default: return &joinTypeError{v} @@ -1585,7 +1622,7 @@ func update(v any, path []any, n any, a allocator) (any, error) { default: return nil, &expectedObjectError{v} } - case int, float64, *big.Int: + case int, float64, *big.Int, json.Number: i, _ := toInt(p) switch v := v.(type) { case nil: @@ -1632,9 +1669,7 @@ func updateObject(v map[string]any, k string, path []any, n any, a allocator) (a return v, nil } w := a.makeObject(len(v) + 1) - for k, v := range v { - w[k] = v - } + maps.Copy(w, v) w[k] = u return w, nil } @@ -1653,7 +1688,7 @@ func updateArrayIndex(v []any, i int, path []any, n any, a allocator) (any, erro if n == struct{}{} { return v, nil } - if i >= 0x8000000 { + if i >= 0x20000000 { return nil, &arrayIndexTooLargeError{i} } } @@ -2043,7 +2078,6 @@ func compileRegexp(re, flags string) (*regexp.Regexp, error) { }) >= 0 { return nil, fmt.Errorf("unsupported regular expression flag: %q", flags) } - re = strings.ReplaceAll(re, "(?<", "(?P<") if strings.ContainsRune(flags, 'i') { re = "(?i)" + re } @@ -2116,11 +2150,20 @@ func toInt(x any) (int, bool) { return math.MaxInt, true } return math.MinInt, true + case json.Number: + return toInt(parseNumber(x)) default: return 0, false } } +func toIntCeil(x any) (int, bool) { + if f, ok := x.(float64); ok { + x = math.Ceil(f) + } + return toInt(x) +} + func floatToInt(x float64) int { if math.MinInt <= x && x <= math.MaxInt { return int(x) @@ -2139,6 +2182,9 @@ func toFloat(x any) (float64, bool) { return x, true case *big.Int: return bigToFloat(x), true + case json.Number: + v, err := x.Float64() + return v, err == nil default: return 0.0, false } @@ -2153,3 +2199,21 @@ func bigToFloat(x *big.Int) float64 { } return math.Inf(x.Sign()) } + +func parseNumber(v json.Number) any { + if i, err := v.Int64(); err == nil && math.MinInt <= i && i <= math.MaxInt { + return int(i) + } + if strings.ContainsAny(v.String(), ".eE") { + if f, err := v.Float64(); err == nil { + return f + } + } + if bi, ok := new(big.Int).SetString(v.String(), 10); ok { + return bi + } + if strings.HasPrefix(v.String(), "-") { + return math.Inf(-1) + } + return math.Inf(1) +} diff --git a/vendor/github.com/itchyny/gojq/go.dev.mod b/vendor/github.com/itchyny/gojq/go.dev.mod index bdc69df6..dbf53785 100644 --- a/vendor/github.com/itchyny/gojq/go.dev.mod +++ b/vendor/github.com/itchyny/gojq/go.dev.mod @@ -1,8 +1,8 @@ module github.com/itchyny/gojq -go 1.21 +go 1.24.0 require ( - github.com/itchyny/astgen-go v0.0.0-20231113225122-e1c22b9aaf7b // indirect - github.com/itchyny/timefmt-go v0.1.6 // indirect + github.com/itchyny/astgen-go v0.0.0-20250520171007-4331c963041e // indirect + github.com/itchyny/timefmt-go v0.1.7 // indirect ) diff --git a/vendor/github.com/itchyny/gojq/go.dev.sum b/vendor/github.com/itchyny/gojq/go.dev.sum index e8691b82..e66f4173 100644 --- a/vendor/github.com/itchyny/gojq/go.dev.sum +++ b/vendor/github.com/itchyny/gojq/go.dev.sum @@ -1,4 +1,4 @@ -github.com/itchyny/astgen-go v0.0.0-20231113225122-e1c22b9aaf7b h1:72fDU7wad+r3iQObaxhlXVIpAIMRUIUMrNa3go1vb8s= -github.com/itchyny/astgen-go v0.0.0-20231113225122-e1c22b9aaf7b/go.mod h1:Zp6xzEWVc2pQ/ObfLD6t/M6gDegsJWKdGKJSiT7qlu0= -github.com/itchyny/timefmt-go v0.1.6 h1:ia3s54iciXDdzWzwaVKXZPbiXzxxnv1SPGFfM/myJ5Q= -github.com/itchyny/timefmt-go v0.1.6/go.mod h1:RRDZYC5s9ErkjQvTvvU7keJjxUYzIISJGxm9/mAERQg= +github.com/itchyny/astgen-go v0.0.0-20250520171007-4331c963041e h1:Pu7Ev38D+75aWdsHzULyVZfMP3WrgIHNUaAUH81CTqE= +github.com/itchyny/astgen-go v0.0.0-20250520171007-4331c963041e/go.mod h1:8EXgnGrgW1p0qVnOF1A/4ORQEUAi8TvxQdIR+zJfKxM= +github.com/itchyny/timefmt-go v0.1.7 h1:xyftit9Tbw+Dc/huSSPJaEmX1TVL8lw5vxjJLK4GMMA= +github.com/itchyny/timefmt-go v0.1.7/go.mod h1:5E46Q+zj7vbTgWY8o5YkMeYb4I6GeWLFnetPy5oBrAI= diff --git a/vendor/github.com/itchyny/gojq/iter.go b/vendor/github.com/itchyny/gojq/iter.go index d0bed960..fb8a8ffe 100644 --- a/vendor/github.com/itchyny/gojq/iter.go +++ b/vendor/github.com/itchyny/gojq/iter.go @@ -6,14 +6,14 @@ type Iter interface { } // NewIter creates a new [Iter] from values. -func NewIter(values ...any) Iter { +func NewIter[T any](values ...T) Iter { switch len(values) { case 0: return emptyIter{} case 1: return &unitIter{value: values[0]} default: - iter := sliceIter(values) + iter := sliceIter[T](values) return &iter } } @@ -37,9 +37,9 @@ func (iter *unitIter) Next() (any, bool) { return iter.value, true } -type sliceIter []any +type sliceIter[T any] []T -func (iter *sliceIter) Next() (any, bool) { +func (iter *sliceIter[T]) Next() (any, bool) { if len(*iter) == 0 { return nil, false } diff --git a/vendor/github.com/itchyny/gojq/lexer.go b/vendor/github.com/itchyny/gojq/lexer.go index 0c2efd12..82aeef31 100644 --- a/vendor/github.com/itchyny/gojq/lexer.go +++ b/vendor/github.com/itchyny/gojq/lexer.go @@ -507,7 +507,7 @@ func quoteAndEscape(src string, quote bool, controls int) []byte { buf[len(buf)-1] = '"' j++ } - for i := 0; i < len(src); i++ { + for i := range len(src) { if ch := src[i]; ch < ' ' { const hex = "0123456789abcdef" copy(buf[j:], `\u00`) diff --git a/vendor/github.com/itchyny/gojq/normalize.go b/vendor/github.com/itchyny/gojq/normalize.go deleted file mode 100644 index 2bfcd215..00000000 --- a/vendor/github.com/itchyny/gojq/normalize.go +++ /dev/null @@ -1,84 +0,0 @@ -package gojq - -import ( - "encoding/json" - "math" - "math/big" - "strings" -) - -func normalizeNumber(v json.Number) any { - if i, err := v.Int64(); err == nil && math.MinInt <= i && i <= math.MaxInt { - return int(i) - } - if strings.ContainsAny(v.String(), ".eE") { - if f, err := v.Float64(); err == nil { - return f - } - } - if bi, ok := new(big.Int).SetString(v.String(), 10); ok { - return bi - } - if strings.HasPrefix(v.String(), "-") { - return math.Inf(-1) - } - return math.Inf(1) -} - -func normalizeNumbers(v any) any { - switch v := v.(type) { - case json.Number: - return normalizeNumber(v) - case *big.Int: - if v.IsInt64() { - if i := v.Int64(); math.MinInt <= i && i <= math.MaxInt { - return int(i) - } - } - return v - case int64: - if math.MinInt <= v && v <= math.MaxInt { - return int(v) - } - return big.NewInt(v) - case int32: - return int(v) - case int16: - return int(v) - case int8: - return int(v) - case uint: - if v <= math.MaxInt { - return int(v) - } - return new(big.Int).SetUint64(uint64(v)) - case uint64: - if v <= math.MaxInt { - return int(v) - } - return new(big.Int).SetUint64(v) - case uint32: - if uint64(v) <= math.MaxInt { - return int(v) - } - return new(big.Int).SetUint64(uint64(v)) - case uint16: - return int(v) - case uint8: - return int(v) - case float32: - return float64(v) - case []any: - for i, x := range v { - v[i] = normalizeNumbers(x) - } - return v - case map[string]any: - for k, x := range v { - v[k] = normalizeNumbers(x) - } - return v - default: - return v - } -} diff --git a/vendor/github.com/itchyny/gojq/operator.go b/vendor/github.com/itchyny/gojq/operator.go index 64b74b78..a49e84f2 100644 --- a/vendor/github.com/itchyny/gojq/operator.go +++ b/vendor/github.com/itchyny/gojq/operator.go @@ -1,6 +1,8 @@ package gojq import ( + "encoding/json" + "maps" "math" "math/big" "strings" @@ -154,19 +156,15 @@ func (op Operator) GoString() (str string) { func (op Operator) getFunc() string { switch op { - case OpPipe: - panic("unreachable") - case OpComma: - panic("unreachable") - case OpAdd: + case OpAdd, OpUpdateAdd: return "_add" - case OpSub: + case OpSub, OpUpdateSub: return "_subtract" - case OpMul: + case OpMul, OpUpdateMul: return "_multiply" - case OpDiv: + case OpDiv, OpUpdateDiv: return "_divide" - case OpMod: + case OpMod, OpUpdateMod: return "_modulo" case OpEq: return "_equal" @@ -180,26 +178,10 @@ func (op Operator) getFunc() string { return "_greatereq" case OpLe: return "_lesseq" - case OpAnd: - panic("unreachable") - case OpOr: - panic("unreachable") - case OpAlt: - panic("unreachable") case OpAssign: return "_assign" case OpModify: return "_modify" - case OpUpdateAdd: - return "_add" - case OpUpdateSub: - return "_subtract" - case OpUpdateMul: - return "_multiply" - case OpUpdateDiv: - return "_divide" - case OpUpdateMod: - return "_modulo" case OpUpdateAlt: return "_alternative" default: @@ -207,15 +189,21 @@ func (op Operator) getFunc() string { } } -func binopTypeSwitch( +func binopTypeSwitch[T any]( l, r any, - callbackInts func(_, _ int) any, - callbackFloats func(_, _ float64) any, - callbackBigInts func(_, _ *big.Int) any, - callbackStrings func(_, _ string) any, - callbackArrays func(_, _ []any) any, - callbackMaps func(_, _ map[string]any) any, - fallback func(_, _ any) any) any { + callbackInts func(_, _ int) T, + callbackFloats func(_, _ float64) T, + callbackBigInts func(_, _ *big.Int) T, + callbackStrings func(_, _ string) T, + callbackArrays func(_, _ []any) T, + callbackMaps func(_, _ map[string]any) T, + fallback func(_, _ any) T) T { + if n, ok := l.(json.Number); ok { + l = parseNumber(n) + } + if n, ok := r.(json.Number); ok { + r = parseNumber(n) + } switch l := l.(type) { case int: switch r := r.(type) { @@ -284,6 +272,8 @@ func funcOpPlus(v any) any { return v case *big.Int: return v + case json.Number: + return v default: return &unaryTypeError{"plus", v} } @@ -297,6 +287,11 @@ func funcOpNegate(v any) any { return -v case *big.Int: return new(big.Int).Neg(v) + case json.Number: + if strings.HasPrefix(v.String(), "-") { + return v[1:] + } + return "-" + v default: return &unaryTypeError{"negate", v} } @@ -334,12 +329,8 @@ func funcOpAdd(_, l, r any) any { return l } m := make(map[string]any, len(l)+len(r)) - for k, v := range l { - m[k] = v - } - for k, v := range r { - m[k] = v - } + maps.Copy(m, l) + maps.Copy(m, r) return m }, func(l, r any) any { @@ -416,9 +407,7 @@ func funcOpMul(_, l, r any) any { func deepMergeObjects(l, r map[string]any) any { m := make(map[string]any, len(l)+len(r)) - for k, v := range l { - m[k] = v - } + maps.Copy(m, l) for k, v := range r { if mk, ok := m[k]; ok { if mk, ok := mk.(map[string]any); ok { @@ -433,12 +422,15 @@ func deepMergeObjects(l, r map[string]any) any { } func repeatString(s string, n float64) any { - if n < 0.0 || len(s) > 0 && n > float64(0x10000000/len(s)) || math.IsNaN(n) { + if n < 0.0 || math.IsNaN(n) { return nil } if s == "" { return "" } + if n >= float64(math.MaxInt32/len(s)) { + return &repeatStringTooLargeError{s, n} + } return strings.Repeat(s, int(n)) } diff --git a/vendor/github.com/itchyny/gojq/option.go b/vendor/github.com/itchyny/gojq/option.go index f1a110fa..801e9a99 100644 --- a/vendor/github.com/itchyny/gojq/option.go +++ b/vendor/github.com/itchyny/gojq/option.go @@ -33,7 +33,7 @@ func WithVariables(variables []string) CompilerOption { // WithFunction is a compiler option for adding a custom internal function. // Specify the minimum and maximum count of the function arguments. These // values should satisfy 0 <= minarity <= maxarity <= 30, otherwise panics. -// On handling numbers, you should take account to int, float64 and *big.Int. +// On handling numbers, take account of int, float64, *big.Int, and json.Number. // These are the number types you are allowed to return, so do not return int64. // Refer to [ValueError] to return a value error just like built-in error // function. If you want to emit multiple values, call the empty function, diff --git a/vendor/github.com/itchyny/gojq/parser.go b/vendor/github.com/itchyny/gojq/parser.go index 5a0dfdc7..277bd3ee 100644 --- a/vendor/github.com/itchyny/gojq/parser.go +++ b/vendor/github.com/itchyny/gojq/parser.go @@ -147,147 +147,147 @@ const yyEofCode = 1 const yyErrCode = 2 const yyInitialStackSize = 16 -//line parser.go.y:671 +//line parser.go.y:669 //line yacctab:1 var yyExca = [...]int16{ -1, 1, 1, -1, -2, 0, - -1, 145, + -1, 138, 5, 0, -2, 27, - -1, 148, + -1, 141, 7, 0, -2, 30, - -1, 199, + -1, 198, 59, 114, -2, 49, } const yyPrivate = 57344 -const yyLast = 782 +const yyLast = 781 var yyAct = [...]int16{ - 78, 134, 186, 102, 103, 10, 175, 195, 32, 211, - 48, 108, 81, 176, 131, 6, 229, 5, 50, 73, - 74, 159, 14, 180, 181, 182, 124, 98, 110, 135, - 280, 97, 228, 279, 115, 104, 16, 158, 265, 121, - 114, 178, 123, 179, 244, 73, 74, 180, 181, 182, - 73, 74, 112, 113, 154, 155, 136, 117, 117, 117, - 254, 243, 137, 183, 282, 178, 255, 179, 220, 6, - 247, 116, 118, 119, 128, 129, 73, 74, 99, 73, - 74, 227, 73, 74, 246, 141, 238, 183, 201, 237, - 132, 200, 139, 6, 235, 226, 138, 163, 208, 80, - 157, 207, 241, 231, 230, 161, 162, 73, 74, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 83, - 82, 278, 84, 144, 145, 146, 147, 148, 149, 150, - 151, 152, 153, 184, 185, 174, 50, 160, 193, 73, - 74, 127, 196, 202, 203, 126, 197, 73, 74, 125, - 73, 74, 248, 253, 189, 204, 45, 240, 206, 73, - 74, 245, 143, 210, 214, 215, 73, 74, 104, 217, - 218, 213, 79, 219, 86, 87, 76, 90, 88, 89, - 169, 43, 44, 117, 117, 73, 74, 75, 166, 117, - 222, 224, 80, 225, 73, 74, 273, 212, 212, 232, - 132, 223, 234, 216, 120, 271, 73, 74, 191, 239, - 43, 44, 83, 82, 85, 84, 274, 270, 96, 91, - 92, 93, 94, 95, 73, 74, 93, 94, 95, 249, - 84, 164, 251, 252, 196, 236, 267, 250, 197, 130, - 25, 256, 73, 74, 262, 263, 187, 188, 3, 190, - 257, 258, 260, 261, 264, 24, 266, 73, 74, 9, - 221, 268, 269, 117, 117, 111, 171, 272, 172, 170, - 13, 275, 276, 77, 90, 277, 89, 212, 212, 13, - 177, 281, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 106, 107, 91, 92, 93, 94, 95, - 47, 43, 44, 101, 165, 259, 91, 92, 93, 94, - 95, 242, 156, 122, 194, 17, 192, 15, 37, 21, - 22, 23, 33, 133, 105, 205, 7, 34, 209, 35, - 36, 39, 41, 40, 42, 19, 20, 28, 31, 43, - 44, 8, 4, 2, 86, 87, 1, 90, 88, 89, - 0, 29, 30, 0, 168, 90, 18, 0, 0, 27, - 0, 142, 38, 0, 140, 26, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 106, 107, 91, - 92, 93, 94, 95, 0, 43, 44, 91, 92, 93, - 94, 95, 0, 0, 0, 0, 0, 11, 12, 17, - 0, 15, 37, 21, 22, 23, 33, 0, 105, 0, - 0, 34, 100, 35, 36, 39, 41, 40, 42, 19, - 20, 28, 31, 43, 44, 0, 0, 0, 0, 86, - 87, 0, 90, 88, 89, 29, 30, 0, 0, 167, - 18, 0, 0, 27, 0, 0, 38, 0, 17, 26, + 78, 133, 174, 185, 103, 10, 210, 194, 175, 130, + 108, 102, 5, 134, 48, 228, 158, 50, 73, 74, + 123, 6, 32, 93, 73, 74, 243, 14, 110, 246, + 204, 227, 157, 203, 115, 279, 122, 264, 278, 120, + 135, 98, 97, 245, 148, 149, 136, 73, 74, 104, + 179, 180, 181, 226, 114, 242, 73, 74, 179, 180, + 181, 281, 116, 117, 118, 73, 74, 225, 177, 253, + 178, 255, 73, 74, 127, 128, 177, 99, 178, 234, + 237, 207, 233, 240, 206, 131, 230, 162, 229, 160, + 182, 73, 74, 73, 74, 219, 6, 153, 182, 159, + 156, 126, 125, 247, 6, 277, 161, 252, 137, 138, + 139, 140, 141, 142, 143, 144, 145, 146, 151, 150, + 124, 73, 74, 188, 45, 73, 74, 239, 183, 184, + 73, 74, 73, 74, 50, 244, 147, 192, 173, 213, + 91, 195, 92, 272, 168, 73, 74, 76, 199, 200, + 73, 74, 75, 202, 119, 205, 270, 90, 84, 196, + 83, 269, 95, 94, 214, 96, 165, 212, 216, 217, + 209, 190, 218, 80, 81, 129, 84, 82, 83, 43, + 44, 104, 266, 167, 25, 221, 3, 211, 211, 24, + 223, 220, 224, 215, 131, 222, 73, 74, 231, 96, + 85, 86, 87, 88, 89, 236, 176, 232, 238, 47, + 80, 81, 189, 84, 82, 83, 43, 44, 85, 86, + 87, 88, 89, 85, 86, 87, 88, 89, 248, 73, + 74, 250, 251, 195, 186, 187, 249, 101, 254, 87, + 88, 89, 164, 261, 262, 258, 256, 257, 241, 263, + 273, 196, 163, 155, 265, 85, 86, 87, 88, 89, + 267, 268, 84, 82, 83, 121, 271, 211, 211, 193, + 274, 275, 84, 191, 276, 132, 73, 74, 73, 74, + 280, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 106, 107, 85, 86, 87, 88, 89, 9, + 43, 44, 259, 260, 85, 86, 87, 88, 89, 170, + 17, 171, 169, 77, 16, 201, 15, 37, 21, 22, + 23, 33, 7, 105, 8, 4, 34, 208, 35, 36, + 39, 41, 40, 42, 19, 20, 28, 31, 43, 44, + 112, 113, 2, 80, 81, 1, 84, 82, 83, 0, + 29, 30, 0, 166, 0, 18, 0, 0, 27, 0, + 154, 38, 0, 152, 26, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 106, 107, 85, 86, + 87, 88, 89, 0, 43, 44, 0, 0, 0, 0, + 0, 0, 0, 0, 111, 0, 11, 12, 16, 13, + 15, 37, 21, 22, 23, 33, 0, 105, 13, 0, + 34, 100, 35, 36, 39, 41, 40, 42, 19, 20, + 28, 31, 43, 44, 0, 0, 0, 0, 80, 81, + 0, 84, 82, 83, 29, 30, 0, 0, 79, 18, + 0, 0, 27, 0, 0, 38, 0, 16, 26, 15, + 37, 21, 22, 23, 33, 0, 0, 0, 0, 34, + 0, 35, 36, 39, 41, 40, 42, 19, 20, 28, + 31, 43, 44, 85, 86, 87, 88, 89, 0, 0, + 0, 0, 0, 29, 30, 0, 0, 0, 18, 0, + 0, 27, 0, 0, 38, 0, 235, 26, 16, 0, 15, 37, 21, 22, 23, 33, 0, 0, 0, 0, 34, 0, 35, 36, 39, 41, 40, 42, 19, 20, - 28, 31, 43, 44, 91, 92, 93, 94, 95, 0, - 0, 0, 0, 0, 29, 30, 90, 88, 89, 18, - 0, 0, 27, 0, 0, 38, 0, 233, 26, 17, + 28, 31, 43, 44, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 29, 30, 0, 0, 0, 18, + 0, 0, 27, 0, 0, 38, 0, 109, 26, 16, 0, 15, 37, 21, 22, 23, 33, 0, 0, 0, 0, 34, 0, 35, 36, 39, 41, 40, 42, 19, - 20, 28, 31, 43, 44, 0, 0, 0, 91, 92, - 93, 94, 95, 0, 0, 29, 30, 0, 0, 0, - 18, 0, 0, 27, 0, 0, 38, 0, 109, 26, - 17, 0, 15, 37, 21, 22, 23, 33, 0, 0, - 0, 0, 34, 0, 35, 36, 39, 41, 40, 42, - 19, 20, 28, 31, 43, 44, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 29, 30, 0, 0, - 0, 18, 0, 0, 27, 0, 0, 38, 0, 0, - 26, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 49, 0, 0, 0, 0, 0, 0, 0, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 49, 0, 0, 0, 0, 173, 0, 0, - 51, 37, 21, 22, 23, 33, 0, 0, 0, 0, - 34, 0, 35, 36, 39, 41, 40, 42, 19, 20, - 28, 31, 43, 44, 0, 0, 0, 46, 0, 0, - 0, 0, 0, 0, 29, 30, 0, 0, 0, 18, - 0, 0, 27, 0, 0, 38, 0, 0, 26, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 106, 199, 0, 0, 0, 0, 0, 0, 43, 44, + 20, 28, 31, 43, 44, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 29, 30, 0, 0, 0, + 18, 0, 0, 27, 0, 0, 38, 0, 0, 26, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 49, 0, 0, 0, 0, 0, 0, 0, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 49, 0, 0, 0, 0, 172, 0, 0, 51, + 37, 21, 22, 23, 33, 0, 0, 0, 0, 34, + 0, 35, 36, 39, 41, 40, 42, 19, 20, 28, + 31, 43, 44, 0, 0, 0, 46, 0, 0, 0, + 0, 0, 0, 29, 30, 0, 0, 0, 18, 0, + 0, 27, 0, 0, 38, 0, 0, 26, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 106, + 198, 0, 0, 0, 0, 0, 0, 43, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 198, + 197, } var yyPact = [...]int16{ - 238, -1000, -1000, -48, 406, 98, 643, -1000, -1000, -1000, - 112, 150, 139, 557, 158, 184, 170, 189, 173, -1000, - -1000, -1000, -1000, -1000, 18, -1000, 368, 506, -1000, 665, - 665, 144, -1000, 557, 665, 665, 665, 174, 557, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -22, -1000, 90, - 86, 82, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + 176, -1000, -1000, -42, 405, 66, 642, -1000, -1000, -1000, + 182, 115, 110, 556, 444, 127, 111, 108, 142, -1000, + -1000, -1000, -1000, -1000, 17, -1000, 367, 505, -1000, 664, + 664, 179, -1000, 556, 664, 664, 664, 124, 556, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -28, -1000, 61, + 43, 42, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 557, 557, 225, -48, -1000, 112, -1, - -1000, -1000, -1000, 173, 312, 115, 665, 665, 665, 665, - 665, 665, 665, 665, 665, 665, -5, -1000, -1000, 557, - -1000, -27, -1000, 78, 46, 557, -1000, -1000, -1000, -1000, - 35, 557, 65, 65, -1000, 210, 162, 65, 445, 350, - -1000, 119, 229, -1000, 613, 30, 30, 30, 112, -1000, - 217, 96, -1000, 202, -1000, -1000, -1, 721, -1000, -1000, - -1000, 29, 557, 557, 170, 499, 267, 358, 256, 175, - 175, -1000, -1000, -1000, 557, 217, 40, 112, -1000, 274, - 665, 665, 103, -1000, 557, -1000, 665, -1, -1, -1000, - -1000, -1000, 557, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 6, -1000, -1000, -48, -1000, -1000, -1000, - 557, -1, 33, -1000, -32, -1000, 45, 44, 557, -1000, - -1000, 455, 32, 112, 177, 28, -1000, -1000, 557, -1000, - -1000, 110, 170, 110, 43, 112, -1000, 1, -16, 100, - -1000, 22, -1000, 94, 112, -1000, -1000, -1, -1000, 721, - -1, -1, 92, -1000, -2, -1000, -1000, 7, 217, 112, - 665, 665, 230, 557, 557, -1000, -1000, 30, -1000, -1000, - -1000, -1000, -1000, -21, -1000, 557, -1000, 110, 110, 212, - 557, 557, 159, 147, -1000, -1, 138, -1000, 195, 112, - 557, 557, -1000, -1000, 557, 60, -28, 112, -1000, -1000, - 557, 3, -1000, + -1000, -1000, -1000, 556, 556, 161, -42, -1000, 182, -17, + 664, 664, 664, 664, 664, 664, 664, 664, 664, 664, + 89, -15, -1000, -1000, -1000, 142, 311, -1000, -1000, 556, + -1000, -32, -1000, 40, 30, 556, -1000, -1000, -1000, -1000, + 25, 556, 108, 108, -1000, 231, 140, 349, 169, -1000, + 83, 282, -1000, 612, 41, 41, 41, 182, -1000, 205, + 65, -1000, 165, -1000, -1000, -17, 720, 206, 255, 151, + 265, 174, 188, 188, -1000, -1000, -1000, 556, 556, 205, + -1000, -1000, -1000, -29, 556, 23, 182, -1000, 273, 664, + 664, 78, -1000, 556, -1000, 664, -17, -17, -1000, -1000, + -1000, 556, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, 33, -1000, -1000, -42, -1000, -1000, -1000, 556, + -17, 5, -1000, -33, -1000, 29, 27, 556, -1000, 182, + 149, 21, -1000, -1000, 454, 18, -1000, 556, -1000, -1000, + 80, 206, 80, 24, 182, -1000, -5, -34, 74, -1000, + -19, -1000, 45, 182, -1000, -1000, -17, -1000, 720, -17, + -17, 46, -1000, 10, 205, -1000, 9, -1000, 182, 664, + 664, 290, 556, 556, -1000, -1000, 41, -1000, -1000, -1000, + -1000, -1000, -22, 556, -1000, -1000, 80, 80, 158, 556, + 556, 103, 98, -1000, -17, 85, -1000, 229, 182, 556, + 556, -1000, -1000, 556, 44, -23, 182, -1000, -1000, 556, + 0, -1000, } var yyPgo = [...]int16{ - 0, 356, 353, 352, 351, 14, 336, 259, 265, 335, - 0, 333, 1, 326, 324, 7, 36, 22, 8, 323, - 12, 322, 321, 315, 314, 313, 3, 9, 6, 13, - 310, 10, 280, 260, 2, 255, 240, 11, 4, + 0, 355, 352, 335, 334, 9, 332, 309, 414, 325, + 0, 275, 1, 273, 269, 7, 27, 320, 22, 265, + 23, 253, 248, 245, 242, 237, 11, 6, 2, 8, + 209, 14, 206, 191, 3, 189, 184, 10, 4, } var yyR1 = [...]int8{ @@ -330,66 +330,66 @@ var yyR2 = [...]int8{ var yyChk = [...]int16{ -1000, -1, -2, 10, -3, -29, 63, -6, -4, -7, - -10, 11, 12, -8, -17, 15, -16, 13, 54, 33, + -10, 11, 12, -8, -16, 15, 13, -17, 54, 33, 34, 17, 18, 19, -35, -36, 63, 57, 35, 49, 50, 36, -18, 20, 25, 27, 28, 16, 60, 29, 31, 30, 32, 37, 38, 58, 64, -30, -31, 29, -37, 37, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 47, 48, 37, 37, -7, -10, 14, - 34, -20, 55, 54, 57, 30, 4, 5, 8, 9, - 7, 49, 50, 51, 52, 53, 29, -20, -18, 60, + 4, 5, 8, 9, 7, 49, 50, 51, 52, 53, + 30, 29, 34, -20, 55, 54, 57, -20, -18, 60, 64, -25, -26, -38, -18, 60, 29, 30, -37, 62, - -10, -8, -17, -17, -18, -10, -16, -17, -16, -16, - 30, -10, -19, 64, 48, 59, 59, 59, -10, -10, - 14, -5, -29, -11, -12, 30, 57, 63, -20, -18, - 62, -10, 59, 47, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, 59, 60, -21, -10, 64, 48, - 59, 59, -10, 62, 21, -24, 26, 14, 14, 61, - 40, 37, 39, 64, -31, -28, -29, -32, 35, 37, - 17, 18, 19, 57, -28, -28, -34, 29, 30, 58, - 47, 6, -13, -12, -14, -15, -38, -18, 60, 30, - 62, 59, -10, -10, -10, -9, -34, 61, 58, 64, - -26, -27, -16, -27, 61, -10, -16, -12, -12, -10, - 62, -33, -28, -5, -10, -12, 62, 48, 64, 48, - 59, 59, -10, 62, -10, 62, 58, 61, 58, -10, - 47, 59, -22, 60, 60, 61, 62, 48, 58, -12, - -15, -12, -12, 61, 62, 59, -34, -27, -27, -23, - 22, 23, -10, -10, -28, 59, -10, 24, -10, -10, - 58, 58, -12, 58, 21, -10, -10, -10, 61, 61, - 58, -10, 61, + -10, -8, -17, -17, -18, -10, -16, -16, -16, 30, + -10, -19, 64, 48, 59, 59, 59, -10, -10, 14, + -5, -29, -11, -12, 30, 57, 63, -16, -16, -16, + -16, -16, -16, -16, -16, -16, -16, 47, 59, 60, + -20, -18, 62, -10, 59, -21, -10, 64, 48, 59, + 59, -10, 62, 21, -24, 26, 14, 14, 61, 40, + 37, 39, 64, -31, -28, -29, -32, 35, 37, 17, + 18, 19, 57, -28, -28, -34, 29, 30, 58, 47, + 6, -13, -12, -14, -15, -38, -18, 60, 30, -10, + -10, -9, -34, 62, 59, -10, 61, 58, 64, -26, + -27, -16, -27, 61, -10, -16, -12, -12, -10, 62, + -33, -28, -5, -10, -12, 62, 48, 64, 48, 59, + 59, -10, 58, 61, 58, 62, -10, 62, -10, 47, + 59, -22, 60, 60, 61, 62, 48, 58, -12, -15, + -12, -12, 61, 59, -34, 62, -27, -27, -23, 22, + 23, -10, -10, -28, 59, -10, 24, -10, -10, 58, + 58, -12, 58, 21, -10, -10, -10, 61, 61, 58, + -10, 61, } var yyDef = [...]int16{ 2, -2, 4, 0, 12, 0, 0, 1, 5, 10, - 11, 0, 0, 12, 36, 0, 25, 0, 50, 51, + 11, 0, 0, 12, 25, 0, 0, 36, 50, 51, 52, 55, 56, 57, 58, 60, 0, 0, 66, 0, 0, 69, 71, 0, 0, 0, 0, 0, 0, 89, 90, 91, 92, 84, 86, 3, 125, 0, 128, 0, 0, 0, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 0, 0, 0, 8, 13, 20, 0, - 79, 80, 81, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 53, 54, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 79, 80, 81, 0, 0, 53, 54, 0, 61, 0, 106, 111, 112, 0, 113, 114, 115, 64, - 0, 0, 67, 68, 70, 0, 104, 36, 0, 0, - 77, 0, 0, 126, 0, 0, 0, 0, 21, 24, - 0, 0, 9, 0, 37, 39, 0, 0, 82, 83, - 93, 0, 0, 0, 26, -2, 28, 29, -2, 31, - 32, 33, 34, 35, 0, 0, 0, 98, 62, 0, - 0, 0, 0, 65, 0, 73, 0, 0, 0, 78, - 85, 87, 0, 127, 129, 130, 118, 119, 120, 121, - 122, 123, 124, 0, 131, 132, 8, 18, 19, 7, - 0, 0, 0, 42, 0, 44, 0, 0, 0, -2, - 94, 0, 0, 23, 0, 0, 16, 59, 0, 63, - 107, 108, 117, 109, 0, 100, 105, 0, 0, 0, - 133, 0, 135, 0, 22, 38, 40, 0, 41, 0, - 0, 0, 0, 95, 0, 96, 14, 0, 0, 99, - 0, 0, 102, 0, 0, 88, 134, 0, 6, 43, - 45, 46, 47, 0, 97, 0, 17, 116, 110, 0, - 0, 0, 0, 0, 136, 0, 0, 72, 0, 103, - 0, 0, 48, 15, 0, 0, 0, 101, 74, 75, - 0, 0, 76, + 0, 0, 67, 68, 70, 0, 104, 0, 0, 77, + 0, 0, 126, 0, 0, 0, 0, 21, 24, 0, + 0, 9, 0, 37, 39, 0, 0, 26, -2, 28, + 29, -2, 31, 32, 33, 34, 35, 0, 0, 0, + 82, 83, 93, 0, 0, 0, 98, 62, 0, 0, + 0, 0, 65, 0, 73, 0, 0, 0, 78, 85, + 87, 0, 127, 129, 130, 118, 119, 120, 121, 122, + 123, 124, 0, 131, 132, 8, 18, 19, 7, 0, + 0, 0, 42, 0, 44, 0, 0, 0, -2, 23, + 0, 0, 16, 94, 0, 0, 59, 0, 63, 107, + 108, 117, 109, 0, 100, 105, 0, 0, 0, 133, + 0, 135, 0, 22, 38, 40, 0, 41, 0, 0, + 0, 0, 14, 0, 0, 95, 0, 96, 99, 0, + 0, 102, 0, 0, 88, 134, 0, 6, 43, 45, + 46, 47, 0, 0, 17, 97, 116, 110, 0, 0, + 0, 0, 0, 136, 0, 0, 72, 0, 103, 0, + 0, 48, 15, 0, 0, 0, 101, 74, 75, 0, + 0, 76, } var yyTok1 = [...]int8{ @@ -868,187 +868,185 @@ yydefault: yyDollar = yyS[yypt-5 : yypt+1] //line parser.go.y:155 { - term := yyDollar[1].value.(*Term) - term.SuffixList = append(term.SuffixList, &Suffix{Bind: &Bind{yyDollar[3].value.([]*Pattern), yyDollar[5].value.(*Query)}}) - yyVAL.value = &Query{Term: term} + yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpPipe, Right: yyDollar[5].value.(*Query), Patterns: yyDollar[3].value.([]*Pattern)} } case 23: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:161 +//line parser.go.y:159 { yyVAL.value = &Query{Term: &Term{Type: TermTypeLabel, Label: &Label{yyDollar[2].token, yyDollar[4].value.(*Query)}}} } case 24: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:165 +//line parser.go.y:163 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpComma, Right: yyDollar[3].value.(*Query)} } case 26: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:172 +//line parser.go.y:170 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: yyDollar[2].operator, Right: yyDollar[3].value.(*Query)} } case 27: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:176 +//line parser.go.y:174 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: yyDollar[2].operator, Right: yyDollar[3].value.(*Query)} } case 28: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:180 +//line parser.go.y:178 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpOr, Right: yyDollar[3].value.(*Query)} } case 29: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:184 +//line parser.go.y:182 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpAnd, Right: yyDollar[3].value.(*Query)} } case 30: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:188 +//line parser.go.y:186 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: yyDollar[2].operator, Right: yyDollar[3].value.(*Query)} } case 31: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:192 +//line parser.go.y:190 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpAdd, Right: yyDollar[3].value.(*Query)} } case 32: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:196 +//line parser.go.y:194 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpSub, Right: yyDollar[3].value.(*Query)} } case 33: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:200 +//line parser.go.y:198 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpMul, Right: yyDollar[3].value.(*Query)} } case 34: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:204 +//line parser.go.y:202 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpDiv, Right: yyDollar[3].value.(*Query)} } case 35: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:208 +//line parser.go.y:206 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpMod, Right: yyDollar[3].value.(*Query)} } case 36: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:212 +//line parser.go.y:210 { yyVAL.value = &Query{Term: yyDollar[1].value.(*Term)} } case 37: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:218 +//line parser.go.y:216 { yyVAL.value = []*Pattern{yyDollar[1].value.(*Pattern)} } case 38: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:222 +//line parser.go.y:220 { yyVAL.value = append(yyDollar[1].value.([]*Pattern), yyDollar[3].value.(*Pattern)) } case 39: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:228 +//line parser.go.y:226 { yyVAL.value = &Pattern{Name: yyDollar[1].token} } case 40: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:232 +//line parser.go.y:230 { yyVAL.value = &Pattern{Array: yyDollar[2].value.([]*Pattern)} } case 41: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:236 +//line parser.go.y:234 { yyVAL.value = &Pattern{Object: yyDollar[2].value.([]*PatternObject)} } case 42: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:242 +//line parser.go.y:240 { yyVAL.value = []*Pattern{yyDollar[1].value.(*Pattern)} } case 43: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:246 +//line parser.go.y:244 { yyVAL.value = append(yyDollar[1].value.([]*Pattern), yyDollar[3].value.(*Pattern)) } case 44: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:252 +//line parser.go.y:250 { yyVAL.value = []*PatternObject{yyDollar[1].value.(*PatternObject)} } case 45: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:256 +//line parser.go.y:254 { yyVAL.value = append(yyDollar[1].value.([]*PatternObject), yyDollar[3].value.(*PatternObject)) } case 46: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:262 +//line parser.go.y:260 { yyVAL.value = &PatternObject{Key: yyDollar[1].token, Val: yyDollar[3].value.(*Pattern)} } case 47: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:266 +//line parser.go.y:264 { yyVAL.value = &PatternObject{KeyString: yyDollar[1].value.(*String), Val: yyDollar[3].value.(*Pattern)} } case 48: yyDollar = yyS[yypt-5 : yypt+1] -//line parser.go.y:270 +//line parser.go.y:268 { yyVAL.value = &PatternObject{KeyQuery: yyDollar[2].value.(*Query), Val: yyDollar[5].value.(*Pattern)} } case 49: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:274 +//line parser.go.y:272 { yyVAL.value = &PatternObject{Key: yyDollar[1].token} } case 50: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:280 +//line parser.go.y:278 { yyVAL.value = &Term{Type: TermTypeIdentity} } case 51: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:284 +//line parser.go.y:282 { yyVAL.value = &Term{Type: TermTypeRecurse} } case 52: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:288 +//line parser.go.y:286 { yyVAL.value = &Term{Type: TermTypeIndex, Index: &Index{Name: yyDollar[1].token}} } case 53: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:292 +//line parser.go.y:290 { suffix := yyDollar[2].value.(*Suffix) if suffix.Iter { @@ -1059,452 +1057,452 @@ yydefault: } case 54: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:301 +//line parser.go.y:299 { yyVAL.value = &Term{Type: TermTypeIndex, Index: &Index{Str: yyDollar[2].value.(*String)}} } case 55: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:305 +//line parser.go.y:303 { yyVAL.value = &Term{Type: TermTypeNull} } case 56: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:309 +//line parser.go.y:307 { yyVAL.value = &Term{Type: TermTypeTrue} } case 57: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:313 +//line parser.go.y:311 { yyVAL.value = &Term{Type: TermTypeFalse} } case 58: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:317 +//line parser.go.y:315 { yyVAL.value = &Term{Type: TermTypeFunc, Func: &Func{Name: yyDollar[1].token}} } case 59: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:321 +//line parser.go.y:319 { yyVAL.value = &Term{Type: TermTypeFunc, Func: &Func{Name: yyDollar[1].token, Args: yyDollar[3].value.([]*Query)}} } case 60: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:325 +//line parser.go.y:323 { yyVAL.value = &Term{Type: TermTypeFunc, Func: &Func{Name: yyDollar[1].token}} } case 61: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:329 +//line parser.go.y:327 { yyVAL.value = &Term{Type: TermTypeObject, Object: &Object{}} } case 62: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:333 +//line parser.go.y:331 { yyVAL.value = &Term{Type: TermTypeObject, Object: &Object{yyDollar[2].value.([]*ObjectKeyVal)}} } case 63: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:337 +//line parser.go.y:335 { yyVAL.value = &Term{Type: TermTypeObject, Object: &Object{yyDollar[2].value.([]*ObjectKeyVal)}} } case 64: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:341 +//line parser.go.y:339 { yyVAL.value = &Term{Type: TermTypeArray, Array: &Array{}} } case 65: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:345 +//line parser.go.y:343 { yyVAL.value = &Term{Type: TermTypeArray, Array: &Array{yyDollar[2].value.(*Query)}} } case 66: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:349 +//line parser.go.y:347 { yyVAL.value = &Term{Type: TermTypeNumber, Number: yyDollar[1].token} } case 67: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:353 +//line parser.go.y:351 { yyVAL.value = &Term{Type: TermTypeUnary, Unary: &Unary{OpAdd, yyDollar[2].value.(*Term)}} } case 68: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:357 +//line parser.go.y:355 { yyVAL.value = &Term{Type: TermTypeUnary, Unary: &Unary{OpSub, yyDollar[2].value.(*Term)}} } case 69: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:361 +//line parser.go.y:359 { yyVAL.value = &Term{Type: TermTypeFormat, Format: yyDollar[1].token} } case 70: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:365 +//line parser.go.y:363 { yyVAL.value = &Term{Type: TermTypeFormat, Format: yyDollar[1].token, Str: yyDollar[2].value.(*String)} } case 71: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:369 +//line parser.go.y:367 { yyVAL.value = &Term{Type: TermTypeString, Str: yyDollar[1].value.(*String)} } case 72: yyDollar = yyS[yypt-7 : yypt+1] -//line parser.go.y:373 +//line parser.go.y:371 { yyVAL.value = &Term{Type: TermTypeIf, If: &If{yyDollar[2].value.(*Query), yyDollar[4].value.(*Query), yyDollar[5].value.([]*IfElif), yyDollar[6].value.(*Query)}} } case 73: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:377 +//line parser.go.y:375 { yyVAL.value = &Term{Type: TermTypeTry, Try: &Try{yyDollar[2].value.(*Query), yyDollar[3].value.(*Query)}} } case 74: yyDollar = yyS[yypt-9 : yypt+1] -//line parser.go.y:381 +//line parser.go.y:379 { yyVAL.value = &Term{Type: TermTypeReduce, Reduce: &Reduce{yyDollar[2].value.(*Query), yyDollar[4].value.(*Pattern), yyDollar[6].value.(*Query), yyDollar[8].value.(*Query)}} } case 75: yyDollar = yyS[yypt-9 : yypt+1] -//line parser.go.y:385 +//line parser.go.y:383 { yyVAL.value = &Term{Type: TermTypeForeach, Foreach: &Foreach{yyDollar[2].value.(*Query), yyDollar[4].value.(*Pattern), yyDollar[6].value.(*Query), yyDollar[8].value.(*Query), nil}} } case 76: yyDollar = yyS[yypt-11 : yypt+1] -//line parser.go.y:389 +//line parser.go.y:387 { yyVAL.value = &Term{Type: TermTypeForeach, Foreach: &Foreach{yyDollar[2].value.(*Query), yyDollar[4].value.(*Pattern), yyDollar[6].value.(*Query), yyDollar[8].value.(*Query), yyDollar[10].value.(*Query)}} } case 77: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:393 +//line parser.go.y:391 { yyVAL.value = &Term{Type: TermTypeBreak, Break: yyDollar[2].token} } case 78: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:397 +//line parser.go.y:395 { yyVAL.value = &Term{Type: TermTypeQuery, Query: yyDollar[2].value.(*Query)} } case 79: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:401 +//line parser.go.y:399 { yyDollar[1].value.(*Term).SuffixList = append(yyDollar[1].value.(*Term).SuffixList, &Suffix{Index: &Index{Name: yyDollar[2].token}}) } case 80: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:405 +//line parser.go.y:403 { yyDollar[1].value.(*Term).SuffixList = append(yyDollar[1].value.(*Term).SuffixList, yyDollar[2].value.(*Suffix)) } case 81: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:409 +//line parser.go.y:407 { yyDollar[1].value.(*Term).SuffixList = append(yyDollar[1].value.(*Term).SuffixList, &Suffix{Optional: true}) } case 82: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:413 +//line parser.go.y:411 { yyDollar[1].value.(*Term).SuffixList = append(yyDollar[1].value.(*Term).SuffixList, yyDollar[3].value.(*Suffix)) } case 83: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:417 +//line parser.go.y:415 { yyDollar[1].value.(*Term).SuffixList = append(yyDollar[1].value.(*Term).SuffixList, &Suffix{Index: &Index{Str: yyDollar[3].value.(*String)}}) } case 84: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:423 +//line parser.go.y:421 { yyVAL.value = &String{Str: yyDollar[1].token} } case 85: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:427 +//line parser.go.y:425 { yyVAL.value = &String{Queries: yyDollar[2].value.([]*Query)} } case 86: yyDollar = yyS[yypt-0 : yypt+1] -//line parser.go.y:433 +//line parser.go.y:431 { yyVAL.value = []*Query{} } case 87: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:437 +//line parser.go.y:435 { yyVAL.value = append(yyDollar[1].value.([]*Query), &Query{Term: &Term{Type: TermTypeString, Str: &String{Str: yyDollar[2].token}}}) } case 88: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:441 +//line parser.go.y:439 { yylex.(*lexer).inString = true yyVAL.value = append(yyDollar[1].value.([]*Query), &Query{Term: &Term{Type: TermTypeQuery, Query: yyDollar[3].value.(*Query)}}) } case 93: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:456 +//line parser.go.y:454 { yyVAL.value = &Suffix{Iter: true} } case 94: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:460 +//line parser.go.y:458 { yyVAL.value = &Suffix{Index: &Index{Start: yyDollar[2].value.(*Query)}} } case 95: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:464 +//line parser.go.y:462 { yyVAL.value = &Suffix{Index: &Index{Start: yyDollar[2].value.(*Query), IsSlice: true}} } case 96: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:468 +//line parser.go.y:466 { yyVAL.value = &Suffix{Index: &Index{End: yyDollar[3].value.(*Query), IsSlice: true}} } case 97: yyDollar = yyS[yypt-5 : yypt+1] -//line parser.go.y:472 +//line parser.go.y:470 { yyVAL.value = &Suffix{Index: &Index{Start: yyDollar[2].value.(*Query), End: yyDollar[4].value.(*Query), IsSlice: true}} } case 98: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:478 +//line parser.go.y:476 { yyVAL.value = []*Query{yyDollar[1].value.(*Query)} } case 99: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:482 +//line parser.go.y:480 { yyVAL.value = append(yyDollar[1].value.([]*Query), yyDollar[3].value.(*Query)) } case 100: yyDollar = yyS[yypt-0 : yypt+1] -//line parser.go.y:488 +//line parser.go.y:486 { yyVAL.value = []*IfElif(nil) } case 101: yyDollar = yyS[yypt-5 : yypt+1] -//line parser.go.y:492 +//line parser.go.y:490 { yyVAL.value = append(yyDollar[1].value.([]*IfElif), &IfElif{yyDollar[3].value.(*Query), yyDollar[5].value.(*Query)}) } case 102: yyDollar = yyS[yypt-0 : yypt+1] -//line parser.go.y:498 +//line parser.go.y:496 { yyVAL.value = (*Query)(nil) } case 103: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:502 +//line parser.go.y:500 { yyVAL.value = yyDollar[2].value } case 104: yyDollar = yyS[yypt-0 : yypt+1] -//line parser.go.y:508 +//line parser.go.y:506 { yyVAL.value = (*Query)(nil) } case 105: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:512 +//line parser.go.y:510 { yyVAL.value = yyDollar[2].value } case 106: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:518 +//line parser.go.y:516 { yyVAL.value = []*ObjectKeyVal{yyDollar[1].value.(*ObjectKeyVal)} } case 107: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:522 +//line parser.go.y:520 { yyVAL.value = append(yyDollar[1].value.([]*ObjectKeyVal), yyDollar[3].value.(*ObjectKeyVal)) } case 108: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:528 +//line parser.go.y:526 { yyVAL.value = &ObjectKeyVal{Key: yyDollar[1].token, Val: yyDollar[3].value.(*Query)} } case 109: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:532 +//line parser.go.y:530 { yyVAL.value = &ObjectKeyVal{KeyString: yyDollar[1].value.(*String), Val: yyDollar[3].value.(*Query)} } case 110: yyDollar = yyS[yypt-5 : yypt+1] -//line parser.go.y:536 +//line parser.go.y:534 { yyVAL.value = &ObjectKeyVal{KeyQuery: yyDollar[2].value.(*Query), Val: yyDollar[5].value.(*Query)} } case 111: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:540 +//line parser.go.y:538 { yyVAL.value = &ObjectKeyVal{Key: yyDollar[1].token} } case 112: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:544 +//line parser.go.y:542 { yyVAL.value = &ObjectKeyVal{KeyString: yyDollar[1].value.(*String)} } case 116: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:555 +//line parser.go.y:553 { yyVAL.value = &Query{Left: yyDollar[1].value.(*Query), Op: OpPipe, Right: yyDollar[3].value.(*Query)} } case 118: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:562 +//line parser.go.y:560 { yyVAL.value = &ConstTerm{Object: yyDollar[1].value.(*ConstObject)} } case 119: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:566 +//line parser.go.y:564 { yyVAL.value = &ConstTerm{Array: yyDollar[1].value.(*ConstArray)} } case 120: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:570 +//line parser.go.y:568 { yyVAL.value = &ConstTerm{Number: yyDollar[1].token} } case 121: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:574 +//line parser.go.y:572 { yyVAL.value = &ConstTerm{Str: yyDollar[1].token} } case 122: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:578 +//line parser.go.y:576 { yyVAL.value = &ConstTerm{Null: true} } case 123: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:582 +//line parser.go.y:580 { yyVAL.value = &ConstTerm{True: true} } case 124: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:586 +//line parser.go.y:584 { yyVAL.value = &ConstTerm{False: true} } case 125: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:592 +//line parser.go.y:590 { yyVAL.value = &ConstObject{} } case 126: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:596 +//line parser.go.y:594 { yyVAL.value = &ConstObject{yyDollar[2].value.([]*ConstObjectKeyVal)} } case 127: yyDollar = yyS[yypt-4 : yypt+1] -//line parser.go.y:600 +//line parser.go.y:598 { yyVAL.value = &ConstObject{yyDollar[2].value.([]*ConstObjectKeyVal)} } case 128: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:606 +//line parser.go.y:604 { yyVAL.value = []*ConstObjectKeyVal{yyDollar[1].value.(*ConstObjectKeyVal)} } case 129: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:610 +//line parser.go.y:608 { yyVAL.value = append(yyDollar[1].value.([]*ConstObjectKeyVal), yyDollar[3].value.(*ConstObjectKeyVal)) } case 130: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:616 +//line parser.go.y:614 { yyVAL.value = &ConstObjectKeyVal{Key: yyDollar[1].token, Val: yyDollar[3].value.(*ConstTerm)} } case 131: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:620 +//line parser.go.y:618 { yyVAL.value = &ConstObjectKeyVal{Key: yyDollar[1].token, Val: yyDollar[3].value.(*ConstTerm)} } case 132: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:624 +//line parser.go.y:622 { yyVAL.value = &ConstObjectKeyVal{KeyString: yyDollar[1].token, Val: yyDollar[3].value.(*ConstTerm)} } case 133: yyDollar = yyS[yypt-2 : yypt+1] -//line parser.go.y:630 +//line parser.go.y:628 { yyVAL.value = &ConstArray{} } case 134: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:634 +//line parser.go.y:632 { yyVAL.value = &ConstArray{yyDollar[2].value.([]*ConstTerm)} } case 135: yyDollar = yyS[yypt-1 : yypt+1] -//line parser.go.y:640 +//line parser.go.y:638 { yyVAL.value = []*ConstTerm{yyDollar[1].value.(*ConstTerm)} } case 136: yyDollar = yyS[yypt-3 : yypt+1] -//line parser.go.y:644 +//line parser.go.y:642 { yyVAL.value = append(yyDollar[1].value.([]*ConstTerm), yyDollar[3].value.(*ConstTerm)) } diff --git a/vendor/github.com/itchyny/gojq/parser.go.y b/vendor/github.com/itchyny/gojq/parser.go.y index 5481e211..5f9df778 100644 --- a/vendor/github.com/itchyny/gojq/parser.go.y +++ b/vendor/github.com/itchyny/gojq/parser.go.y @@ -151,11 +151,9 @@ query { $$ = &Query{Left: $1.(*Query), Op: OpPipe, Right: $3.(*Query)} } - | term tokAs bindpatterns '|' query + | query tokAs bindpatterns '|' query { - term := $1.(*Term) - term.SuffixList = append(term.SuffixList, &Suffix{Bind: &Bind{$3.([]*Pattern), $5.(*Query)}}) - $$ = &Query{Term: term} + $$ = &Query{Left: $1.(*Query), Op: OpPipe, Right: $5.(*Query), Patterns: $3.([]*Pattern)} } | tokLabel tokVariable '|' query { diff --git a/vendor/github.com/itchyny/gojq/preview.go b/vendor/github.com/itchyny/gojq/preview.go index e082eb56..92f1a54a 100644 --- a/vendor/github.com/itchyny/gojq/preview.go +++ b/vendor/github.com/itchyny/gojq/preview.go @@ -7,9 +7,9 @@ import "unicode/utf8" // by 30 bytes, and more efficient than truncating the result of [Marshal]. // // This method is used by error messages of built-in operators and functions, -// and accepts only limited types (nil, bool, int, float64, *big.Int, string, -// []any, and map[string]any). Note that the maximum width and trailing strings -// on truncation may be changed in the future. +// and accepts only limited types (nil, bool, int, float64, *big.Int, +// json.Number, string, []any, and map[string]any). Note that the maximum width +// and trailing strings on truncation may be changed in the future. func Preview(v any) string { bs := jsonLimitedMarshal(v, 32) if l := 30; len(bs) > l { diff --git a/vendor/github.com/itchyny/gojq/query.go b/vendor/github.com/itchyny/gojq/query.go index e7cf7789..512fa80d 100644 --- a/vendor/github.com/itchyny/gojq/query.go +++ b/vendor/github.com/itchyny/gojq/query.go @@ -26,15 +26,14 @@ type Query struct { FuncDefs []*FuncDef Term *Term Left *Query - Op Operator Right *Query - Func string + Patterns []*Pattern + Op Operator } // Run the query. // // It is safe to call this method in goroutines, to reuse a parsed [*Query]. -// But for arguments, do not give values sharing same data between goroutines. func (e *Query) Run(v any) Iter { return e.RunWithContext(context.Background(), v) } @@ -67,40 +66,28 @@ func (e *Query) writeTo(s *strings.Builder) { fd.writeTo(s) s.WriteByte(' ') } - if e.Func != "" { - s.WriteString(e.Func) - } else if e.Term != nil { + if e.Term != nil { e.Term.writeTo(s) } else if e.Right != nil { e.Left.writeTo(s) - if e.Op == OpComma { - s.WriteString(", ") - } else { + if e.Op != OpComma { s.WriteByte(' ') - s.WriteString(e.Op.String()) + } + for i, p := range e.Patterns { + if i == 0 { + s.WriteString("as ") + } else { + s.WriteString("?// ") + } + p.writeTo(s) s.WriteByte(' ') } + s.WriteString(e.Op.String()) + s.WriteByte(' ') e.Right.writeTo(s) } } -func (e *Query) minify() { - for _, e := range e.FuncDefs { - e.Minify() - } - if e.Term != nil { - if name := e.Term.toFunc(); name != "" { - e.Term = nil - e.Func = name - } else { - e.Term.minify() - } - } else if e.Right != nil { - e.Left.minify() - e.Right.minify() - } -} - func (e *Query) toIndexKey() any { if e.Term == nil { return nil @@ -177,11 +164,6 @@ func (e *FuncDef) writeTo(s *strings.Builder) { s.WriteByte(';') } -// Minify ... -func (e *FuncDef) Minify() { - e.Body.minify() -} - // Term ... type Term struct { Type TermType @@ -264,65 +246,6 @@ func (e *Term) writeTo(s *strings.Builder) { } } -func (e *Term) minify() { - switch e.Type { - case TermTypeIndex: - e.Index.minify() - case TermTypeFunc: - e.Func.minify() - case TermTypeObject: - e.Object.minify() - case TermTypeArray: - e.Array.minify() - case TermTypeUnary: - e.Unary.minify() - case TermTypeFormat: - if e.Str != nil { - e.Str.minify() - } - case TermTypeString: - e.Str.minify() - case TermTypeIf: - e.If.minify() - case TermTypeTry: - e.Try.minify() - case TermTypeReduce: - e.Reduce.minify() - case TermTypeForeach: - e.Foreach.minify() - case TermTypeLabel: - e.Label.minify() - case TermTypeQuery: - e.Query.minify() - } - for _, e := range e.SuffixList { - e.minify() - } -} - -func (e *Term) toFunc() string { - if len(e.SuffixList) != 0 { - return "" - } - // ref: compiler#compileQuery - switch e.Type { - case TermTypeIdentity: - return "." - case TermTypeRecurse: - return ".." - case TermTypeNull: - return "null" - case TermTypeTrue: - return "true" - case TermTypeFalse: - return "false" - case TermTypeFunc: - return e.Func.toFunc() - default: - return "" - } -} - func (e *Term) toIndexKey() any { switch e.Type { case TermTypeNumber: @@ -384,10 +307,6 @@ func (e *Unary) writeTo(s *strings.Builder) { e.Term.writeTo(s) } -func (e *Unary) minify() { - e.Term.minify() -} - func (e *Unary) toNumber() any { v := e.Term.toNumber() if v != nil && e.Op == OpSub { @@ -511,18 +430,6 @@ func (e *Index) writeSuffixTo(s *strings.Builder) { } } -func (e *Index) minify() { - if e.Str != nil { - e.Str.minify() - } - if e.Start != nil { - e.Start.minify() - } - if e.End != nil { - e.End.minify() - } -} - func (e *Index) toIndexKey() any { if e.Name != "" { return e.Name @@ -583,19 +490,6 @@ func (e *Func) writeTo(s *strings.Builder) { } } -func (e *Func) minify() { - for _, x := range e.Args { - x.minify() - } -} - -func (e *Func) toFunc() string { - if len(e.Args) != 0 { - return "" - } - return e.Name -} - // String ... type String struct { Str string @@ -626,12 +520,6 @@ func (e *String) writeTo(s *strings.Builder) { s.WriteByte('"') } -func (e *String) minify() { - for _, e := range e.Queries { - e.minify() - } -} - // Object ... type Object struct { KeyVals []*ObjectKeyVal @@ -658,12 +546,6 @@ func (e *Object) writeTo(s *strings.Builder) { s.WriteString(" }") } -func (e *Object) minify() { - for _, e := range e.KeyVals { - e.minify() - } -} - // ObjectKeyVal ... type ObjectKeyVal struct { Key string @@ -694,17 +576,6 @@ func (e *ObjectKeyVal) writeTo(s *strings.Builder) { } } -func (e *ObjectKeyVal) minify() { - if e.KeyString != nil { - e.KeyString.minify() - } else if e.KeyQuery != nil { - e.KeyQuery.minify() - } - if e.Val != nil { - e.Val.minify() - } -} - // Array ... type Array struct { Query *Query @@ -724,18 +595,11 @@ func (e *Array) writeTo(s *strings.Builder) { s.WriteByte(']') } -func (e *Array) minify() { - if e.Query != nil { - e.Query.minify() - } -} - // Suffix ... type Suffix struct { Index *Index Iter bool Optional bool - Bind *Bind } func (e *Suffix) String() string { @@ -755,16 +619,6 @@ func (e *Suffix) writeTo(s *strings.Builder) { s.WriteString("[]") } else if e.Optional { s.WriteByte('?') - } else if e.Bind != nil { - e.Bind.writeTo(s) - } -} - -func (e *Suffix) minify() { - if e.Index != nil { - e.Index.minify() - } else if e.Bind != nil { - e.Bind.minify() } } @@ -785,38 +639,6 @@ func (e *Suffix) toIndices(xs []any) []any { return e.Index.toIndices(xs) } -// Bind ... -type Bind struct { - Patterns []*Pattern - Body *Query -} - -func (e *Bind) String() string { - var s strings.Builder - e.writeTo(&s) - return s.String() -} - -func (e *Bind) writeTo(s *strings.Builder) { - for i, p := range e.Patterns { - if i == 0 { - s.WriteString(" as ") - p.writeTo(s) - s.WriteByte(' ') - } else { - s.WriteString("?// ") - p.writeTo(s) - s.WriteByte(' ') - } - } - s.WriteString("| ") - e.Body.writeTo(s) -} - -func (e *Bind) minify() { - e.Body.minify() -} - // If ... type If struct { Cond *Query @@ -847,17 +669,6 @@ func (e *If) writeTo(s *strings.Builder) { s.WriteString(" end") } -func (e *If) minify() { - e.Cond.minify() - e.Then.minify() - for _, x := range e.Elif { - x.minify() - } - if e.Else != nil { - e.Else.minify() - } -} - // IfElif ... type IfElif struct { Cond *Query @@ -877,11 +688,6 @@ func (e *IfElif) writeTo(s *strings.Builder) { e.Then.writeTo(s) } -func (e *IfElif) minify() { - e.Cond.minify() - e.Then.minify() -} - // Try ... type Try struct { Body *Query @@ -903,13 +709,6 @@ func (e *Try) writeTo(s *strings.Builder) { } } -func (e *Try) minify() { - e.Body.minify() - if e.Catch != nil { - e.Catch.minify() - } -} - // Reduce ... type Reduce struct { Query *Query @@ -936,12 +735,6 @@ func (e *Reduce) writeTo(s *strings.Builder) { s.WriteByte(')') } -func (e *Reduce) minify() { - e.Query.minify() - e.Start.minify() - e.Update.minify() -} - // Foreach ... type Foreach struct { Query *Query @@ -973,15 +766,6 @@ func (e *Foreach) writeTo(s *strings.Builder) { s.WriteByte(')') } -func (e *Foreach) minify() { - e.Query.minify() - e.Start.minify() - e.Update.minify() - if e.Extract != nil { - e.Extract.minify() - } -} - // Label ... type Label struct { Ident string @@ -1001,10 +785,6 @@ func (e *Label) writeTo(s *strings.Builder) { e.Body.writeTo(s) } -func (e *Label) minify() { - e.Body.minify() -} - // ConstTerm ... type ConstTerm struct { Object *ConstObject diff --git a/vendor/github.com/itchyny/gojq/type.go b/vendor/github.com/itchyny/gojq/type.go index bb388e20..89ccda0e 100644 --- a/vendor/github.com/itchyny/gojq/type.go +++ b/vendor/github.com/itchyny/gojq/type.go @@ -1,6 +1,7 @@ package gojq import ( + "encoding/json" "fmt" "math/big" ) @@ -8,14 +9,15 @@ import ( // TypeOf returns the jq-flavored type name of v. // // This method is used by built-in type/0 function, and accepts only limited -// types (nil, bool, int, float64, *big.Int, string, []any, and map[string]any). +// types (nil, bool, int, float64, *big.Int, json.Number, string, []any, and +// map[string]any). func TypeOf(v any) string { switch v.(type) { case nil: return "null" case bool: return "boolean" - case int, float64, *big.Int: + case int, float64, *big.Int, json.Number: return "number" case string: return "string" diff --git a/vendor/github.com/skycoin/skycoin/src/cipher/ripemd160/ripemd160block.go b/vendor/github.com/skycoin/skycoin/src/cipher/ripemd160/ripemd160block.go index 31f70095..a87ccda4 100644 --- a/vendor/github.com/skycoin/skycoin/src/cipher/ripemd160/ripemd160block.go +++ b/vendor/github.com/skycoin/skycoin/src/cipher/ripemd160/ripemd160block.go @@ -76,14 +76,14 @@ func _Block(md *digest, p []byte) int { // round 2 for i < 32 { - alpha = a + (b&c | ^b&d) + x[_n[i]] + 0x5a827999 + alpha = a + (b&c | ^b&d) + x[_n[i]] + 0x5a827999 //nolint:gosec // G602: i is bounded by loop, array access is safe s := _r[i] alpha = (alpha<>(32-s)) + e beta = c<<10 | c>>22 a, b, c, d, e = e, alpha, b, beta, d // parallel line - alpha = aa + (bb&dd | cc&^dd) + x[n_[i]] + 0x5c4dd124 + alpha = aa + (bb&dd | cc&^dd) + x[n_[i]] + 0x5c4dd124 //nolint:gosec // G602: i is bounded by loop, array access is safe s = r_[i] alpha = (alpha<>(32-s)) + ee beta = cc<<10 | cc>>22 @@ -94,14 +94,14 @@ func _Block(md *digest, p []byte) int { // round 3 for i < 48 { - alpha = a + (b | ^c ^ d) + x[_n[i]] + 0x6ed9eba1 + alpha = a + (b | ^c ^ d) + x[_n[i]] + 0x6ed9eba1 //nolint:gosec // G602: i is bounded by loop, array access is safe s := _r[i] alpha = (alpha<>(32-s)) + e beta = c<<10 | c>>22 a, b, c, d, e = e, alpha, b, beta, d // parallel line - alpha = aa + (bb | ^cc ^ dd) + x[n_[i]] + 0x6d703ef3 + alpha = aa + (bb | ^cc ^ dd) + x[n_[i]] + 0x6d703ef3 //nolint:gosec // G602: i is bounded by loop, array access is safe s = r_[i] alpha = (alpha<>(32-s)) + ee beta = cc<<10 | cc>>22 @@ -112,14 +112,14 @@ func _Block(md *digest, p []byte) int { // round 4 for i < 64 { - alpha = a + (b&d | c&^d) + x[_n[i]] + 0x8f1bbcdc + alpha = a + (b&d | c&^d) + x[_n[i]] + 0x8f1bbcdc //nolint:gosec // G602: i is bounded by loop, array access is safe s := _r[i] alpha = (alpha<>(32-s)) + e beta = c<<10 | c>>22 a, b, c, d, e = e, alpha, b, beta, d // parallel line - alpha = aa + (bb&cc | ^bb&dd) + x[n_[i]] + 0x7a6d76e9 + alpha = aa + (bb&cc | ^bb&dd) + x[n_[i]] + 0x7a6d76e9 //nolint:gosec // G602: i is bounded by loop, array access is safe s = r_[i] alpha = (alpha<>(32-s)) + ee beta = cc<<10 | cc>>22 @@ -130,14 +130,14 @@ func _Block(md *digest, p []byte) int { // round 5 for i < 80 { - alpha = a + (b ^ (c | ^d)) + x[_n[i]] + 0xa953fd4e + alpha = a + (b ^ (c | ^d)) + x[_n[i]] + 0xa953fd4e //nolint:gosec // G602: i is bounded by loop, array access is safe s := _r[i] alpha = (alpha<>(32-s)) + e beta = c<<10 | c>>22 a, b, c, d, e = e, alpha, b, beta, d // parallel line - alpha = aa + (bb ^ cc ^ dd) + x[n_[i]] + alpha = aa + (bb ^ cc ^ dd) + x[n_[i]] //nolint:gosec // G602: i is bounded by loop, array access is safe s = r_[i] alpha = (alpha<>(32-s)) + ee beta = cc<<10 | cc>>22 diff --git a/vendor/github.com/spf13/cobra/.golangci.yml b/vendor/github.com/spf13/cobra/.golangci.yml index 6acf8ab1..104dc244 100644 --- a/vendor/github.com/spf13/cobra/.golangci.yml +++ b/vendor/github.com/spf13/cobra/.golangci.yml @@ -57,3 +57,10 @@ linters: - common-false-positives - legacy - std-error-handling + settings: + govet: + # Disable buildtag check to allow dual build tag syntax (both //go:build and // +build). + # This is necessary for Go 1.15 compatibility since //go:build was introduced in Go 1.17. + # This can be removed once Cobra requires Go 1.17 or higher. + disable: + - buildtag diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go index 78088db6..c05fed45 100644 --- a/vendor/github.com/spf13/cobra/command.go +++ b/vendor/github.com/spf13/cobra/command.go @@ -557,7 +557,7 @@ func (c *Command) FlagErrorFunc() (f func(*Command, error) error) { } } -var minUsagePadding = 25 +const minUsagePadding = 25 // UsagePadding return padding for the usage. func (c *Command) UsagePadding() int { @@ -567,7 +567,7 @@ func (c *Command) UsagePadding() int { return c.parent.commandsMaxUseLen } -var minCommandPathPadding = 11 +const minCommandPathPadding = 11 // CommandPathPadding return padding for the command path. func (c *Command) CommandPathPadding() int { @@ -577,7 +577,7 @@ func (c *Command) CommandPathPadding() int { return c.parent.commandsMaxCommandPathLen } -var minNamePadding = 11 +const minNamePadding = 11 // NamePadding returns padding for the name. func (c *Command) NamePadding() int { @@ -1939,7 +1939,7 @@ type tmplFunc struct { fn func(io.Writer, interface{}) error } -var defaultUsageTemplate = `Usage:{{if .Runnable}} +const defaultUsageTemplate = `Usage:{{if .Runnable}} {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}} @@ -2039,7 +2039,7 @@ func defaultUsageFunc(w io.Writer, in interface{}) error { return nil } -var defaultHelpTemplate = `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}} +const defaultHelpTemplate = `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}} {{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}` @@ -2061,7 +2061,7 @@ func defaultHelpFunc(w io.Writer, in interface{}) error { return nil } -var defaultVersionTemplate = `{{with .DisplayName}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}} +const defaultVersionTemplate = `{{with .DisplayName}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}} ` // defaultVersionFunc is equivalent to executing defaultVersionTemplate. The two should be changed in sync. diff --git a/vendor/github.com/xtaci/smux/pkg.go b/vendor/github.com/xtaci/smux/pkg.go index e5f110a7..7f45d919 100644 --- a/vendor/github.com/xtaci/smux/pkg.go +++ b/vendor/github.com/xtaci/smux/pkg.go @@ -1,6 +1,6 @@ // Package smux is a multiplexing library for Golang. // -// It relies on an underlying connection to provide reliability and ordering, such as TCP or KCP, -// and provides stream-oriented multiplexing over a single channel. +// It relies on an underlying connection to provide reliability and ordering, such as TCP +// or KCP, and provides stream-oriented multiplexing over a single channel. package smux diff --git a/vendor/github.com/xtaci/smux/session.go b/vendor/github.com/xtaci/smux/session.go index e4319c41..8c8b5dfa 100644 --- a/vendor/github.com/xtaci/smux/session.go +++ b/vendor/github.com/xtaci/smux/session.go @@ -87,6 +87,7 @@ type Session struct { conn io.ReadWriteCloser config *Config + goAway int32 // flag id exhausted nextStreamID uint32 // next stream identifier nextStreamIDLock sync.Mutex @@ -114,11 +115,8 @@ type Session struct { chAccepts chan *stream - dataReady int32 // flag data has arrived - - goAway int32 // flag id exhausted - - deadline atomic.Value + sessionIsActive int32 // flag session is active + acceptDeadline atomic.Value // deadline for Accept() requestID uint32 // Monotonic increasing write request ID shaper chan writeRequest // a shaper for writing @@ -172,13 +170,16 @@ func (s *Session) OpenStream() (*Stream, error) { return nil, ErrGoAway } - s.nextStreamID += 2 - sid := s.nextStreamID - if sid == sid%2 { // stream-id overflows + // check for stream id overflow + if s.nextStreamID+2 < s.nextStreamID { s.goAway = 1 s.nextStreamIDLock.Unlock() return nil, ErrGoAway } + + // allocate next stream id + s.nextStreamID += 2 + sid := s.nextStreamID s.nextStreamIDLock.Unlock() stream := newStream(sid, s.config.MaxFrameSize, s) @@ -218,7 +219,7 @@ func (s *Session) Open() (io.ReadWriteCloser, error) { // is ready to be accepted. func (s *Session) AcceptStream() (*Stream, error) { var deadline <-chan time.Time - if d, ok := s.deadline.Load().(time.Time); ok && !d.IsZero() { + if d, ok := s.acceptDeadline.Load().(time.Time); ok && !d.IsZero() { timer := time.NewTimer(time.Until(d)) defer timer.Stop() deadline = timer.C @@ -255,16 +256,16 @@ func (s *Session) Close() error { once = true }) - if once { - s.streamLock.Lock() - for k := range s.streams { - s.streams[k].sessionClose() - } - s.streamLock.Unlock() - return s.conn.Close() - } else { + if !once { return io.ErrClosedPipe } + + s.streamLock.Lock() + for k := range s.streams { + s.streams[k].sessionClose() + } + s.streamLock.Unlock() + return s.conn.Close() } // CloseChan can be used by someone who wants to be notified immediately when this @@ -325,7 +326,7 @@ func (s *Session) NumStreams() int { // SetDeadline sets a deadline used by Accept* calls. // A zero time value disables the deadline. func (s *Session) SetDeadline(t time.Time) error { - s.deadline.Store(t) + s.acceptDeadline.Store(t) return nil } @@ -352,16 +353,20 @@ func (s *Session) RemoteAddr() net.Addr { // notify the session that a stream has closed func (s *Session) streamClosed(sid uint32) { s.streamLock.Lock() - if stream, ok := s.streams[sid]; ok { - n := stream.recycleTokens() - if n > 0 { // return remaining tokens to the bucket - if atomic.AddInt32(&s.bucket, int32(n)) > 0 { - s.notifyBucket() - } + defer s.streamLock.Unlock() + + stream, ok := s.streams[sid] + if !ok { + return + } + + if n := stream.recycleTokens(); n > 0 { + // return remaining tokens to the bucket + if atomic.AddInt32(&s.bucket, int32(n)) > 0 { + s.notifyBucket() } - delete(s.streams, sid) } - s.streamLock.Unlock() + delete(s.streams, sid) } // returnTokens is called by stream to return token after read @@ -377,85 +382,109 @@ func (s *Session) recvLoop() { var updHdr updHeader for { + // Wait until we have tokens or session is closed. for atomic.LoadInt32(&s.bucket) <= 0 && !s.IsClosed() { select { case <-s.bucketNotify: case <-s.die: + // If it returns here, Accept() and OpenStream() are unblocked with io.ErrClosedPipe, + // causing recvLoop to exit gracefully. If recvLoop is blocked in io.ReadFull, however, + // it will be unblocked by a socket read error instead. return } } + // As long as we have tokens, try to read frames. // read header first - if _, err := io.ReadFull(s.conn, hdr[:]); err == nil { - atomic.StoreInt32(&s.dataReady, 1) - if hdr.Version() != byte(s.config.Version) { - s.notifyProtoError(ErrInvalidProtocol) + _, err := io.ReadFull(s.conn, hdr[:]) + if err != nil { + s.notifyReadError(err) + return + } + + // Mark the session as active + atomic.StoreInt32(&s.sessionIsActive, 1) + + // validate protocol version + if hdr.Version() != byte(s.config.Version) { + s.notifyProtoError(ErrInvalidProtocol) + return + } + + // handle different command types + sid := hdr.StreamID() + switch hdr.Cmd() { + case cmdNOP: + case cmdSYN: // stream opening + s.streamLock.Lock() + if _, ok := s.streams[sid]; !ok { + stream := newStream(sid, s.config.MaxFrameSize, s) + s.streams[sid] = stream + select { + case s.chAccepts <- stream: + case <-s.die: + } + } + s.streamLock.Unlock() + + case cmdFIN: // stream closing + s.streamLock.Lock() + if stream, ok := s.streams[sid]; ok { + stream.fin() // fin unblocks the readers and writers + } + s.streamLock.Unlock() + + case cmdPSH: // data frame + if hdr.Length() == 0 { + continue + } + + // read payload from the underlying connection + pNewbuf := defaultAllocator.Get(int(hdr.Length())) + written, err := io.ReadFull(s.conn, *pNewbuf) + if err != nil { + s.notifyReadError(err) + + // recycle the buffer immediately. + defaultAllocator.Put(pNewbuf) return } - sid := hdr.StreamID() - switch hdr.Cmd() { - case cmdNOP: - case cmdSYN: // stream opening - s.streamLock.Lock() - if _, ok := s.streams[sid]; !ok { - stream := newStream(sid, s.config.MaxFrameSize, s) - s.streams[sid] = stream - select { - case s.chAccepts <- stream: - case <-s.die: - } - } - s.streamLock.Unlock() - case cmdFIN: // stream closing - s.streamLock.Lock() - if stream, ok := s.streams[sid]; ok { - stream.fin() - stream.notifyReadEvent() - } - s.streamLock.Unlock() - case cmdPSH: // data frame - if hdr.Length() > 0 { - pNewbuf := defaultAllocator.Get(int(hdr.Length())) - if written, err := io.ReadFull(s.conn, *pNewbuf); err == nil { - s.streamLock.Lock() - if stream, ok := s.streams[sid]; ok { - stream.pushBytes(pNewbuf) - // a stream used some token - atomic.AddInt32(&s.bucket, -int32(written)) - stream.notifyReadEvent() - } else { - // data directed to a missing/closed stream, recycle the buffer immediately. - defaultAllocator.Put(pNewbuf) - } - s.streamLock.Unlock() - } else { - s.notifyReadError(err) - return - } - } - case cmdUPD: // a window update signal - if _, err := io.ReadFull(s.conn, updHdr[:]); err == nil { - s.streamLock.Lock() - if stream, ok := s.streams[sid]; ok { - stream.update(updHdr.Consumed(), updHdr.Window()) - } - s.streamLock.Unlock() - } else { - s.notifyReadError(err) - return - } - default: - s.notifyProtoError(ErrInvalidProtocol) + + // push data to the corresponding stream + s.streamLock.Lock() + if stream, ok := s.streams[sid]; ok { + stream.pushBytes(pNewbuf) + // deduct tokens from the bucket + atomic.AddInt32(&s.bucket, -int32(written)) + stream.wakeupReader() + } else { + // data directed to a missing/closed stream, recycle the buffer immediately. + defaultAllocator.Put(pNewbuf) + } + s.streamLock.Unlock() + + case cmdUPD: // a window update signal + _, err := io.ReadFull(s.conn, updHdr[:]) + if err != nil { + s.notifyReadError(err) return } - } else { - s.notifyReadError(err) + + // update the window size for the corresponding stream + s.streamLock.Lock() + if stream, ok := s.streams[sid]; ok { + stream.update(updHdr.Consumed(), updHdr.Window()) + } + s.streamLock.Unlock() + + default: + s.notifyProtoError(ErrInvalidProtocol) return } } } -// keepalive sends NOP frame to peer to keep the connection alive, and detect dead peers +// keepalive sends NOP frames periodically to keep the connection alive func (s *Session) keepalive() { tickerPing := time.NewTicker(s.config.KeepAliveInterval) tickerTimeout := time.NewTicker(s.config.KeepAliveTimeout) @@ -465,9 +494,9 @@ func (s *Session) keepalive() { select { case <-tickerPing.C: s.writeFrameInternal(newFrame(byte(s.config.Version), cmdNOP, 0), tickerPing.C, CLSCTRL) - s.notifyBucket() // force a signal to the recvLoop + s.notifyBucket() // force a wakeup signal to the recvLoop case <-tickerTimeout.C: - if !atomic.CompareAndSwapInt32(&s.dataReady, 1, 0) { + if !atomic.CompareAndSwapInt32(&s.sessionIsActive, 1, 0) { // recvLoop may block while bucket is 0, in this case, // session should not be closed. if atomic.LoadInt32(&s.bucket) > 0 { @@ -525,7 +554,7 @@ func (s *Session) notifyShaperConsumed() { } } -// sendLoop sends frames to the underlying connection +// sendLoop sends frames over the underlying connection func (s *Session) sendLoop() { var buf []byte var n int diff --git a/vendor/github.com/xtaci/smux/stream.go b/vendor/github.com/xtaci/smux/stream.go index 31ca0e49..615e44f2 100644 --- a/vendor/github.com/xtaci/smux/stream.go +++ b/vendor/github.com/xtaci/smux/stream.go @@ -41,28 +41,29 @@ type stream struct { id uint32 // Stream identifier sess *Session - buffers []*[]byte // the sequential buffers of stream + buffers []*[]byte // slice of buffers holding ordered incoming data heads []*[]byte // slice heads of the buffers above, kept for recycle bufferLock sync.Mutex // Mutex to protect access to buffers frameSize int // Maximum frame size for the stream - // notify a read event - chReadEvent chan struct{} + // wakeup channels + chReaderWakeup chan struct{} + chWriterWakeup chan struct{} - // flag the stream has closed + // stream closing die chan struct{} dieOnce sync.Once // Ensures die channel is closed only once - // FIN command + // to handle FIN event(i.e. EOF) chFinEvent chan struct{} finEventOnce sync.Once // Ensures chFinEvent is closed only once - // deadlines + // read/write deadline readDeadline atomic.Value writeDeadline atomic.Value - // per stream sliding window control + // v2 stream fields(flow control) numRead uint32 // count num of bytes read numWritten uint32 // count num of bytes written incr uint32 // bytes sent since last window update @@ -77,7 +78,8 @@ type stream struct { func newStream(id uint32, frameSize int, sess *Session) *stream { s := new(stream) s.id = id - s.chReadEvent = make(chan struct{}, 1) + s.chReaderWakeup = make(chan struct{}, 1) + s.chWriterWakeup = make(chan struct{}, 1) s.chUpdate = make(chan struct{}, 1) s.frameSize = frameSize s.sess = sess @@ -96,47 +98,52 @@ func (s *stream) ID() uint32 { // Read reads data from the stream into the provided buffer. func (s *stream) Read(b []byte) (n int, err error) { for { - n, err = s.tryRead(b) - if err == ErrWouldBlock { - if ew := s.waitRead(); ew != nil { - return 0, ew - } - } else { + switch s.sess.config.Version { + case 2: + n, err = s.tryReadV2(b) + default: + n, err = s.tryReadV1(b) + } + + if err != ErrWouldBlock { return n, err } - } -} -// tryRead attempts to read data from the stream without blocking. -func (s *stream) tryRead(b []byte) (n int, err error) { - if s.sess.config.Version == 2 { - return s.tryReadv2(b) + if ew := s.waitRead(); ew != nil { + return 0, ew + } } +} +func (s *stream) tryReadV1(b []byte) (n int, err error) { if len(b) == 0 { return 0, nil } - // A critical section to copy data from buffers to + // A critical section to copy data from buffers to b s.bufferLock.Lock() if len(s.buffers) > 0 { n = copy(b, *s.buffers[0]) *s.buffers[0] = (*s.buffers[0])[n:] + + // recycle buffer when fully consumed if len(*s.buffers[0]) == 0 { s.buffers[0] = nil s.buffers = s.buffers[1:] - // full recycle defaultAllocator.Put(s.heads[0]) s.heads = s.heads[1:] } } s.bufferLock.Unlock() + // return tokens to session to allow more data to be received if n > 0 { s.sess.returnTokens(n) return n, nil } + // even if the stream has been closed, we try to deliver all buffered data first. + // only when there's no data left in buffer, we return EOF to reader. select { case <-s.die: return 0, io.EOF @@ -145,8 +152,8 @@ func (s *stream) tryRead(b []byte) (n int, err error) { } } -// tryReadv2 is the non-blocking version of Read for version 2 streams. -func (s *stream) tryReadv2(b []byte) (n int, err error) { +// tryReadV2 is the non-blocking version of Read for version 2 streams. +func (s *stream) tryReadV2(b []byte) (n int, err error) { if len(b) == 0 { return 0, nil } @@ -156,29 +163,31 @@ func (s *stream) tryReadv2(b []byte) (n int, err error) { if len(s.buffers) > 0 { n = copy(b, *s.buffers[0]) *s.buffers[0] = (*s.buffers[0])[n:] + + // recycle buffer when fully consumed if len(*s.buffers[0]) == 0 { s.buffers[0] = nil s.buffers = s.buffers[1:] - // full recycle defaultAllocator.Put(s.heads[0]) s.heads = s.heads[1:] } } - // in an ideal environment: - // if more than half of buffer has consumed, send read ack to peer - // based on round-trip time of ACK, continous flowing data - // won't slow down due to waiting for ACK, as long as the - // consumer keeps on reading data. + // In an ideal environment: + // If more than half of the buffer has been consumed, send a read ACK to the peer. + // With the ACK round-trip time taken into account, a continuous data stream + // will not slow down due to waiting for ACKs, as long as the consumer + // continues reading data. // - // s.numRead == n implies that it's the initial reading + // s.numRead == n indicates that this is the initial read. s.numRead += uint32(n) s.incr += uint32(n) - // for initial reading, send window update + // send window update if the increased bytes exceed half of the buffer size + // or this is the initial read. if s.incr >= uint32(s.sess.config.MaxStreamBuffer/2) || s.numRead == uint32(n) { notifyConsumed = s.numRead - s.incr = 0 // reset couting for next window update + s.incr = 0 // reset incr counter } s.bufferLock.Unlock() @@ -187,11 +196,9 @@ func (s *stream) tryReadv2(b []byte) (n int, err error) { // send window update if necessary if notifyConsumed > 0 { - err := s.sendWindowUpdate(notifyConsumed) - return n, err - } else { - return n, nil + return n, s.sendWindowUpdate(notifyConsumed) } + return n, nil } select { @@ -209,12 +216,20 @@ func (s *stream) tryReadv2(b []byte) (n int, err error) { // If the underlying stream is a v2 stream, it will send window update to peer when necessary. // If the underlying stream is a v1 stream, it will not send window update to peer. func (s *stream) WriteTo(w io.Writer) (n int64, err error) { - if s.sess.config.Version == 2 { - return s.writeTov2(w) + switch s.sess.config.Version { + case 2: + return s.writeToV2(w) + default: + return s.writeToV1(w) } +} +// check comments in WriteTo +func (s *stream) writeToV1(w io.Writer) (n int64, err error) { for { var pbuf *[]byte + + // get the next buffer to write s.bufferLock.Lock() if len(s.buffers) > 0 { pbuf = s.buffers[0] @@ -223,6 +238,7 @@ func (s *stream) WriteTo(w io.Writer) (n int64, err error) { } s.bufferLock.Unlock() + // write the buffer to w if pbuf != nil { nw, ew := w.Write(*pbuf) // NOTE: WriteTo is a reader, so we need to return tokens here @@ -242,28 +258,35 @@ func (s *stream) WriteTo(w io.Writer) (n int64, err error) { } // check comments in WriteTo -func (s *stream) writeTov2(w io.Writer) (n int64, err error) { +func (s *stream) writeToV2(w io.Writer) (n int64, err error) { for { var notifyConsumed uint32 var pbuf *[]byte + + // get the next buffer to write s.bufferLock.Lock() if len(s.buffers) > 0 { pbuf = s.buffers[0] s.buffers = s.buffers[1:] s.heads = s.heads[1:] } + + // in v2, we need to track the number of bytes read var bufLen uint32 if pbuf != nil { bufLen = uint32(len(*pbuf)) } s.numRead += bufLen s.incr += bufLen + + // send window update if the increased bytes exceed half of the buffer size if s.incr >= uint32(s.sess.config.MaxStreamBuffer/2) || s.numRead == bufLen { notifyConsumed = s.numRead s.incr = 0 } s.bufferLock.Unlock() + // same as v1, write the buffer to w if pbuf != nil { nw, ew := w.Write(*pbuf) // NOTE: WriteTo is a reader, so we need to return tokens here @@ -277,6 +300,7 @@ func (s *stream) writeTov2(w io.Writer) (n int64, err error) { return n, ew } + // send window update if notifyConsumed > 0 { if err := s.sendWindowUpdate(notifyConsumed); err != nil { return n, err @@ -288,7 +312,7 @@ func (s *stream) writeTov2(w io.Writer) (n int64, err error) { } } -// sendWindowUpdate sends a window update frame to the peer. +// sendWindowUpdate sends a window update command to the peer. func (s *stream) sendWindowUpdate(consumed uint32) error { var timer *time.Timer var deadline <-chan time.Time @@ -303,7 +327,7 @@ func (s *stream) sendWindowUpdate(consumed uint32) error { binary.LittleEndian.PutUint32(hdr[:], consumed) binary.LittleEndian.PutUint32(hdr[4:], uint32(s.sess.config.MaxStreamBuffer)) frame.data = hdr[:] - _, err := s.sess.writeFrameInternal(frame, deadline, CLSCTRL) + _, err := s.sess.writeFrameInternal(frame, deadline, CLSCTRL) // <-- NOTE(x): use control channel return err } @@ -318,7 +342,7 @@ func (s *stream) waitRead() error { } select { - case <-s.chReadEvent: // notify some data has arrived, or closed + case <-s.chReaderWakeup: // notify some data has arrived, or closed return nil case <-s.chFinEvent: // BUGFIX(xtaci): Fix for https://github.com/xtaci/smux/issues/82 @@ -345,15 +369,19 @@ func (s *stream) waitRead() error { // Note that the behavior when multiple goroutines write concurrently is not deterministic, // frames may interleave in random way. func (s *stream) Write(b []byte) (n int, err error) { - if s.sess.config.Version == 2 { + switch s.sess.config.Version { + case 2: return s.writeV2(b) + default: + return s.writeV1(b) } +} - var deadline <-chan time.Time - if d, ok := s.writeDeadline.Load().(time.Time); ok && !d.IsZero() { - timer := time.NewTimer(time.Until(d)) - defer timer.Stop() - deadline = timer.C +// writeV1 writes data to the stream for version 1 streams. +func (s *stream) writeV1(b []byte) (n int, err error) { + // check empty input + if len(b) == 0 { + return 0, nil } // check if stream has closed @@ -365,23 +393,32 @@ func (s *stream) Write(b []byte) (n int, err error) { default: } + // create write deadline timer + var deadline <-chan time.Time + if d, ok := s.writeDeadline.Load().(time.Time); ok && !d.IsZero() { + timer := time.NewTimer(time.Until(d)) + defer timer.Stop() + deadline = timer.C + } + // frame split and transmit sent := 0 frame := newFrame(byte(s.sess.config.Version), cmdPSH, s.id) - bts := b - for len(bts) > 0 { - sz := len(bts) - if sz > s.frameSize { - sz = s.frameSize + for len(b) > 0 { + size := len(b) + if size > s.frameSize { + size = s.frameSize } - frame.data = bts[:sz] - bts = bts[sz:] + + frame.data = b[:size] n, err := s.sess.writeFrameInternal(frame, deadline, CLSDATA) s.numWritten++ sent += n if err != nil { return sent, err } + + b = b[size:] } return sent, nil @@ -403,23 +440,22 @@ func (s *stream) writeV2(b []byte) (n int, err error) { default: } - // create write deadline timer - var deadline <-chan time.Time - if d, ok := s.writeDeadline.Load().(time.Time); ok && !d.IsZero() { - timer := time.NewTimer(time.Until(d)) - defer timer.Stop() - deadline = timer.C - } - // frame split and transmit process sent := 0 frame := newFrame(byte(s.sess.config.Version), cmdPSH, s.id) for { + // update write deadline timer + var deadline <-chan time.Time + if d, ok := s.writeDeadline.Load().(time.Time); ok && !d.IsZero() { + timer := time.NewTimer(time.Until(d)) + defer timer.Stop() + deadline = timer.C + } + // per stream sliding window control // [.... [consumed... numWritten] ... win... ] // [.... [consumed...................+rmtwnd]] - var bts []byte // note: // even if uint32 overflow, this math still works: // eg1: uint32(0) - uint32(math.MaxUint32) = 1 @@ -436,78 +472,80 @@ func (s *stream) writeV2(b []byte) (n int, err error) { if win > 0 { // determine how many bytes to send - if win > int32(len(b)) { - bts = b - b = nil - } else { - bts = b[:win] - b = b[win:] + n := len(b) + if n > int(win) { + n = int(win) } // frame split and transmit + bts := b[:n] for len(bts) > 0 { // splitting frame - sz := len(bts) - if sz > s.frameSize { - sz = s.frameSize + size := len(bts) + if size > s.frameSize { + size = s.frameSize } - frame.data = bts[:sz] - bts = bts[sz:] + frame.data = bts[:size] // transmit of frame - n, err := s.sess.writeFrameInternal(frame, deadline, CLSDATA) - atomic.AddUint32(&s.numWritten, uint32(sz)) - sent += n + nw, err := s.sess.writeFrameInternal(frame, deadline, CLSDATA) + atomic.AddUint32(&s.numWritten, uint32(size)) + sent += nw if err != nil { return sent, err } + + bts = bts[size:] } + + b = b[n:] } - // if there is any data left to be sent, - // wait until stream closes, window changes or deadline reached - // this blocking behavior will back propagate flow control to upper layer. - if len(b) > 0 { - select { - case <-s.chFinEvent: - return 0, io.EOF - case <-s.die: - return sent, io.ErrClosedPipe - case <-deadline: - return sent, ErrTimeout - case <-s.sess.chSocketWriteError: - return sent, s.sess.socketWriteError.Load().(error) - case <-s.chUpdate: // notify of remote data consuming and window update - continue - } - } else { + // all data has been sent + if len(b) <= 0 { return sent, nil } + + // If there is remaining data to be sent, + // wait until the stream is closed, the window changes, or the deadline is reached. + // This blocking behavior propagates flow control back to the upper layer (backpressure). + select { + case <-s.chWriterWakeup: // wakeup + case <-s.chFinEvent: + return 0, io.EOF + case <-s.die: + return sent, io.ErrClosedPipe + case <-deadline: + return sent, ErrTimeout + case <-s.sess.chSocketWriteError: + return sent, s.sess.socketWriteError.Load().(error) + case <-s.chUpdate: // notify of remote data consuming and window update + continue + } } } // Close implements net.Conn func (s *stream) Close() error { var once bool - var err error s.dieOnce.Do(func() { close(s.die) once = true }) - if once { - // send FIN in order - f := newFrame(byte(s.sess.config.Version), cmdFIN, s.id) - - timer := time.NewTimer(openCloseTimeout) - defer timer.Stop() - - _, err = s.sess.writeFrameInternal(f, timer.C, CLSDATA) - s.sess.streamClosed(s.id) - return err - } else { + if !once { return io.ErrClosedPipe } + + // send FIN in order + f := newFrame(byte(s.sess.config.Version), cmdFIN, s.id) + + timer := time.NewTimer(openCloseTimeout) + defer timer.Stop() + + _, err := s.sess.writeFrameInternal(f, timer.C, CLSDATA) // NOTE(x): use data channel, EOF as data. + s.sess.streamClosed(s.id) + return err } // GetDieCh returns a readonly chan which can be readable @@ -521,7 +559,7 @@ func (s *stream) GetDieCh() <-chan struct{} { // A zero time value disables the deadline. func (s *stream) SetReadDeadline(t time.Time) error { s.readDeadline.Store(t) - s.notifyReadEvent() + s.wakeupReader() return nil } @@ -530,6 +568,7 @@ func (s *stream) SetReadDeadline(t time.Time) error { // A zero time value disables the deadline. func (s *stream) SetWriteDeadline(t time.Time) error { s.writeDeadline.Store(t) + s.wakeupWriter() return nil } @@ -570,46 +609,58 @@ func (s *stream) RemoteAddr() net.Addr { } // pushBytes append buf to buffers -func (s *stream) pushBytes(pbuf *[]byte) (written int, err error) { +func (s *stream) pushBytes(pbuf *[]byte) { s.bufferLock.Lock() + defer s.bufferLock.Unlock() + s.buffers = append(s.buffers, pbuf) s.heads = append(s.heads, pbuf) - s.bufferLock.Unlock() - return } // recycleTokens transform remaining bytes to tokens(will truncate buffer) func (s *stream) recycleTokens() (n int) { s.bufferLock.Lock() + defer s.bufferLock.Unlock() + for k := range s.buffers { n += len(*s.buffers[k]) defaultAllocator.Put(s.heads[k]) } s.buffers = nil s.heads = nil - s.bufferLock.Unlock() return } -// notify read event -func (s *stream) notifyReadEvent() { +// wakeupReader notifies read process +func (s *stream) wakeupReader() { select { - case s.chReadEvent <- struct{}{}: + case s.chReaderWakeup <- struct{}{}: + default: + } +} + +// wakeupWriter notifies write process +func (s *stream) wakeupWriter() { + select { + case s.chWriterWakeup <- struct{}{}: default: } } // update command func (s *stream) update(consumed uint32, window uint32) { + // update peer consumed and window size immediately atomic.StoreUint32(&s.peerConsumed, consumed) atomic.StoreUint32(&s.peerWindow, window) + + // notify write process select { case s.chUpdate <- struct{}{}: default: } } -// mark this stream has been closed in protocol +// mark this stream has been closed in protocol, i.e. receive EOF func (s *stream) fin() { s.finEventOnce.Do(func() { close(s.chFinEvent) diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index 1965913e..ccb87e6d 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -376,11 +376,24 @@ type ClientConn struct { // completely unresponsive connection. pendingResets int + // readBeforeStreamID is the smallest stream ID that has not been followed by + // a frame read from the peer. We use this to determine when a request may + // have been sent to a completely unresponsive connection: + // If the request ID is less than readBeforeStreamID, then we have had some + // indication of life on the connection since sending the request. + readBeforeStreamID uint32 + // reqHeaderMu is a 1-element semaphore channel controlling access to sending new requests. // Write to reqHeaderMu to lock it, read from it to unlock. // Lock reqmu BEFORE mu or wmu. reqHeaderMu chan struct{} + // internalStateHook reports state changes back to the net/http.ClientConn. + // Note that this is different from the user state hook registered by + // net/http.ClientConn.SetStateHook: The internal hook calls ClientConn, + // which calls the user hook. + internalStateHook func() + // wmu is held while writing. // Acquire BEFORE mu when holding both, to avoid blocking mu on network writes. // Only acquire both at the same time when changing peer settings. @@ -710,7 +723,7 @@ func canRetryError(err error) bool { func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse bool) (*ClientConn, error) { if t.transportTestHooks != nil { - return t.newClientConn(nil, singleUse) + return t.newClientConn(nil, singleUse, nil) } host, _, err := net.SplitHostPort(addr) if err != nil { @@ -720,7 +733,7 @@ func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse b if err != nil { return nil, err } - return t.newClientConn(tconn, singleUse) + return t.newClientConn(tconn, singleUse, nil) } func (t *Transport) newTLSConfig(host string) *tls.Config { @@ -772,10 +785,10 @@ func (t *Transport) expectContinueTimeout() time.Duration { } func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { - return t.newClientConn(c, t.disableKeepAlives()) + return t.newClientConn(c, t.disableKeepAlives(), nil) } -func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) { +func (t *Transport) newClientConn(c net.Conn, singleUse bool, internalStateHook func()) (*ClientConn, error) { conf := configFromTransport(t) cc := &ClientConn{ t: t, @@ -797,6 +810,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro pings: make(map[[8]byte]chan struct{}), reqHeaderMu: make(chan struct{}, 1), lastActive: time.Now(), + internalStateHook: internalStateHook, } if t.transportTestHooks != nil { t.transportTestHooks.newclientconn(cc) @@ -1037,10 +1051,7 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) { maxConcurrentOkay = cc.currentRequestCountLocked() < int(cc.maxConcurrentStreams) } - st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay && - !cc.doNotReuse && - int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 && - !cc.tooIdleLocked() + st.canTakeNewRequest = maxConcurrentOkay && cc.isUsableLocked() // If this connection has never been used for a request and is closed, // then let it take a request (which will fail). @@ -1056,6 +1067,31 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) { return } +func (cc *ClientConn) isUsableLocked() bool { + return cc.goAway == nil && + !cc.closed && + !cc.closing && + !cc.doNotReuse && + int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 && + !cc.tooIdleLocked() +} + +// canReserveLocked reports whether a net/http.ClientConn can reserve a slot on this conn. +// +// This follows slightly different rules than clientConnIdleState.canTakeNewRequest. +// We only permit reservations up to the conn's concurrency limit. +// This differs from ClientConn.ReserveNewRequest, which permits reservations +// past the limit when StrictMaxConcurrentStreams is set. +func (cc *ClientConn) canReserveLocked() bool { + if cc.currentRequestCountLocked() >= int(cc.maxConcurrentStreams) { + return false + } + if !cc.isUsableLocked() { + return false + } + return true +} + // currentRequestCountLocked reports the number of concurrency slots currently in use, // including active streams, reserved slots, and reset streams waiting for acknowledgement. func (cc *ClientConn) currentRequestCountLocked() int { @@ -1067,6 +1103,14 @@ func (cc *ClientConn) canTakeNewRequestLocked() bool { return st.canTakeNewRequest } +// availableLocked reports the number of concurrency slots available. +func (cc *ClientConn) availableLocked() int { + if !cc.canTakeNewRequestLocked() { + return 0 + } + return max(0, int(cc.maxConcurrentStreams)-cc.currentRequestCountLocked()) +} + // tooIdleLocked reports whether this connection has been been sitting idle // for too much wall time. func (cc *ClientConn) tooIdleLocked() bool { @@ -1091,6 +1135,7 @@ func (cc *ClientConn) closeConn() { t := time.AfterFunc(250*time.Millisecond, cc.forceCloseConn) defer t.Stop() cc.tconn.Close() + cc.maybeCallStateHook() } // A tls.Conn.Close can hang for a long time if the peer is unresponsive. @@ -1616,6 +1661,8 @@ func (cs *clientStream) cleanupWriteRequest(err error) { } bodyClosed := cs.reqBodyClosed closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() || cc.goAway != nil + // Have we read any frames from the connection since sending this request? + readSinceStream := cc.readBeforeStreamID > cs.ID cc.mu.Unlock() if mustCloseBody { cs.reqBody.Close() @@ -1647,8 +1694,10 @@ func (cs *clientStream) cleanupWriteRequest(err error) { // // This could be due to the server becoming unresponsive. // To avoid sending too many requests on a dead connection, - // we let the request continue to consume a concurrency slot - // until we can confirm the server is still responding. + // if we haven't read any frames from the connection since + // sending this request, we let it continue to consume + // a concurrency slot until we can confirm the server is + // still responding. // We do this by sending a PING frame along with the RST_STREAM // (unless a ping is already in flight). // @@ -1659,7 +1708,7 @@ func (cs *clientStream) cleanupWriteRequest(err error) { // because it's short lived and will probably be closed before // we get the ping response. ping := false - if !closeOnIdle { + if !closeOnIdle && !readSinceStream { cc.mu.Lock() // rstStreamPingsBlocked works around a gRPC behavior: // see comment on the field for details. @@ -1693,6 +1742,7 @@ func (cs *clientStream) cleanupWriteRequest(err error) { } close(cs.donec) + cc.maybeCallStateHook() } // awaitOpenSlotForStreamLocked waits until len(streams) < maxConcurrentStreams. @@ -2745,6 +2795,7 @@ func (rl *clientConnReadLoop) streamByID(id uint32, headerOrData bool) *clientSt // See comment on ClientConn.rstStreamPingsBlocked for details. rl.cc.rstStreamPingsBlocked = false } + rl.cc.readBeforeStreamID = rl.cc.nextStreamID cs := rl.cc.streams[id] if cs != nil && !cs.readAborted { return cs @@ -2795,6 +2846,7 @@ func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error { func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error { cc := rl.cc + defer cc.maybeCallStateHook() cc.mu.Lock() defer cc.mu.Unlock() @@ -2975,6 +3027,7 @@ func (cc *ClientConn) Ping(ctx context.Context) error { func (rl *clientConnReadLoop) processPing(f *PingFrame) error { if f.IsAck() { cc := rl.cc + defer cc.maybeCallStateHook() cc.mu.Lock() defer cc.mu.Unlock() // If ack, notify listener if any @@ -3198,9 +3251,13 @@ func registerHTTPSProtocol(t *http.Transport, rt noDialH2RoundTripper) (err erro } // noDialH2RoundTripper is a RoundTripper which only tries to complete the request -// if there's already has a cached connection to the host. +// if there's already a cached connection to the host. // (The field is exported so it can be accessed via reflect from net/http; tested // by TestNoDialH2RoundTripperType) +// +// A noDialH2RoundTripper is registered with http1.Transport.RegisterProtocol, +// and the http1.Transport can use type assertions to call non-RoundTrip methods on it. +// This lets us expose, for example, NewClientConn to net/http. type noDialH2RoundTripper struct{ *Transport } func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { @@ -3211,6 +3268,85 @@ func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, err return res, err } +func (rt noDialH2RoundTripper) NewClientConn(conn net.Conn, internalStateHook func()) (http.RoundTripper, error) { + tr := rt.Transport + cc, err := tr.newClientConn(conn, tr.disableKeepAlives(), internalStateHook) + if err != nil { + return nil, err + } + + // RoundTrip should block when the conn is at its concurrency limit, + // not return an error. Setting strictMaxConcurrentStreams enables this. + cc.strictMaxConcurrentStreams = true + + return netHTTPClientConn{cc}, nil +} + +// netHTTPClientConn wraps ClientConn and implements the interface net/http expects from +// the RoundTripper returned by NewClientConn. +type netHTTPClientConn struct { + cc *ClientConn +} + +func (cc netHTTPClientConn) RoundTrip(req *http.Request) (*http.Response, error) { + return cc.cc.RoundTrip(req) +} + +func (cc netHTTPClientConn) Close() error { + return cc.cc.Close() +} + +func (cc netHTTPClientConn) Err() error { + cc.cc.mu.Lock() + defer cc.cc.mu.Unlock() + if cc.cc.closed { + return errors.New("connection closed") + } + return nil +} + +func (cc netHTTPClientConn) Reserve() error { + defer cc.cc.maybeCallStateHook() + cc.cc.mu.Lock() + defer cc.cc.mu.Unlock() + if !cc.cc.canReserveLocked() { + return errors.New("connection is unavailable") + } + cc.cc.streamsReserved++ + return nil +} + +func (cc netHTTPClientConn) Release() { + defer cc.cc.maybeCallStateHook() + cc.cc.mu.Lock() + defer cc.cc.mu.Unlock() + // We don't complain if streamsReserved is 0. + // + // This is consistent with RoundTrip: both Release and RoundTrip will + // consume a reservation iff one exists. + if cc.cc.streamsReserved > 0 { + cc.cc.streamsReserved-- + } +} + +func (cc netHTTPClientConn) Available() int { + cc.cc.mu.Lock() + defer cc.cc.mu.Unlock() + return cc.cc.availableLocked() +} + +func (cc netHTTPClientConn) InFlight() int { + cc.cc.mu.Lock() + defer cc.cc.mu.Unlock() + return cc.cc.currentRequestCountLocked() +} + +func (cc *ClientConn) maybeCallStateHook() { + if cc.internalStateHook != nil { + cc.internalStateHook() + } +} + func (t *Transport) idleConnTimeout() time.Duration { // to keep things backwards compatible, we use non-zero values of // IdleConnTimeout, followed by using the IdleConnTimeout on the underlying diff --git a/vendor/golang.org/x/sys/cpu/cpu.go b/vendor/golang.org/x/sys/cpu/cpu.go index 34c9ae76..63541994 100644 --- a/vendor/golang.org/x/sys/cpu/cpu.go +++ b/vendor/golang.org/x/sys/cpu/cpu.go @@ -92,9 +92,6 @@ var ARM64 struct { HasSHA2 bool // SHA2 hardware implementation HasCRC32 bool // CRC32 hardware implementation HasATOMICS bool // Atomic memory operation instruction set - HasHPDS bool // Hierarchical permission disables in translations tables - HasLOR bool // Limited ordering regions - HasPAN bool // Privileged access never HasFPHP bool // Half precision floating-point instruction set HasASIMDHP bool // Advanced SIMD half precision instruction set HasCPUID bool // CPUID identification scheme registers diff --git a/vendor/golang.org/x/sys/cpu/cpu_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_arm64.go index f449c679..af2aa99f 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_arm64.go @@ -65,10 +65,10 @@ func setMinimalFeatures() { func readARM64Registers() { Initialized = true - parseARM64SystemRegisters(getisar0(), getisar1(), getmmfr1(), getpfr0()) + parseARM64SystemRegisters(getisar0(), getisar1(), getpfr0()) } -func parseARM64SystemRegisters(isar0, isar1, mmfr1, pfr0 uint64) { +func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { // ID_AA64ISAR0_EL1 switch extractBits(isar0, 4, 7) { case 1: @@ -152,22 +152,6 @@ func parseARM64SystemRegisters(isar0, isar1, mmfr1, pfr0 uint64) { ARM64.HasI8MM = true } - // ID_AA64MMFR1_EL1 - switch extractBits(mmfr1, 12, 15) { - case 1, 2: - ARM64.HasHPDS = true - } - - switch extractBits(mmfr1, 16, 19) { - case 1: - ARM64.HasLOR = true - } - - switch extractBits(mmfr1, 20, 23) { - case 1, 2, 3: - ARM64.HasPAN = true - } - // ID_AA64PFR0_EL1 switch extractBits(pfr0, 16, 19) { case 0: diff --git a/vendor/golang.org/x/sys/cpu/cpu_arm64.s b/vendor/golang.org/x/sys/cpu/cpu_arm64.s index a4f24b3b..3b0450a0 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_arm64.s +++ b/vendor/golang.org/x/sys/cpu/cpu_arm64.s @@ -20,13 +20,6 @@ TEXT ·getisar1(SB),NOSPLIT,$0-8 MOVD R0, ret+0(FP) RET -// func getmmfr1() uint64 -TEXT ·getmmfr1(SB),NOSPLIT,$0-8 - // get Memory Model Feature Register 1 into x0 - MRS ID_AA64MMFR1_EL1, R0 - MOVD R0, ret+0(FP) - RET - // func getpfr0() uint64 TEXT ·getpfr0(SB),NOSPLIT,$0-8 // get Processor Feature Register 0 into x0 diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go index e3fc5a8d..6ac6e1ef 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go @@ -8,6 +8,5 @@ package cpu func getisar0() uint64 func getisar1() uint64 -func getmmfr1() uint64 func getpfr0() uint64 func getzfr0() uint64 diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go index 8df2079e..7f194678 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go @@ -8,5 +8,4 @@ package cpu func getisar0() uint64 { return 0 } func getisar1() uint64 { return 0 } -func getmmfr1() uint64 { return 0 } func getpfr0() uint64 { return 0 } diff --git a/vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go index 19aea063..ebfb3fc8 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go @@ -167,7 +167,7 @@ func doinit() { setMinimalFeatures() return } - parseARM64SystemRegisters(cpuid.aa64isar0, cpuid.aa64isar1, cpuid.aa64mmfr1, cpuid.aa64pfr0) + parseARM64SystemRegisters(cpuid.aa64isar0, cpuid.aa64isar1, cpuid.aa64pfr0) Initialized = true } diff --git a/vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go index 87fd3a77..85b64d5c 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go @@ -59,7 +59,7 @@ func doinit() { if !ok { return } - parseARM64SystemRegisters(isar0, isar1, 0, 0) + parseARM64SystemRegisters(isar0, isar1, 0) Initialized = true } diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 42517077..fd39be4e 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -256,6 +256,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -613,7 +614,7 @@ ccflags="$@" $2 !~ /IOC_MAGIC/ && $2 ~ /^[A-Z][A-Z0-9_]+_MAGIC2?$/ || $2 ~ /^(VM|VMADDR)_/ || - $2 ~ /^IOCTL_VM_SOCKETS_/ || + $2 ~ /^(IOCTL_VM_SOCKETS_|IOCTL_MEI_)/ || $2 ~ /^(TASKSTATS|TS)_/ || $2 ~ /^CGROUPSTATS_/ || $2 ~ /^GENL_/ || diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index d0a75da5..120a7b35 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -1615,6 +1615,8 @@ const ( IN_OPEN = 0x20 IN_Q_OVERFLOW = 0x4000 IN_UNMOUNT = 0x2000 + IOCTL_MEI_CONNECT_CLIENT = 0xc0104801 + IOCTL_MEI_CONNECT_CLIENT_VTAG = 0xc0144804 IPPROTO_AH = 0x33 IPPROTO_BEETPH = 0x5e IPPROTO_COMP = 0x6c diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 1c37f9fb..97a61fc5 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -116,6 +116,8 @@ const ( IEXTEN = 0x8000 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x80044803 + IOCTL_MEI_NOTIFY_SET = 0x40044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 6f54d34a..a0d6d498 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -116,6 +116,8 @@ const ( IEXTEN = 0x8000 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x80044803 + IOCTL_MEI_NOTIFY_SET = 0x40044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 783ec5c1..dd9c903f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x8000 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x80044803 + IOCTL_MEI_NOTIFY_SET = 0x40044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index ca83d3ba..384c61ca 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -120,6 +120,8 @@ const ( IEXTEN = 0x8000 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x80044803 + IOCTL_MEI_NOTIFY_SET = 0x40044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 607e611c..6384c983 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -116,6 +116,8 @@ const ( IEXTEN = 0x8000 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x80044803 + IOCTL_MEI_NOTIFY_SET = 0x40044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index b9cb5bd3..553c1c6f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x100 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x80 + IOCTL_MEI_NOTIFY_GET = 0x40044803 + IOCTL_MEI_NOTIFY_SET = 0x80044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 IPV6_FLOWINFO_MASK = 0xfffffff IPV6_FLOWLABEL_MASK = 0xfffff diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index 65b078a6..b3339f20 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x100 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x80 + IOCTL_MEI_NOTIFY_GET = 0x40044803 + IOCTL_MEI_NOTIFY_SET = 0x80044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 IPV6_FLOWINFO_MASK = 0xfffffff IPV6_FLOWLABEL_MASK = 0xfffff diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index 5298a303..177091d2 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x100 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x80 + IOCTL_MEI_NOTIFY_GET = 0x40044803 + IOCTL_MEI_NOTIFY_SET = 0x80044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 7bc557c8..c5abf156 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x100 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x80 + IOCTL_MEI_NOTIFY_GET = 0x40044803 + IOCTL_MEI_NOTIFY_SET = 0x80044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 152399bb..f1f3fadf 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x400 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x40044803 + IOCTL_MEI_NOTIFY_SET = 0x80044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 IPV6_FLOWINFO_MASK = 0xfffffff IPV6_FLOWLABEL_MASK = 0xfffff diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index 1a1ce240..203ad9c5 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x400 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x40044803 + IOCTL_MEI_NOTIFY_SET = 0x80044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 IPV6_FLOWINFO_MASK = 0xfffffff IPV6_FLOWLABEL_MASK = 0xfffff diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index 4231a1fb..4b9abcb2 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x400 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x40044803 + IOCTL_MEI_NOTIFY_SET = 0x80044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 21c0e952..f8798303 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x8000 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x80044803 + IOCTL_MEI_NOTIFY_SET = 0x40044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index f00d1cd7..64347eb3 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -115,6 +115,8 @@ const ( IEXTEN = 0x8000 IN_CLOEXEC = 0x80000 IN_NONBLOCK = 0x800 + IOCTL_MEI_NOTIFY_GET = 0x80044803 + IOCTL_MEI_NOTIFY_SET = 0x40044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 IPV6_FLOWINFO_MASK = 0xfffffff IPV6_FLOWLABEL_MASK = 0xfffff diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index bc8d539e..7d719117 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -119,6 +119,8 @@ const ( IEXTEN = 0x8000 IN_CLOEXEC = 0x400000 IN_NONBLOCK = 0x4000 + IOCTL_MEI_NOTIFY_GET = 0x40044803 + IOCTL_MEI_NOTIFY_SET = 0x80044802 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 IPV6_FLOWINFO_MASK = 0xfffffff IPV6_FLOWLABEL_MASK = 0xfffff diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go index 439548ec..50e8e644 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go @@ -104,7 +104,7 @@ type Statvfs_t struct { Fsid uint32 Namemax uint32 Owner uint32 - Spare [4]uint32 + Spare [4]uint64 Fstypename [32]byte Mntonname [1024]byte Mntfromname [1024]byte diff --git a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go index 950a6a32..65aaf4d2 100644 --- a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +++ b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go @@ -26,6 +26,7 @@ const ( Edition_EDITION_PROTO3_enum_value = 999 Edition_EDITION_2023_enum_value = 1000 Edition_EDITION_2024_enum_value = 1001 + Edition_EDITION_UNSTABLE_enum_value = 9999 Edition_EDITION_1_TEST_ONLY_enum_value = 1 Edition_EDITION_2_TEST_ONLY_enum_value = 2 Edition_EDITION_99997_TEST_ONLY_enum_value = 99997 diff --git a/vendor/google.golang.org/protobuf/proto/decode.go b/vendor/google.golang.org/protobuf/proto/decode.go index 4cbf1aea..889d8511 100644 --- a/vendor/google.golang.org/protobuf/proto/decode.go +++ b/vendor/google.golang.org/protobuf/proto/decode.go @@ -121,9 +121,8 @@ func (o UnmarshalOptions) unmarshal(b []byte, m protoreflect.Message) (out proto out, err = methods.Unmarshal(in) } else { - o.RecursionLimit-- - if o.RecursionLimit < 0 { - return out, errors.New("exceeded max recursion depth") + if o.RecursionLimit--; o.RecursionLimit < 0 { + return out, errRecursionDepth } err = o.unmarshalMessageSlow(b, m) } @@ -220,6 +219,9 @@ func (o UnmarshalOptions) unmarshalSingular(b []byte, wtyp protowire.Type, m pro } func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv protoreflect.Map, fd protoreflect.FieldDescriptor) (n int, err error) { + if o.RecursionLimit--; o.RecursionLimit < 0 { + return 0, errRecursionDepth + } if wtyp != protowire.BytesType { return 0, errUnknown } @@ -305,3 +307,5 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto var errUnknown = errors.New("BUG: internal error (unknown)") var errDecode = errors.New("cannot parse invalid wire-format data") + +var errRecursionDepth = errors.New("exceeded maximum recursion depth") diff --git a/vendor/modules.txt b/vendor/modules.txt index a385ff3a..cf3f7203 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -146,7 +146,7 @@ github.com/fatih/color # github.com/felixge/httpsnoop v1.0.4 ## explicit; go 1.13 github.com/felixge/httpsnoop -# github.com/gabriel-vasile/mimetype v1.4.11 +# github.com/gabriel-vasile/mimetype v1.4.12 ## explicit; go 1.21 github.com/gabriel-vasile/mimetype github.com/gabriel-vasile/mimetype/internal/charset @@ -184,7 +184,7 @@ github.com/go-playground/locales/currency # github.com/go-playground/universal-translator v0.18.1 ## explicit; go 1.18 github.com/go-playground/universal-translator -# github.com/go-playground/validator/v10 v10.28.0 +# github.com/go-playground/validator/v10 v10.29.0 ## explicit; go 1.24.0 github.com/go-playground/validator/v10 # github.com/go-redis/redis/v8 v8.11.5 @@ -225,8 +225,8 @@ github.com/hashicorp/yamux # github.com/inconshreveable/mousetrap v1.1.0 ## explicit; go 1.18 github.com/inconshreveable/mousetrap -# github.com/itchyny/gojq v0.12.17 -## explicit; go 1.21 +# github.com/itchyny/gojq v0.12.18 +## explicit; go 1.24.0 github.com/itchyny/gojq # github.com/itchyny/timefmt-go v0.1.7 ## explicit; go 1.24 @@ -321,7 +321,7 @@ github.com/sirupsen/logrus/hooks/syslog # github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 ## explicit github.com/skycoin/noise -# github.com/skycoin/skycoin v0.28.1-0.20251109152000-9018c9f37372 +# github.com/skycoin/skycoin v0.28.1-0.20251215160458-f84f07154eae ## explicit; go 1.25.1 github.com/skycoin/skycoin/src/cipher github.com/skycoin/skycoin/src/cipher/base58 @@ -342,7 +342,7 @@ github.com/skycoin/skywire/pkg/skywire-utilities/pkg/logging github.com/skycoin/skywire/pkg/skywire-utilities/pkg/metricsutil github.com/skycoin/skywire/pkg/skywire-utilities/pkg/netutil github.com/skycoin/skywire/pkg/skywire-utilities/pkg/networkmonitor -# github.com/spf13/cobra v1.10.1 +# github.com/spf13/cobra v1.10.2 ## explicit; go 1.15 github.com/spf13/cobra # github.com/spf13/pflag v1.0.10 @@ -381,7 +381,7 @@ github.com/valyala/fastrand # github.com/valyala/histogram v1.2.0 ## explicit; go 1.12 github.com/valyala/histogram -# github.com/xtaci/smux v1.5.44 +# github.com/xtaci/smux v1.5.47 ## explicit; go 1.18 github.com/xtaci/smux # go.opentelemetry.io/auto/sdk v1.1.0 @@ -422,7 +422,7 @@ go.opentelemetry.io/otel/trace/noop # golang.org/x/arch v0.23.0 ## explicit; go 1.24.0 golang.org/x/arch/x86/x86asm -# golang.org/x/crypto v0.45.0 +# golang.org/x/crypto v0.46.0 ## explicit; go 1.24.0 golang.org/x/crypto/blake2b golang.org/x/crypto/blake2s @@ -433,7 +433,7 @@ golang.org/x/crypto/hkdf golang.org/x/crypto/internal/alias golang.org/x/crypto/internal/poly1305 golang.org/x/crypto/sha3 -# golang.org/x/net v0.47.0 +# golang.org/x/net v0.48.0 ## explicit; go 1.24.0 golang.org/x/net/bpf golang.org/x/net/context @@ -450,16 +450,16 @@ golang.org/x/net/ipv4 golang.org/x/net/ipv6 golang.org/x/net/nettest golang.org/x/net/proxy -# golang.org/x/sys v0.38.0 +# golang.org/x/sys v0.39.0 ## explicit; go 1.24.0 golang.org/x/sys/cpu golang.org/x/sys/plan9 golang.org/x/sys/unix golang.org/x/sys/windows -# golang.org/x/term v0.37.0 +# golang.org/x/term v0.38.0 ## explicit; go 1.24.0 golang.org/x/term -# golang.org/x/text v0.31.0 +# golang.org/x/text v0.32.0 ## explicit; go 1.24.0 golang.org/x/text/internal/language golang.org/x/text/internal/language/compact @@ -471,7 +471,7 @@ golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm # golang.org/x/time v0.14.0 ## explicit; go 1.24.0 -# google.golang.org/protobuf v1.36.10 +# google.golang.org/protobuf v1.36.11 ## explicit; go 1.23 google.golang.org/protobuf/encoding/protowire google.golang.org/protobuf/internal/detrand