diff --git a/.drone.yml b/.drone.yml
index 8fb385b..72d3b03 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -1,70 +1,89 @@
---
kind: pipeline
type: docker
-name: build-linux
-
-environment:
- GOOS: linux
- GOOPTIONS: -mod=vendor
- SRCFILES: cmd/pki/*.go
- PROJECTNAME: pki
+name: cleanup-before
steps:
- - name: build-linux-amd64
- image: golang
+ - name: clean
+ image: alpine
commands:
- - go build -o $PROJECTNAME $GOOPTIONS $SRCFILES
- environment:
- GOARCH: amd64
+ - rm -rf /build/*
+ volumes:
+ - name: build
+ path: /build
when:
- event:
- exclude:
- - tag
- - name: build-linux-arm64
- image: golang
- commands:
- - go build -o $PROJECTNAME $GOOPTIONS $SRCFILES
- environment:
- GOARCH: arm64
- when:
- event:
- exclude:
- - tag
+ event: tag
+
+volumes:
+ - name: build
+ host:
+ path: /tmp/pki/build
---
kind: pipeline
type: docker
-name: gitea-release-linux
-
-environment:
- GOOS: linux
- GOOPTIONS: -mod=vendor
- SRCFILES: cmd/pki/*.go
- PROJECTNAME: pki
+name: default-linux-amd64
steps:
- - name: build-linux-amd64
+ - name: build
image: golang
commands:
- - go build -o $PROJECTNAME $GOOPTIONS $SRCFILES
- - tar -czvf $PROJECTNAME-$DRONE_TAG-$GOOS-$GOARCH.tar.gz $PROJECTNAME
- - echo $PROJECTNAME $DRONE_TAG > VERSION
+ - ./ci-build.sh build
environment:
+ GOOS: linux
GOARCH: amd64
- when:
- event:
- - tag
- - name: build-linux-arm64
+ volumes:
+ - name: build
+ path: /build
+
+volumes:
+ - name: build
+ host:
+ path: /tmp/pki/build
+
+depends_on:
+ - cleanup-before
+
+---
+kind: pipeline
+type: docker
+name: default-linux-arm64
+
+steps:
+ - name: build
image: golang
commands:
- - go build -o $PROJECTNAME $GOOPTIONS $SRCFILES
- - tar -czvf $PROJECTNAME-$DRONE_TAG-$GOOS-$GOARCH.tar.gz $PROJECTNAME
- - echo $PROJECTNAME $DRONE_TAG > VERSION
+ - ./ci-build.sh build
environment:
+ GOOS: linux
GOARCH: arm64
+ volumes:
+ - name: build
+ path: /build
+
+volumes:
+ - name: build
+ host:
+ path: /tmp/pki/build
+
+depends_on:
+ - cleanup-before
+
+---
+kind: pipeline
+type: docker
+name: gitea-release
+
+steps:
+ - name: move
+ image: alpine
+ commands:
+ - mv build/* ./
+ volumes:
+ - name: build
+ path: /drone/src/build
when:
- event:
- - tag
+ event: tag
- name: release
image: plugins/gitea-release
settings:
@@ -76,6 +95,50 @@ steps:
- sha256
- sha512
title: VERSION
+ volumes:
+ - name: build
+ path: /drone/src/build
when:
- event:
- - tag
+ event: tag
+ - name: ls
+ image: alpine
+ commands:
+ - find .
+ volumes:
+ - name: build
+ path: /drone/src/build
+ when:
+ event: tag
+
+volumes:
+ - name: build
+ host:
+ path: /tmp/pki/build
+
+depends_on:
+ - default-linux-amd64
+ - default-linux-arm64
+
+---
+kind: pipeline
+type: docker
+name: cleanup-after
+
+steps:
+ - name: clean
+ image: alpine
+ commands:
+ - rm -rf /build/*
+ volumes:
+ - name: build
+ path: /build
+ when:
+ event: tag
+
+volumes:
+ - name: build
+ host:
+ path: /tmp/pki/build
+
+depends_on:
+ - gitea-release
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a544f18
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,18 @@
+# pki Makefile
+
+GOCMD=go
+GOBUILDCMD=${GOCMD} build
+GOOPTIONS=-mod=vendor -ldflags="-s -w"
+
+RMCMD=rm
+BINNAME=pki
+
+SRCFILES=cmd/pki/*.go
+
+all: build
+
+build:
+ ${GOBUILDCMD} ${GOOPTIONS} ${SRCFILES}
+
+clean:
+ ${RMCMD} -f ${BINNAME}
\ No newline at end of file
diff --git a/README.md b/README.md
index bc0eeaf..a4f6277 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ PKI is a centralized Letsencrypt database server and renewer for certificate man
### Build
```bash
-go build cmd/pki/pki.go
+make
```
### Sample config in pki.ini
@@ -40,7 +40,7 @@ ovhck=
## License
```text
-Copyright (c) 2020, 2021, 2022 PaulBSD
+Copyright (c) 2020, 2021 PaulBSD
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/ci-build.sh b/ci-build.sh
new file mode 100755
index 0000000..85f340d
--- /dev/null
+++ b/ci-build.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+set -e
+
+PROJECTNAME=pki
+RELEASENAME=${PROJECTNAME}
+VERSION="0"
+
+GOOPTIONS="-mod=vendor"
+SRCFILES=cmd/${PROJECTNAME}/*.go
+
+build() {
+ echo "Begin of build"
+ if [[ ! -z $DRONE_TAG ]]
+ then
+ echo "Drone tag set, let's do a release"
+ VERSION=$DRONE_TAG
+ echo "${PROJECTNAME} ${VERSION}" > /build/VERSION
+ elif [[ ! -z $DRONE_TAG ]]
+ then
+ echo "Drone not set, let's only do a build"
+ VERSION=$DRONE_COMMIT
+ fi
+
+ if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]]
+ then
+ echo "Let's set a release name"
+ RELEASENAME=${PROJECTNAME}-${VERSION}-${GOOS}-${GOARCH}
+ fi
+
+ echo "Building project"
+ go build -o ${PROJECTNAME} ${GOOPTIONS} ${SRCFILES}
+
+ if [[ ! -z $DRONE_TAG ]]
+ then
+ echo "Let's make archives"
+ mkdir -p /build
+ tar -czvf /build/${RELEASENAME}.tar.gz ${PROJECTNAME}
+ fi
+
+ echo "Removing binary file"
+ rm ${PROJECTNAME}
+
+ echo "End of build"
+}
+
+clean() {
+ rm -rf $RELEASEDIR
+}
+
+case $1 in
+ "build")
+ build
+ ;;
+ "clean")
+ clean
+ ;;
+ *)
+ echo "No options choosen"
+ exit 1
+ ;;
+esac
diff --git a/go.mod b/go.mod
index 922c318..7eb1e93 100644
--- a/go.mod
+++ b/go.mod
@@ -1,42 +1,41 @@
module git.paulbsd.com/paulbsd/pki
-go 1.24.4
+go 1.17
require (
- github.com/go-acme/lego/v4 v4.23.1
- github.com/golang/snappy v1.0.0 // indirect
- github.com/labstack/echo/v4 v4.13.4
- github.com/lib/pq v1.10.9
- github.com/miekg/dns v1.1.66 // indirect
+ github.com/go-acme/lego/v4 v4.4.0
+ github.com/golang/snappy v0.0.4 // indirect
+ github.com/google/go-cmp v0.5.5 // indirect
+ github.com/gopherjs/gopherjs v0.0.0-20210406100015-1e088ea4ee04 // indirect
+ github.com/labstack/echo/v4 v4.5.0
+ github.com/lib/pq v1.10.3
+ github.com/miekg/dns v1.1.43 // indirect
github.com/onsi/ginkgo v1.16.0 // indirect
github.com/onsi/gomega v1.11.0 // indirect
- golang.org/x/crypto v0.39.0 // indirect
- golang.org/x/net v0.41.0 // indirect
- golang.org/x/sys v0.33.0 // indirect
- golang.org/x/text v0.26.0 // indirect
- golang.org/x/time v0.12.0 // indirect
- gopkg.in/ini.v1 v1.67.0
- xorm.io/builder v0.3.13 // indirect
- xorm.io/xorm v1.3.9
+ github.com/smartystreets/assertions v1.2.0 // indirect
+ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
+ golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
+ golang.org/x/sys v0.0.0-20210903071746-97244b99971b // indirect
+ golang.org/x/text v0.3.7 // indirect
+ golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
+ gopkg.in/ini.v1 v1.62.1
+ xorm.io/builder v0.3.9 // indirect
+ xorm.io/xorm v1.2.3
)
require (
- github.com/cenkalti/backoff/v4 v4.3.0 // indirect
- github.com/go-jose/go-jose/v4 v4.1.1 // indirect
- github.com/goccy/go-json v0.10.5 // indirect
+ github.com/cenkalti/backoff/v4 v4.1.1 // indirect
+ github.com/goccy/go-json v0.7.8 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
- github.com/json-iterator/go v1.1.12 // indirect
- github.com/labstack/gommon v0.4.2 // indirect
- github.com/mattn/go-colorable v0.1.14 // indirect
- github.com/mattn/go-isatty v0.0.20 // indirect
+ github.com/json-iterator/go v1.1.11 // indirect
+ github.com/labstack/gommon v0.3.0 // indirect
+ github.com/mattn/go-colorable v0.1.8 // indirect
+ github.com/mattn/go-isatty v0.0.13 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
- github.com/modern-go/reflect2 v1.0.2 // indirect
- github.com/ovh/go-ovh v1.9.0 // indirect
+ github.com/modern-go/reflect2 v1.0.1 // indirect
+ github.com/ovh/go-ovh v1.1.0 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
- github.com/valyala/fasttemplate v1.2.2 // indirect
- golang.org/x/mod v0.25.0 // indirect
- golang.org/x/oauth2 v0.30.0 // indirect
- golang.org/x/sync v0.15.0 // indirect
- golang.org/x/tools v0.34.0 // indirect
+ github.com/valyala/fasttemplate v1.2.1 // indirect
+ gopkg.in/square/go-jose.v2 v2.6.0 // indirect
)
diff --git a/go.sum b/go.sum
index 5f656dc..54d1601 100644
--- a/go.sum
+++ b/go.sum
@@ -1,42 +1,190 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
+cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
+cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
+cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
+cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
+cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
+cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
+cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
+cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
+cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
+cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
+cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
+cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
+cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
+cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
+cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
+cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
+cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
+cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
+cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
+cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
+contrib.go.opencensus.io/exporter/ocagent v0.4.12/go.mod h1:450APlNTSR6FrvC3CTRqYosuDstRB9un7SOx2k/9ckA=
+dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
-github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
-github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
+github.com/Azure/azure-sdk-for-go v32.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
+github.com/Azure/go-autorest/autorest v0.1.0/go.mod h1:AKyIcETwSUFxIcs/Wnq/C+kwCtlEYGUVd7FPNb2slmg=
+github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
+github.com/Azure/go-autorest/autorest/adal v0.1.0/go.mod h1:MeS4XhScH55IST095THyTxElntu7WqB7pNbZo8Q5G3E=
+github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
+github.com/Azure/go-autorest/autorest/azure/auth v0.1.0/go.mod h1:Gf7/i2FUpyb/sGBLIFxTBzrNzBo7aPXXE3ZVeDRwdpM=
+github.com/Azure/go-autorest/autorest/azure/cli v0.1.0/go.mod h1:Dk8CUAt/b/PzkfeRsWzVG9Yj3ps8mS8ECztu43rdU8U=
+github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
+github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
+github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
+github.com/Azure/go-autorest/autorest/to v0.2.0/go.mod h1:GunWKJp1AEqgMaGLV+iocmRAJWqST1wQYhyyjXJ3SJc=
+github.com/Azure/go-autorest/autorest/validation v0.1.0/go.mod h1:Ha3z/SqBeaalWQvokg3NZAlQTalVMtOIAs1aGK7G6u8=
+github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
+github.com/Azure/go-autorest/tracing v0.1.0/go.mod h1:ROEEAFwXycQw7Sn3DXNtEedEvdeRAgDr0izn4z5Ij88=
+github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
+github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
+github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
+github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
+github.com/OpenDNS/vegadns2client v0.0.0-20180418235048-a3fa4a771d87/go.mod h1:iGLljf5n9GjT6kc0HBvyI1nOKnGQbNB66VzSNbK5iks=
+github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
+github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
+github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
+github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
+github.com/akamai/AkamaiOPEN-edgegrid-golang v1.1.0/go.mod h1:kX6YddBkXqqywAe8c9LyvgTCyFuZCTMF4cRPQhc3Fy8=
+github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
+github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
+github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/aliyun/alibaba-cloud-sdk-go v1.61.976/go.mod h1:pUKYbK5JQ+1Dfxk80P0qxGqe5dkxDoabbZS7zOcouyA=
+github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
+github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
+github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
+github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
+github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
+github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
+github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
+github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
+github.com/aws/aws-sdk-go v1.37.27/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
+github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
+github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
+github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
+github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
+github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
+github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
+github.com/c-bata/go-prompt v0.2.5/go.mod h1:vFnjEGDIIA/Lib7giyE4E9c50Lvl8j0S+7FVlAwDAVw=
+github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
+github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
+github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
+github.com/cenkalti/backoff/v4 v4.1.0/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
+github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
+github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
+github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
+github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
+github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
+github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
+github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
+github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
+github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/cloudflare/cloudflare-go v0.14.0/go.mod h1:EnwdgGMaFOruiPZRFSgn+TsQ3hQ7C/YWzIGLeu5c304=
+github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
+github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
+github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
+github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
+github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
+github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
+github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
+github.com/cpu/goacmedns v0.1.1/go.mod h1:MuaouqEhPAHxsbqjgnck5zeghuwBP1dLnPoobeGqugQ=
+github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
+github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
-github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
+github.com/deepmap/oapi-codegen v1.3.11/go.mod h1:suMvK7+rKlx3+tpa8ByptmvoXbAV70wERKTOGH3hLp0=
+github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
+github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
+github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
+github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
+github.com/dnsimple/dnsimple-go v0.63.0/go.mod h1:O5TJ0/U6r7AfT8niYNlmohpLbCSG+c71tQlGr9SeGrg=
+github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
+github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
+github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
+github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
+github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
+github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
+github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/exoscale/egoscale v0.46.0/go.mod h1:mpEXBpROAa/2i5GC0r33rfxG+TxSEka11g1PIXt9+zc=
+github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
+github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
+github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
+github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
-github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
-github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
-github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
-github.com/go-acme/lego/v4 v4.16.1 h1:JxZ93s4KG0jL27rZ30UsIgxap6VGzKuREsSkkyzeoCQ=
-github.com/go-acme/lego/v4 v4.16.1/go.mod h1:AVvwdPned/IWpD/ihHhMsKnveF7HHYAz/CmtXi7OZoE=
-github.com/go-acme/lego/v4 v4.17.4 h1:h0nePd3ObP6o7kAkndtpTzCw8shOZuWckNYeUQwo36Q=
-github.com/go-acme/lego/v4 v4.17.4/go.mod h1:dU94SvPNqimEeb7EVilGGSnS0nU1O5Exir0pQ4QFL4U=
-github.com/go-acme/lego/v4 v4.23.1 h1:lZ5fGtGESA2L9FB8dNTvrQUq3/X4QOb8ExkKyY7LSV4=
-github.com/go-acme/lego/v4 v4.23.1/go.mod h1:7UMVR7oQbIYw6V7mTgGwi4Er7B6Ww0c+c8feiBM0EgI=
-github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWqS6U=
-github.com/go-jose/go-jose/v4 v4.0.1/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY=
-github.com/go-jose/go-jose/v4 v4.0.4 h1:VsjPI33J0SB9vQM6PLmNjoHqMQNGPiZ0rHL7Ni7Q6/E=
-github.com/go-jose/go-jose/v4 v4.0.4/go.mod h1:NKb5HO1EZccyMpiZNbdUw/14tiXNyUJh188dfnMCAfc=
-github.com/go-jose/go-jose/v4 v4.1.1 h1:JYhSgy4mXXzAdF3nUx3ygx347LRXJRrpgyU3adRmkAI=
-github.com/go-jose/go-jose/v4 v4.1.1/go.mod h1:BdsZGqgdO3b6tTc6LSE56wcDbMMLuPsw5d4ZD5f94kA=
-github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
-github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
+github.com/getkin/kin-openapi v0.13.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s+pcEVXFuAjw=
+github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/go-acme/lego/v4 v4.4.0 h1:uHhU5LpOYQOdp3aDU+XY2bajseu8fuExphTL1Ss6/Fc=
+github.com/go-acme/lego/v4 v4.4.0/go.mod h1:l3+tFUFZb590dWcqhWZegynUthtaHJbG2fevUpoOOE0=
+github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
+github.com/go-cmd/cmd v1.0.5/go.mod h1:y8q8qlK5wQibcw63djSl/ntiHUHXHGdCkPk0j4QeW4s=
+github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
+github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
+github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
+github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
+github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
+github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
+github.com/go-resty/resty/v2 v2.1.1-0.20191201195748-d7b97669fe48/go.mod h1:dZGr0i9PLlaaTD4H/hoZIDjQ+r6xq8mgbRzHZf7f2J8=
+github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
+github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
+github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
+github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
-github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
-github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
-github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
-github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
-github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
-github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
+github.com/gobs/pretty v0.0.0-20180724170744-09732c25a95b/go.mod h1:Xo4aNUOrJnVruqWQJBtW6+bTBDTniY8yZum5rF3b5jw=
+github.com/goccy/go-json v0.7.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/goccy/go-json v0.7.8 h1:CvMH7LotYymYuLGEohBM1lTZWX4g6jzWUUl2aLFuBoE=
+github.com/goccy/go-json v0.7.8/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
+github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
+github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
+github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
+github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
+github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
+github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
@@ -47,56 +195,254 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
-github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
-github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y=
+github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
-github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-github/v32 v32.1.0/go.mod h1:rIEpZD9CTDQwDK9GDrtMTycQNA4JU3qBsCizh3q2WCI=
+github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
-github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
-github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
+github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
+github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
+github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
+github.com/gophercloud/gophercloud v0.15.1-0.20210202035223-633d73521055/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
+github.com/gophercloud/gophercloud v0.16.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
+github.com/gophercloud/utils v0.0.0-20210216074907-f6de111f2eae/go.mod h1:wx8HMD8oQD0Ryhz6+6ykq75PJ79iPyEqYHfwZ4l7OsA=
+github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gopherjs/gopherjs v0.0.0-20210406100015-1e088ea4ee04 h1:Enykqupm0u6qiUZAc+SiFkMJVqt4o8knNcKJu8NdlJ0=
+github.com/gopherjs/gopherjs v0.0.0-20210406100015-1e088ea4ee04/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
+github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
+github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
+github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
+github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
+github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
+github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
+github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
+github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
+github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
+github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
+github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
+github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
+github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
+github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
+github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
+github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
+github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
+github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
+github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
+github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
+github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
+github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
+github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
+github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
+github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
+github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
-github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc=
-github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
-github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
-github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
+github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df/go.mod h1:QMZY7/J/KSQEhKWFeDesPjMj+wCHReeknARU3wqlyN4=
+github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
+github.com/infobloxopen/infoblox-go-client v1.1.1/go.mod h1:BXiw7S2b9qJoM8MS40vfgCNB2NLHGusk1DtO16BD9zI=
+github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
+github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
+github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
+github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
+github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
+github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
+github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5lahk=
+github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI=
+github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI=
+github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
+github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/lE2g=
+github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
+github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
+github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
+github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
+github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
+github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
+github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
+github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
+github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
+github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
+github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
+github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
+github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
+github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
+github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
+github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
+github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
+github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
+github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4WpC0=
+github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po=
+github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ=
+github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI75BE=
+github.com/jackc/pgtype v1.8.0/go.mod h1:PqDKcEBtllAtk/2p6z6SHdXW5UB+MhE75tUol2OKexE=
+github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
+github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
+github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
+github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXgo+kA=
+github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o=
+github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg=
+github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CIdYfcc=
+github.com/jackc/pgx/v4 v4.12.0/go.mod h1:fE547h6VulLPA3kySjfnSG/e2D861g/50JlVUa/ub60=
+github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
+github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
+github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
+github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
+github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
+github.com/jarcoal/httpmock v1.0.6/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
+github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
+github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
+github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
+github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
+github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
+github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
+github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
+github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
+github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
+github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
-github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
-github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
-github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA=
-github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ=
-github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
-github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
-github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
-github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
-github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
-github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
-github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
-github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
-github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
-github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
-github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
-github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
-github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
-github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g=
-github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM=
-github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs=
-github.com/miekg/dns v1.1.59/go.mod h1:nZpewl5p6IvctfgrckopVx2OlSEHPRO/U4SYkRklrEk=
-github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
-github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
-github.com/miekg/dns v1.1.66 h1:FeZXOS3VCVsKnEAd+wBkjMC3D2K+ww66Cq3VnCINuJE=
-github.com/miekg/dns v1.1.66/go.mod h1:jGFzBsSNbJw6z1HYut1RKBKHA9PBdxeHrZG8J+gC2WE=
+github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
+github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/labbsr0x/bindman-dns-webhook v1.0.2/go.mod h1:p6b+VCXIR8NYKpDr8/dg1HKfQoRHCdcsROXKvmoehKA=
+github.com/labbsr0x/goh v1.0.1/go.mod h1:8K2UhVoaWXcCU7Lxoa2omWnC8gyW8px7/lmO61c027w=
+github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g=
+github.com/labstack/echo/v4 v4.5.0 h1:JXk6H5PAw9I3GwizqUHhYyS4f45iyGebR/c1xNCeOCY=
+github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y=
+github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=
+github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
+github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
+github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
+github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
+github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
+github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
+github.com/linode/linodego v0.25.3/go.mod h1:GSBKPpjoQfxEfryoCRcgkuUOCuVtGHWhzI8OMdycNTE=
+github.com/liquidweb/go-lwApi v0.0.0-20190605172801-52a4864d2738/go.mod h1:0sYF9rMXb0vlG+4SzdiGMXHheCZxjguMq+Zb4S2BfBs=
+github.com/liquidweb/go-lwApi v0.0.5/go.mod h1:0sYF9rMXb0vlG+4SzdiGMXHheCZxjguMq+Zb4S2BfBs=
+github.com/liquidweb/liquidweb-cli v0.6.9/go.mod h1:cE1uvQ+x24NGUL75D0QagOFCG8Wdvmwu8aL9TLmA/eQ=
+github.com/liquidweb/liquidweb-go v1.6.3/go.mod h1:SuXXp+thr28LnjEw18AYtWwIbWMHSUiajPQs8T9c/Rc=
+github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
+github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
+github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
+github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
+github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
+github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
+github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
+github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
+github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
+github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
+github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
+github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
+github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
+github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
+github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
+github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
+github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
+github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE=
+github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0=
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
+github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
+github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
+github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg=
+github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
+github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
+github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
+github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed/go.mod h1:3rdaFaCv4AyBgu5ALFM0+tSuHrBh6v692nyQe3ikrq0=
+github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
+github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
+github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
-github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
-github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
+github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/namedotcom/go v0.0.0-20180403034216-08470befbe04/go.mod h1:5sN+Lt1CaY4wsPvgQH/jsuJi4XO2ssZbdsIizr4CVC8=
+github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
+github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
+github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
+github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
+github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
+github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
+github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
+github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
+github.com/nrdcg/auroradns v1.0.1/go.mod h1:y4pc0i9QXYlFCWrhWrUSIETnZgrf4KuwjDIWmmXo3JI=
+github.com/nrdcg/desec v0.5.0/go.mod h1:2ejvMazkav1VdDbv2HeQO7w+Ta1CGHqzQr27ZBYTuEQ=
+github.com/nrdcg/dnspod-go v0.4.0/go.mod h1:vZSoFSFeQVm2gWLMkyX61LZ8HI3BaqtHZWgPTGKr6KQ=
+github.com/nrdcg/goinwx v0.8.1/go.mod h1:tILVc10gieBp/5PMvbcYeXM6pVQ+c9jxDZnpaR1UW7c=
+github.com/nrdcg/namesilo v0.2.1/go.mod h1:lwMvfQTyYq+BbjJd30ylEG4GPSS6PII0Tia4rRpRiyw=
+github.com/nrdcg/porkbun v0.1.1/go.mod h1:JWl/WKnguWos4mjfp4YizvvToigk9qpQwrodOk+CPoA=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
+github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
+github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
+github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
+github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
+github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
@@ -107,159 +453,535 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug=
github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg=
-github.com/ovh/go-ovh v1.5.1 h1:P8O+7H+NQuFK9P/j4sFW5C0fvSS2DnHYGPwdVCp45wI=
-github.com/ovh/go-ovh v1.5.1/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC7c=
-github.com/ovh/go-ovh v1.6.0 h1:ixLOwxQdzYDx296sXcgS35TOPEahJkpjMGtzPadCjQI=
-github.com/ovh/go-ovh v1.6.0/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC7c=
-github.com/ovh/go-ovh v1.9.0 h1:6K8VoL3BYjVV3In9tPJUdT7qMx9h0GExN9EXx1r2kKE=
-github.com/ovh/go-ovh v1.9.0/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC7c=
+github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
+github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
+github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
+github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
+github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
+github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA=
+github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
+github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
+github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
+github.com/oracle/oci-go-sdk v24.3.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=
+github.com/ovh/go-ovh v1.1.0 h1:bHXZmw8nTgZin4Nv7JuaLs0KG5x54EQR7migYTd1zrk=
+github.com/ovh/go-ovh v1.1.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA=
+github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
+github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
+github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
+github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
+github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
+github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
+github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
+github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
+github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
+github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
+github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
+github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
+github.com/pquerna/otp v1.3.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
+github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
+github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
+github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
+github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
+github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
+github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
+github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
+github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
+github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
+github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
+github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
+github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
+github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
+github.com/rainycape/memcache v0.0.0-20150622160815-1031fa0ce2f2/go.mod h1:7tZKcyumwBO6qip7RNQ5r77yrssm9bfCowcLEBcU5IA=
+github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
+github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
+github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
+github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
+github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
+github.com/sacloud/libsacloud v1.36.2/go.mod h1:P7YAOVmnIn3DKHqCZcUKYUXmSwGBm3yS7IBEjKVSrjg=
+github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
+github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
+github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210127161313-bd30bebeac4f/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
+github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
+github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
+github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
+github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
+github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
+github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
+github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
+github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
+github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
+github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
+github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/smartystreets/gunit v1.0.4/go.mod h1:EH5qMBab2UclzXUcpR8b93eHsIlp9u+pDQIRp5DZNzQ=
+github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
+github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
+github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
+github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/afero v1.4.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
+github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
+github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
+github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
+github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
+github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
+github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
+github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
+github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
+github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
+github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
-github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
-github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
+github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
+github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
+github.com/transip/gotransip/v6 v6.2.0/go.mod h1:pQZ36hWWRahCUXkFWlx9Hs711gLd8J4qdgLdRzmtY+g=
+github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex1PFV8g=
+github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
+github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
+github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
+github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
-github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
-github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
+github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
+github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
+github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
+github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
+github.com/vinyldns/go-vinyldns v0.0.0-20200917153823-148a5f6b8f14/go.mod h1:RWc47jtnVuQv6+lY3c768WtXCas/Xi+U5UFc5xULmYg=
+github.com/vultr/govultr/v2 v2.0.0/go.mod h1:2PsEeg+gs3p/Fo5Pw8F9mv+DUBEOlrNZ8GmCTGmhOhs=
+github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
+github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
+github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
+github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
+github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
+go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
+go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
+go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
+go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
+go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
+go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
+go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
+go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
+go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
+go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
+go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
+go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
+go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
+go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
+go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277/go.mod h1:2X8KaoNd1J0lZV+PxJk/5+DGbO/tpwLR1m++a7FnB/Y=
+go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
+go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
+go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
+go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
+golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
+golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
+golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
-golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
-golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
-golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
-golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
-golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
+golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
+golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
+golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
+golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
+golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
+golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
+golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
+golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
+golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
+golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
+golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
+golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
+golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
+golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
+golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
+golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
-golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
-golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
-golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
-golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
-golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
-golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
-golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
-golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
-golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
-golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
-golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
-golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
-golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
-golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
-golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
-golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
-golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
+golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
+golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f h1:w6wWR0H+nyVpbSAQbzVEIACVyr/h8l/BEkY6Sokc7Eg=
+golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
-golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
-golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
-golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
-golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
-golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180622082034-63fc586f45fe/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201110211018-35f3e6cf4a65/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
-golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
-golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
-golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
-golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
+golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210903071746-97244b99971b h1:3Dq0eVHn0uaQJmPO+/aYPI/fRMqdrVDbu7MQcku54gg=
+golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
-golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
-golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
-golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
-golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
-golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
-golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
-golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
-golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
-golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
-golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
-golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
+golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs=
+golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
+golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e h1:4nW4NLDYnU28ojHaHO8OVxFHk/aQ33U01a9cjED+pzE=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
-golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
-golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
-golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
-golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
-golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
-golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
+golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
+google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
+google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
+google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
+google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s=
+google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
+google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
+google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
+google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
+google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
+google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
+google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
-gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
-gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
+gopkg.in/h2non/gock.v1 v1.0.15/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE=
+gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
+gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/ini.v1 v1.62.1 h1:Idt4Iidq1iKKmhakQtqAIvBBL53JTyuNIX+wR/rmkp4=
+gopkg.in/ini.v1 v1.62.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/ns1/ns1-go.v2 v2.4.4/go.mod h1:GMnKY+ZuoJ+lVLL+78uSTjwTz2jMazq6AfGKQOYhsPk=
+gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
+gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
+gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
+gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
-gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
-gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
-lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
-modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw=
-modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0=
-modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw=
-modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY=
-modernc.org/libc v1.22.2 h1:4U7v51GyhlWqQmwCHj28Rdq2Yzwk55ovjFrdPjs8Hb0=
-modernc.org/libc v1.22.2/go.mod h1:uvQavJ1pZ0hIoC/jfqNoMLURIMhKzINIWypNM17puug=
-modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
-modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
-modernc.org/memory v1.4.0 h1:crykUfNSnMAXaOJnnxcSzbUGMqkLWjklJKkBK2nwZwk=
-modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
-modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
-modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
-modernc.org/sqlite v1.20.4 h1:J8+m2trkN+KKoE7jglyHYYYiaq5xmz2HoHJIiBlRzbE=
-modernc.org/sqlite v1.20.4/go.mod h1:zKcGyrICaxNTMEHSr1HQ2GUraP0j+845GYw37+EyT6A=
-modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY=
-modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
-modernc.org/token v1.0.1 h1:A3qvTqOwexpfZZeyI0FeGPDlSWX5pjZu9hF4lU+EKWg=
-modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
-xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo=
-xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
-xorm.io/xorm v1.3.9 h1:TUovzS0ko+IQ1XnNLfs5dqK1cJl1H5uHpWbWqAQ04nU=
-xorm.io/xorm v1.3.9/go.mod h1:LsCCffeeYp63ssk0pKumP6l96WZcHix7ChpurcLNuMw=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
+honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
+lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU=
+lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
+modernc.org/cc/v3 v3.33.6 h1:r63dgSzVzRxUpAJFPQWHy1QeZeY1ydNENUDaBx1GqYc=
+modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
+modernc.org/ccgo/v3 v3.9.5 h1:dEuUSf8WN51rDkprFuAqjfchKEzN0WttP/Py3enBwjk=
+modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
+modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
+modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
+modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
+modernc.org/libc v1.9.11 h1:QUxZMs48Ahg2F7SN41aERvMfGLY2HU/ADnB9DC4Yts8=
+modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q=
+modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
+modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
+modernc.org/mathutil v1.4.0 h1:GCjoRaBew8ECCKINQA2nYjzvufFW9YiEuuB+rQ9bn2E=
+modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
+modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM=
+modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
+modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
+modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
+modernc.org/sqlite v1.11.2 h1:ShWQpeD3ag/bmx6TqidBlIWonWmQaSQKls3aenCbt+w=
+modernc.org/sqlite v1.11.2/go.mod h1:+mhs/P1ONd+6G7hcAs6irwDi/bjTQ7nLW6LHRBsEa3A=
+modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs=
+modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
+modernc.org/tcl v1.5.5/go.mod h1:ADkaTUuwukkrlhqwERyq0SM8OvyXo7+TjFz7yAF56EI=
+modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
+modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
+modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
+rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
+rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
+sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
+sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
+xorm.io/builder v0.3.9 h1:Sd65/LdWyO7LR8+Cbd+e7mm3sK/7U9k0jS3999IDHMc=
+xorm.io/builder v0.3.9/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
+xorm.io/xorm v1.2.3 h1:ZsVtQEsfkA31bbe8lhrP5cZKUjrxXQQO5tsr7Tf/0eo=
+xorm.io/xorm v1.2.3/go.mod h1:fTG8tSjk6O1BYxwuohZUK+S1glnRycsCF05L1qQyEU0=
diff --git a/src/cert/main.go b/src/cert/main.go
index 2d7e85b..fc68d34 100644
--- a/src/cert/main.go
+++ b/src/cert/main.go
@@ -2,13 +2,10 @@ package cert
import "time"
-func (e *Entry) Z() {
-}
-
// Entry is the main struct for stored certificates
type Entry struct {
ID int `xorm:"pk autoincr"`
- Domain string `xorm:"notnull"`
+ Domains string `xorm:"notnull"`
Certificate string `xorm:"text notnull"`
PrivateKey string `xorm:"text notnull"`
AuthURL string `xorm:"notnull"`
diff --git a/src/config/main.go b/src/config/main.go
index a482135..5a3f31e 100644
--- a/src/config/main.go
+++ b/src/config/main.go
@@ -2,6 +2,7 @@ package config
import (
"flag"
+ "fmt"
"git.paulbsd.com/paulbsd/pki/utils"
"github.com/go-acme/lego/v4/lego"
@@ -38,6 +39,7 @@ func (cfg *Config) GetConfig() error {
}
pkisection := inicfg.Section("pki")
+ options := make(map[string]string)
cfg.DbParams.DbHostname = pkisection.Key("db_hostname").MustString("localhost")
cfg.DbParams.DbName = pkisection.Key("db_name").MustString("database")
@@ -53,13 +55,23 @@ func (cfg *Config) GetConfig() error {
cfg.ACME.Env = pkisection.Key("env").MustString("prod")
cfg.ACME.MaxDaysBefore = pkisection.Key("maxdaysbefore").MustInt(0)
+ options["ovhendpoint"] = pkisection.Key("ovhendpoint").MustString("ovh-eu")
+ options["ovhak"] = pkisection.Key("ovhak").MustString("")
+ options["ovhas"] = pkisection.Key("ovhas").MustString("")
+ options["ovhck"] = pkisection.Key("ovhck").MustString("")
+
+ cfg.ACME.ProviderOptions = options
+ for k, v := range options {
+ if v == "" {
+ utils.Advice(fmt.Sprintf("OVH provider parameter %s not set", k))
+ }
+ }
+
switch cfg.ACME.Env {
case "prod":
cfg.ACME.AuthURL = lego.LEDirectoryProduction
case "staging":
cfg.ACME.AuthURL = lego.LEDirectoryStaging
- default:
- cfg.ACME.AuthURL = lego.LEDirectoryStaging
}
return nil
@@ -86,9 +98,10 @@ type Config struct {
Init bool `json:"init"`
} `json:"-"`
ACME struct {
- Env string `json:"env"`
- AuthURL string `json:"authurl"`
- MaxDaysBefore int `json:"maxdaysbefore"`
+ Env string `json:"env"`
+ AuthURL string `json:"authurl"`
+ ProviderOptions map[string]string `json:"provideroptions"`
+ MaxDaysBefore int `json:"maxdaysbefore"`
}
Init struct {
Email string `json:"email"`
diff --git a/src/database/main.go b/src/database/main.go
index 2528b77..641bb62 100644
--- a/src/database/main.go
+++ b/src/database/main.go
@@ -7,7 +7,6 @@ import (
"git.paulbsd.com/paulbsd/pki/src/cert"
"git.paulbsd.com/paulbsd/pki/src/config"
- "git.paulbsd.com/paulbsd/pki/src/domain"
"git.paulbsd.com/paulbsd/pki/src/pki"
_ "github.com/lib/pq"
"xorm.io/xorm"
@@ -17,8 +16,8 @@ import (
// Init creates connection to database and exec Schema
func Init(cfg *config.Config) (err error) {
var databaseEngine = "postgres"
- tables := []any{cert.Entry{},
- pki.User{}, domain.Domain{}, pki.Provider{}}
+ tables := []interface{}{cert.Entry{},
+ pki.User{}}
cfg.Db, err = xorm.NewEngine(databaseEngine,
fmt.Sprintf("%s://%s:%s@%s/%s",
@@ -42,14 +41,8 @@ func Init(cfg *config.Config) (err error) {
log.Println("Syncing tables")
for _, table := range tables {
- err = cfg.Db.CreateTables(table)
- if err != nil {
- log.Fatalln(err)
- }
- err = cfg.Db.Sync(table)
- if err != nil {
- log.Fatalln(err)
- }
+ cfg.Db.CreateTables(table)
+ cfg.Db.Sync2(table)
}
return
}
diff --git a/src/domain/main.go b/src/domain/main.go
deleted file mode 100644
index 3d13b65..0000000
--- a/src/domain/main.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package domain
-
-import "time"
-
-// Domain describes a domain
-type Domain struct {
- ID int `xorm:"pk autoincr"`
- Domain string `xorm:"text notnull unique(domain_provider)"`
- Provider string `xorm:"text notnull unique(domain_provider)"`
- Created time.Time `xorm:"created notnull"`
- Updated time.Time `xorm:"updated notnull"`
-}
diff --git a/src/pki/acme.go b/src/pki/acme.go
index 6cd9609..11c77b2 100644
--- a/src/pki/acme.go
+++ b/src/pki/acme.go
@@ -9,13 +9,12 @@ import (
"encoding/pem"
"fmt"
"log"
+ "strings"
"git.paulbsd.com/paulbsd/pki/src/cert"
"git.paulbsd.com/paulbsd/pki/src/config"
- "git.paulbsd.com/paulbsd/pki/src/domain"
"github.com/go-acme/lego/v4/certcrypto"
"github.com/go-acme/lego/v4/certificate"
- "github.com/go-acme/lego/v4/challenge"
"github.com/go-acme/lego/v4/lego"
"github.com/go-acme/lego/v4/registration"
)
@@ -30,12 +29,15 @@ func (u *User) Init(cfg *config.Config) (err error) {
}
// GetEntry returns requested acme ressource in database relative to domain
-func (u *User) GetEntry(cfg *config.Config, domain *string) (Entry cert.Entry, err error) {
- has, err := cfg.Db.Where("domain = ?", domain).And(
+func (u *User) GetEntry(cfg *config.Config, domains []string) (Entry cert.Entry, err error) {
+
+ has, err := cfg.Db.Where("domains = ?", strings.Join(domains, ",")).And(
"auth_url = ?", cfg.ACME.AuthURL).And(
fmt.Sprintf("validity_end::timestamp-'%d DAY'::INTERVAL >= now()", cfg.ACME.MaxDaysBefore)).Desc(
"id").Get(&Entry)
+ fmt.Println(has, err)
+
if !has {
err = fmt.Errorf("entry doesn't exists")
}
@@ -66,45 +68,12 @@ func (u *User) HandleRegistration(cfg *config.Config, client *lego.Client) (err
}
// RequestNewCert returns a newly requested certificate to letsencrypt
-func (u *User) RequestNewCert(cfg *config.Config, domainnames *[]string) (certs *certificate.Resource, err error) {
+func (u *User) RequestNewCert(cfg *config.Config, domains []string) (certificates *certificate.Resource, err error) {
legoconfig := lego.NewConfig(u)
legoconfig.CADirURL = cfg.ACME.AuthURL
legoconfig.Certificate.KeyType = certcrypto.RSA2048
- var dom domain.Domain
- var has bool
- for _, d := range *domainnames {
- dom = domain.Domain{Domain: d}
- if has, err = cfg.Db.Get(&dom); has {
- break
- }
- if err != nil {
- log.Println(err)
- }
- }
-
- if !has {
- err = fmt.Errorf("supplied domain not in allowed domains")
- return
- }
-
- var provider challenge.Provider
- var pkiprovider Provider
-
- _, err = cfg.Db.Where("name = ?", dom.Provider).Get(&pkiprovider)
- if err != nil {
- log.Println(err)
- return
- }
-
- switch dom.Provider {
- case "ovh":
- provider, err = pkiprovider.initOVHProvider()
- case "pdns":
- provider, err = pkiprovider.initPowerDNSProvider()
- default:
- return
- }
+ ovhprovider, err := initProvider(cfg)
if err != nil {
log.Println(err)
}
@@ -114,7 +83,7 @@ func (u *User) RequestNewCert(cfg *config.Config, domainnames *[]string) (certs
log.Println(err)
}
- err = client.Challenge.SetDNS01Provider(provider)
+ err = client.Challenge.SetDNS01Provider(ovhprovider)
if err != nil {
log.Println(err)
}
@@ -128,15 +97,14 @@ func (u *User) RequestNewCert(cfg *config.Config, domainnames *[]string) (certs
}
request := certificate.ObtainRequest{
- Domains: *domainnames,
+ Domains: domains,
Bundle: true,
}
- certs, err = client.Certificate.Obtain(request)
+ certificates, err = client.Certificate.Obtain(request)
if err != nil {
log.Println(err)
}
-
return
}
diff --git a/src/pki/provider.go b/src/pki/provider.go
index 4828d82..691c3a9 100644
--- a/src/pki/provider.go
+++ b/src/pki/provider.go
@@ -1,65 +1,20 @@
package pki
import (
- "encoding/json"
- "log"
- "net/url"
- "time"
-
+ "git.paulbsd.com/paulbsd/pki/src/config"
"github.com/go-acme/lego/v4/providers/dns/ovh"
- "github.com/go-acme/lego/v4/providers/dns/pdns"
)
-// initOVHProvider initialize DNS provider configuration
-func (p *Provider) initOVHProvider() (ovhprovider *ovh.DNSProvider, err error) {
+// initProvider initialize DNS provider configuration
+func initProvider(cfg *config.Config) (ovhprovider *ovh.DNSProvider, err error) {
ovhconfig := ovh.NewDefaultConfig()
- var data = make(map[string]string)
- err = json.Unmarshal([]byte(p.Config), &data)
- if err != nil {
- log.Println(err)
- return
- }
-
- ovhconfig.APIEndpoint = data["ovhendpoint"]
- ovhconfig.ApplicationKey = data["ovhak"]
- ovhconfig.ApplicationSecret = data["ovhas"]
- ovhconfig.ConsumerKey = data["ovhck"]
+ ovhconfig.APIEndpoint = cfg.ACME.ProviderOptions["ovhendpoint"]
+ ovhconfig.ApplicationKey = cfg.ACME.ProviderOptions["ovhak"]
+ ovhconfig.ApplicationSecret = cfg.ACME.ProviderOptions["ovhas"]
+ ovhconfig.ConsumerKey = cfg.ACME.ProviderOptions["ovhck"]
ovhprovider, err = ovh.NewDNSProviderConfig(ovhconfig)
- if err != nil {
- log.Println(err)
- }
return
}
-
-// initPowerDNSProvider initialize DNS provider configuration
-func (p *Provider) initPowerDNSProvider() (pdnsprovider *pdns.DNSProvider, err error) {
- pdnsconfig := pdns.NewDefaultConfig()
-
- var data = make(map[string]string)
- err = json.Unmarshal([]byte(p.Config), &data)
- if err != nil {
- log.Println(err)
- return
- }
-
- pdnsconfig.Host, err = url.Parse(data["pdnsapiurl"])
- pdnsconfig.APIKey = data["pdnsapikey"]
-
- pdnsprovider, err = pdns.NewDNSProviderConfig(pdnsconfig)
- if err != nil {
- log.Println(err)
- }
-
- return
-}
-
-type Provider struct {
- ID int `xorm:"pk autoincr"`
- Name string `xorm:"text notnull unique"`
- Config string `xorm:"json notnull"`
- Created time.Time `xorm:"created notnull"`
- Updated time.Time `xorm:"updated notnull"`
-}
diff --git a/src/pkiws/server.go b/src/pkiws/server.go
index 34b5635..87fb940 100644
--- a/src/pkiws/server.go
+++ b/src/pkiws/server.go
@@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net/http"
+ "strings"
"git.paulbsd.com/paulbsd/pki/src/config"
"git.paulbsd.com/paulbsd/pki/src/pki"
@@ -29,18 +30,13 @@ func RunServer(cfg *config.Config) (err error) {
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Welcome to PKI software (https://git.paulbsd.com/paulbsd/pki)")
})
- e.POST("/cert", func(c echo.Context) (err error) {
- var request = new(EntryRequest)
- var result = make(map[string]EntryResponse)
- err = c.Bind(&request)
- if err != nil {
- log.Println(err)
- return c.JSON(http.StatusInternalServerError, "error parsing request")
- }
+ e.GET("/domain/:domains", func(c echo.Context) (err error) {
+ var result EntryResponse
+ var domains = strings.Split(c.Param("domains"), ",")
- log.Printf("Providing %s to user %s at %s\n", request.Domains, c.Get("username"), c.RealIP())
+ log.Println(fmt.Sprintf("Providing %s to user %s at %s", domains, c.Get("username"), c.RealIP()))
- result, err = GetCertificate(cfg, c.Get("user").(*pki.User), &request.Domains)
+ result, err = GetCertificate(cfg, c.Get("user").(*pki.User), domains)
if err != nil {
return c.String(http.StatusInternalServerError, fmt.Sprintf("%s", err))
}
diff --git a/src/pkiws/serverhandle.go b/src/pkiws/serverhandle.go
index dc1f623..73a2336 100644
--- a/src/pkiws/serverhandle.go
+++ b/src/pkiws/serverhandle.go
@@ -6,6 +6,7 @@ import (
"fmt"
"log"
"regexp"
+ "strings"
"time"
"git.paulbsd.com/paulbsd/pki/src/cert"
@@ -13,24 +14,18 @@ import (
"git.paulbsd.com/paulbsd/pki/src/pki"
)
-const timeformatstring string = "2006-01-02 15:04:05"
-
-var domainRegex, err = regexp.Compile(`^[a-z0-9\*]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$`)
-
// GetCertificate get certificate from database if exists, of request it from ACME
-func GetCertificate(cfg *config.Config, user *pki.User, domains *[]string) (result map[string]EntryResponse, err error) {
+func GetCertificate(cfg *config.Config, user *pki.User, domains []string) (result EntryResponse, err error) {
err = CheckDomains(domains)
if err != nil {
return result, err
}
- result = make(map[string]EntryResponse)
- firstdomain := (*domains)[0]
- entry, err := user.GetEntry(cfg, &firstdomain)
+ entry, err := user.GetEntry(cfg, domains)
if err != nil {
certs, err := user.RequestNewCert(cfg, domains)
if err != nil {
- log.Printf("Error fetching new certificate %s\n", err)
+ log.Println(fmt.Sprintf("Error fetching new certificate %s", err))
return result, err
}
NotBefore, NotAfter, err := GetDates(certs.Certificate)
@@ -38,36 +33,33 @@ func GetCertificate(cfg *config.Config, user *pki.User, domains *[]string) (resu
log.Println("Error where parsing dates")
return result, err
}
- entry := cert.Entry{Domain: certs.Domain,
+ entry := cert.Entry{Domains: strings.Join(domains, ","),
Certificate: string(certs.Certificate),
PrivateKey: string(certs.PrivateKey),
ValidityBegin: NotBefore,
ValidityEnd: NotAfter,
AuthURL: cfg.ACME.AuthURL}
cfg.Db.Insert(&entry)
- result[firstdomain] = convertEntryToResponse(entry)
+ result = convertEntryToResponse(entry)
return result, err
}
- result[firstdomain] = convertEntryToResponse(entry)
+ result = convertEntryToResponse(entry)
return
}
// CheckDomains check if requested domains are valid
-func CheckDomains(domains *[]string) (err error) {
- for _, domain := range *domains {
- err = CheckDomain(&domain)
- if err != nil {
- return
- }
- }
- return
-}
+func CheckDomains(domains []string) (err error) {
+ domainRegex, err := regexp.Compile(`^[a-z0-9\*]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$`)
-// CheckDomain check if requested domain are valid
-func CheckDomain(domain *string) (err error) {
- res := domainRegex.Match([]byte(*domain))
- if !res {
- return fmt.Errorf("Domain %s has not a valid syntax %s, please verify", *domain, err)
+ if err != nil {
+ return
+ }
+
+ for _, d := range domains {
+ res := domainRegex.Match([]byte(d))
+ if !res {
+ return fmt.Errorf(fmt.Sprintf("Domain %s has not a valid syntax %s, please verify", d, err))
+ }
}
return
}
@@ -88,7 +80,9 @@ func GetDates(cert []byte) (NotBefore time.Time, NotAfter time.Time, err error)
// convertEntryToResponse converts database ACME entry to JSON ACME entry
func convertEntryToResponse(in cert.Entry) (out EntryResponse) {
- out.Domains = append(out.Domains, in.Domain)
+ timeformatstring := "2006-01-02 15:04:05"
+
+ out.Domains = in.Domains
out.Certificate = in.Certificate
out.PrivateKey = in.PrivateKey
out.ValidityBegin = in.ValidityBegin.Format(timeformatstring)
@@ -97,16 +91,11 @@ func convertEntryToResponse(in cert.Entry) (out EntryResponse) {
return
}
-// EntryRequest
-type EntryRequest struct {
- Domains []string `json:"domains"`
-}
-
// EntryResponse is the struct defining JSON response from webservice
type EntryResponse struct {
- Domains []string `json:"domains"`
- Certificate string `json:"certificate"`
- PrivateKey string `json:"privatekey"`
- ValidityBegin string `json:"validitybegin"`
- ValidityEnd string `json:"validityend"`
+ Domains string `json:"domains"`
+ Certificate string `json:"certificate"`
+ PrivateKey string `json:"privatekey"`
+ ValidityBegin string `json:"validitybegin"`
+ ValidityEnd string `json:"validityend"`
}
diff --git a/vendor/github.com/cenkalti/backoff/v4/.travis.yml b/vendor/github.com/cenkalti/backoff/v4/.travis.yml
new file mode 100644
index 0000000..c79105c
--- /dev/null
+++ b/vendor/github.com/cenkalti/backoff/v4/.travis.yml
@@ -0,0 +1,10 @@
+language: go
+go:
+ - 1.13
+ - 1.x
+ - tip
+before_install:
+ - go get github.com/mattn/goveralls
+ - go get golang.org/x/tools/cmd/cover
+script:
+ - $HOME/gopath/bin/goveralls -service=travis-ci
diff --git a/vendor/github.com/cenkalti/backoff/v4/README.md b/vendor/github.com/cenkalti/backoff/v4/README.md
index 9433004..16abdfc 100644
--- a/vendor/github.com/cenkalti/backoff/v4/README.md
+++ b/vendor/github.com/cenkalti/backoff/v4/README.md
@@ -1,4 +1,4 @@
-# Exponential Backoff [![GoDoc][godoc image]][godoc] [![Coverage Status][coveralls image]][coveralls]
+# Exponential Backoff [![GoDoc][godoc image]][godoc] [![Build Status][travis image]][travis] [![Coverage Status][coveralls image]][coveralls]
This is a Go port of the exponential backoff algorithm from [Google's HTTP Client Library for Java][google-http-java-client].
@@ -21,6 +21,8 @@ Use https://pkg.go.dev/github.com/cenkalti/backoff/v4 to view the documentation.
[godoc]: https://pkg.go.dev/github.com/cenkalti/backoff/v4
[godoc image]: https://godoc.org/github.com/cenkalti/backoff?status.png
+[travis]: https://travis-ci.org/cenkalti/backoff
+[travis image]: https://travis-ci.org/cenkalti/backoff.png?branch=master
[coveralls]: https://coveralls.io/github/cenkalti/backoff?branch=master
[coveralls image]: https://coveralls.io/repos/github/cenkalti/backoff/badge.svg?branch=master
diff --git a/vendor/github.com/cenkalti/backoff/v4/exponential.go b/vendor/github.com/cenkalti/backoff/v4/exponential.go
index aac99f1..3d34532 100644
--- a/vendor/github.com/cenkalti/backoff/v4/exponential.go
+++ b/vendor/github.com/cenkalti/backoff/v4/exponential.go
@@ -71,9 +71,6 @@ type Clock interface {
Now() time.Time
}
-// ExponentialBackOffOpts is a function type used to configure ExponentialBackOff options.
-type ExponentialBackOffOpts func(*ExponentialBackOff)
-
// Default values for ExponentialBackOff.
const (
DefaultInitialInterval = 500 * time.Millisecond
@@ -84,7 +81,7 @@ const (
)
// NewExponentialBackOff creates an instance of ExponentialBackOff using default values.
-func NewExponentialBackOff(opts ...ExponentialBackOffOpts) *ExponentialBackOff {
+func NewExponentialBackOff() *ExponentialBackOff {
b := &ExponentialBackOff{
InitialInterval: DefaultInitialInterval,
RandomizationFactor: DefaultRandomizationFactor,
@@ -94,62 +91,10 @@ func NewExponentialBackOff(opts ...ExponentialBackOffOpts) *ExponentialBackOff {
Stop: Stop,
Clock: SystemClock,
}
- for _, fn := range opts {
- fn(b)
- }
b.Reset()
return b
}
-// WithInitialInterval sets the initial interval between retries.
-func WithInitialInterval(duration time.Duration) ExponentialBackOffOpts {
- return func(ebo *ExponentialBackOff) {
- ebo.InitialInterval = duration
- }
-}
-
-// WithRandomizationFactor sets the randomization factor to add jitter to intervals.
-func WithRandomizationFactor(randomizationFactor float64) ExponentialBackOffOpts {
- return func(ebo *ExponentialBackOff) {
- ebo.RandomizationFactor = randomizationFactor
- }
-}
-
-// WithMultiplier sets the multiplier for increasing the interval after each retry.
-func WithMultiplier(multiplier float64) ExponentialBackOffOpts {
- return func(ebo *ExponentialBackOff) {
- ebo.Multiplier = multiplier
- }
-}
-
-// WithMaxInterval sets the maximum interval between retries.
-func WithMaxInterval(duration time.Duration) ExponentialBackOffOpts {
- return func(ebo *ExponentialBackOff) {
- ebo.MaxInterval = duration
- }
-}
-
-// WithMaxElapsedTime sets the maximum total time for retries.
-func WithMaxElapsedTime(duration time.Duration) ExponentialBackOffOpts {
- return func(ebo *ExponentialBackOff) {
- ebo.MaxElapsedTime = duration
- }
-}
-
-// WithRetryStopDuration sets the duration after which retries should stop.
-func WithRetryStopDuration(duration time.Duration) ExponentialBackOffOpts {
- return func(ebo *ExponentialBackOff) {
- ebo.Stop = duration
- }
-}
-
-// WithClockProvider sets the clock used to measure time.
-func WithClockProvider(clock Clock) ExponentialBackOffOpts {
- return func(ebo *ExponentialBackOff) {
- ebo.Clock = clock
- }
-}
-
type systemClock struct{}
func (t systemClock) Now() time.Time {
@@ -202,9 +147,6 @@ func (b *ExponentialBackOff) incrementCurrentInterval() {
// Returns a random value from the following interval:
// [currentInterval - randomizationFactor * currentInterval, currentInterval + randomizationFactor * currentInterval].
func getRandomValueFromInterval(randomizationFactor, random float64, currentInterval time.Duration) time.Duration {
- if randomizationFactor == 0 {
- return currentInterval // make sure no randomness is used when randomizationFactor is 0.
- }
var delta = randomizationFactor * float64(currentInterval)
var minInterval = float64(currentInterval) - delta
var maxInterval = float64(currentInterval) + delta
diff --git a/vendor/github.com/cenkalti/backoff/v4/retry.go b/vendor/github.com/cenkalti/backoff/v4/retry.go
index b9c0c51..1ce2507 100644
--- a/vendor/github.com/cenkalti/backoff/v4/retry.go
+++ b/vendor/github.com/cenkalti/backoff/v4/retry.go
@@ -5,20 +5,10 @@ import (
"time"
)
-// An OperationWithData is executing by RetryWithData() or RetryNotifyWithData().
-// The operation will be retried using a backoff policy if it returns an error.
-type OperationWithData[T any] func() (T, error)
-
// An Operation is executing by Retry() or RetryNotify().
// The operation will be retried using a backoff policy if it returns an error.
type Operation func() error
-func (o Operation) withEmptyData() OperationWithData[struct{}] {
- return func() (struct{}, error) {
- return struct{}{}, o()
- }
-}
-
// Notify is a notify-on-error function. It receives an operation error and
// backoff delay if the operation failed (with an error).
//
@@ -38,41 +28,18 @@ func Retry(o Operation, b BackOff) error {
return RetryNotify(o, b, nil)
}
-// RetryWithData is like Retry but returns data in the response too.
-func RetryWithData[T any](o OperationWithData[T], b BackOff) (T, error) {
- return RetryNotifyWithData(o, b, nil)
-}
-
// RetryNotify calls notify function with the error and wait duration
// for each failed attempt before sleep.
func RetryNotify(operation Operation, b BackOff, notify Notify) error {
return RetryNotifyWithTimer(operation, b, notify, nil)
}
-// RetryNotifyWithData is like RetryNotify but returns data in the response too.
-func RetryNotifyWithData[T any](operation OperationWithData[T], b BackOff, notify Notify) (T, error) {
- return doRetryNotify(operation, b, notify, nil)
-}
-
// RetryNotifyWithTimer calls notify function with the error and wait duration using the given Timer
// for each failed attempt before sleep.
// A default timer that uses system timer is used when nil is passed.
func RetryNotifyWithTimer(operation Operation, b BackOff, notify Notify, t Timer) error {
- _, err := doRetryNotify(operation.withEmptyData(), b, notify, t)
- return err
-}
-
-// RetryNotifyWithTimerAndData is like RetryNotifyWithTimer but returns data in the response too.
-func RetryNotifyWithTimerAndData[T any](operation OperationWithData[T], b BackOff, notify Notify, t Timer) (T, error) {
- return doRetryNotify(operation, b, notify, t)
-}
-
-func doRetryNotify[T any](operation OperationWithData[T], b BackOff, notify Notify, t Timer) (T, error) {
- var (
- err error
- next time.Duration
- res T
- )
+ var err error
+ var next time.Duration
if t == nil {
t = &defaultTimer{}
}
@@ -85,22 +52,21 @@ func doRetryNotify[T any](operation OperationWithData[T], b BackOff, notify Noti
b.Reset()
for {
- res, err = operation()
- if err == nil {
- return res, nil
+ if err = operation(); err == nil {
+ return nil
}
var permanent *PermanentError
if errors.As(err, &permanent) {
- return res, permanent.Err
+ return permanent.Err
}
if next = b.NextBackOff(); next == Stop {
if cerr := ctx.Err(); cerr != nil {
- return res, cerr
+ return cerr
}
- return res, err
+ return err
}
if notify != nil {
@@ -111,7 +77,7 @@ func doRetryNotify[T any](operation OperationWithData[T], b BackOff, notify Noti
select {
case <-ctx.Done():
- return res, ctx.Err()
+ return ctx.Err()
case <-t.C():
}
}
diff --git a/vendor/github.com/go-acme/lego/v4/LICENSE b/vendor/github.com/go-acme/lego/v4/LICENSE
index d8eaf91..270cba0 100644
--- a/vendor/github.com/go-acme/lego/v4/LICENSE
+++ b/vendor/github.com/go-acme/lego/v4/LICENSE
@@ -1,6 +1,5 @@
The MIT License (MIT)
-Copyright (c) 2017-2024 Ludovic Fernandez
Copyright (c) 2015-2017 Sebastian Erhart
Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/account.go b/vendor/github.com/go-acme/lego/v4/acme/api/account.go
index 85de84e..d1cd72d 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/account.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/account.go
@@ -16,7 +16,7 @@ func (a *AccountService) New(req acme.Account) (acme.ExtendedAccount, error) {
resp, err := a.core.post(a.core.GetDirectory().NewAccountURL, req, &account)
location := getLocation(resp)
- if location != "" {
+ if len(location) > 0 {
a.core.jws.SetKid(location)
}
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/api.go b/vendor/github.com/go-acme/lego/v4/acme/api/api.go
index b8c9cf0..06b47c4 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/api.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/api.go
@@ -2,6 +2,7 @@ package api
import (
"bytes"
+ "context"
"crypto"
"encoding/json"
"errors"
@@ -70,7 +71,7 @@ func (a *Core) post(uri string, reqBody, response interface{}) (*http.Response,
}
// postAsGet performs an HTTP POST ("POST-as-GET") request.
-// https://www.rfc-editor.org/rfc/rfc8555.html#section-6.3
+// https://tools.ietf.org/html/rfc8555#section-6.3
func (a *Core) postAsGet(uri string, response interface{}) (*http.Response, error) {
return a.retrievablePost(uri, []byte{}, response)
}
@@ -82,6 +83,8 @@ func (a *Core) retrievablePost(uri string, content []byte, response interface{})
bo.MaxInterval = 5 * time.Second
bo.MaxElapsedTime = 20 * time.Second
+ ctx, cancel := context.WithCancel(context.Background())
+
var resp *http.Response
operation := func() error {
var err error
@@ -93,7 +96,8 @@ func (a *Core) retrievablePost(uri string, content []byte, response interface{})
return err
}
- return backoff.Permanent(err)
+ cancel()
+ return err
}
return nil
@@ -103,7 +107,7 @@ func (a *Core) retrievablePost(uri string, content []byte, response interface{})
log.Infof("retry due to: %v", err)
}
- err := backoff.RetryNotify(operation, bo, notify)
+ err := backoff.RetryNotify(operation, backoff.WithContext(bo, ctx), notify)
if err != nil {
return resp, err
}
@@ -117,7 +121,7 @@ func (a *Core) signedPost(uri string, content []byte, response interface{}) (*ht
return nil, fmt.Errorf("failed to post JWS message: failed to sign content: %w", err)
}
- signedBody := bytes.NewBufferString(signedContent.FullSerialize())
+ signedBody := bytes.NewBuffer([]byte(signedContent.FullSerialize()))
resp, err := a.doer.Post(uri, signedBody, "application/jose+json", response)
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/certificate.go b/vendor/github.com/go-acme/lego/v4/acme/api/certificate.go
index 5f31968..8923644 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/certificate.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/certificate.go
@@ -1,11 +1,10 @@
package api
import (
- "bytes"
"crypto/x509"
"encoding/pem"
"errors"
- "io"
+ "io/ioutil"
"net/http"
"github.com/go-acme/lego/v4/acme"
@@ -40,7 +39,7 @@ func (c *CertificateService) GetAll(certURL string, bundle bool) (map[string]*ac
certs := map[string]*acme.RawCertificate{certURL: cert}
// URLs of "alternate" link relation
- // - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4.2
+ // - https://tools.ietf.org/html/rfc8555#section-7.4.2
alts := getLinks(headers, "alternate")
for _, alt := range alts {
@@ -72,7 +71,7 @@ func (c *CertificateService) get(certURL string, bundle bool) (*acme.RawCertific
return nil, nil, err
}
- data, err := io.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
+ data, err := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
if err != nil {
return nil, resp.Header, err
}
@@ -88,17 +87,12 @@ func (c *CertificateService) getCertificateChain(cert []byte, headers http.Heade
// See https://community.letsencrypt.org/t/acme-v2-no-up-link-in-response/64962
_, issuer := pem.Decode(cert)
if issuer != nil {
- // If bundle is false, we want to return a single certificate.
- // To do this, we remove the issuer cert(s) from the issued cert.
- if !bundle {
- cert = bytes.TrimSuffix(cert, issuer)
- }
return &acme.RawCertificate{Cert: cert, Issuer: issuer}
}
// The issuer certificate link may be supplied via an "up" link
// in the response headers of a new certificate.
- // See https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4.2
+ // See https://tools.ietf.org/html/rfc8555#section-7.4.2
up := getLink(headers, "up")
issuer, err := c.getIssuerFromLink(up)
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/internal/nonces/nonce_manager.go b/vendor/github.com/go-acme/lego/v4/acme/api/internal/nonces/nonce_manager.go
index d089cf0..154cc5e 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/internal/nonces/nonce_manager.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/internal/nonces/nonce_manager.go
@@ -63,7 +63,7 @@ func (n *Manager) getNonce() (string, error) {
return GetFromResponse(resp)
}
-// GetFromResponse Extracts a nonce from an HTTP response.
+// GetFromResponse Extracts a nonce from a HTTP response.
func GetFromResponse(resp *http.Response) (string, error) {
if resp == nil {
return "", errors.New("nil response")
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/internal/secure/jws.go b/vendor/github.com/go-acme/lego/v4/acme/api/internal/secure/jws.go
index 8afd446..8bc0831 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/internal/secure/jws.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/internal/secure/jws.go
@@ -9,7 +9,7 @@ import (
"fmt"
"github.com/go-acme/lego/v4/acme/api/internal/nonces"
- jose "github.com/go-jose/go-jose/v4"
+ jose "gopkg.in/square/go-jose.v2"
)
// JWS Represents a JWS.
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/internal/sender/sender.go b/vendor/github.com/go-acme/lego/v4/acme/api/internal/sender/sender.go
index 042a131..fec2a33 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/internal/sender/sender.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/internal/sender/sender.go
@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
+ "io/ioutil"
"net/http"
"runtime"
"strings"
@@ -95,7 +96,7 @@ func (d *Doer) do(req *http.Request, response interface{}) (*http.Response, erro
}
if response != nil {
- raw, err := io.ReadAll(resp.Body)
+ raw, err := ioutil.ReadAll(resp.Body)
if err != nil {
return resp, err
}
@@ -119,7 +120,7 @@ func (d *Doer) formatUserAgent() string {
func checkError(req *http.Request, resp *http.Response) error {
if resp.StatusCode >= http.StatusBadRequest {
- body, err := io.ReadAll(resp.Body)
+ body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("%d :: %s :: %s :: %w", resp.StatusCode, req.Method, req.URL, err)
}
@@ -133,19 +134,11 @@ func checkError(req *http.Request, resp *http.Response) error {
errorDetails.Method = req.Method
errorDetails.URL = req.URL.String()
- if errorDetails.HTTPStatus == 0 {
- errorDetails.HTTPStatus = resp.StatusCode
- }
-
// Check for errors we handle specifically
if errorDetails.HTTPStatus == http.StatusBadRequest && errorDetails.Type == acme.BadNonceErr {
return &acme.NonceError{ProblemDetails: errorDetails}
}
- if errorDetails.HTTPStatus == http.StatusConflict && errorDetails.Type == acme.AlreadyReplacedErr {
- return &acme.AlreadyReplacedError{ProblemDetails: errorDetails}
- }
-
return errorDetails
}
return nil
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/internal/sender/useragent.go b/vendor/github.com/go-acme/lego/v4/acme/api/internal/sender/useragent.go
index 326cfb4..77f1d23 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/internal/sender/useragent.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/internal/sender/useragent.go
@@ -1,10 +1,11 @@
-// Code generated by 'internal/releaser'; DO NOT EDIT.
-
package sender
+// CODE GENERATED AUTOMATICALLY
+// THIS FILE MUST NOT BE EDITED BY HAND
+
const (
// ourUserAgent is the User-Agent of this underlying library package.
- ourUserAgent = "xenolf-acme/4.23.1"
+ ourUserAgent = "xenolf-acme/4.4.0"
// ourUserAgentComment is part of the UA comment linked to the version status of this underlying library package.
// values: detach|release
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/order.go b/vendor/github.com/go-acme/lego/v4/acme/api/order.go
index 4d310e0..7b2a2be 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/order.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/order.go
@@ -3,86 +3,25 @@ package api
import (
"encoding/base64"
"errors"
- "fmt"
- "net"
- "time"
"github.com/go-acme/lego/v4/acme"
)
-// OrderOptions used to create an order (optional).
-type OrderOptions struct {
- NotBefore time.Time
- NotAfter time.Time
-
- // A string uniquely identifying the profile
- // which will be used to affect issuance of the certificate requested by this Order.
- // - https://www.ietf.org/id/draft-aaron-acme-profiles-00.html#section-4
- Profile string
-
- // A string uniquely identifying a previously-issued certificate which this
- // order is intended to replace.
- // - https://datatracker.ietf.org/doc/html/draft-ietf-acme-ari-03#section-5
- ReplacesCertID string
-}
-
type OrderService service
// New Creates a new order.
func (o *OrderService) New(domains []string) (acme.ExtendedOrder, error) {
- return o.NewWithOptions(domains, nil)
-}
-
-// NewWithOptions Creates a new order.
-func (o *OrderService) NewWithOptions(domains []string, opts *OrderOptions) (acme.ExtendedOrder, error) {
var identifiers []acme.Identifier
for _, domain := range domains {
- ident := acme.Identifier{Value: domain, Type: "dns"}
-
- if net.ParseIP(domain) != nil {
- ident.Type = "ip"
- }
-
- identifiers = append(identifiers, ident)
+ identifiers = append(identifiers, acme.Identifier{Type: "dns", Value: domain})
}
orderReq := acme.Order{Identifiers: identifiers}
- if opts != nil {
- if !opts.NotAfter.IsZero() {
- orderReq.NotAfter = opts.NotAfter.Format(time.RFC3339)
- }
-
- if !opts.NotBefore.IsZero() {
- orderReq.NotBefore = opts.NotBefore.Format(time.RFC3339)
- }
-
- if o.core.GetDirectory().RenewalInfo != "" {
- orderReq.Replaces = opts.ReplacesCertID
- }
-
- if opts.Profile != "" {
- orderReq.Profile = opts.Profile
- }
- }
-
var order acme.Order
resp, err := o.core.post(o.core.GetDirectory().NewOrderURL, orderReq, &order)
if err != nil {
- are := &acme.AlreadyReplacedError{}
- if !errors.As(err, &are) {
- return acme.ExtendedOrder{}, err
- }
-
- // If the Server rejects the request because the identified certificate has already been marked as replaced,
- // it MUST return an HTTP 409 (Conflict) with a problem document of type "alreadyReplaced" (see Section 7.4).
- // https://datatracker.ietf.org/doc/html/draft-ietf-acme-ari-08#section-5
- orderReq.Replaces = ""
-
- resp, err = o.core.post(o.core.GetDirectory().NewOrderURL, orderReq, &order)
- if err != nil {
- return acme.ExtendedOrder{}, err
- }
+ return acme.ExtendedOrder{}, err
}
return acme.ExtendedOrder{
@@ -119,7 +58,7 @@ func (o *OrderService) UpdateForCSR(orderURL string, csr []byte) (acme.ExtendedO
}
if order.Status == acme.StatusInvalid {
- return acme.ExtendedOrder{}, fmt.Errorf("invalid order: %w", order.Err())
+ return acme.ExtendedOrder{}, order.Error
}
return acme.ExtendedOrder{Order: order}, nil
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/renewal.go b/vendor/github.com/go-acme/lego/v4/acme/api/renewal.go
deleted file mode 100644
index 5b4046c..0000000
--- a/vendor/github.com/go-acme/lego/v4/acme/api/renewal.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package api
-
-import (
- "errors"
- "net/http"
-)
-
-// ErrNoARI is returned when the server does not advertise a renewal info endpoint.
-var ErrNoARI = errors.New("renewalInfo[get/post]: server does not advertise a renewal info endpoint")
-
-// GetRenewalInfo GETs renewal information for a certificate from the renewalInfo endpoint.
-// This is used to determine if a certificate needs to be renewed.
-//
-// Note: this endpoint is part of a draft specification, not all ACME servers will implement it.
-// This method will return api.ErrNoARI if the server does not advertise a renewal info endpoint.
-//
-// https://datatracker.ietf.org/doc/draft-ietf-acme-ari
-func (c *CertificateService) GetRenewalInfo(certID string) (*http.Response, error) {
- if c.core.GetDirectory().RenewalInfo == "" {
- return nil, ErrNoARI
- }
-
- if certID == "" {
- return nil, errors.New("renewalInfo[get]: 'certID' cannot be empty")
- }
-
- return c.core.HTTPClient.Get(c.core.GetDirectory().RenewalInfo + "/" + certID)
-}
diff --git a/vendor/github.com/go-acme/lego/v4/acme/commons.go b/vendor/github.com/go-acme/lego/v4/acme/commons.go
index d22ea96..9635c6b 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/commons.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/commons.go
@@ -1,5 +1,5 @@
// Package acme contains all objects related the ACME endpoints.
-// https://www.rfc-editor.org/rfc/rfc8555.html
+// https://tools.ietf.org/html/rfc8555
package acme
import (
@@ -7,38 +7,20 @@ import (
"time"
)
-// ACME status values of Account, Order, Authorization and Challenge objects.
-// See https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.6 for details.
+// Challenge statuses.
+// https://tools.ietf.org/html/rfc8555#section-7.1.6
const (
+ StatusPending = "pending"
+ StatusInvalid = "invalid"
+ StatusValid = "valid"
+ StatusProcessing = "processing"
StatusDeactivated = "deactivated"
StatusExpired = "expired"
- StatusInvalid = "invalid"
- StatusPending = "pending"
- StatusProcessing = "processing"
- StatusReady = "ready"
StatusRevoked = "revoked"
- StatusUnknown = "unknown"
- StatusValid = "valid"
-)
-
-// CRL reason codes as defined in RFC 5280.
-// https://datatracker.ietf.org/doc/html/rfc5280#section-5.3.1
-const (
- CRLReasonUnspecified uint = 0
- CRLReasonKeyCompromise uint = 1
- CRLReasonCACompromise uint = 2
- CRLReasonAffiliationChanged uint = 3
- CRLReasonSuperseded uint = 4
- CRLReasonCessationOfOperation uint = 5
- CRLReasonCertificateHold uint = 6
- CRLReasonRemoveFromCRL uint = 8
- CRLReasonPrivilegeWithdrawn uint = 9
- CRLReasonAACompromise uint = 10
)
// Directory the ACME directory object.
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.1
-// - https://datatracker.ietf.org/doc/draft-ietf-acme-ari/
+// - https://tools.ietf.org/html/rfc8555#section-7.1.1
type Directory struct {
NewNonceURL string `json:"newNonce"`
NewAccountURL string `json:"newAccount"`
@@ -47,11 +29,10 @@ type Directory struct {
RevokeCertURL string `json:"revokeCert"`
KeyChangeURL string `json:"keyChange"`
Meta Meta `json:"meta"`
- RenewalInfo string `json:"renewalInfo"`
}
// Meta the ACME meta object (related to Directory).
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.1
+// - https://tools.ietf.org/html/rfc8555#section-7.1.1
type Meta struct {
// termsOfService (optional, string):
// A URL identifying the current terms of service.
@@ -71,17 +52,12 @@ type Meta struct {
// externalAccountRequired (optional, boolean):
// If this field is present and set to "true",
- // then the CA requires that all new-account requests include an "externalAccountBinding" field
+ // then the CA requires that all new- account requests include an "externalAccountBinding" field
// associating the new account with an external account.
ExternalAccountRequired bool `json:"externalAccountRequired"`
-
- // profiles (optional, object):
- // A map of profile names to human-readable descriptions of those profiles.
- // https://www.ietf.org/id/draft-aaron-acme-profiles-00.html#section-3
- Profiles map[string]string `json:"profiles"`
}
-// ExtendedAccount an extended Account.
+// ExtendedAccount a extended Account.
type ExtendedAccount struct {
Account
// Contains the value of the response header `Location`
@@ -89,14 +65,14 @@ type ExtendedAccount struct {
}
// Account the ACME account Object.
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.2
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.3
+// - https://tools.ietf.org/html/rfc8555#section-7.1.2
+// - https://tools.ietf.org/html/rfc8555#section-7.3
type Account struct {
// status (required, string):
// The status of this account.
// Possible values are: "valid", "deactivated", and "revoked".
// The value "deactivated" should be used to indicate client-initiated deactivation
- // whereas "revoked" should be used to indicate server-initiated deactivation. (See Section 7.1.6)
+ // whereas "revoked" should be used to indicate server- initiated deactivation. (See Section 7.1.6)
Status string `json:"status,omitempty"`
// contact (optional, array of string):
@@ -136,7 +112,7 @@ type ExtendedOrder struct {
}
// Order the ACME order Object.
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.3
+// - https://tools.ietf.org/html/rfc8555#section-7.1.3
type Order struct {
// status (required, string):
// The status of this order.
@@ -153,12 +129,6 @@ type Order struct {
// An array of identifier objects that the order pertains to.
Identifiers []Identifier `json:"identifiers"`
- // profile (string, optional):
- // A string uniquely identifying the profile
- // which will be used to affect issuance of the certificate requested by this Order.
- // https://www.ietf.org/id/draft-aaron-acme-profiles-00.html#section-4
- Profile string `json:"profile,omitempty"`
-
// notBefore (optional, string):
// The requested value of the notBefore field in the certificate,
// in the date format defined in [RFC3339].
@@ -192,24 +162,10 @@ type Order struct {
// certificate (optional, string):
// A URL for the certificate that has been issued in response to this order
Certificate string `json:"certificate,omitempty"`
-
- // replaces (optional, string):
- // replaces (string, optional): A string uniquely identifying a
- // previously-issued certificate which this order is intended to replace.
- // - https://datatracker.ietf.org/doc/html/draft-ietf-acme-ari-03#section-5
- Replaces string `json:"replaces,omitempty"`
-}
-
-func (r *Order) Err() error {
- if r.Error != nil {
- return r.Error
- }
-
- return nil
}
// Authorization the ACME authorization object.
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.4
+// - https://tools.ietf.org/html/rfc8555#section-7.1.4
type Authorization struct {
// status (required, string):
// The status of this authorization.
@@ -251,8 +207,8 @@ type ExtendedChallenge struct {
}
// Challenge the ACME challenge object.
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.5
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-8
+// - https://tools.ietf.org/html/rfc8555#section-7.1.5
+// - https://tools.ietf.org/html/rfc8555#section-8
type Challenge struct {
// type (required, string):
// The type of challenge encoded in the object.
@@ -285,31 +241,23 @@ type Challenge struct {
// It MUST NOT contain any characters outside the base64url alphabet,
// and MUST NOT include base64 padding characters ("=").
// See [RFC4086] for additional information on randomness requirements.
- // https://www.rfc-editor.org/rfc/rfc8555.html#section-8.3
- // https://www.rfc-editor.org/rfc/rfc8555.html#section-8.4
+ // https://tools.ietf.org/html/rfc8555#section-8.3
+ // https://tools.ietf.org/html/rfc8555#section-8.4
Token string `json:"token"`
- // https://www.rfc-editor.org/rfc/rfc8555.html#section-8.1
+ // https://tools.ietf.org/html/rfc8555#section-8.1
KeyAuthorization string `json:"keyAuthorization"`
}
-func (c *Challenge) Err() error {
- if c.Error != nil {
- return c.Error
- }
-
- return nil
-}
-
// Identifier the ACME identifier object.
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-9.7.7
+// - https://tools.ietf.org/html/rfc8555#section-9.7.7
type Identifier struct {
Type string `json:"type"`
Value string `json:"value"`
}
// CSRMessage Certificate Signing Request.
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
+// - https://tools.ietf.org/html/rfc8555#section-7.4
type CSRMessage struct {
// csr (required, string):
// A CSR encoding the parameters for the certificate being requested [RFC2986].
@@ -319,8 +267,8 @@ type CSRMessage struct {
}
// RevokeCertMessage a certificate revocation message.
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.6
-// - https://www.rfc-editor.org/rfc/rfc5280.html#section-5.3.1
+// - https://tools.ietf.org/html/rfc8555#section-7.6
+// - https://tools.ietf.org/html/rfc5280#section-5.3.1
type RevokeCertMessage struct {
// certificate (required, string):
// The certificate to be revoked, in the base64url-encoded version of the DER format.
@@ -341,36 +289,3 @@ type RawCertificate struct {
Cert []byte
Issuer []byte
}
-
-// Window is a window of time.
-type Window struct {
- Start time.Time `json:"start"`
- End time.Time `json:"end"`
-}
-
-// RenewalInfoResponse is the response to GET requests made the renewalInfo endpoint.
-// - (4.1. Getting Renewal Information) https://datatracker.ietf.org/doc/draft-ietf-acme-ari/
-type RenewalInfoResponse struct {
- // SuggestedWindow contains two fields, start and end,
- // whose values are timestamps which bound the window of time in which the CA recommends renewing the certificate.
- SuggestedWindow Window `json:"suggestedWindow"`
- // ExplanationURL is an optional URL pointing to a page which may explain why the suggested renewal window is what it is.
- // For example, it may be a page explaining the CA's dynamic load-balancing strategy,
- // or a page documenting which certificates are affected by a mass revocation event.
- // Callers SHOULD provide this URL to their operator, if present.
- ExplanationURL string `json:"explanationURL"`
-}
-
-// RenewalInfoUpdateRequest is the JWS payload for POST requests made to the renewalInfo endpoint.
-// - (4.2. RenewalInfo Objects) https://datatracker.ietf.org/doc/html/draft-ietf-acme-ari-03#section-4.2
-type RenewalInfoUpdateRequest struct {
- // CertID is a composite string in the format: base64url(AKI) || '.' || base64url(Serial), where AKI is the
- // certificate's authority key identifier and Serial is the certificate's serial number. For details, see:
- // https://datatracker.ietf.org/doc/html/draft-ietf-acme-ari-03#section-4.1
- CertID string `json:"certID"`
- // Replaced is required and indicates whether or not the client considers the certificate to have been replaced.
- // A certificate is considered replaced when its revocation would not disrupt any ongoing services,
- // for instance because it has been renewed and the new certificate is in use, or because it is no longer in use.
- // Clients SHOULD NOT send a request where this value is false.
- Replaced bool `json:"replaced"`
-}
diff --git a/vendor/github.com/go-acme/lego/v4/acme/errors.go b/vendor/github.com/go-acme/lego/v4/acme/errors.go
index a9d6353..3d6a5ab 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/errors.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/errors.go
@@ -6,14 +6,13 @@ import (
// Errors types.
const (
- errNS = "urn:ietf:params:acme:error:"
- BadNonceErr = errNS + "badNonce"
- AlreadyReplacedErr = errNS + "alreadyReplaced"
+ errNS = "urn:ietf:params:acme:error:"
+ BadNonceErr = errNS + "badNonce"
)
// ProblemDetails the problem details object.
-// - https://www.rfc-editor.org/rfc/rfc7807.html#section-3.1
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-7.3.3
+// - https://tools.ietf.org/html/rfc7807#section-3.1
+// - https://tools.ietf.org/html/rfc8555#section-7.3.3
type ProblemDetails struct {
Type string `json:"type,omitempty"`
Detail string `json:"detail,omitempty"`
@@ -26,7 +25,15 @@ type ProblemDetails struct {
URL string `json:"url,omitempty"`
}
-func (p *ProblemDetails) Error() string {
+// SubProblem a "subproblems".
+// - https://tools.ietf.org/html/rfc8555#section-6.7.1
+type SubProblem struct {
+ Type string `json:"type,omitempty"`
+ Detail string `json:"detail,omitempty"`
+ Identifier Identifier `json:"identifier,omitempty"`
+}
+
+func (p ProblemDetails) Error() string {
msg := fmt.Sprintf("acme: error: %d", p.HTTPStatus)
if p.Method != "" || p.URL != "" {
msg += fmt.Sprintf(" :: %s :: %s", p.Method, p.URL)
@@ -44,23 +51,8 @@ func (p *ProblemDetails) Error() string {
return msg
}
-// SubProblem a "subproblems".
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-6.7.1
-type SubProblem struct {
- Type string `json:"type,omitempty"`
- Detail string `json:"detail,omitempty"`
- Identifier Identifier `json:"identifier,omitempty"`
-}
-
// NonceError represents the error which is returned
// if the nonce sent by the client was not accepted by the server.
type NonceError struct {
*ProblemDetails
}
-
-// AlreadyReplacedError represents the error which is returned
-// If the Server rejects the request because the identified certificate has already been marked as replaced.
-// - https://datatracker.ietf.org/doc/html/draft-ietf-acme-ari-08#section-5
-type AlreadyReplacedError struct {
- *ProblemDetails
-}
diff --git a/vendor/github.com/go-acme/lego/v4/certcrypto/crypto.go b/vendor/github.com/go-acme/lego/v4/certcrypto/crypto.go
index c655107..44f6e4d 100644
--- a/vendor/github.com/go-acme/lego/v4/certcrypto/crypto.go
+++ b/vendor/github.com/go-acme/lego/v4/certcrypto/crypto.go
@@ -14,8 +14,6 @@ import (
"errors"
"fmt"
"math/big"
- "net"
- "slices"
"strings"
"time"
@@ -27,7 +25,6 @@ const (
EC256 = KeyType("P256")
EC384 = KeyType("P384")
RSA2048 = KeyType("2048")
- RSA3072 = KeyType("3072")
RSA4096 = KeyType("4096")
RSA8192 = KeyType("8192")
)
@@ -85,12 +82,9 @@ func ParsePEMBundle(bundle []byte) ([]*x509.Certificate, error) {
// ParsePEMPrivateKey parses a private key from key, which is a PEM block.
// Borrowed from Go standard library, to handle various private key and PEM block types.
// https://github.com/golang/go/blob/693748e9fa385f1e2c3b91ca9acbb6c0ad2d133d/src/crypto/tls/tls.go#L291-L308
-// https://github.com/golang/go/blob/693748e9fa385f1e2c3b91ca9acbb6c0ad2d133d/src/crypto/tls/tls.go#L238
+// https://github.com/golang/go/blob/693748e9fa385f1e2c3b91ca9acbb6c0ad2d133d/src/crypto/tls/tls.go#L238)
func ParsePEMPrivateKey(key []byte) (crypto.PrivateKey, error) {
keyBlockDER, _ := pem.Decode(key)
- if keyBlockDER == nil {
- return nil, errors.New("invalid PEM block")
- }
if keyBlockDER.Type != "PRIVATE KEY" && !strings.HasSuffix(keyBlockDER.Type, " PRIVATE KEY") {
return nil, fmt.Errorf("unknown PEM header %q", keyBlockDER.Type)
@@ -124,8 +118,6 @@ func GeneratePrivateKey(keyType KeyType) (crypto.PrivateKey, error) {
return ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
case RSA2048:
return rsa.GenerateKey(rand.Reader, 2048)
- case RSA3072:
- return rsa.GenerateKey(rand.Reader, 3072)
case RSA4096:
return rsa.GenerateKey(rand.Reader, 4096)
case RSA8192:
@@ -135,41 +127,13 @@ func GeneratePrivateKey(keyType KeyType) (crypto.PrivateKey, error) {
return nil, fmt.Errorf("invalid KeyType: %s", keyType)
}
-// Deprecated: uses [CreateCSR] instead.
func GenerateCSR(privateKey crypto.PrivateKey, domain string, san []string, mustStaple bool) ([]byte, error) {
- return CreateCSR(privateKey, CSROptions{
- Domain: domain,
- SAN: san,
- MustStaple: mustStaple,
- })
-}
-
-type CSROptions struct {
- Domain string
- SAN []string
- MustStaple bool
- EmailAddresses []string
-}
-
-func CreateCSR(privateKey crypto.PrivateKey, opts CSROptions) ([]byte, error) {
- var dnsNames []string
- var ipAddresses []net.IP
- for _, altname := range opts.SAN {
- if ip := net.ParseIP(altname); ip != nil {
- ipAddresses = append(ipAddresses, ip)
- } else {
- dnsNames = append(dnsNames, altname)
- }
- }
-
template := x509.CertificateRequest{
- Subject: pkix.Name{CommonName: opts.Domain},
- DNSNames: dnsNames,
- EmailAddresses: opts.EmailAddresses,
- IPAddresses: ipAddresses,
+ Subject: pkix.Name{CommonName: domain},
+ DNSNames: san,
}
- if opts.MustStaple {
+ if mustStaple {
template.ExtraExtensions = append(template.ExtraExtensions, pkix.Extension{
Id: tlsFeatureExtensionOID,
Value: ocspMustStapleFeature,
@@ -234,26 +198,6 @@ func ParsePEMCertificate(cert []byte) (*x509.Certificate, error) {
return x509.ParseCertificate(pemBlock.Bytes)
}
-func GetCertificateMainDomain(cert *x509.Certificate) (string, error) {
- return getMainDomain(cert.Subject, cert.DNSNames)
-}
-
-func GetCSRMainDomain(cert *x509.CertificateRequest) (string, error) {
- return getMainDomain(cert.Subject, cert.DNSNames)
-}
-
-func getMainDomain(subject pkix.Name, dnsNames []string) (string, error) {
- if subject.CommonName == "" && len(dnsNames) == 0 {
- return "", errors.New("missing domain")
- }
-
- if subject.CommonName != "" {
- return subject.CommonName, nil
- }
-
- return dnsNames[0], nil
-}
-
func ExtractDomains(cert *x509.Certificate) []string {
var domains []string
if cert.Subject.CommonName != "" {
@@ -268,13 +212,6 @@ func ExtractDomains(cert *x509.Certificate) []string {
domains = append(domains, sanDomain)
}
- commonNameIP := net.ParseIP(cert.Subject.CommonName)
- for _, sanIP := range cert.IPAddresses {
- if !commonNameIP.Equal(sanIP) {
- domains = append(domains, sanIP.String())
- }
- }
-
return domains
}
@@ -286,7 +223,7 @@ func ExtractDomainsCSR(csr *x509.CertificateRequest) []string {
// loop over the SubjectAltName DNS names
for _, sanName := range csr.DNSNames {
- if slices.Contains(domains, sanName) {
+ if containsSAN(domains, sanName) {
// Duplicate; skip this name
continue
}
@@ -295,14 +232,16 @@ func ExtractDomainsCSR(csr *x509.CertificateRequest) []string {
domains = append(domains, sanName)
}
- cnip := net.ParseIP(csr.Subject.CommonName)
- for _, sanIP := range csr.IPAddresses {
- if !cnip.Equal(sanIP) {
- domains = append(domains, sanIP.String())
+ return domains
+}
+
+func containsSAN(domains []string, sanName string) bool {
+ for _, existingName := range domains {
+ if existingName == sanName {
+ return true
}
}
-
- return domains
+ return false
}
func GeneratePemCert(privateKey *rsa.PrivateKey, domain string, extensions []pkix.Extension) ([]byte, error) {
@@ -322,7 +261,7 @@ func generateDerCert(privateKey *rsa.PrivateKey, expiration time.Time, domain st
}
if expiration.IsZero() {
- expiration = time.Now().AddDate(1, 0, 0)
+ expiration = time.Now().Add(365)
}
template := x509.Certificate{
@@ -335,15 +274,9 @@ func generateDerCert(privateKey *rsa.PrivateKey, expiration time.Time, domain st
KeyUsage: x509.KeyUsageKeyEncipherment,
BasicConstraintsValid: true,
+ DNSNames: []string{domain},
ExtraExtensions: extensions,
}
- // handling SAN filling as type suspected
- if ip := net.ParseIP(domain); ip != nil {
- template.IPAddresses = []net.IP{ip}
- } else {
- template.DNSNames = []string{domain}
- }
-
return x509.CreateCertificate(rand.Reader, &template, &template, &privateKey.PublicKey, privateKey)
}
diff --git a/vendor/github.com/go-acme/lego/v4/certificate/authorization.go b/vendor/github.com/go-acme/lego/v4/certificate/authorization.go
index c77bcbd..9161d75 100644
--- a/vendor/github.com/go-acme/lego/v4/certificate/authorization.go
+++ b/vendor/github.com/go-acme/lego/v4/certificate/authorization.go
@@ -7,10 +7,18 @@ import (
"github.com/go-acme/lego/v4/log"
)
+const (
+ // overallRequestLimit is the overall number of request per second
+ // limited on the "new-reg", "new-authz" and "new-cert" endpoints.
+ // From the documentation the limitation is 20 requests per second,
+ // but using 20 as value doesn't work but 18 do.
+ overallRequestLimit = 18
+)
+
func (c *Certifier) getAuthorizations(order acme.ExtendedOrder) ([]acme.Authorization, error) {
resc, errc := make(chan acme.Authorization), make(chan domainError)
- delay := time.Second / time.Duration(c.overallRequestLimit)
+ delay := time.Second / overallRequestLimit
for _, authzURL := range order.Authorizations {
time.Sleep(delay)
@@ -27,14 +35,13 @@ func (c *Certifier) getAuthorizations(order acme.ExtendedOrder) ([]acme.Authoriz
}
var responses []acme.Authorization
-
- failures := newObtainError()
- for range len(order.Authorizations) {
+ failures := make(obtainError)
+ for i := 0; i < len(order.Authorizations); i++ {
select {
case res := <-resc:
responses = append(responses, res)
case err := <-errc:
- failures.Add(err.Domain, err.Error)
+ failures[err.Domain] = err.Error
}
}
@@ -45,18 +52,23 @@ func (c *Certifier) getAuthorizations(order acme.ExtendedOrder) ([]acme.Authoriz
close(resc)
close(errc)
- return responses, failures.Join()
+ // be careful to not return an empty failures map;
+ // even if empty, they become non-nil error values
+ if len(failures) > 0 {
+ return responses, failures
+ }
+ return responses, nil
}
-func (c *Certifier) deactivateAuthorizations(order acme.ExtendedOrder, force bool) {
+func (c *Certifier) deactivateAuthorizations(order acme.ExtendedOrder) {
for _, authzURL := range order.Authorizations {
auth, err := c.core.Authorizations.Get(authzURL)
if err != nil {
- log.Infof("Unable to get the authorization for %s: %v", authzURL, err)
+ log.Infof("Unable to get the authorization for: %s", authzURL)
continue
}
- if auth.Status == acme.StatusValid && !force {
+ if auth.Status == acme.StatusValid {
log.Infof("Skipping deactivating of valid auth: %s", authzURL)
continue
}
diff --git a/vendor/github.com/go-acme/lego/v4/certificate/certificates.go b/vendor/github.com/go-acme/lego/v4/certificate/certificates.go
index d03e99c..a130680 100644
--- a/vendor/github.com/go-acme/lego/v4/certificate/certificates.go
+++ b/vendor/github.com/go-acme/lego/v4/certificate/certificates.go
@@ -7,7 +7,7 @@ import (
"encoding/base64"
"errors"
"fmt"
- "io"
+ "io/ioutil"
"net/http"
"strings"
"time"
@@ -22,17 +22,6 @@ import (
"golang.org/x/net/idna"
)
-const (
- // DefaultOverallRequestLimit is the overall number of request per second
- // limited on the "new-reg", "new-authz" and "new-cert" endpoints.
- // From the documentation the limitation is 20 requests per second,
- // but using 20 as value doesn't work but 18 do.
- // https://letsencrypt.org/docs/rate-limits/
- // ZeroSSL has a limit of 7.
- // https://help.zerossl.com/hc/en-us/articles/17864245480093-Advantages-over-Using-Let-s-Encrypt#h_01HT4Z1JCJFJQFJ1M3P7S085Q9
- DefaultOverallRequestLimit = 18
-)
-
// maxBodySize is the maximum size of body that we will read.
const maxBodySize = 1024 * 1024
@@ -60,61 +49,22 @@ type Resource struct {
// If you do not want that you can supply your own private key in the privateKey parameter.
// If this parameter is non-nil it will be used instead of generating a new one.
//
-// If `Bundle` is true, the `[]byte` contains both the issuer certificate and your issued certificate as a bundle.
-//
-// If `AlwaysDeactivateAuthorizations` is true, the authorizations are also relinquished if the obtain request was successful.
-// See https://datatracker.ietf.org/doc/html/rfc8555#section-7.5.2.
+// If bundle is true, the []byte contains both the issuer certificate and your issued certificate as a bundle.
type ObtainRequest struct {
Domains []string
+ Bundle bool
PrivateKey crypto.PrivateKey
MustStaple bool
- EmailAddresses []string
-
- NotBefore time.Time
- NotAfter time.Time
- Bundle bool
PreferredChain string
-
- // A string uniquely identifying the profile
- // which will be used to affect issuance of the certificate requested by this Order.
- // - https://www.ietf.org/id/draft-aaron-acme-profiles-00.html#section-4
- Profile string
-
- AlwaysDeactivateAuthorizations bool
-
- // A string uniquely identifying a previously-issued certificate which this
- // order is intended to replace.
- // - https://datatracker.ietf.org/doc/html/draft-ietf-acme-ari-03#section-5
- ReplacesCertID string
}
// ObtainForCSRRequest The request to obtain a certificate matching the CSR passed into it.
//
-// If `Bundle` is true, the `[]byte` contains both the issuer certificate and your issued certificate as a bundle.
-//
-// If `AlwaysDeactivateAuthorizations` is true, the authorizations are also relinquished if the obtain request was successful.
-// See https://datatracker.ietf.org/doc/html/rfc8555#section-7.5.2.
+// If bundle is true, the []byte contains both the issuer certificate and your issued certificate as a bundle.
type ObtainForCSRRequest struct {
- CSR *x509.CertificateRequest
-
- PrivateKey crypto.PrivateKey
-
- NotBefore time.Time
- NotAfter time.Time
+ CSR *x509.CertificateRequest
Bundle bool
PreferredChain string
-
- // A string uniquely identifying the profile
- // which will be used to affect issuance of the certificate requested by this Order.
- // - https://www.ietf.org/id/draft-aaron-acme-profiles-00.html#section-4
- Profile string
-
- AlwaysDeactivateAuthorizations bool
-
- // A string uniquely identifying a previously-issued certificate which this
- // order is intended to replace.
- // - https://datatracker.ietf.org/doc/html/draft-ietf-acme-ari-03#section-5
- ReplacesCertID string
}
type resolver interface {
@@ -122,33 +72,24 @@ type resolver interface {
}
type CertifierOptions struct {
- KeyType certcrypto.KeyType
- Timeout time.Duration
- OverallRequestLimit int
+ KeyType certcrypto.KeyType
+ Timeout time.Duration
}
// Certifier A service to obtain/renew/revoke certificates.
type Certifier struct {
- core *api.Core
- resolver resolver
- options CertifierOptions
- overallRequestLimit int
+ core *api.Core
+ resolver resolver
+ options CertifierOptions
}
// NewCertifier creates a Certifier.
func NewCertifier(core *api.Core, resolver resolver, options CertifierOptions) *Certifier {
- c := &Certifier{
+ return &Certifier{
core: core,
resolver: resolver,
options: options,
}
-
- c.overallRequestLimit = options.OverallRequestLimit
- if c.overallRequestLimit <= 0 {
- c.overallRequestLimit = DefaultOverallRequestLimit
- }
-
- return c
}
// Obtain tries to obtain a single certificate using all domains passed into it.
@@ -168,14 +109,7 @@ func (c *Certifier) Obtain(request ObtainRequest) (*Resource, error) {
log.Infof("[%s] acme: Obtaining SAN certificate", strings.Join(domains, ", "))
}
- orderOpts := &api.OrderOptions{
- NotBefore: request.NotBefore,
- NotAfter: request.NotAfter,
- Profile: request.Profile,
- ReplacesCertID: request.ReplacesCertID,
- }
-
- order, err := c.core.Orders.NewWithOptions(domains, orderOpts)
+ order, err := c.core.Orders.New(domains)
if err != nil {
return nil, err
}
@@ -183,32 +117,33 @@ func (c *Certifier) Obtain(request ObtainRequest) (*Resource, error) {
authz, err := c.getAuthorizations(order)
if err != nil {
// If any challenge fails, return. Do not generate partial SAN certificates.
- c.deactivateAuthorizations(order, request.AlwaysDeactivateAuthorizations)
+ c.deactivateAuthorizations(order)
return nil, err
}
err = c.resolver.Solve(authz)
if err != nil {
// If any challenge fails, return. Do not generate partial SAN certificates.
- c.deactivateAuthorizations(order, request.AlwaysDeactivateAuthorizations)
+ c.deactivateAuthorizations(order)
return nil, err
}
log.Infof("[%s] acme: Validations succeeded; requesting certificates", strings.Join(domains, ", "))
- failures := newObtainError()
- cert, err := c.getForOrder(domains, order, request)
+ failures := make(obtainError)
+ cert, err := c.getForOrder(domains, order, request.Bundle, request.PrivateKey, request.MustStaple, request.PreferredChain)
if err != nil {
for _, auth := range authz {
- failures.Add(challenge.GetTargetedDomain(auth), err)
+ failures[challenge.GetTargetedDomain(auth)] = err
}
}
- if request.AlwaysDeactivateAuthorizations {
- c.deactivateAuthorizations(order, true)
+ // Do not return an empty failures map, because
+ // it would still be a non-nil error value
+ if len(failures) > 0 {
+ return cert, failures
}
-
- return cert, failures.Join()
+ return cert, nil
}
// ObtainForCSR tries to obtain a certificate matching the CSR passed into it.
@@ -235,14 +170,7 @@ func (c *Certifier) ObtainForCSR(request ObtainForCSRRequest) (*Resource, error)
log.Infof("[%s] acme: Obtaining SAN certificate given a CSR", strings.Join(domains, ", "))
}
- orderOpts := &api.OrderOptions{
- NotBefore: request.NotBefore,
- NotAfter: request.NotAfter,
- Profile: request.Profile,
- ReplacesCertID: request.ReplacesCertID,
- }
-
- order, err := c.core.Orders.NewWithOptions(domains, orderOpts)
+ order, err := c.core.Orders.New(domains)
if err != nil {
return nil, err
}
@@ -250,48 +178,41 @@ func (c *Certifier) ObtainForCSR(request ObtainForCSRRequest) (*Resource, error)
authz, err := c.getAuthorizations(order)
if err != nil {
// If any challenge fails, return. Do not generate partial SAN certificates.
- c.deactivateAuthorizations(order, request.AlwaysDeactivateAuthorizations)
+ c.deactivateAuthorizations(order)
return nil, err
}
err = c.resolver.Solve(authz)
if err != nil {
// If any challenge fails, return. Do not generate partial SAN certificates.
- c.deactivateAuthorizations(order, request.AlwaysDeactivateAuthorizations)
+ c.deactivateAuthorizations(order)
return nil, err
}
log.Infof("[%s] acme: Validations succeeded; requesting certificates", strings.Join(domains, ", "))
- failures := newObtainError()
-
- var privateKey []byte
- if request.PrivateKey != nil {
- privateKey = certcrypto.PEMEncode(request.PrivateKey)
- }
-
- cert, err := c.getForCSR(domains, order, request.Bundle, request.CSR.Raw, privateKey, request.PreferredChain)
+ failures := make(obtainError)
+ cert, err := c.getForCSR(domains, order, request.Bundle, request.CSR.Raw, nil, request.PreferredChain)
if err != nil {
for _, auth := range authz {
- failures.Add(challenge.GetTargetedDomain(auth), err)
+ failures[challenge.GetTargetedDomain(auth)] = err
}
}
- if request.AlwaysDeactivateAuthorizations {
- c.deactivateAuthorizations(order, true)
- }
-
if cert != nil {
// Add the CSR to the certificate so that it can be used for renewals.
cert.CSR = certcrypto.PEMEncode(request.CSR)
}
- return cert, failures.Join()
+ // Do not return an empty failures map,
+ // because it would still be a non-nil error value
+ if len(failures) > 0 {
+ return cert, failures
+ }
+ return cert, nil
}
-func (c *Certifier) getForOrder(domains []string, order acme.ExtendedOrder, request ObtainRequest) (*Resource, error) {
- privateKey := request.PrivateKey
-
+func (c *Certifier) getForOrder(domains []string, order acme.ExtendedOrder, bundle bool, privateKey crypto.PrivateKey, mustStaple bool, preferredChain string) (*Resource, error) {
if privateKey == nil {
var err error
privateKey, err = certcrypto.GeneratePrivateKey(c.options.KeyType)
@@ -300,42 +221,29 @@ func (c *Certifier) getForOrder(domains []string, order acme.ExtendedOrder, requ
}
}
- commonName := ""
- if len(domains[0]) <= 64 {
- commonName = domains[0]
- }
+ // Determine certificate name(s) based on the authorization resources
+ commonName := domains[0]
// RFC8555 Section 7.4 "Applying for Certificate Issuance"
- // https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
+ // https://tools.ietf.org/html/rfc8555#section-7.4
// says:
// Clients SHOULD NOT make any assumptions about the sort order of
// "identifiers" or "authorizations" elements in the returned order
// object.
-
- var san []string
- if commonName != "" {
- san = append(san, commonName)
- }
-
+ san := []string{commonName}
for _, auth := range order.Identifiers {
if auth.Value != commonName {
san = append(san, auth.Value)
}
}
- csrOptions := certcrypto.CSROptions{
- Domain: commonName,
- SAN: san,
- MustStaple: request.MustStaple,
- EmailAddresses: request.EmailAddresses,
- }
-
- csr, err := certcrypto.CreateCSR(privateKey, csrOptions)
+ // TODO: should the CSR be customizable?
+ csr, err := certcrypto.GenerateCSR(privateKey, commonName, san, mustStaple)
if err != nil {
return nil, err
}
- return c.getForCSR(domains, order, request.Bundle, csr, certcrypto.PEMEncode(privateKey), request.PreferredChain)
+ return c.getForCSR(domains, order, bundle, csr, certcrypto.PEMEncode(privateKey), preferredChain)
}
func (c *Certifier) getForCSR(domains []string, order acme.ExtendedOrder, bundle bool, csr, privateKeyPem []byte, preferredChain string) (*Resource, error) {
@@ -344,14 +252,15 @@ func (c *Certifier) getForCSR(domains []string, order acme.ExtendedOrder, bundle
return nil, err
}
+ commonName := domains[0]
certRes := &Resource{
- Domain: domains[0],
+ Domain: commonName,
CertURL: respOrder.Certificate,
PrivateKey: privateKeyPem,
}
if respOrder.Status == acme.StatusValid {
- // if the certificate is available right away, shortcut!
+ // if the certificate is available right away, short cut!
ok, errR := c.checkResponse(respOrder, certRes, bundle, preferredChain)
if errR != nil {
return nil, errR
@@ -440,11 +349,6 @@ func (c *Certifier) checkResponse(order acme.ExtendedOrder, certRes *Resource, b
// Revoke takes a PEM encoded certificate or bundle and tries to revoke it at the CA.
func (c *Certifier) Revoke(cert []byte) error {
- return c.RevokeWithReason(cert, nil)
-}
-
-// RevokeWithReason takes a PEM encoded certificate or bundle and tries to revoke it at the CA.
-func (c *Certifier) RevokeWithReason(cert []byte, reason *uint) error {
certificates, err := certcrypto.ParsePEMBundle(cert)
if err != nil {
return err
@@ -457,28 +361,11 @@ func (c *Certifier) RevokeWithReason(cert []byte, reason *uint) error {
revokeMsg := acme.RevokeCertMessage{
Certificate: base64.RawURLEncoding.EncodeToString(x509Cert.Raw),
- Reason: reason,
}
return c.core.Certificates.Revoke(revokeMsg)
}
-// RenewOptions options used by Certifier.RenewWithOptions.
-type RenewOptions struct {
- NotBefore time.Time
- NotAfter time.Time
- // If true, the []byte contains both the issuer certificate and your issued certificate as a bundle.
- Bundle bool
- PreferredChain string
-
- Profile string
-
- AlwaysDeactivateAuthorizations bool
- // Not supported for CSR request.
- MustStaple bool
- EmailAddresses []string
-}
-
// Renew takes a Resource and tries to renew the certificate.
//
// If the renewal process succeeds, the new certificate will be returned in a new CertResource.
@@ -489,26 +376,7 @@ type RenewOptions struct {
// If bundle is true, the []byte contains both the issuer certificate and your issued certificate as a bundle.
//
// For private key reuse the PrivateKey property of the passed in Resource should be non-nil.
-// Deprecated: use RenewWithOptions instead.
func (c *Certifier) Renew(certRes Resource, bundle, mustStaple bool, preferredChain string) (*Resource, error) {
- return c.RenewWithOptions(certRes, &RenewOptions{
- Bundle: bundle,
- PreferredChain: preferredChain,
- MustStaple: mustStaple,
- })
-}
-
-// RenewWithOptions takes a Resource and tries to renew the certificate.
-//
-// If the renewal process succeeds, the new certificate will be returned in a new CertResource.
-// Please be aware that this function will return a new certificate in ANY case that is not an error.
-// If the server does not provide us with a new cert on a GET request to the CertURL
-// this function will start a new-cert flow where a new certificate gets generated.
-//
-// If bundle is true, the []byte contains both the issuer certificate and your issued certificate as a bundle.
-//
-// For private key reuse the PrivateKey property of the passed in Resource should be non-nil.
-func (c *Certifier) RenewWithOptions(certRes Resource, options *RenewOptions) (*Resource, error) {
// Input certificate is PEM encoded.
// Decode it here as we may need the decoded cert later on in the renewal process.
// The input may be a bundle or a single certificate.
@@ -535,18 +403,11 @@ func (c *Certifier) RenewWithOptions(certRes Resource, options *RenewOptions) (*
return nil, errP
}
- request := ObtainForCSRRequest{CSR: csr}
-
- if options != nil {
- request.NotBefore = options.NotBefore
- request.NotAfter = options.NotAfter
- request.Bundle = options.Bundle
- request.PreferredChain = options.PreferredChain
- request.Profile = options.Profile
- request.AlwaysDeactivateAuthorizations = options.AlwaysDeactivateAuthorizations
- }
-
- return c.ObtainForCSR(request)
+ return c.ObtainForCSR(ObtainForCSRRequest{
+ CSR: csr,
+ Bundle: bundle,
+ PreferredChain: preferredChain,
+ })
}
var privateKey crypto.PrivateKey
@@ -557,23 +418,13 @@ func (c *Certifier) RenewWithOptions(certRes Resource, options *RenewOptions) (*
}
}
- request := ObtainRequest{
+ query := ObtainRequest{
Domains: certcrypto.ExtractDomains(x509Cert),
+ Bundle: bundle,
PrivateKey: privateKey,
+ MustStaple: mustStaple,
}
-
- if options != nil {
- request.MustStaple = options.MustStaple
- request.NotBefore = options.NotBefore
- request.NotAfter = options.NotAfter
- request.Bundle = options.Bundle
- request.PreferredChain = options.PreferredChain
- request.EmailAddresses = options.EmailAddresses
- request.Profile = options.Profile
- request.AlwaysDeactivateAuthorizations = options.AlwaysDeactivateAuthorizations
- }
-
- return c.Obtain(request)
+ return c.Obtain(query)
}
// GetOCSP takes a PEM encoded cert or cert bundle returning the raw OCSP response,
@@ -614,7 +465,7 @@ func (c *Certifier) GetOCSP(bundle []byte) ([]byte, *ocsp.Response, error) {
}
defer resp.Body.Close()
- issuerBytes, errC := io.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
+ issuerBytes, errC := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
if errC != nil {
return nil, nil, errC
}
@@ -643,7 +494,7 @@ func (c *Certifier) GetOCSP(bundle []byte) ([]byte, *ocsp.Response, error) {
}
defer resp.Body.Close()
- ocspResBytes, err := io.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
+ ocspResBytes, err := ioutil.ReadAll(http.MaxBytesReader(nil, resp.Body, maxBodySize))
if err != nil {
return nil, nil, err
}
@@ -674,13 +525,8 @@ func (c *Certifier) Get(url string, bundle bool) (*Resource, error) {
return nil, err
}
- domain, err := certcrypto.GetCertificateMainDomain(x509Certs[0])
- if err != nil {
- return nil, err
- }
-
return &Resource{
- Domain: domain,
+ Domain: x509Certs[0].Subject.CommonName,
Certificate: cert,
IssuerCertificate: issuer,
CertURL: url,
@@ -708,17 +554,17 @@ func checkOrderStatus(order acme.ExtendedOrder) (bool, error) {
case acme.StatusValid:
return true, nil
case acme.StatusInvalid:
- return false, fmt.Errorf("invalid order: %w", order.Err())
+ return false, order.Error
default:
return false, nil
}
}
-// https://www.rfc-editor.org/rfc/rfc8555.html#section-7.1.4
+// https://tools.ietf.org/html/rfc8555#section-7.1.4
// The domain name MUST be encoded in the form in which it would appear in a certificate.
// That is, it MUST be encoded according to the rules in Section 7 of [RFC5280].
//
-// https://www.rfc-editor.org/rfc/rfc5280.html#section-7
+// https://tools.ietf.org/html/rfc5280#section-7
func sanitizeDomain(domains []string) []string {
var sanitizedDomains []string
for _, domain := range domains {
diff --git a/vendor/github.com/go-acme/lego/v4/certificate/errors.go b/vendor/github.com/go-acme/lego/v4/certificate/errors.go
index f305524..3adbc78 100644
--- a/vendor/github.com/go-acme/lego/v4/certificate/errors.go
+++ b/vendor/github.com/go-acme/lego/v4/certificate/errors.go
@@ -1,37 +1,27 @@
package certificate
import (
- "errors"
+ "bytes"
"fmt"
+ "sort"
)
-type obtainError struct {
- data map[string]error
-}
+// obtainError is returned when there are specific errors available per domain.
+type obtainError map[string]error
-func newObtainError() *obtainError {
- return &obtainError{data: make(map[string]error)}
-}
+func (e obtainError) Error() string {
+ buffer := bytes.NewBufferString("error: one or more domains had a problem:\n")
-func (e *obtainError) Add(domain string, err error) {
- e.data[domain] = err
-}
-
-func (e *obtainError) Join() error {
- if e == nil {
- return nil
+ var domains []string
+ for domain := range e {
+ domains = append(domains, domain)
}
+ sort.Strings(domains)
- if len(e.data) == 0 {
- return nil
+ for _, domain := range domains {
+ buffer.WriteString(fmt.Sprintf("[%s] %s\n", domain, e[domain]))
}
-
- var err error
- for d, e := range e.data {
- err = errors.Join(err, fmt.Errorf("%s: %w", d, e))
- }
-
- return fmt.Errorf("error: one or more domains had a problem:\n%w", err)
+ return buffer.String()
}
type domainError struct {
diff --git a/vendor/github.com/go-acme/lego/v4/certificate/renewal.go b/vendor/github.com/go-acme/lego/v4/certificate/renewal.go
deleted file mode 100644
index ab21592..0000000
--- a/vendor/github.com/go-acme/lego/v4/certificate/renewal.go
+++ /dev/null
@@ -1,131 +0,0 @@
-package certificate
-
-import (
- "crypto/x509"
- "encoding/asn1"
- "encoding/base64"
- "encoding/json"
- "errors"
- "fmt"
- "math/rand"
- "time"
-
- "github.com/go-acme/lego/v4/acme"
-)
-
-// RenewalInfoRequest contains the necessary renewal information.
-type RenewalInfoRequest struct {
- Cert *x509.Certificate
-}
-
-// RenewalInfoResponse is a wrapper around acme.RenewalInfoResponse that provides a method for determining when to renew a certificate.
-type RenewalInfoResponse struct {
- acme.RenewalInfoResponse
-
- // RetryAfter header indicating the polling interval that the ACME server recommends.
- // Conforming clients SHOULD query the renewalInfo URL again after the RetryAfter period has passed,
- // as the server may provide a different suggestedWindow.
- // https://datatracker.ietf.org/doc/html/draft-ietf-acme-ari-03#section-4.2
- RetryAfter time.Duration
-}
-
-// ShouldRenewAt determines the optimal renewal time based on the current time (UTC),renewal window suggest by ARI, and the client's willingness to sleep.
-// It returns a pointer to a time.Time value indicating when the renewal should be attempted or nil if deferred until the next normal wake time.
-// This method implements the RECOMMENDED algorithm described in draft-ietf-acme-ari.
-//
-// - (4.1-11. Getting Renewal Information) https://datatracker.ietf.org/doc/draft-ietf-acme-ari/
-func (r *RenewalInfoResponse) ShouldRenewAt(now time.Time, willingToSleep time.Duration) *time.Time {
- // Explicitly convert all times to UTC.
- now = now.UTC()
- start := r.SuggestedWindow.Start.UTC()
- end := r.SuggestedWindow.End.UTC()
-
- // Select a uniform random time within the suggested window.
- rt := start
- if window := end.Sub(start); window > 0 {
- randomDuration := time.Duration(rand.Int63n(int64(window)))
- rt = rt.Add(randomDuration)
- }
-
- // If the selected time is in the past, attempt renewal immediately.
- if rt.Before(now) {
- return &now
- }
-
- // Otherwise, if the client can schedule itself to attempt renewal at exactly the selected time, do so.
- willingToSleepUntil := now.Add(willingToSleep)
- if willingToSleepUntil.After(rt) || willingToSleepUntil.Equal(rt) {
- return &rt
- }
-
- // TODO: Otherwise, if the selected time is before the next time that the client would wake up normally, attempt renewal immediately.
-
- // Otherwise, sleep until the next normal wake time, re-check ARI, and return to Step 1.
- return nil
-}
-
-// GetRenewalInfo sends a request to the ACME server's renewalInfo endpoint to obtain a suggested renewal window.
-// The caller MUST provide the certificate and issuer certificate for the certificate they wish to renew.
-// The caller should attempt to renew the certificate at the time indicated by the ShouldRenewAt method of the returned RenewalInfoResponse object.
-//
-// Note: this endpoint is part of a draft specification, not all ACME servers will implement it.
-// This method will return api.ErrNoARI if the server does not advertise a renewal info endpoint.
-//
-// https://datatracker.ietf.org/doc/draft-ietf-acme-ari
-func (c *Certifier) GetRenewalInfo(req RenewalInfoRequest) (*RenewalInfoResponse, error) {
- certID, err := MakeARICertID(req.Cert)
- if err != nil {
- return nil, fmt.Errorf("error making certID: %w", err)
- }
-
- resp, err := c.core.Certificates.GetRenewalInfo(certID)
- if err != nil {
- return nil, err
- }
- defer resp.Body.Close()
-
- var info RenewalInfoResponse
- err = json.NewDecoder(resp.Body).Decode(&info)
- if err != nil {
- return nil, err
- }
-
- if retry := resp.Header.Get("Retry-After"); retry != "" {
- info.RetryAfter, err = time.ParseDuration(retry + "s")
- if err != nil {
- return nil, err
- }
- }
-
- return &info, nil
-}
-
-// MakeARICertID constructs a certificate identifier as described in draft-ietf-acme-ari-03, section 4.1.
-func MakeARICertID(leaf *x509.Certificate) (string, error) {
- if leaf == nil {
- return "", errors.New("leaf certificate is nil")
- }
-
- // Marshal the Serial Number into DER.
- der, err := asn1.Marshal(leaf.SerialNumber)
- if err != nil {
- return "", err
- }
-
- // Check if the DER encoded bytes are sufficient (at least 3 bytes: tag,
- // length, and value).
- if len(der) < 3 {
- return "", errors.New("invalid DER encoding of serial number")
- }
-
- // Extract only the integer bytes from the DER encoded Serial Number
- // Skipping the first 2 bytes (tag and length).
- serial := base64.RawURLEncoding.EncodeToString(der[2:])
-
- // Convert the Authority Key Identifier to base64url encoding without
- // padding.
- aki := base64.RawURLEncoding.EncodeToString(leaf.AuthorityKeyId)
-
- // Construct the final identifier by concatenating AKI and Serial Number.
- return fmt.Sprintf("%s.%s", aki, serial), nil
-}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/challenges.go b/vendor/github.com/go-acme/lego/v4/challenge/challenges.go
index 39bf3be..4f6dc6b 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/challenges.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/challenges.go
@@ -10,15 +10,15 @@ import (
type Type string
const (
- // HTTP01 is the "http-01" ACME challenge https://www.rfc-editor.org/rfc/rfc8555.html#section-8.3
+ // HTTP01 is the "http-01" ACME challenge https://tools.ietf.org/html/rfc8555#section-8.3
// Note: ChallengePath returns the URL path to fulfill this challenge.
HTTP01 = Type("http-01")
- // DNS01 is the "dns-01" ACME challenge https://www.rfc-editor.org/rfc/rfc8555.html#section-8.4
+ // DNS01 is the "dns-01" ACME challenge https://tools.ietf.org/html/rfc8555#section-8.4
// Note: GetRecord returns a DNS record which will fulfill this challenge.
DNS01 = Type("dns-01")
- // TLSALPN01 is the "tls-alpn-01" ACME challenge https://www.rfc-editor.org/rfc/rfc8737.html
+ // TLSALPN01 is the "tls-alpn-01" ACME challenge https://tools.ietf.org/html/draft-ietf-acme-tls-alpn-07
TLSALPN01 = Type("tls-alpn-01")
)
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/dns01/cname.go b/vendor/github.com/go-acme/lego/v4/challenge/dns01/cname.go
index 26fe150..ab35ee8 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/dns01/cname.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/dns01/cname.go
@@ -1,16 +1,12 @@
package dns01
-import (
- "strings"
-
- "github.com/miekg/dns"
-)
+import "github.com/miekg/dns"
// Update FQDN with CNAME if any.
func updateDomainWithCName(r *dns.Msg, fqdn string) string {
for _, rr := range r.Answer {
if cn, ok := rr.(*dns.CNAME); ok {
- if strings.EqualFold(cn.Hdr.Name, fqdn) {
+ if cn.Hdr.Name == fqdn {
return cn.Target
}
}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/dns01/dns_challenge.go b/vendor/github.com/go-acme/lego/v4/challenge/dns01/dns_challenge.go
index 8594d27..e46e9ba 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/dns01/dns_challenge.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/dns01/dns_challenge.go
@@ -6,7 +6,6 @@ import (
"fmt"
"os"
"strconv"
- "strings"
"time"
"github.com/go-acme/lego/v4/acme"
@@ -115,7 +114,7 @@ func (c *Challenge) Solve(authz acme.Authorization) error {
return err
}
- info := GetChallengeInfo(authz.Identifier.Value, keyAuth)
+ fqdn, value := GetRecord(authz.Identifier.Value, keyAuth)
var timeout, interval time.Duration
switch provider := c.provider.(type) {
@@ -125,12 +124,12 @@ func (c *Challenge) Solve(authz acme.Authorization) error {
timeout, interval = DefaultPropagationTimeout, DefaultPollingInterval
}
- log.Infof("[%s] acme: Checking DNS record propagation. [nameservers=%s]", domain, strings.Join(recursiveNameservers, ","))
+ log.Infof("[%s] acme: Checking DNS record propagation using %+v", domain, recursiveNameservers)
time.Sleep(interval)
err = wait.For("propagation", timeout, interval, func() (bool, error) {
- stop, errP := c.preCheck.call(domain, info.EffectiveFQDN, info.Value)
+ stop, errP := c.preCheck.call(domain, fqdn, value)
if !stop || errP != nil {
log.Infof("[%s] acme: Waiting for DNS record propagation.", domain)
}
@@ -173,67 +172,19 @@ type sequential interface {
}
// GetRecord returns a DNS record which will fulfill the `dns-01` challenge.
-// Deprecated: use GetChallengeInfo instead.
func GetRecord(domain, keyAuth string) (fqdn, value string) {
- info := GetChallengeInfo(domain, keyAuth)
-
- return info.EffectiveFQDN, info.Value
-}
-
-// ChallengeInfo contains the information use to create the TXT record.
-type ChallengeInfo struct {
- // FQDN is the full-qualified challenge domain (i.e. `_acme-challenge.[domain].`)
- FQDN string
-
- // EffectiveFQDN contains the resulting FQDN after the CNAMEs resolutions.
- EffectiveFQDN string
-
- // Value contains the value for the TXT record.
- Value string
-}
-
-// GetChallengeInfo returns information used to create a DNS record which will fulfill the `dns-01` challenge.
-func GetChallengeInfo(domain, keyAuth string) ChallengeInfo {
keyAuthShaBytes := sha256.Sum256([]byte(keyAuth))
// base64URL encoding without padding
- value := base64.RawURLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size])
+ value = base64.RawURLEncoding.EncodeToString(keyAuthShaBytes[:sha256.Size])
+ fqdn = fmt.Sprintf("_acme-challenge.%s.", domain)
- ok, _ := strconv.ParseBool(os.Getenv("LEGO_DISABLE_CNAME_SUPPORT"))
-
- return ChallengeInfo{
- Value: value,
- FQDN: getChallengeFQDN(domain, false),
- EffectiveFQDN: getChallengeFQDN(domain, !ok),
- }
-}
-
-func getChallengeFQDN(domain string, followCNAME bool) string {
- fqdn := fmt.Sprintf("_acme-challenge.%s.", domain)
-
- if !followCNAME {
- return fqdn
- }
-
- // recursion counter so it doesn't spin out of control
- for range 50 {
- // Keep following CNAMEs
+ if ok, _ := strconv.ParseBool(os.Getenv("LEGO_EXPERIMENTAL_CNAME_SUPPORT")); ok {
r, err := dnsQuery(fqdn, dns.TypeCNAME, recursiveNameservers, true)
-
- if err != nil || r.Rcode != dns.RcodeSuccess {
- // No more CNAME records to follow, exit
- break
+ // Check if the domain has CNAME then return that
+ if err == nil && r.Rcode == dns.RcodeSuccess {
+ fqdn = updateDomainWithCName(r, fqdn)
}
-
- // Check if the domain has CNAME then use that
- cname := updateDomainWithCName(r, fqdn)
- if cname == fqdn {
- break
- }
-
- log.Infof("Found CNAME entry for %q: %q", fqdn, cname)
-
- fqdn = cname
}
- return fqdn
+ return
}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/dns01/dns_challenge_manual.go b/vendor/github.com/go-acme/lego/v4/challenge/dns01/dns_challenge_manual.go
index c00d640..b2f5d41 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/dns01/dns_challenge_manual.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/dns01/dns_challenge_manual.go
@@ -8,7 +8,7 @@ import (
)
const (
- dnsTemplate = `%s %d IN TXT %q`
+ dnsTemplate = `%s %d IN TXT "%s"`
)
// DNSProviderManual is an implementation of the ChallengeProvider interface.
@@ -21,36 +21,33 @@ func NewDNSProviderManual() (*DNSProviderManual, error) {
// Present prints instructions for manually creating the TXT record.
func (*DNSProviderManual) Present(domain, token, keyAuth string) error {
- info := GetChallengeInfo(domain, keyAuth)
+ fqdn, value := GetRecord(domain, keyAuth)
- authZone, err := FindZoneByFqdn(info.EffectiveFQDN)
+ authZone, err := FindZoneByFqdn(fqdn)
if err != nil {
- return fmt.Errorf("manual: could not find zone: %w", err)
+ return err
}
fmt.Printf("lego: Please create the following TXT record in your %s zone:\n", authZone)
- fmt.Printf(dnsTemplate+"\n", info.EffectiveFQDN, DefaultTTL, info.Value)
+ fmt.Printf(dnsTemplate+"\n", fqdn, DefaultTTL, value)
fmt.Printf("lego: Press 'Enter' when you are done\n")
_, err = bufio.NewReader(os.Stdin).ReadBytes('\n')
- if err != nil {
- return fmt.Errorf("manual: %w", err)
- }
- return nil
+ return err
}
// CleanUp prints instructions for manually removing the TXT record.
func (*DNSProviderManual) CleanUp(domain, token, keyAuth string) error {
- info := GetChallengeInfo(domain, keyAuth)
+ fqdn, _ := GetRecord(domain, keyAuth)
- authZone, err := FindZoneByFqdn(info.EffectiveFQDN)
+ authZone, err := FindZoneByFqdn(fqdn)
if err != nil {
- return fmt.Errorf("manual: could not find zone: %w", err)
+ return err
}
fmt.Printf("lego: You can now remove this TXT record from your %s zone:\n", authZone)
- fmt.Printf(dnsTemplate+"\n", info.EffectiveFQDN, DefaultTTL, "...")
+ fmt.Printf(dnsTemplate+"\n", fqdn, DefaultTTL, "...")
return nil
}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/dns01/domain.go b/vendor/github.com/go-acme/lego/v4/challenge/dns01/domain.go
deleted file mode 100644
index e9b0cec..0000000
--- a/vendor/github.com/go-acme/lego/v4/challenge/dns01/domain.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package dns01
-
-import (
- "fmt"
- "strings"
-
- "github.com/miekg/dns"
-)
-
-// ExtractSubDomain extracts the subdomain part from a domain and a zone.
-func ExtractSubDomain(domain, zone string) (string, error) {
- canonDomain := dns.Fqdn(domain)
- canonZone := dns.Fqdn(zone)
-
- if canonDomain == canonZone {
- return "", fmt.Errorf("no subdomain because the domain and the zone are identical: %s", canonDomain)
- }
-
- if !dns.IsSubDomain(canonZone, canonDomain) {
- return "", fmt.Errorf("%s is not a subdomain of %s", canonDomain, canonZone)
- }
-
- return strings.TrimSuffix(canonDomain, "."+canonZone), nil
-}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver.go b/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver.go
index a8d678a..a6947e9 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver.go
@@ -4,9 +4,6 @@ import (
"errors"
"fmt"
"net"
- "os"
- "slices"
- "strconv"
"strings"
"sync"
"time"
@@ -16,7 +13,13 @@ import (
const defaultResolvConf = "/etc/resolv.conf"
-var fqdnSoaCache = &sync.Map{}
+// dnsTimeout is used to override the default DNS timeout of 10 seconds.
+var dnsTimeout = 10 * time.Second
+
+var (
+ fqdnSoaCache = map[string]*soaCacheEntry{}
+ muFqdnSoaCache sync.Mutex
+)
var defaultNameservers = []string{
"google-public-dns-a.google.com:53",
@@ -48,11 +51,9 @@ func (cache *soaCacheEntry) isExpired() bool {
// ClearFqdnCache clears the cache of fqdn to zone mappings. Primarily used in testing.
func ClearFqdnCache() {
- // TODO(ldez): use `fqdnSoaCache.Clear()` when updating to go1.23
- fqdnSoaCache.Range(func(k, v any) bool {
- fqdnSoaCache.Delete(k)
- return true
- })
+ muFqdnSoaCache.Lock()
+ fqdnSoaCache = map[string]*soaCacheEntry{}
+ muFqdnSoaCache.Unlock()
}
func AddDNSTimeout(timeout time.Duration) ChallengeOption {
@@ -98,12 +99,12 @@ func lookupNameservers(fqdn string) ([]string, error) {
zone, err := FindZoneByFqdn(fqdn)
if err != nil {
- return nil, fmt.Errorf("could not find zone: %w", err)
+ return nil, fmt.Errorf("could not determine the zone: %w", err)
}
r, err := dnsQuery(zone, dns.TypeNS, recursiveNameservers, true)
if err != nil {
- return nil, fmt.Errorf("NS call failed: %w", err)
+ return nil, err
}
for _, rr := range r.Answer {
@@ -115,8 +116,7 @@ func lookupNameservers(fqdn string) ([]string, error) {
if len(authoritativeNss) > 0 {
return authoritativeNss, nil
}
-
- return nil, fmt.Errorf("[zone=%s] could not determine authoritative nameservers", zone)
+ return nil, errors.New("could not determine authoritative nameservers")
}
// FindPrimaryNsByFqdn determines the primary nameserver of the zone apex for the given fqdn
@@ -130,7 +130,7 @@ func FindPrimaryNsByFqdn(fqdn string) (string, error) {
func FindPrimaryNsByFqdnCustom(fqdn string, nameservers []string) (string, error) {
soa, err := lookupSoaByFqdn(fqdn, nameservers)
if err != nil {
- return "", fmt.Errorf("[fqdn=%s] %w", fqdn, err)
+ return "", err
}
return soa.primaryNs, nil
}
@@ -146,19 +146,18 @@ func FindZoneByFqdn(fqdn string) (string, error) {
func FindZoneByFqdnCustom(fqdn string, nameservers []string) (string, error) {
soa, err := lookupSoaByFqdn(fqdn, nameservers)
if err != nil {
- return "", fmt.Errorf("[fqdn=%s] %w", fqdn, err)
+ return "", err
}
return soa.zone, nil
}
func lookupSoaByFqdn(fqdn string, nameservers []string) (*soaCacheEntry, error) {
+ muFqdnSoaCache.Lock()
+ defer muFqdnSoaCache.Unlock()
+
// Do we have it cached and is it still fresh?
- entAny, ok := fqdnSoaCache.Load(fqdn)
- if ok && entAny != nil {
- ent, ok1 := entAny.(*soaCacheEntry)
- if ok1 && !ent.isExpired() {
- return ent, nil
- }
+ if ent := fqdnSoaCache[fqdn]; ent != nil && !ent.isExpired() {
+ return ent, nil
}
ent, err := fetchSoaByFqdn(fqdn, nameservers)
@@ -166,42 +165,41 @@ func lookupSoaByFqdn(fqdn string, nameservers []string) (*soaCacheEntry, error)
return nil, err
}
- fqdnSoaCache.Store(fqdn, ent)
-
+ fqdnSoaCache[fqdn] = ent
return ent, nil
}
func fetchSoaByFqdn(fqdn string, nameservers []string) (*soaCacheEntry, error) {
var err error
- var r *dns.Msg
+ var in *dns.Msg
labelIndexes := dns.Split(fqdn)
for _, index := range labelIndexes {
domain := fqdn[index:]
- r, err = dnsQuery(domain, dns.TypeSOA, nameservers, true)
+ in, err = dnsQuery(domain, dns.TypeSOA, nameservers, true)
if err != nil {
continue
}
- if r == nil {
+ if in == nil {
continue
}
- switch r.Rcode {
+ switch in.Rcode {
case dns.RcodeSuccess:
// Check if we got a SOA RR in the answer section
- if len(r.Answer) == 0 {
+ if len(in.Answer) == 0 {
continue
}
// CNAME records cannot/should not exist at the root of a zone.
// So we skip a domain when a CNAME is found.
- if dnsMsgContainsCNAME(r) {
+ if dnsMsgContainsCNAME(in) {
continue
}
- for _, ans := range r.Answer {
+ for _, ans := range in.Answer {
if soa, ok := ans.(*dns.SOA); ok {
return newSoaCacheEntry(soa), nil
}
@@ -210,46 +208,36 @@ func fetchSoaByFqdn(fqdn string, nameservers []string) (*soaCacheEntry, error) {
// NXDOMAIN
default:
// Any response code other than NOERROR and NXDOMAIN is treated as error
- return nil, &DNSError{Message: fmt.Sprintf("unexpected response for '%s'", domain), MsgOut: r}
+ return nil, fmt.Errorf("unexpected response code '%s' for %s", dns.RcodeToString[in.Rcode], domain)
}
}
- return nil, &DNSError{Message: fmt.Sprintf("could not find the start of authority for '%s'", fqdn), MsgOut: r, Err: err}
+ return nil, fmt.Errorf("could not find the start of authority for %s%s", fqdn, formatDNSError(in, err))
}
// dnsMsgContainsCNAME checks for a CNAME answer in msg.
func dnsMsgContainsCNAME(msg *dns.Msg) bool {
- return slices.ContainsFunc(msg.Answer, func(rr dns.RR) bool {
- _, ok := rr.(*dns.CNAME)
- return ok
- })
+ for _, ans := range msg.Answer {
+ if _, ok := ans.(*dns.CNAME); ok {
+ return true
+ }
+ }
+ return false
}
func dnsQuery(fqdn string, rtype uint16, nameservers []string, recursive bool) (*dns.Msg, error) {
m := createDNSMsg(fqdn, rtype, recursive)
- if len(nameservers) == 0 {
- return nil, &DNSError{Message: "empty list of nameservers"}
- }
-
- var r *dns.Msg
+ var in *dns.Msg
var err error
- var errAll error
for _, ns := range nameservers {
- r, err = sendDNSQuery(m, ns)
- if err == nil && len(r.Answer) > 0 {
+ in, err = sendDNSQuery(m, ns)
+ if err == nil && len(in.Answer) > 0 {
break
}
-
- errAll = errors.Join(errAll, err)
}
-
- if err != nil {
- return r, errAll
- }
-
- return r, nil
+ return in, err
}
func createDNSMsg(fqdn string, rtype uint16, recursive bool) *dns.Msg {
@@ -265,84 +253,32 @@ func createDNSMsg(fqdn string, rtype uint16, recursive bool) *dns.Msg {
}
func sendDNSQuery(m *dns.Msg, ns string) (*dns.Msg, error) {
- if ok, _ := strconv.ParseBool(os.Getenv("LEGO_EXPERIMENTAL_DNS_TCP_ONLY")); ok {
- tcp := &dns.Client{Net: "tcp", Timeout: dnsTimeout}
- r, _, err := tcp.Exchange(m, ns)
- if err != nil {
- return r, &DNSError{Message: "DNS call error", MsgIn: m, NS: ns, Err: err}
- }
+ udp := &dns.Client{Net: "udp", Timeout: dnsTimeout}
+ in, _, err := udp.Exchange(m, ns)
- return r, nil
+ if in != nil && in.Truncated {
+ tcp := &dns.Client{Net: "tcp", Timeout: dnsTimeout}
+ // If the TCP request succeeds, the err will reset to nil
+ in, _, err = tcp.Exchange(m, ns)
}
- udp := &dns.Client{Net: "udp", Timeout: dnsTimeout}
- r, _, err := udp.Exchange(m, ns)
+ return in, err
+}
- if r != nil && r.Truncated {
- tcp := &dns.Client{Net: "tcp", Timeout: dnsTimeout}
- // If the TCP request succeeds, the "err" will reset to nil
- r, _, err = tcp.Exchange(m, ns)
+func formatDNSError(msg *dns.Msg, err error) string {
+ var parts []string
+
+ if msg != nil {
+ parts = append(parts, dns.RcodeToString[msg.Rcode])
}
if err != nil {
- return r, &DNSError{Message: "DNS call error", MsgIn: m, NS: ns, Err: err}
+ parts = append(parts, err.Error())
}
- return r, nil
-}
-
-// DNSError error related to DNS calls.
-type DNSError struct {
- Message string
- NS string
- MsgIn *dns.Msg
- MsgOut *dns.Msg
- Err error
-}
-
-func (d *DNSError) Error() string {
- var details []string
- if d.NS != "" {
- details = append(details, "ns="+d.NS)
- }
-
- if d.MsgIn != nil && len(d.MsgIn.Question) > 0 {
- details = append(details, fmt.Sprintf("question='%s'", formatQuestions(d.MsgIn.Question)))
- }
-
- if d.MsgOut != nil {
- if d.MsgIn == nil || len(d.MsgIn.Question) == 0 {
- details = append(details, fmt.Sprintf("question='%s'", formatQuestions(d.MsgOut.Question)))
- }
-
- details = append(details, "code="+dns.RcodeToString[d.MsgOut.Rcode])
- }
-
- msg := "DNS error"
- if d.Message != "" {
- msg = d.Message
- }
-
- if d.Err != nil {
- msg += ": " + d.Err.Error()
- }
-
- if len(details) > 0 {
- msg += " [" + strings.Join(details, ", ") + "]"
- }
-
- return msg
-}
-
-func (d *DNSError) Unwrap() error {
- return d.Err
-}
-
-func formatQuestions(questions []dns.Question) string {
- var parts []string
- for _, question := range questions {
- parts = append(parts, strings.ReplaceAll(strings.TrimPrefix(question.String(), ";"), "\t", " "))
- }
-
- return strings.Join(parts, ";")
+ if len(parts) > 0 {
+ return ": " + strings.Join(parts, " ")
+ }
+
+ return ""
}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver_unix.go b/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver_unix.go
deleted file mode 100644
index a3cbad1..0000000
--- a/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver_unix.go
+++ /dev/null
@@ -1,8 +0,0 @@
-//go:build !windows
-
-package dns01
-
-import "time"
-
-// dnsTimeout is used to override the default DNS timeout of 10 seconds.
-var dnsTimeout = 10 * time.Second
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver_windows.go b/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver_windows.go
deleted file mode 100644
index 739e54a..0000000
--- a/vendor/github.com/go-acme/lego/v4/challenge/dns01/nameserver_windows.go
+++ /dev/null
@@ -1,8 +0,0 @@
-//go:build windows
-
-package dns01
-
-import "time"
-
-// dnsTimeout is used to override the default DNS timeout of 20 seconds.
-var dnsTimeout = 20 * time.Second
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/dns01/precheck.go b/vendor/github.com/go-acme/lego/v4/challenge/dns01/precheck.go
index 706e8db..f65dfb5 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/dns01/precheck.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/dns01/precheck.go
@@ -4,7 +4,6 @@ import (
"fmt"
"net"
"strings"
- "time"
"github.com/miekg/dns"
)
@@ -24,52 +23,23 @@ func WrapPreCheck(wrap WrapPreCheckFunc) ChallengeOption {
}
}
-// DisableCompletePropagationRequirement obsolete.
-// Deprecated: use DisableAuthoritativeNssPropagationRequirement instead.
func DisableCompletePropagationRequirement() ChallengeOption {
- return DisableAuthoritativeNssPropagationRequirement()
-}
-
-func DisableAuthoritativeNssPropagationRequirement() ChallengeOption {
return func(chlg *Challenge) error {
- chlg.preCheck.requireAuthoritativeNssPropagation = false
+ chlg.preCheck.requireCompletePropagation = false
return nil
}
}
-func RecursiveNSsPropagationRequirement() ChallengeOption {
- return func(chlg *Challenge) error {
- chlg.preCheck.requireRecursiveNssPropagation = true
- return nil
- }
-}
-
-func PropagationWait(wait time.Duration, skipCheck bool) ChallengeOption {
- return WrapPreCheck(func(domain, fqdn, value string, check PreCheckFunc) (bool, error) {
- time.Sleep(wait)
-
- if skipCheck {
- return true, nil
- }
-
- return check(fqdn, value)
- })
-}
-
type preCheck struct {
// checks DNS propagation before notifying ACME that the DNS challenge is ready.
checkFunc WrapPreCheckFunc
-
// require the TXT record to be propagated to all authoritative name servers
- requireAuthoritativeNssPropagation bool
-
- // require the TXT record to be propagated to all recursive name servers
- requireRecursiveNssPropagation bool
+ requireCompletePropagation bool
}
func newPreCheck() preCheck {
return preCheck{
- requireAuthoritativeNssPropagation: true,
+ requireCompletePropagation: true,
}
}
@@ -83,48 +53,32 @@ func (p preCheck) call(domain, fqdn, value string) (bool, error) {
// checkDNSPropagation checks if the expected TXT record has been propagated to all authoritative nameservers.
func (p preCheck) checkDNSPropagation(fqdn, value string) (bool, error) {
- // Initial attempt to resolve at the recursive NS (require to get CNAME)
+ // Initial attempt to resolve at the recursive NS
r, err := dnsQuery(fqdn, dns.TypeTXT, recursiveNameservers, true)
if err != nil {
- return false, fmt.Errorf("initial recursive nameserver: %w", err)
+ return false, err
+ }
+
+ if !p.requireCompletePropagation {
+ return true, nil
}
if r.Rcode == dns.RcodeSuccess {
fqdn = updateDomainWithCName(r, fqdn)
}
- if p.requireRecursiveNssPropagation {
- _, err = checkNameserversPropagation(fqdn, value, recursiveNameservers, false)
- if err != nil {
- return false, fmt.Errorf("recursive nameservers: %w", err)
- }
- }
-
- if !p.requireAuthoritativeNssPropagation {
- return true, nil
- }
-
authoritativeNss, err := lookupNameservers(fqdn)
if err != nil {
return false, err
}
- found, err := checkNameserversPropagation(fqdn, value, authoritativeNss, true)
- if err != nil {
- return found, fmt.Errorf("authoritative nameservers: %w", err)
- }
-
- return found, nil
+ return checkAuthoritativeNss(fqdn, value, authoritativeNss)
}
-// checkNameserversPropagation queries each of the given nameservers for the expected TXT record.
-func checkNameserversPropagation(fqdn, value string, nameservers []string, addPort bool) (bool, error) {
+// checkAuthoritativeNss queries each of the given nameservers for the expected TXT record.
+func checkAuthoritativeNss(fqdn, value string, nameservers []string) (bool, error) {
for _, ns := range nameservers {
- if addPort {
- ns = net.JoinHostPort(ns, "53")
- }
-
- r, err := dnsQuery(fqdn, dns.TypeTXT, []string{ns}, false)
+ r, err := dnsQuery(fqdn, dns.TypeTXT, []string{net.JoinHostPort(ns, "53")}, false)
if err != nil {
return false, err
}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/http01/domain_matcher.go b/vendor/github.com/go-acme/lego/v4/challenge/http01/domain_matcher.go
index c31aeed..6ac6eab 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/http01/domain_matcher.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/http01/domain_matcher.go
@@ -3,7 +3,6 @@ package http01
import (
"fmt"
"net/http"
- "net/netip"
"strings"
)
@@ -24,17 +23,14 @@ import (
// RFC7239 has standardized the different forwarding headers into a single header named Forwarded.
// The header value has a different format, so you should use forwardedMatcher
// when the http01.ProviderServer operates behind a RFC7239 compatible proxy.
-// https://www.rfc-editor.org/rfc/rfc7239.html
+// https://tools.ietf.org/html/rfc7239
//
// Note: RFC7239 also reminds us, "that an HTTP list [...] may be split over multiple header fields" (section 7.1),
// meaning that
-//
-// X-Header: a
-// X-Header: b
-//
+// X-Header: a
+// X-Header: b
// is equal to
-//
-// X-Header: a, b
+// X-Header: a, b
//
// All matcher implementations (explicitly not excluding arbitraryMatcher!)
// have in common that they only match against the first value in such lists.
@@ -55,10 +51,10 @@ func (m *hostMatcher) name() string {
}
func (m *hostMatcher) matches(r *http.Request, domain string) bool {
- return matchDomain(r.Host, domain)
+ return strings.HasPrefix(r.Host, domain)
}
-// arbitraryMatcher checks whether the specified (*net/http.Request).Header value starts with a domain name.
+// hostMatcher checks whether the specified (*net/http.Request).Header value starts with a domain name.
type arbitraryMatcher string
func (m arbitraryMatcher) name() string {
@@ -66,11 +62,11 @@ func (m arbitraryMatcher) name() string {
}
func (m arbitraryMatcher) matches(r *http.Request, domain string) bool {
- return matchDomain(r.Header.Get(m.name()), domain)
+ return strings.HasPrefix(r.Header.Get(m.name()), domain)
}
// forwardedMatcher checks whether the Forwarded header contains a "host" element starting with a domain name.
-// See https://www.rfc-editor.org/rfc/rfc7239.html for details.
+// See https://tools.ietf.org/html/rfc7239 for details.
type forwardedMatcher struct{}
func (m *forwardedMatcher) name() string {
@@ -88,7 +84,7 @@ func (m *forwardedMatcher) matches(r *http.Request, domain string) bool {
}
host := fwds[0]["host"]
- return matchDomain(host, domain)
+ return strings.HasPrefix(host, domain)
}
// parsing requires some form of state machine.
@@ -134,7 +130,9 @@ func parseForwardedHeader(s string) (elements []map[string]string, err error) {
case r == ',': // end of forwarded-element
if key != "" {
- val = s[pos:i]
+ if val == "" {
+ val = s[pos:i]
+ }
cur[key] = val
}
elements = append(elements, cur)
@@ -184,12 +182,3 @@ func skipWS(s string, i int) int {
func isWS(r rune) bool {
return strings.ContainsRune(" \t\v\r\n", r)
}
-
-func matchDomain(src, domain string) bool {
- addr, err := netip.ParseAddr(domain)
- if err == nil && addr.Is6() {
- domain = "[" + domain + "]"
- }
-
- return strings.HasPrefix(src, domain)
-}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/http01/http_challenge.go b/vendor/github.com/go-acme/lego/v4/challenge/http01/http_challenge.go
index 79dbfb4..f23e483 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/http01/http_challenge.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/http01/http_challenge.go
@@ -2,7 +2,6 @@ package http01
import (
"fmt"
- "time"
"github.com/go-acme/lego/v4/acme"
"github.com/go-acme/lego/v4/acme/api"
@@ -12,16 +11,6 @@ import (
type ValidateFunc func(core *api.Core, domain string, chlng acme.Challenge) error
-type ChallengeOption func(*Challenge) error
-
-// SetDelay sets a delay between the start of the HTTP server and the challenge validation.
-func SetDelay(delay time.Duration) ChallengeOption {
- return func(chlg *Challenge) error {
- chlg.delay = delay
- return nil
- }
-}
-
// ChallengePath returns the URL path for the `http-01` challenge.
func ChallengePath(token string) string {
return "/.well-known/acme-challenge/" + token
@@ -31,24 +20,14 @@ type Challenge struct {
core *api.Core
validate ValidateFunc
provider challenge.Provider
- delay time.Duration
}
-func NewChallenge(core *api.Core, validate ValidateFunc, provider challenge.Provider, opts ...ChallengeOption) *Challenge {
- chlg := &Challenge{
+func NewChallenge(core *api.Core, validate ValidateFunc, provider challenge.Provider) *Challenge {
+ return &Challenge{
core: core,
validate: validate,
provider: provider,
}
-
- for _, opt := range opts {
- err := opt(chlg)
- if err != nil {
- log.Infof("challenge option error: %v", err)
- }
- }
-
- return chlg
}
func (c *Challenge) SetProvider(provider challenge.Provider) {
@@ -81,10 +60,6 @@ func (c *Challenge) Solve(authz acme.Authorization) error {
}
}()
- if c.delay > 0 {
- time.Sleep(c.delay)
- }
-
chlng.KeyAuthorization = keyAuth
return c.validate(c.core, domain, chlng)
}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/http01/http_challenge_server.go b/vendor/github.com/go-acme/lego/v4/challenge/http01/http_challenge_server.go
index 009271c..84a3353 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/http01/http_challenge_server.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/http01/http_challenge_server.go
@@ -2,11 +2,9 @@ package http01
import (
"fmt"
- "io/fs"
"net"
"net/http"
"net/textproto"
- "os"
"strings"
"github.com/go-acme/lego/v4/log"
@@ -16,11 +14,8 @@ import (
// It may be instantiated without using the NewProviderServer function if
// you want only to use the default values.
type ProviderServer struct {
- address string
- network string // must be valid argument to net.Listen
-
- socketMode fs.FileMode
-
+ iface string
+ port string
matcher domainMatcher
done chan bool
listener net.Listener
@@ -34,36 +29,24 @@ func NewProviderServer(iface, port string) *ProviderServer {
port = "80"
}
- return &ProviderServer{network: "tcp", address: net.JoinHostPort(iface, port), matcher: &hostMatcher{}}
-}
-
-func NewUnixProviderServer(socketPath string, mode fs.FileMode) *ProviderServer {
- return &ProviderServer{network: "unix", address: socketPath, socketMode: mode, matcher: &hostMatcher{}}
+ return &ProviderServer{iface: iface, port: port, matcher: &hostMatcher{}}
}
// Present starts a web server and makes the token available at `ChallengePath(token)` for web requests.
func (s *ProviderServer) Present(domain, token, keyAuth string) error {
var err error
- s.listener, err = net.Listen(s.network, s.GetAddress())
+ s.listener, err = net.Listen("tcp", s.GetAddress())
if err != nil {
return fmt.Errorf("could not start HTTP server for challenge: %w", err)
}
- if s.network == "unix" {
- if err = os.Chmod(s.address, s.socketMode); err != nil {
- return fmt.Errorf("chmod %s: %w", s.address, err)
- }
- }
-
s.done = make(chan bool)
-
go s.serve(domain, token, keyAuth)
-
return nil
}
func (s *ProviderServer) GetAddress() string {
- return s.address
+ return net.JoinHostPort(s.iface, s.port)
}
// CleanUp closes the HTTP server and removes the token from `ChallengePath(token)`.
@@ -71,11 +54,8 @@ func (s *ProviderServer) CleanUp(domain, token, keyAuth string) error {
if s.listener == nil {
return nil
}
-
s.listener.Close()
-
<-s.done
-
return nil
}
@@ -89,7 +69,7 @@ func (s *ProviderServer) CleanUp(domain, token, keyAuth string) error {
//
// The exact behavior depends on the value of headerName:
// - "" (the empty string) and "Host" will restore the default and only check the Host header
-// - "Forwarded" will look for a Forwarded header, and inspect it according to https://www.rfc-editor.org/rfc/rfc7239.html
+// - "Forwarded" will look for a Forwarded header, and inspect it according to https://tools.ietf.org/html/rfc7239
// - any other value will check the header value with the same name.
func (s *ProviderServer) SetProxyHeader(headerName string) {
switch h := textproto.CanonicalMIMEHeaderKey(headerName); h {
@@ -105,30 +85,26 @@ func (s *ProviderServer) SetProxyHeader(headerName string) {
func (s *ProviderServer) serve(domain, token, keyAuth string) {
path := ChallengePath(token)
- // The incoming request will be validated to prevent DNS rebind attacks.
+ // The incoming request must will be validated to prevent DNS rebind attacks.
// We only respond with the keyAuth, when we're receiving a GET requests with
// the "Host" header matching the domain (the latter is configurable though SetProxyHeader).
mux := http.NewServeMux()
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet && s.matcher.matches(r, domain) {
w.Header().Set("Content-Type", "text/plain")
-
_, err := w.Write([]byte(keyAuth))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
-
log.Infof("[%s] Served key authentication", domain)
- return
- }
-
- log.Warnf("Received request for domain %s with method %s but the domain did not match any challenge. Please ensure you are passing the %s header properly.", r.Host, r.Method, s.matcher.name())
-
- _, err := w.Write([]byte("TEST"))
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
+ } else {
+ log.Warnf("Received request for domain %s with method %s but the domain did not match any challenge. Please ensure your are passing the %s header properly.", r.Host, r.Method, s.matcher.name())
+ _, err := w.Write([]byte("TEST"))
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
}
})
@@ -142,6 +118,5 @@ func (s *ProviderServer) serve(domain, token, keyAuth string) {
if err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
log.Println(err)
}
-
s.done <- true
}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/resolver/errors.go b/vendor/github.com/go-acme/lego/v4/challenge/resolver/errors.go
index 94ccbd7..e9da1eb 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/resolver/errors.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/resolver/errors.go
@@ -19,7 +19,7 @@ func (e obtainError) Error() string {
sort.Strings(domains)
for _, domain := range domains {
- _, _ = fmt.Fprintf(buffer, "[%s] %s\n", domain, e[domain])
+ buffer.WriteString(fmt.Sprintf("[%s] %s\n", domain, e[domain]))
}
return buffer.String()
}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/resolver/prober.go b/vendor/github.com/go-acme/lego/v4/challenge/resolver/prober.go
index 021facb..42c2029 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/resolver/prober.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/resolver/prober.go
@@ -128,7 +128,7 @@ func sequentialSolve(authSolvers []*selectedAuthSolver, failures obtainError) {
}
func parallelSolve(authSolvers []*selectedAuthSolver, failures obtainError) {
- // For all valid preSolvers, first submit the challenges, so they have max time to propagate
+ // For all valid preSolvers, first submit the challenges so they have max time to propagate
for _, authSolver := range authSolvers {
authz := authSolver.authz
if solvr, ok := authSolver.solver.(preSolver); ok {
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/resolver/solver_manager.go b/vendor/github.com/go-acme/lego/v4/challenge/resolver/solver_manager.go
index dcde3a3..07d9db5 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/resolver/solver_manager.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/resolver/solver_manager.go
@@ -1,6 +1,7 @@
package resolver
import (
+ "context"
"errors"
"fmt"
"sort"
@@ -36,14 +37,14 @@ func NewSolversManager(core *api.Core) *SolverManager {
}
// SetHTTP01Provider specifies a custom provider p that can solve the given HTTP-01 challenge.
-func (c *SolverManager) SetHTTP01Provider(p challenge.Provider, opts ...http01.ChallengeOption) error {
- c.solvers[challenge.HTTP01] = http01.NewChallenge(c.core, validate, p, opts...)
+func (c *SolverManager) SetHTTP01Provider(p challenge.Provider) error {
+ c.solvers[challenge.HTTP01] = http01.NewChallenge(c.core, validate, p)
return nil
}
// SetTLSALPN01Provider specifies a custom provider p that can solve the given TLS-ALPN-01 challenge.
-func (c *SolverManager) SetTLSALPN01Provider(p challenge.Provider, opts ...tlsalpn01.ChallengeOption) error {
- c.solvers[challenge.TLSALPN01] = tlsalpn01.NewChallenge(c.core, validate, p, opts...)
+func (c *SolverManager) SetTLSALPN01Provider(p challenge.Provider) error {
+ c.solvers[challenge.TLSALPN01] = tlsalpn01.NewChallenge(c.core, validate, p)
return nil
}
@@ -53,7 +54,7 @@ func (c *SolverManager) SetDNS01Provider(p challenge.Provider, opts ...dns01.Cha
return nil
}
-// Remove removes a challenge type from the available solvers.
+// Remove Remove a challenge type from the available solvers.
func (c *SolverManager) Remove(chlgType challenge.Type) {
delete(c.solvers, chlgType)
}
@@ -106,17 +107,21 @@ func validate(core *api.Core, domain string, chlg acme.Challenge) error {
bo.MaxInterval = 10 * initialInterval
bo.MaxElapsedTime = 100 * initialInterval
+ ctx, cancel := context.WithCancel(context.Background())
+
// After the path is sent, the ACME server will access our server.
// Repeatedly check the server for an updated status on our request.
operation := func() error {
authz, err := core.Authorizations.Get(chlng.AuthorizationURL)
if err != nil {
- return backoff.Permanent(err)
+ cancel()
+ return err
}
valid, err := checkAuthorizationStatus(authz)
if err != nil {
- return backoff.Permanent(err)
+ cancel()
+ return err
}
if valid {
@@ -124,10 +129,10 @@ func validate(core *api.Core, domain string, chlg acme.Challenge) error {
return nil
}
- return fmt.Errorf("the server didn't respond to our request (status=%s)", authz.Status)
+ return errors.New("the server didn't respond to our request")
}
- return backoff.Retry(operation, bo)
+ return backoff.Retry(operation, backoff.WithContext(bo, ctx))
}
func checkChallengeStatus(chlng acme.ExtendedChallenge) (bool, error) {
@@ -137,9 +142,9 @@ func checkChallengeStatus(chlng acme.ExtendedChallenge) (bool, error) {
case acme.StatusPending, acme.StatusProcessing:
return false, nil
case acme.StatusInvalid:
- return false, fmt.Errorf("invalid challenge: %w", chlng.Err())
+ return false, chlng.Error
default:
- return false, fmt.Errorf("the server returned an unexpected challenge status: %s", chlng.Status)
+ return false, errors.New("the server returned an unexpected state")
}
}
@@ -154,11 +159,11 @@ func checkAuthorizationStatus(authz acme.Authorization) (bool, error) {
case acme.StatusInvalid:
for _, chlg := range authz.Challenges {
if chlg.Status == acme.StatusInvalid && chlg.Error != nil {
- return false, fmt.Errorf("invalid authorization: %w", chlg.Err())
+ return false, chlg.Error
}
}
- return false, errors.New("invalid authorization")
+ return false, fmt.Errorf("the authorization state %s", authz.Status)
default:
- return false, fmt.Errorf("the server returned an unexpected authorization status: %s", authz.Status)
+ return false, errors.New("the server returned an unexpected state")
}
}
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/tlsalpn01/tls_alpn_challenge.go b/vendor/github.com/go-acme/lego/v4/challenge/tlsalpn01/tls_alpn_challenge.go
index 559e1f9..7eb02cf 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/tlsalpn01/tls_alpn_challenge.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/tlsalpn01/tls_alpn_challenge.go
@@ -7,7 +7,6 @@ import (
"crypto/x509/pkix"
"encoding/asn1"
"fmt"
- "time"
"github.com/go-acme/lego/v4/acme"
"github.com/go-acme/lego/v4/acme/api"
@@ -17,43 +16,23 @@ import (
)
// idPeAcmeIdentifierV1 is the SMI Security for PKIX Certification Extension OID referencing the ACME extension.
-// Reference: https://www.rfc-editor.org/rfc/rfc8737.html#section-6.1
+// Reference: https://tools.ietf.org/html/draft-ietf-acme-tls-alpn-07#section-6.1
var idPeAcmeIdentifierV1 = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 31}
type ValidateFunc func(core *api.Core, domain string, chlng acme.Challenge) error
-type ChallengeOption func(*Challenge) error
-
-// SetDelay sets a delay between the start of the TLS listener and the challenge validation.
-func SetDelay(delay time.Duration) ChallengeOption {
- return func(chlg *Challenge) error {
- chlg.delay = delay
- return nil
- }
-}
-
type Challenge struct {
core *api.Core
validate ValidateFunc
provider challenge.Provider
- delay time.Duration
}
-func NewChallenge(core *api.Core, validate ValidateFunc, provider challenge.Provider, opts ...ChallengeOption) *Challenge {
- chlg := &Challenge{
+func NewChallenge(core *api.Core, validate ValidateFunc, provider challenge.Provider) *Challenge {
+ return &Challenge{
core: core,
validate: validate,
provider: provider,
}
-
- for _, opt := range opts {
- err := opt(chlg)
- if err != nil {
- log.Infof("challenge option error: %v", err)
- }
- }
-
- return chlg
}
func (c *Challenge) SetProvider(provider challenge.Provider) {
@@ -87,10 +66,6 @@ func (c *Challenge) Solve(authz acme.Authorization) error {
}
}()
- if c.delay > 0 {
- time.Sleep(c.delay)
- }
-
chlng.KeyAuthorization = keyAuth
return c.validate(c.core, domain, chlng)
}
@@ -108,7 +83,7 @@ func ChallengeBlocks(domain, keyAuth string) ([]byte, []byte, error) {
// Add the keyAuth digest as the acmeValidation-v1 extension
// (marked as critical such that it won't be used by non-ACME software).
- // Reference: https://www.rfc-editor.org/rfc/rfc8737.html#section-3
+ // Reference: https://tools.ietf.org/html/draft-ietf-acme-tls-alpn-07#section-3
extensions := []pkix.Extension{
{
Id: idPeAcmeIdentifierV1,
diff --git a/vendor/github.com/go-acme/lego/v4/challenge/tlsalpn01/tls_alpn_challenge_server.go b/vendor/github.com/go-acme/lego/v4/challenge/tlsalpn01/tls_alpn_challenge_server.go
index e5581b1..a49dd93 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/tlsalpn01/tls_alpn_challenge_server.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/tlsalpn01/tls_alpn_challenge_server.go
@@ -40,7 +40,7 @@ func (s *ProviderServer) GetAddress() string {
return net.JoinHostPort(s.iface, s.port)
}
-// Present generates a certificate with an SHA-256 digest of the keyAuth provided
+// Present generates a certificate with a SHA-256 digest of the keyAuth provided
// as the acmeValidation-v1 extension value to conform to the ACME-TLS-ALPN spec.
func (s *ProviderServer) Present(domain, token, keyAuth string) error {
if s.port == "" {
@@ -61,7 +61,7 @@ func (s *ProviderServer) Present(domain, token, keyAuth string) error {
// We must set that the `acme-tls/1` application level protocol is supported
// so that the protocol negotiation can succeed. Reference:
- // https://www.rfc-editor.org/rfc/rfc8737.html#section-6.2
+ // https://tools.ietf.org/html/draft-ietf-acme-tls-alpn-07#section-6.2
tlsConf.NextProtos = []string{ACMETLS1Protocol}
// Create the listener with the created tls.Config.
diff --git a/vendor/github.com/go-acme/lego/v4/lego/client.go b/vendor/github.com/go-acme/lego/v4/lego/client.go
index 1109e12..ef72a28 100644
--- a/vendor/github.com/go-acme/lego/v4/lego/client.go
+++ b/vendor/github.com/go-acme/lego/v4/lego/client.go
@@ -53,7 +53,7 @@ func NewClient(config *Config) (*Client, error) {
solversManager := resolver.NewSolversManager(core)
prober := resolver.NewProber(solversManager)
- certifier := certificate.NewCertifier(core, prober, certificate.CertifierOptions{KeyType: config.Certificate.KeyType, Timeout: config.Certificate.Timeout, OverallRequestLimit: config.Certificate.OverallRequestLimit})
+ certifier := certificate.NewCertifier(core, prober, certificate.CertifierOptions{KeyType: config.Certificate.KeyType, Timeout: config.Certificate.Timeout})
return &Client{
Certificate: certifier,
diff --git a/vendor/github.com/go-acme/lego/v4/lego/client_config.go b/vendor/github.com/go-acme/lego/v4/lego/client_config.go
index fdf1a55..90ad808 100644
--- a/vendor/github.com/go-acme/lego/v4/lego/client_config.go
+++ b/vendor/github.com/go-acme/lego/v4/lego/client_config.go
@@ -4,11 +4,10 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
+ "io/ioutil"
"net"
"net/http"
"os"
- "strconv"
- "strings"
"time"
"github.com/go-acme/lego/v4/certcrypto"
@@ -18,18 +17,13 @@ import (
const (
// caCertificatesEnvVar is the environment variable name that can be used to
// specify the path to PEM encoded CA Certificates that can be used to
- // authenticate an ACME server with an HTTPS certificate not issued by a CA in
+ // authenticate an ACME server with a HTTPS certificate not issued by a CA in
// the system-wide trusted root list.
- // Multiple file paths can be added by using os.PathListSeparator as a separator.
caCertificatesEnvVar = "LEGO_CA_CERTIFICATES"
- // caSystemCertPool is the environment variable name that can be used to define
- // if the certificates pool must use a copy of the system cert pool.
- caSystemCertPool = "LEGO_CA_SYSTEM_CERT_POOL"
-
// caServerNameEnvVar is the environment variable name that can be used to
// specify the CA server name that can be used to
- // authenticate an ACME server with an HTTPS certificate not issued by a CA in
+ // authenticate an ACME server with a HTTPS certificate not issued by a CA in
// the system-wide trusted root list.
caServerNameEnvVar = "LEGO_CA_SERVER_NAME"
@@ -61,9 +55,8 @@ func NewConfig(user registration.User) *Config {
}
type CertificateConfig struct {
- KeyType certcrypto.KeyType
- Timeout time.Duration
- OverallRequestLimit int
+ KeyType certcrypto.KeyType
+ Timeout time.Duration
}
// createDefaultHTTPClient Creates an HTTP client with a reasonable timeout value
@@ -89,60 +82,23 @@ func createDefaultHTTPClient() *http.Client {
}
// initCertPool creates a *x509.CertPool populated with the PEM certificates
-// found in the filepath specified in the caCertificatesEnvVar OS environment variable.
-// If the caCertificatesEnvVar is not set then initCertPool will return nil.
-// If there is an error creating a *x509.CertPool from the provided caCertificatesEnvVar value then initCertPool will panic.
-// If the caSystemCertPool is set to a "truthy value" (`1`, `t`, `T`, `TRUE`, `true`, `True`) then a copy of system cert pool will be used.
-// caSystemCertPool requires caCertificatesEnvVar to be set.
+// found in the filepath specified in the caCertificatesEnvVar OS environment
+// variable. If the caCertificatesEnvVar is not set then initCertPool will
+// return nil. If there is an error creating a *x509.CertPool from the provided
+// caCertificatesEnvVar value then initCertPool will panic.
func initCertPool() *x509.CertPool {
- customCACertsPath := os.Getenv(caCertificatesEnvVar)
- if customCACertsPath == "" {
- return nil
- }
-
- useSystemCertPool, _ := strconv.ParseBool(os.Getenv(caSystemCertPool))
-
- caCerts := strings.Split(customCACertsPath, string(os.PathListSeparator))
-
- certPool, err := CreateCertPool(caCerts, useSystemCertPool)
- if err != nil {
- panic(fmt.Sprintf("create certificates pool: %v", err))
- }
-
- return certPool
-}
-
-// CreateCertPool creates a *x509.CertPool populated with the PEM certificates.
-func CreateCertPool(caCerts []string, useSystemCertPool bool) (*x509.CertPool, error) {
- if len(caCerts) == 0 {
- return nil, nil
- }
-
- certPool := newCertPool(useSystemCertPool)
-
- for _, customPath := range caCerts {
- customCAs, err := os.ReadFile(customPath)
+ if customCACertsPath := os.Getenv(caCertificatesEnvVar); customCACertsPath != "" {
+ customCAs, err := ioutil.ReadFile(customCACertsPath)
if err != nil {
- return nil, fmt.Errorf("error reading %q: %w", customPath, err)
+ panic(fmt.Sprintf("error reading %s=%q: %v",
+ caCertificatesEnvVar, customCACertsPath, err))
}
-
+ certPool := x509.NewCertPool()
if ok := certPool.AppendCertsFromPEM(customCAs); !ok {
- return nil, fmt.Errorf("error creating x509 cert pool from %q: %w", customPath, err)
+ panic(fmt.Sprintf("error creating x509 cert pool from %s=%q: %v",
+ caCertificatesEnvVar, customCACertsPath, err))
}
+ return certPool
}
-
- return certPool, nil
-}
-
-func newCertPool(useSystemCertPool bool) *x509.CertPool {
- if !useSystemCertPool {
- return x509.NewCertPool()
- }
-
- pool, err := x509.SystemCertPool()
- if err == nil {
- return pool
- }
-
- return x509.NewCertPool()
+ return nil
}
diff --git a/vendor/github.com/go-acme/lego/v4/platform/config/env/env.go b/vendor/github.com/go-acme/lego/v4/platform/config/env/env.go
index 3fd1e3a..d6428b0 100644
--- a/vendor/github.com/go-acme/lego/v4/platform/config/env/env.go
+++ b/vendor/github.com/go-acme/lego/v4/platform/config/env/env.go
@@ -3,6 +3,7 @@ package env
import (
"errors"
"fmt"
+ "io/ioutil"
"os"
"strconv"
"strings"
@@ -54,6 +55,7 @@ func Get(names ...string) (map[string]string, error) {
// // LEGO_TWO=""
// env.GetWithFallback([]string{"LEGO_ONE", "LEGO_TWO"})
// // => error
+//
func GetWithFallback(groups ...[]string) (map[string]string, error) {
values := map[string]string{}
@@ -78,26 +80,15 @@ func GetWithFallback(groups ...[]string) (map[string]string, error) {
return values, nil
}
-func GetOneWithFallback[T any](main string, defaultValue T, fn func(string) (T, error), names ...string) T {
- v, _ := getOneWithFallback(main, names...)
-
- value, err := fn(v)
- if err != nil {
- return defaultValue
- }
-
- return value
-}
-
func getOneWithFallback(main string, names ...string) (string, string) {
value := GetOrFile(main)
- if value != "" {
+ if len(value) > 0 {
return value, main
}
for _, name := range names {
value := GetOrFile(name)
- if value != "" {
+ if len(value) > 0 {
return value, main
}
}
@@ -105,32 +96,43 @@ func getOneWithFallback(main string, names ...string) (string, string) {
return "", main
}
+// GetOrDefaultInt returns the given environment variable value as an integer.
+// Returns the default if the envvar cannot be coopered to an int, or is not found.
+func GetOrDefaultInt(envVar string, defaultValue int) int {
+ v, err := strconv.Atoi(GetOrFile(envVar))
+ if err != nil {
+ return defaultValue
+ }
+
+ return v
+}
+
+// GetOrDefaultSecond returns the given environment variable value as an time.Duration (second).
+// Returns the default if the envvar cannot be coopered to an int, or is not found.
+func GetOrDefaultSecond(envVar string, defaultValue time.Duration) time.Duration {
+ v := GetOrDefaultInt(envVar, -1)
+ if v < 0 {
+ return defaultValue
+ }
+
+ return time.Duration(v) * time.Second
+}
+
// GetOrDefaultString returns the given environment variable value as a string.
-// Returns the default if the env var cannot be found.
-func GetOrDefaultString(envVar string, defaultValue string) string {
- return getOrDefault(envVar, defaultValue, ParseString)
+// Returns the default if the envvar cannot be find.
+func GetOrDefaultString(envVar, defaultValue string) string {
+ v := GetOrFile(envVar)
+ if v == "" {
+ return defaultValue
+ }
+
+ return v
}
// GetOrDefaultBool returns the given environment variable value as a boolean.
-// Returns the default if the env var cannot be coopered to a boolean, or is not found.
+// Returns the default if the envvar cannot be coopered to a boolean, or is not found.
func GetOrDefaultBool(envVar string, defaultValue bool) bool {
- return getOrDefault(envVar, defaultValue, strconv.ParseBool)
-}
-
-// GetOrDefaultInt returns the given environment variable value as an integer.
-// Returns the default if the env var cannot be coopered to an int, or is not found.
-func GetOrDefaultInt(envVar string, defaultValue int) int {
- return getOrDefault(envVar, defaultValue, strconv.Atoi)
-}
-
-// GetOrDefaultSecond returns the given environment variable value as a time.Duration (second).
-// Returns the default if the env var cannot be coopered to an int, or is not found.
-func GetOrDefaultSecond(envVar string, defaultValue time.Duration) time.Duration {
- return getOrDefault(envVar, defaultValue, ParseSecond)
-}
-
-func getOrDefault[T any](envVar string, defaultValue T, fn func(string) (T, error)) T {
- v, err := fn(GetOrFile(envVar))
+ v, err := strconv.ParseBool(GetOrFile(envVar))
if err != nil {
return defaultValue
}
@@ -153,7 +155,7 @@ func GetOrFile(envVar string) string {
return envVarValue
}
- fileContents, err := os.ReadFile(fileVarValue)
+ fileContents, err := ioutil.ReadFile(fileVarValue)
if err != nil {
log.Printf("Failed to read the file %s (defined by env var %s): %s", fileVarValue, fileVar, err)
return ""
@@ -161,26 +163,3 @@ func GetOrFile(envVar string) string {
return strings.TrimSuffix(string(fileContents), "\n")
}
-
-// ParseSecond parses env var value (string) to a second (time.Duration).
-func ParseSecond(s string) (time.Duration, error) {
- v, err := strconv.Atoi(s)
- if err != nil {
- return 0, err
- }
-
- if v < 0 {
- return 0, fmt.Errorf("unsupported value: %d", v)
- }
-
- return time.Duration(v) * time.Second, nil
-}
-
-// ParseString parses env var value (string) to a string but throws an error when the string is empty.
-func ParseString(s string) (string, error) {
- if s == "" {
- return "", errors.New("empty string")
- }
-
- return s, nil
-}
diff --git a/vendor/github.com/go-acme/lego/v4/platform/wait/wait.go b/vendor/github.com/go-acme/lego/v4/platform/wait/wait.go
index 6ad817b..d0c078b 100644
--- a/vendor/github.com/go-acme/lego/v4/platform/wait/wait.go
+++ b/vendor/github.com/go-acme/lego/v4/platform/wait/wait.go
@@ -1,6 +1,7 @@
package wait
import (
+ "errors"
"fmt"
"time"
@@ -17,9 +18,9 @@ func For(msg string, timeout, interval time.Duration, f func() (bool, error)) er
select {
case <-timeUp:
if lastErr == nil {
- return fmt.Errorf("%s: time limit exceeded", msg)
+ return errors.New("time limit exceeded")
}
- return fmt.Errorf("%s: time limit exceeded: last error: %w", msg, lastErr)
+ return fmt.Errorf("time limit exceeded: last error: %w", lastErr)
default:
}
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/internal/errutils/client.go b/vendor/github.com/go-acme/lego/v4/providers/dns/internal/errutils/client.go
deleted file mode 100644
index 09f1344..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/internal/errutils/client.go
+++ /dev/null
@@ -1,133 +0,0 @@
-package errutils
-
-import (
- "bytes"
- "fmt"
- "io"
- "net/http"
- "os"
- "strconv"
-)
-
-const legoDebugClientVerboseError = "LEGO_DEBUG_CLIENT_VERBOSE_ERROR"
-
-// HTTPDoError uses with `(http.Client).Do` error.
-type HTTPDoError struct {
- req *http.Request
- err error
-}
-
-// NewHTTPDoError creates a new HTTPDoError.
-func NewHTTPDoError(req *http.Request, err error) *HTTPDoError {
- return &HTTPDoError{req: req, err: err}
-}
-
-func (h HTTPDoError) Error() string {
- msg := "unable to communicate with the API server:"
-
- if ok, _ := strconv.ParseBool(os.Getenv(legoDebugClientVerboseError)); ok {
- msg += fmt.Sprintf(" [request: %s %s]", h.req.Method, h.req.URL)
- }
-
- if h.err == nil {
- return msg
- }
-
- return msg + fmt.Sprintf(" error: %v", h.err)
-}
-
-func (h HTTPDoError) Unwrap() error {
- return h.err
-}
-
-// ReadResponseError use with `io.ReadAll` when reading response body.
-type ReadResponseError struct {
- req *http.Request
- StatusCode int
- err error
-}
-
-// NewReadResponseError creates a new ReadResponseError.
-func NewReadResponseError(req *http.Request, statusCode int, err error) *ReadResponseError {
- return &ReadResponseError{req: req, StatusCode: statusCode, err: err}
-}
-
-func (r ReadResponseError) Error() string {
- msg := "unable to read response body:"
-
- if ok, _ := strconv.ParseBool(os.Getenv(legoDebugClientVerboseError)); ok {
- msg += fmt.Sprintf(" [request: %s %s]", r.req.Method, r.req.URL)
- }
-
- msg += fmt.Sprintf(" [status code: %d]", r.StatusCode)
-
- if r.err == nil {
- return msg
- }
-
- return msg + fmt.Sprintf(" error: %v", r.err)
-}
-
-func (r ReadResponseError) Unwrap() error {
- return r.err
-}
-
-// UnmarshalError uses with `json.Unmarshal` or `xml.Unmarshal` when reading response body.
-type UnmarshalError struct {
- req *http.Request
- StatusCode int
- Body []byte
- err error
-}
-
-// NewUnmarshalError creates a new UnmarshalError.
-func NewUnmarshalError(req *http.Request, statusCode int, body []byte, err error) *UnmarshalError {
- return &UnmarshalError{req: req, StatusCode: statusCode, Body: bytes.TrimSpace(body), err: err}
-}
-
-func (u UnmarshalError) Error() string {
- msg := "unable to unmarshal response:"
-
- if ok, _ := strconv.ParseBool(os.Getenv(legoDebugClientVerboseError)); ok {
- msg += fmt.Sprintf(" [request: %s %s]", u.req.Method, u.req.URL)
- }
-
- msg += fmt.Sprintf(" [status code: %d] body: %s", u.StatusCode, string(u.Body))
-
- if u.err == nil {
- return msg
- }
-
- return msg + fmt.Sprintf(" error: %v", u.err)
-}
-
-func (u UnmarshalError) Unwrap() error {
- return u.err
-}
-
-// UnexpectedStatusCodeError use when the status of the response is unexpected but there is no API error type.
-type UnexpectedStatusCodeError struct {
- req *http.Request
- StatusCode int
- Body []byte
-}
-
-// NewUnexpectedStatusCodeError creates a new UnexpectedStatusCodeError.
-func NewUnexpectedStatusCodeError(req *http.Request, statusCode int, body []byte) *UnexpectedStatusCodeError {
- return &UnexpectedStatusCodeError{req: req, StatusCode: statusCode, Body: bytes.TrimSpace(body)}
-}
-
-func NewUnexpectedResponseStatusCodeError(req *http.Request, resp *http.Response) *UnexpectedStatusCodeError {
- raw, _ := io.ReadAll(resp.Body)
- return &UnexpectedStatusCodeError{req: req, StatusCode: resp.StatusCode, Body: bytes.TrimSpace(raw)}
-}
-
-func (u UnexpectedStatusCodeError) Error() string {
- msg := "unexpected status code:"
-
- if ok, _ := strconv.ParseBool(os.Getenv(legoDebugClientVerboseError)); ok {
- msg += fmt.Sprintf(" [request: %s %s]", u.req.Method, u.req.URL)
- }
-
- return msg + fmt.Sprintf(" [status code: %d] body: %s", u.StatusCode, string(u.Body))
-}
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/internal/useragent/useragent.go b/vendor/github.com/go-acme/lego/v4/providers/dns/internal/useragent/useragent.go
deleted file mode 100644
index 02ce230..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/internal/useragent/useragent.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Code generated by 'internal/releaser'; DO NOT EDIT.
-
-package useragent
-
-import (
- "fmt"
- "net/http"
- "runtime"
-)
-
-const (
- // ourUserAgent is the User-Agent of this underlying library package.
- ourUserAgent = "goacme-lego/4.23.1"
-
- // ourUserAgentComment is part of the UA comment linked to the version status of this underlying library package.
- // values: detach|release
- // NOTE: Update this with each tagged release.
- ourUserAgentComment = "release"
-)
-
-// Get builds and returns the User-Agent string.
-func Get() string {
- return fmt.Sprintf("%s (%s; %s; %s)", ourUserAgent, ourUserAgentComment, runtime.GOOS, runtime.GOARCH)
-}
-
-// SetHeader sets the User-Agent header.
-func SetHeader(h http.Header) {
- h.Set("User-Agent", Get())
-}
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/ovh/ovh.go b/vendor/github.com/go-acme/lego/v4/providers/dns/ovh/ovh.go
index c70e943..f1aaf86 100644
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/ovh/ovh.go
+++ b/vendor/github.com/go-acme/lego/v4/providers/dns/ovh/ovh.go
@@ -5,25 +5,26 @@ import (
"errors"
"fmt"
"net/http"
+ "strings"
"sync"
"time"
- "github.com/go-acme/lego/v4/challenge"
"github.com/go-acme/lego/v4/challenge/dns01"
"github.com/go-acme/lego/v4/platform/config/env"
- "github.com/go-acme/lego/v4/providers/dns/internal/useragent"
"github.com/ovh/go-ovh/ovh"
)
// OVH API reference: https://eu.api.ovh.com/
-// Create a Token: https://eu.api.ovh.com/createToken/
-// Create a OAuth2 client: https://eu.api.ovh.com/console/?section=%2Fme&branch=v1#post-/me/api/oauth2/client
+// Create a Token: https://eu.api.ovh.com/createToken/
// Environment variables names.
const (
envNamespace = "OVH_"
- EnvEndpoint = envNamespace + "ENDPOINT"
+ EnvEndpoint = envNamespace + "ENDPOINT"
+ EnvApplicationKey = envNamespace + "APPLICATION_KEY"
+ EnvApplicationSecret = envNamespace + "APPLICATION_SECRET"
+ EnvConsumerKey = envNamespace + "CONSUMER_KEY"
EnvTTL = envNamespace + "TTL"
EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
@@ -31,24 +32,6 @@ const (
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
)
-// Authenticate using application key.
-const (
- EnvApplicationKey = envNamespace + "APPLICATION_KEY"
- EnvApplicationSecret = envNamespace + "APPLICATION_SECRET"
- EnvConsumerKey = envNamespace + "CONSUMER_KEY"
-)
-
-// Authenticate using OAuth2 client.
-const (
- EnvClientID = envNamespace + "CLIENT_ID"
- EnvClientSecret = envNamespace + "CLIENT_SECRET"
-)
-
-// EnvAccessToken Authenticate using Access Token client.
-const EnvAccessToken = envNamespace + "ACCESS_TOKEN"
-
-var _ challenge.ProviderTimeout = (*DNSProvider)(nil)
-
// Record a DNS record.
type Record struct {
ID int64 `json:"id,omitempty"`
@@ -59,24 +42,12 @@ type Record struct {
Zone string `json:"zone,omitempty"`
}
-// OAuth2Config the OAuth2 specific configuration.
-type OAuth2Config struct {
- ClientID string
- ClientSecret string
-}
-
// Config is used to configure the creation of the DNSProvider.
type Config struct {
- APIEndpoint string
-
- ApplicationKey string
- ApplicationSecret string
- ConsumerKey string
-
- OAuth2Config *OAuth2Config
-
- AccessToken string
-
+ APIEndpoint string
+ ApplicationKey string
+ ApplicationSecret string
+ ConsumerKey string
PropagationTimeout time.Duration
PollingInterval time.Duration
TTL int
@@ -95,10 +66,6 @@ func NewDefaultConfig() *Config {
}
}
-func (c *Config) hasAppKeyAuth() bool {
- return c.ApplicationKey != "" || c.ApplicationSecret != "" || c.ConsumerKey != ""
-}
-
// DNSProvider implements the challenge.Provider interface.
type DNSProvider struct {
config *Config
@@ -111,27 +78,17 @@ type DNSProvider struct {
// Credentials must be passed in the environment variables:
// OVH_ENDPOINT (must be either "ovh-eu" or "ovh-ca"), OVH_APPLICATION_KEY, OVH_APPLICATION_SECRET, OVH_CONSUMER_KEY.
func NewDNSProvider() (*DNSProvider, error) {
- config := NewDefaultConfig()
-
- // https://github.com/ovh/go-ovh/blob/6817886d12a8c5650794b28da635af9fcdfd1162/ovh/configuration.go#L105
- config.APIEndpoint = env.GetOrDefaultString(EnvEndpoint, "ovh-eu")
-
- config.ApplicationKey = env.GetOrFile(EnvApplicationKey)
- config.ApplicationSecret = env.GetOrFile(EnvApplicationSecret)
- config.ConsumerKey = env.GetOrFile(EnvConsumerKey)
-
- config.AccessToken = env.GetOrFile(EnvAccessToken)
-
- clientID := env.GetOrFile(EnvClientID)
- clientSecret := env.GetOrFile(EnvClientSecret)
-
- if clientID != "" || clientSecret != "" {
- config.OAuth2Config = &OAuth2Config{
- ClientID: clientID,
- ClientSecret: clientSecret,
- }
+ values, err := env.Get(EnvEndpoint, EnvApplicationKey, EnvApplicationSecret, EnvConsumerKey)
+ if err != nil {
+ return nil, fmt.Errorf("ovh: %w", err)
}
+ config := NewDefaultConfig()
+ config.APIEndpoint = values[EnvEndpoint]
+ config.ApplicationKey = values[EnvApplicationKey]
+ config.ApplicationSecret = values[EnvApplicationSecret]
+ config.ConsumerKey = values[EnvConsumerKey]
+
return NewDNSProviderConfig(config)
}
@@ -141,27 +98,22 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
return nil, errors.New("ovh: the configuration of the DNS provider is nil")
}
- if config.OAuth2Config != nil && config.hasAppKeyAuth() && config.AccessToken != "" {
- return nil, errors.New("ovh: can't use multiple authentication systems (ApplicationKey, OAuth2, Access Token)")
+ if config.APIEndpoint == "" || config.ApplicationKey == "" || config.ApplicationSecret == "" || config.ConsumerKey == "" {
+ return nil, errors.New("ovh: credentials missing")
}
- if config.OAuth2Config != nil && config.AccessToken != "" {
- return nil, errors.New("ovh: can't use multiple authentication systems (OAuth2, Access Token)")
- }
-
- if config.OAuth2Config != nil && config.hasAppKeyAuth() {
- return nil, errors.New("ovh: can't use multiple authentication systems (ApplicationKey, OAuth2)")
- }
-
- if config.hasAppKeyAuth() && config.AccessToken != "" {
- return nil, errors.New("ovh: can't use multiple authentication systems (ApplicationKey, Access Token)")
- }
-
- client, err := newClient(config)
+ client, err := ovh.NewClient(
+ config.APIEndpoint,
+ config.ApplicationKey,
+ config.ApplicationSecret,
+ config.ConsumerKey,
+ )
if err != nil {
return nil, fmt.Errorf("ovh: %w", err)
}
+ client.Client = config.HTTPClient
+
return &DNSProvider{
config: config,
client: client,
@@ -171,22 +123,19 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
// Present creates a TXT record to fulfill the dns-01 challenge.
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
- info := dns01.GetChallengeInfo(domain, keyAuth)
+ fqdn, value := dns01.GetRecord(domain, keyAuth)
- authZone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
+ // Parse domain name
+ authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
if err != nil {
- return fmt.Errorf("ovh: could not find zone for domain %q: %w", domain, err)
+ return fmt.Errorf("ovh: could not determine zone for domain %q: %w", domain, err)
}
authZone = dns01.UnFqdn(authZone)
-
- subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, authZone)
- if err != nil {
- return fmt.Errorf("ovh: %w", err)
- }
+ subDomain := extractRecordName(fqdn, authZone)
reqURL := fmt.Sprintf("/domain/zone/%s/record", authZone)
- reqData := Record{FieldType: "TXT", SubDomain: subDomain, Target: info.Value, TTL: d.config.TTL}
+ reqData := Record{FieldType: "TXT", SubDomain: subDomain, Target: value, TTL: d.config.TTL}
// Create TXT record
var respData Record
@@ -211,19 +160,19 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
// CleanUp removes the TXT record matching the specified parameters.
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
- info := dns01.GetChallengeInfo(domain, keyAuth)
+ fqdn, _ := dns01.GetRecord(domain, keyAuth)
// get the record's unique ID from when we created it
d.recordIDsMu.Lock()
recordID, ok := d.recordIDs[token]
d.recordIDsMu.Unlock()
if !ok {
- return fmt.Errorf("ovh: unknown record ID for '%s'", info.EffectiveFQDN)
+ return fmt.Errorf("ovh: unknown record ID for '%s'", fqdn)
}
- authZone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
+ authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain))
if err != nil {
- return fmt.Errorf("ovh: could not find zone for domain %q: %w", domain, err)
+ return fmt.Errorf("ovh: could not determine zone for domain %q: %w", domain, err)
}
authZone = dns01.UnFqdn(authZone)
@@ -256,26 +205,10 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
return d.config.PropagationTimeout, d.config.PollingInterval
}
-func newClient(config *Config) (*ovh.Client, error) {
- var client *ovh.Client
- var err error
-
- switch {
- case config.hasAppKeyAuth():
- client, err = ovh.NewClient(config.APIEndpoint, config.ApplicationKey, config.ApplicationSecret, config.ConsumerKey)
- case config.OAuth2Config != nil:
- client, err = ovh.NewOAuth2Client(config.APIEndpoint, config.OAuth2Config.ClientID, config.OAuth2Config.ClientSecret)
- case config.AccessToken != "":
- client, err = ovh.NewAccessTokenClient(config.APIEndpoint, config.AccessToken)
- default:
- client, err = ovh.NewDefaultClient()
+func extractRecordName(fqdn, zone string) string {
+ name := dns01.UnFqdn(fqdn)
+ if idx := strings.Index(name, "."+zone); idx != -1 {
+ return name[:idx]
}
-
- if err != nil {
- return nil, fmt.Errorf("new client: %w", err)
- }
-
- client.UserAgent = useragent.Get()
-
- return client, nil
+ return name
}
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/ovh/ovh.toml b/vendor/github.com/go-acme/lego/v4/providers/dns/ovh/ovh.toml
index 9516218..ea76067 100644
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/ovh/ovh.toml
+++ b/vendor/github.com/go-acme/lego/v4/providers/dns/ovh/ovh.toml
@@ -5,26 +5,11 @@ Code = "ovh"
Since = "v0.4.0"
Example = '''
-# Application Key authentication:
-
OVH_APPLICATION_KEY=1234567898765432 \
OVH_APPLICATION_SECRET=b9841238feb177a84330febba8a832089 \
OVH_CONSUMER_KEY=256vfsd347245sdfg \
OVH_ENDPOINT=ovh-eu \
-lego --email you@example.com --dns ovh -d '*.example.com' -d example.com run
-
-# Or Access Token:
-
-OVH_ACCESS_TOKEN=xxx \
-OVH_ENDPOINT=ovh-eu \
-lego --email you@example.com --dns ovh -d '*.example.com' -d example.com run
-
-# Or OAuth2:
-
-OVH_CLIENT_ID=yyy \
-OVH_CLIENT_SECRET=xxx \
-OVH_ENDPOINT=ovh-eu \
-lego --email you@example.com --dns ovh -d '*.example.com' -d example.com run
+lego --email myemail@example.com --dns ovh --domains my.example.org run
'''
Additional = '''
@@ -32,7 +17,7 @@ Additional = '''
Application key and secret can be created by following the [OVH guide](https://docs.ovh.com/gb/en/customer/first-steps-with-ovh-api/).
-When requesting the consumer key, the following configuration can be used to define access rights:
+When requesting the consumer key, the following configuration can be use to define access rights:
```json
{
@@ -48,38 +33,19 @@ When requesting the consumer key, the following configuration can be used to def
]
}
```
-
-## OAuth2 Client Credentials
-
-Another method for authentication is by using OAuth2 client credentials.
-
-An IAM policy and service account can be created by following the [OVH guide](https://help.ovhcloud.com/csm/en-manage-service-account?id=kb_article_view&sysparm_article=KB0059343).
-
-Following IAM policies need to be authorized for the affected domain:
-
-* dnsZone:apiovh:record/create
-* dnsZone:apiovh:record/delete
-* dnsZone:apiovh:refresh
-
-## Important Note
-
-Both authentication methods cannot be used at the same time.
'''
[Configuration]
[Configuration.Credentials]
OVH_ENDPOINT = "Endpoint URL (ovh-eu or ovh-ca)"
- OVH_APPLICATION_KEY = "Application key (Application Key authentication)"
- OVH_APPLICATION_SECRET = "Application secret (Application Key authentication)"
- OVH_CONSUMER_KEY = "Consumer key (Application Key authentication)"
- OVH_CLIENT_ID = "Client ID (OAuth2)"
- OVH_CLIENT_SECRET = "Client secret (OAuth2)"
- OVH_ACCESS_TOKEN = "Access token"
+ OVH_APPLICATION_KEY = "Application key"
+ OVH_APPLICATION_SECRET = "Application secret"
+ OVH_CONSUMER_KEY = "Consumer key"
[Configuration.Additional]
- OVH_POLLING_INTERVAL = "Time between DNS propagation check in seconds (Default: 2)"
- OVH_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation in seconds (Default: 60)"
- OVH_TTL = "The TTL of the TXT record used for the DNS challenge in seconds (Default: 120)"
- OVH_HTTP_TIMEOUT = "API request timeout in seconds (Default: 180)"
+ OVH_POLLING_INTERVAL = "Time between DNS propagation check"
+ OVH_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation"
+ OVH_TTL = "The TTL of the TXT record used for the DNS challenge"
+ OVH_HTTP_TIMEOUT = "API request timeout"
[Links]
API = "https://eu.api.ovh.com/"
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/internal/client.go b/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/internal/client.go
deleted file mode 100644
index bc525c5..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/internal/client.go
+++ /dev/null
@@ -1,228 +0,0 @@
-package internal
-
-import (
- "bytes"
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "io"
- "net/http"
- "net/url"
- "path"
- "strconv"
- "strings"
- "time"
-
- "github.com/go-acme/lego/v4/providers/dns/internal/errutils"
- "github.com/miekg/dns"
-)
-
-// Client the PowerDNS API client.
-type Client struct {
- serverName string
- apiKey string
-
- apiVersion int
-
- Host *url.URL
- HTTPClient *http.Client
-}
-
-// NewClient creates a new Client.
-func NewClient(host *url.URL, serverName string, apiVersion int, apiKey string) *Client {
- return &Client{
- serverName: serverName,
- apiKey: apiKey,
- apiVersion: apiVersion,
- Host: host,
- HTTPClient: &http.Client{Timeout: 5 * time.Second},
- }
-}
-
-func (c *Client) APIVersion() int {
- return c.apiVersion
-}
-
-func (c *Client) SetAPIVersion(ctx context.Context) error {
- var err error
-
- c.apiVersion, err = c.getAPIVersion(ctx)
-
- return err
-}
-
-func (c *Client) getAPIVersion(ctx context.Context) (int, error) {
- endpoint := c.joinPath("/", "api")
-
- req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil)
- if err != nil {
- return 0, err
- }
-
- result, err := c.do(req)
- if err != nil {
- return 0, err
- }
-
- var versions []apiVersion
- err = json.Unmarshal(result, &versions)
- if err != nil {
- return 0, err
- }
-
- latestVersion := 0
- for _, v := range versions {
- if v.Version > latestVersion {
- latestVersion = v.Version
- }
- }
-
- return latestVersion, err
-}
-
-func (c *Client) GetHostedZone(ctx context.Context, authZone string) (*HostedZone, error) {
- endpoint := c.joinPath("/", "servers", c.serverName, "zones", dns.Fqdn(authZone))
-
- req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil)
- if err != nil {
- return nil, err
- }
-
- result, err := c.do(req)
- if err != nil {
- return nil, err
- }
-
- var zone HostedZone
- err = json.Unmarshal(result, &zone)
- if err != nil {
- return nil, err
- }
-
- // convert pre-v1 API result
- if len(zone.Records) > 0 {
- zone.RRSets = []RRSet{}
- for _, record := range zone.Records {
- set := RRSet{
- Name: record.Name,
- Type: record.Type,
- Records: []Record{record},
- }
- zone.RRSets = append(zone.RRSets, set)
- }
- }
-
- return &zone, nil
-}
-
-func (c *Client) UpdateRecords(ctx context.Context, zone *HostedZone, sets RRSets) error {
- endpoint := c.joinPath("/", "servers", c.serverName, "zones", zone.ID)
-
- req, err := newJSONRequest(ctx, http.MethodPatch, endpoint, sets)
- if err != nil {
- return err
- }
-
- _, err = c.do(req)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func (c *Client) Notify(ctx context.Context, zone *HostedZone) error {
- if c.apiVersion < 1 || zone.Kind != "Master" && zone.Kind != "Slave" {
- return nil
- }
-
- endpoint := c.joinPath("/", "servers", c.serverName, "zones", zone.ID, "notify")
-
- req, err := newJSONRequest(ctx, http.MethodPut, endpoint, nil)
- if err != nil {
- return err
- }
-
- _, err = c.do(req)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func (c *Client) joinPath(elem ...string) *url.URL {
- p := path.Join(elem...)
-
- if p != "/api" && c.apiVersion > 0 && !strings.HasPrefix(p, "/api/v") {
- p = path.Join("/api", "v"+strconv.Itoa(c.apiVersion), p)
- }
-
- return c.Host.JoinPath(p)
-}
-
-func (c *Client) do(req *http.Request) (json.RawMessage, error) {
- req.Header.Set("X-API-Key", c.apiKey)
-
- resp, err := c.HTTPClient.Do(req)
- if err != nil {
- return nil, errutils.NewHTTPDoError(req, err)
- }
-
- defer func() { _ = resp.Body.Close() }()
-
- if resp.StatusCode != http.StatusUnprocessableEntity && (resp.StatusCode < 200 || resp.StatusCode >= 300) {
- return nil, errutils.NewUnexpectedResponseStatusCodeError(req, resp)
- }
-
- var msg json.RawMessage
- err = json.NewDecoder(resp.Body).Decode(&msg)
- if err != nil {
- if errors.Is(err, io.EOF) {
- // empty body
- return nil, nil
- }
- // other error
- return nil, err
- }
-
- // check for PowerDNS error message
- if len(msg) > 0 && msg[0] == '{' {
- var errInfo apiError
- err = json.Unmarshal(msg, &errInfo)
- if err != nil {
- return nil, errutils.NewUnmarshalError(req, resp.StatusCode, msg, err)
- }
- if errInfo.ShortMsg != "" {
- return nil, fmt.Errorf("error talking to PDNS API: %w", errInfo)
- }
- }
-
- return msg, nil
-}
-
-func newJSONRequest(ctx context.Context, method string, endpoint *url.URL, payload any) (*http.Request, error) {
- buf := new(bytes.Buffer)
-
- if payload != nil {
- err := json.NewEncoder(buf).Encode(payload)
- if err != nil {
- return nil, fmt.Errorf("failed to create request JSON body: %w", err)
- }
- }
-
- req, err := http.NewRequestWithContext(ctx, method, strings.TrimSuffix(endpoint.String(), "/"), buf)
- if err != nil {
- return nil, fmt.Errorf("unable to create request: %w", err)
- }
-
- req.Header.Set("Accept", "application/json")
-
- // PowerDNS doesn't follow HTTP convention about the "Content-Type" header.
- if method != http.MethodGet && method != http.MethodDelete {
- req.Header.Set("Content-Type", "application/json")
- }
-
- return req, nil
-}
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/internal/types.go b/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/internal/types.go
deleted file mode 100644
index df885d9..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/internal/types.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package internal
-
-type Record struct {
- Content string `json:"content"`
- Disabled bool `json:"disabled"`
-
- // pre-v1 API
- Name string `json:"name"`
- Type string `json:"type"`
- TTL int `json:"ttl,omitempty"`
-}
-
-type HostedZone struct {
- ID string `json:"id"`
- Name string `json:"name"`
- URL string `json:"url"`
- Kind string `json:"kind"`
- RRSets []RRSet `json:"rrsets"`
-
- // pre-v1 API
- Records []Record `json:"records"`
-}
-
-type RRSet struct {
- Name string `json:"name"`
- Type string `json:"type"`
- Kind string `json:"kind"`
- ChangeType string `json:"changetype"`
- Records []Record `json:"records,omitempty"`
- TTL int `json:"ttl,omitempty"`
-}
-
-type RRSets struct {
- RRSets []RRSet `json:"rrsets"`
-}
-
-type apiError struct {
- ShortMsg string `json:"error"`
-}
-
-func (a apiError) Error() string {
- return a.ShortMsg
-}
-
-type apiVersion struct {
- URL string `json:"url"`
- Version int `json:"version"`
-}
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/pdns.go b/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/pdns.go
deleted file mode 100644
index c2f780b..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/pdns.go
+++ /dev/null
@@ -1,242 +0,0 @@
-// Package pdns implements a DNS provider for solving the DNS-01 challenge using PowerDNS nameserver.
-package pdns
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "strconv"
- "time"
-
- "github.com/go-acme/lego/v4/challenge"
- "github.com/go-acme/lego/v4/challenge/dns01"
- "github.com/go-acme/lego/v4/log"
- "github.com/go-acme/lego/v4/platform/config/env"
- "github.com/go-acme/lego/v4/providers/dns/pdns/internal"
-)
-
-// Environment variables names.
-const (
- envNamespace = "PDNS_"
-
- EnvAPIKey = envNamespace + "API_KEY"
- EnvAPIURL = envNamespace + "API_URL"
-
- EnvTTL = envNamespace + "TTL"
- EnvAPIVersion = envNamespace + "API_VERSION"
- EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
- EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
- EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
- EnvServerName = envNamespace + "SERVER_NAME"
-)
-
-var _ challenge.ProviderTimeout = (*DNSProvider)(nil)
-
-// Config is used to configure the creation of the DNSProvider.
-type Config struct {
- APIKey string
- Host *url.URL
- ServerName string
- APIVersion int
- PropagationTimeout time.Duration
- PollingInterval time.Duration
- TTL int
- HTTPClient *http.Client
-}
-
-// NewDefaultConfig returns a default configuration for the DNSProvider.
-func NewDefaultConfig() *Config {
- return &Config{
- ServerName: env.GetOrDefaultString(EnvServerName, "localhost"),
- APIVersion: env.GetOrDefaultInt(EnvAPIVersion, 0),
- TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL),
- PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 120*time.Second),
- PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 2*time.Second),
- HTTPClient: &http.Client{
- Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),
- },
- }
-}
-
-// DNSProvider implements the challenge.Provider interface.
-type DNSProvider struct {
- config *Config
- client *internal.Client
-}
-
-// NewDNSProvider returns a DNSProvider instance configured for pdns.
-// Credentials must be passed in the environment variable:
-// PDNS_API_URL and PDNS_API_KEY.
-func NewDNSProvider() (*DNSProvider, error) {
- values, err := env.Get(EnvAPIKey, EnvAPIURL)
- if err != nil {
- return nil, fmt.Errorf("pdns: %w", err)
- }
-
- hostURL, err := url.Parse(values[EnvAPIURL])
- if err != nil {
- return nil, fmt.Errorf("pdns: %w", err)
- }
-
- config := NewDefaultConfig()
- config.Host = hostURL
- config.APIKey = values[EnvAPIKey]
-
- return NewDNSProviderConfig(config)
-}
-
-// NewDNSProviderConfig return a DNSProvider instance configured for pdns.
-func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
- if config == nil {
- return nil, errors.New("pdns: the configuration of the DNS provider is nil")
- }
-
- if config.APIKey == "" {
- return nil, errors.New("pdns: API key missing")
- }
-
- if config.Host == nil || config.Host.Host == "" {
- return nil, errors.New("pdns: API URL missing")
- }
-
- client := internal.NewClient(config.Host, config.ServerName, config.APIVersion, config.APIKey)
-
- if config.APIVersion <= 0 {
- err := client.SetAPIVersion(context.Background())
- if err != nil {
- log.Warnf("pdns: failed to get API version %v", err)
- }
- }
-
- return &DNSProvider{config: config, client: client}, nil
-}
-
-// Timeout returns the timeout and interval to use when checking for DNS propagation.
-// Adjusting here to cope with spikes in propagation times.
-func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
- return d.config.PropagationTimeout, d.config.PollingInterval
-}
-
-// Present creates a TXT record to fulfill the dns-01 challenge.
-func (d *DNSProvider) Present(domain, token, keyAuth string) error {
- info := dns01.GetChallengeInfo(domain, keyAuth)
-
- authZone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
- if err != nil {
- return fmt.Errorf("pdns: could not find zone for domain %q: %w", domain, err)
- }
-
- ctx := context.Background()
-
- zone, err := d.client.GetHostedZone(ctx, authZone)
- if err != nil {
- return fmt.Errorf("pdns: %w", err)
- }
-
- name := info.EffectiveFQDN
- if d.client.APIVersion() == 0 {
- // pre-v1 API wants non-fqdn
- name = dns01.UnFqdn(info.EffectiveFQDN)
- }
-
- // Look for existing records.
- existingRRSet := findTxtRecord(zone, info.EffectiveFQDN)
-
- // merge the existing and new records
- var records []internal.Record
- if existingRRSet != nil {
- records = existingRRSet.Records
- }
-
- rec := internal.Record{
- Content: strconv.Quote(info.Value),
- Disabled: false,
-
- // pre-v1 API
- Type: "TXT",
- Name: name,
- TTL: d.config.TTL,
- }
-
- rrSets := internal.RRSets{
- RRSets: []internal.RRSet{
- {
- Name: name,
- ChangeType: "REPLACE",
- Type: "TXT",
- Kind: "Master",
- TTL: d.config.TTL,
- Records: append(records, rec),
- },
- },
- }
-
- err = d.client.UpdateRecords(ctx, zone, rrSets)
- if err != nil {
- return fmt.Errorf("pdns: %w", err)
- }
-
- return d.client.Notify(ctx, zone)
-}
-
-// CleanUp removes the TXT record matching the specified parameters.
-func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
- info := dns01.GetChallengeInfo(domain, keyAuth)
-
- authZone, err := dns01.FindZoneByFqdn(info.EffectiveFQDN)
- if err != nil {
- return fmt.Errorf("pdns: could not find zone for domain %q: %w", domain, err)
- }
-
- ctx := context.Background()
-
- zone, err := d.client.GetHostedZone(ctx, authZone)
- if err != nil {
- return fmt.Errorf("pdns: %w", err)
- }
-
- set := findTxtRecord(zone, info.EffectiveFQDN)
-
- if set == nil {
- return fmt.Errorf("pdns: no existing record found for %s", info.EffectiveFQDN)
- }
-
- var records []internal.Record
- for _, r := range set.Records {
- if r.Content != strconv.Quote(info.Value) {
- records = append(records, r)
- }
- }
-
- rrSet := internal.RRSet{
- Name: set.Name,
- Type: set.Type,
- }
-
- if len(records) > 0 {
- rrSet.ChangeType = "REPLACE"
- rrSet.TTL = d.config.TTL
- rrSet.Records = records
- } else {
- rrSet.ChangeType = "DELETE"
- }
-
- err = d.client.UpdateRecords(ctx, zone, internal.RRSets{RRSets: []internal.RRSet{rrSet}})
- if err != nil {
- return fmt.Errorf("pdns: %w", err)
- }
-
- return d.client.Notify(ctx, zone)
-}
-
-func findTxtRecord(zone *internal.HostedZone, fqdn string) *internal.RRSet {
- for _, set := range zone.RRSets {
- if set.Type == "TXT" && (set.Name == dns01.UnFqdn(fqdn) || set.Name == fqdn) {
- return &set
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/pdns.toml b/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/pdns.toml
deleted file mode 100644
index 53b5547..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/pdns.toml
+++ /dev/null
@@ -1,37 +0,0 @@
-Name = "PowerDNS"
-Description = ''''''
-URL = "https://www.powerdns.com/"
-Code = "pdns"
-Since = "v0.4.0"
-
-Example = '''
-PDNS_API_URL=http://pdns-server:80/ \
-PDNS_API_KEY=xxxx \
-lego --email you@example.com --dns pdns -d '*.example.com' -d example.com run
-'''
-
-Additional = '''
-## Information
-
-Tested and confirmed to work with PowerDNS authoritative server 3.4.8 and 4.0.1. Refer to [PowerDNS documentation](https://doc.powerdns.com/md/httpapi/README/) instructions on how to enable the built-in API interface.
-
-PowerDNS Notes:
-- PowerDNS API does not currently support SSL, therefore you should take care to ensure that traffic between lego and the PowerDNS API is over a trusted network, VPN etc.
-- In order to have the SOA serial automatically increment each time the `_acme-challenge` record is added/modified via the API, set `SOA-EDIT-API` to `INCEPTION-INCREMENT` for the zone in the `domainmetadata` table
-- Some PowerDNS servers doesn't have root API endpoints enabled and API version autodetection will not work. In that case version number can be defined using `PDNS_API_VERSION`.
-'''
-
-[Configuration]
- [Configuration.Credentials]
- PDNS_API_KEY = "API key"
- PDNS_API_URL = "API URL"
- [Configuration.Additional]
- PDNS_SERVER_NAME = "Name of the server in the URL, 'localhost' by default"
- PDNS_API_VERSION = "Skip API version autodetection and use the provided version number."
- PDNS_POLLING_INTERVAL = "Time between DNS propagation check in seconds (Default: 2)"
- PDNS_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation in seconds (Default: 120)"
- PDNS_TTL = "The TTL of the TXT record used for the DNS challenge in seconds (Default: 120)"
- PDNS_HTTP_TIMEOUT = "API request timeout in seconds (Default: 30)"
-
-[Links]
- API = "https://doc.powerdns.com/md/httpapi/README/"
diff --git a/vendor/github.com/go-acme/lego/v4/registration/registar.go b/vendor/github.com/go-acme/lego/v4/registration/registar.go
index 15c28ba..25a1b7d 100644
--- a/vendor/github.com/go-acme/lego/v4/registration/registar.go
+++ b/vendor/github.com/go-acme/lego/v4/registration/registar.go
@@ -9,11 +9,9 @@ import (
"github.com/go-acme/lego/v4/log"
)
-const mailTo = "mailto:"
-
// Resource represents all important information about a registration
// of which the client needs to keep track itself.
-// WARNING: will be removed in the future (acme.ExtendedAccount), https://github.com/go-acme/lego/issues/855.
+// WARNING: will be remove in the future (acme.ExtendedAccount), https://github.com/go-acme/lego/issues/855.
type Resource struct {
Body acme.Account `json:"body,omitempty"`
URI string `json:"uri,omitempty"`
@@ -54,13 +52,13 @@ func (r *Registrar) Register(options RegisterOptions) (*Resource, error) {
if r.user.GetEmail() != "" {
log.Infof("acme: Registering account for %s", r.user.GetEmail())
- accMsg.Contact = []string{mailTo + r.user.GetEmail()}
+ accMsg.Contact = []string{"mailto:" + r.user.GetEmail()}
}
account, err := r.core.Accounts.New(accMsg)
if err != nil {
// seems impossible
- errorDetails := &acme.ProblemDetails{}
+ var errorDetails acme.ProblemDetails
if !errors.As(err, &errorDetails) || errorDetails.HTTPStatus != http.StatusConflict {
return nil, err
}
@@ -78,13 +76,13 @@ func (r *Registrar) RegisterWithExternalAccountBinding(options RegisterEABOption
if r.user.GetEmail() != "" {
log.Infof("acme: Registering account for %s", r.user.GetEmail())
- accMsg.Contact = []string{mailTo + r.user.GetEmail()}
+ accMsg.Contact = []string{"mailto:" + r.user.GetEmail()}
}
account, err := r.core.Accounts.NewEAB(accMsg, options.Kid, options.HmacEncoded)
if err != nil {
// seems impossible
- errorDetails := &acme.ProblemDetails{}
+ var errorDetails acme.ProblemDetails
if !errors.As(err, &errorDetails) || errorDetails.HTTPStatus != http.StatusConflict {
return nil, err
}
@@ -130,7 +128,7 @@ func (r *Registrar) UpdateRegistration(options RegisterOptions) (*Resource, erro
if r.user.GetEmail() != "" {
log.Infof("acme: Registering account for %s", r.user.GetEmail())
- accMsg.Contact = []string{mailTo + r.user.GetEmail()}
+ accMsg.Contact = []string{"mailto:" + r.user.GetEmail()}
}
accountURL := r.user.GetRegistration().URI
diff --git a/vendor/github.com/go-jose/go-jose/v4/.golangci.yml b/vendor/github.com/go-jose/go-jose/v4/.golangci.yml
deleted file mode 100644
index 2a577a8..0000000
--- a/vendor/github.com/go-jose/go-jose/v4/.golangci.yml
+++ /dev/null
@@ -1,53 +0,0 @@
-# https://github.com/golangci/golangci-lint
-
-run:
- skip-files:
- - doc_test.go
- modules-download-mode: readonly
-
-linters:
- enable-all: true
- disable:
- - gochecknoglobals
- - goconst
- - lll
- - maligned
- - nakedret
- - scopelint
- - unparam
- - funlen # added in 1.18 (requires go-jose changes before it can be enabled)
-
-linters-settings:
- gocyclo:
- min-complexity: 35
-
-issues:
- exclude-rules:
- - text: "don't use ALL_CAPS in Go names"
- linters:
- - golint
- - text: "hardcoded credentials"
- linters:
- - gosec
- - text: "weak cryptographic primitive"
- linters:
- - gosec
- - path: json/
- linters:
- - dupl
- - errcheck
- - gocritic
- - gocyclo
- - golint
- - govet
- - ineffassign
- - staticcheck
- - structcheck
- - stylecheck
- - unused
- - path: _test\.go
- linters:
- - scopelint
- - path: jwk.go
- linters:
- - gocyclo
diff --git a/vendor/github.com/go-jose/go-jose/v4/.travis.yml b/vendor/github.com/go-jose/go-jose/v4/.travis.yml
deleted file mode 100644
index 48de631..0000000
--- a/vendor/github.com/go-jose/go-jose/v4/.travis.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-language: go
-
-matrix:
- fast_finish: true
- allow_failures:
- - go: tip
-
-go:
- - "1.13.x"
- - "1.14.x"
- - tip
-
-before_script:
- - export PATH=$HOME/.local/bin:$PATH
-
-before_install:
- - go get -u github.com/mattn/goveralls github.com/wadey/gocovmerge
- - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.18.0
- - pip install cram --user
-
-script:
- - go test -v -covermode=count -coverprofile=profile.cov .
- - go test -v -covermode=count -coverprofile=cryptosigner/profile.cov ./cryptosigner
- - go test -v -covermode=count -coverprofile=cipher/profile.cov ./cipher
- - go test -v -covermode=count -coverprofile=jwt/profile.cov ./jwt
- - go test -v ./json # no coverage for forked encoding/json package
- - golangci-lint run
- - cd jose-util && go build && PATH=$PWD:$PATH cram -v jose-util.t # cram tests jose-util
- - cd ..
-
-after_success:
- - gocovmerge *.cov */*.cov > merged.coverprofile
- - goveralls -coverprofile merged.coverprofile -service=travis-ci
diff --git a/vendor/github.com/go-jose/go-jose/v4/CHANGELOG.md b/vendor/github.com/go-jose/go-jose/v4/CHANGELOG.md
deleted file mode 100644
index 66a8a0f..0000000
--- a/vendor/github.com/go-jose/go-jose/v4/CHANGELOG.md
+++ /dev/null
@@ -1,101 +0,0 @@
-## Changed
-
- - Defined a custom error, ErrUnexpectedSignatureAlgorithm, returned when a JWS
- header contains an unsupported signature algorithm.
-
-# v4.0.4
-
-## Fixed
-
- - Reverted "Allow unmarshalling JSONWebKeySets with unsupported key types" as a
- breaking change. See #136 / #137.
-
-# v4.0.3
-
-## Changed
-
- - Allow unmarshalling JSONWebKeySets with unsupported key types (#130)
- - Document that OpaqueKeyEncrypter can't be implemented (for now) (#129)
- - Dependency updates
-
-# v4.0.2
-
-## Changed
-
- - Improved documentation of Verify() to note that JSONWebKeySet is a supported
- argument type (#104)
- - Defined exported error values for missing x5c header and unsupported elliptic
- curves error cases (#117)
-
-# v4.0.1
-
-## Fixed
-
- - An attacker could send a JWE containing compressed data that used large
- amounts of memory and CPU when decompressed by `Decrypt` or `DecryptMulti`.
- Those functions now return an error if the decompressed data would exceed
- 250kB or 10x the compressed size (whichever is larger). Thanks to
- Enze Wang@Alioth and Jianjun Chen@Zhongguancun Lab (@zer0yu and @chenjj)
- for reporting.
-
-# v4.0.0
-
-This release makes some breaking changes in order to more thoroughly
-address the vulnerabilities discussed in [Three New Attacks Against JSON Web
-Tokens][1], "Sign/encrypt confusion", "Billion hash attack", and "Polyglot
-token".
-
-## Changed
-
- - Limit JWT encryption types (exclude password or public key types) (#78)
- - Enforce minimum length for HMAC keys (#85)
- - jwt: match any audience in a list, rather than requiring all audiences (#81)
- - jwt: accept only Compact Serialization (#75)
- - jws: Add expected algorithms for signatures (#74)
- - Require specifying expected algorithms for ParseEncrypted,
- ParseSigned, ParseDetached, jwt.ParseEncrypted, jwt.ParseSigned,
- jwt.ParseSignedAndEncrypted (#69, #74)
- - Usually there is a small, known set of appropriate algorithms for a program
- to use and it's a mistake to allow unexpected algorithms. For instance the
- "billion hash attack" relies in part on programs accepting the PBES2
- encryption algorithm and doing the necessary work even if they weren't
- specifically configured to allow PBES2.
- - Revert "Strip padding off base64 strings" (#82)
- - The specs require base64url encoding without padding.
- - Minimum supported Go version is now 1.21
-
-## Added
-
- - ParseSignedCompact, ParseSignedJSON, ParseEncryptedCompact, ParseEncryptedJSON.
- - These allow parsing a specific serialization, as opposed to ParseSigned and
- ParseEncrypted, which try to automatically detect which serialization was
- provided. It's common to require a specific serialization for a specific
- protocol - for instance JWT requires Compact serialization.
-
-[1]: https://i.blackhat.com/BH-US-23/Presentations/US-23-Tervoort-Three-New-Attacks-Against-JSON-Web-Tokens.pdf
-
-# v3.0.2
-
-## Fixed
-
- - DecryptMulti: handle decompression error (#19)
-
-## Changed
-
- - jwe/CompactSerialize: improve performance (#67)
- - Increase the default number of PBKDF2 iterations to 600k (#48)
- - Return the proper algorithm for ECDSA keys (#45)
-
-## Added
-
- - Add Thumbprint support for opaque signers (#38)
-
-# v3.0.1
-
-## Fixed
-
- - Security issue: an attacker specifying a large "p2c" value can cause
- JSONWebEncryption.Decrypt and JSONWebEncryption.DecryptMulti to consume large
- amounts of CPU, causing a DoS. Thanks to Matt Schwager (@mschwager) for the
- disclosure and to Tom Tervoort for originally publishing the category of attack.
- https://i.blackhat.com/BH-US-23/Presentations/US-23-Tervoort-Three-New-Attacks-Against-JSON-Web-Tokens.pdf
diff --git a/vendor/github.com/go-jose/go-jose/v4/README.md b/vendor/github.com/go-jose/go-jose/v4/README.md
deleted file mode 100644
index 02b5749..0000000
--- a/vendor/github.com/go-jose/go-jose/v4/README.md
+++ /dev/null
@@ -1,106 +0,0 @@
-# Go JOSE
-
-[](https://pkg.go.dev/github.com/go-jose/go-jose/v4)
-[](https://pkg.go.dev/github.com/go-jose/go-jose/v4/jwt)
-[](https://raw.githubusercontent.com/go-jose/go-jose/master/LICENSE)
-[](https://github.com/go-jose/go-jose/actions)
-
-Package jose aims to provide an implementation of the Javascript Object Signing
-and Encryption set of standards. This includes support for JSON Web Encryption,
-JSON Web Signature, and JSON Web Token standards.
-
-## Overview
-
-The implementation follows the
-[JSON Web Encryption](https://dx.doi.org/10.17487/RFC7516) (RFC 7516),
-[JSON Web Signature](https://dx.doi.org/10.17487/RFC7515) (RFC 7515), and
-[JSON Web Token](https://dx.doi.org/10.17487/RFC7519) (RFC 7519) specifications.
-Tables of supported algorithms are shown below. The library supports both
-the compact and JWS/JWE JSON Serialization formats, and has optional support for
-multiple recipients. It also comes with a small command-line utility
-([`jose-util`](https://pkg.go.dev/github.com/go-jose/go-jose/jose-util))
-for dealing with JOSE messages in a shell.
-
-**Note**: We use a forked version of the `encoding/json` package from the Go
-standard library which uses case-sensitive matching for member names (instead
-of [case-insensitive matching](https://www.ietf.org/mail-archive/web/json/current/msg03763.html)).
-This is to avoid differences in interpretation of messages between go-jose and
-libraries in other languages.
-
-### Versions
-
-[Version 4](https://github.com/go-jose/go-jose)
-([branch](https://github.com/go-jose/go-jose/tree/main),
-[doc](https://pkg.go.dev/github.com/go-jose/go-jose/v4), [releases](https://github.com/go-jose/go-jose/releases)) is the current stable version:
-
- import "github.com/go-jose/go-jose/v4"
-
-The old [square/go-jose](https://github.com/square/go-jose) repo contains the prior v1 and v2 versions, which
-are still useable but not actively developed anymore.
-
-Version 3, in this repo, is still receiving security fixes but not functionality
-updates.
-
-### Supported algorithms
-
-See below for a table of supported algorithms. Algorithm identifiers match
-the names in the [JSON Web Algorithms](https://dx.doi.org/10.17487/RFC7518)
-standard where possible. The Godoc reference has a list of constants.
-
- Key encryption | Algorithm identifier(s)
- :------------------------- | :------------------------------
- RSA-PKCS#1v1.5 | RSA1_5
- RSA-OAEP | RSA-OAEP, RSA-OAEP-256
- AES key wrap | A128KW, A192KW, A256KW
- AES-GCM key wrap | A128GCMKW, A192GCMKW, A256GCMKW
- ECDH-ES + AES key wrap | ECDH-ES+A128KW, ECDH-ES+A192KW, ECDH-ES+A256KW
- ECDH-ES (direct) | ECDH-ES1
- Direct encryption | dir1
-
-1. Not supported in multi-recipient mode
-
- Signing / MAC | Algorithm identifier(s)
- :------------------------- | :------------------------------
- RSASSA-PKCS#1v1.5 | RS256, RS384, RS512
- RSASSA-PSS | PS256, PS384, PS512
- HMAC | HS256, HS384, HS512
- ECDSA | ES256, ES384, ES512
- Ed25519 | EdDSA2
-
-2. Only available in version 2 of the package
-
- Content encryption | Algorithm identifier(s)
- :------------------------- | :------------------------------
- AES-CBC+HMAC | A128CBC-HS256, A192CBC-HS384, A256CBC-HS512
- AES-GCM | A128GCM, A192GCM, A256GCM
-
- Compression | Algorithm identifiers(s)
- :------------------------- | -------------------------------
- DEFLATE (RFC 1951) | DEF
-
-### Supported key types
-
-See below for a table of supported key types. These are understood by the
-library, and can be passed to corresponding functions such as `NewEncrypter` or
-`NewSigner`. Each of these keys can also be wrapped in a JWK if desired, which
-allows attaching a key id.
-
- Algorithm(s) | Corresponding types
- :------------------------- | -------------------------------
- RSA | *[rsa.PublicKey](https://pkg.go.dev/crypto/rsa/#PublicKey), *[rsa.PrivateKey](https://pkg.go.dev/crypto/rsa/#PrivateKey)
- ECDH, ECDSA | *[ecdsa.PublicKey](https://pkg.go.dev/crypto/ecdsa/#PublicKey), *[ecdsa.PrivateKey](https://pkg.go.dev/crypto/ecdsa/#PrivateKey)
- EdDSA1 | [ed25519.PublicKey](https://pkg.go.dev/crypto/ed25519#PublicKey), [ed25519.PrivateKey](https://pkg.go.dev/crypto/ed25519#PrivateKey)
- AES, HMAC | []byte
-
-1. Only available in version 2 or later of the package
-
-## Examples
-
-[](https://pkg.go.dev/github.com/go-jose/go-jose/v4)
-[](https://pkg.go.dev/github.com/go-jose/go-jose/v4/jwt)
-
-Examples can be found in the Godoc
-reference for this package. The
-[`jose-util`](https://github.com/go-jose/go-jose/tree/main/jose-util)
-subdirectory also contains a small command-line utility which might be useful
-as an example as well.
diff --git a/vendor/github.com/go-jose/go-jose/v4/SECURITY.md b/vendor/github.com/go-jose/go-jose/v4/SECURITY.md
deleted file mode 100644
index 2f18a75..0000000
--- a/vendor/github.com/go-jose/go-jose/v4/SECURITY.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Security Policy
-This document explains how to contact the Let's Encrypt security team to report security vulnerabilities.
-
-## Supported Versions
-| Version | Supported |
-| ------- | ----------|
-| >= v3 | ✓ |
-| v2 | ✗ |
-| v1 | ✗ |
-
-## Reporting a vulnerability
-
-Please see [https://letsencrypt.org/contact/#security](https://letsencrypt.org/contact/#security) for the email address to report a vulnerability. Ensure that the subject line for your report contains the word `vulnerability` and is descriptive. Your email should be acknowledged within 24 hours. If you do not receive a response within 24 hours, please follow-up again with another email.
diff --git a/vendor/github.com/go-jose/go-jose/v4/symmetric_go124.go b/vendor/github.com/go-jose/go-jose/v4/symmetric_go124.go
deleted file mode 100644
index 6c5a4e7..0000000
--- a/vendor/github.com/go-jose/go-jose/v4/symmetric_go124.go
+++ /dev/null
@@ -1,28 +0,0 @@
-//go:build go1.24
-
-/*-
- * Copyright 2014 Square Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package jose
-
-import (
- "crypto/pbkdf2"
- "hash"
-)
-
-func pbkdf2Key(h func() hash.Hash, password string, salt []byte, iter, keyLen int) ([]byte, error) {
- return pbkdf2.Key(h, password, salt, iter, keyLen)
-}
diff --git a/vendor/github.com/go-jose/go-jose/v4/symmetric_legacy.go b/vendor/github.com/go-jose/go-jose/v4/symmetric_legacy.go
deleted file mode 100644
index bdfc3d7..0000000
--- a/vendor/github.com/go-jose/go-jose/v4/symmetric_legacy.go
+++ /dev/null
@@ -1,29 +0,0 @@
-//go:build !go1.24
-
-/*-
- * Copyright 2014 Square Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package jose
-
-import (
- "hash"
-
- "golang.org/x/crypto/pbkdf2"
-)
-
-func pbkdf2Key(h func() hash.Hash, password string, salt []byte, iter, keyLen int) ([]byte, error) {
- return pbkdf2.Key([]byte(password), salt, iter, keyLen, h), nil
-}
diff --git a/vendor/github.com/goccy/go-json/.golangci.yml b/vendor/github.com/goccy/go-json/.golangci.yml
index 977acca..44ae40f 100644
--- a/vendor/github.com/goccy/go-json/.golangci.yml
+++ b/vendor/github.com/goccy/go-json/.golangci.yml
@@ -48,17 +48,6 @@ linters:
- nlreturn
- testpackage
- wsl
- - varnamelen
- - nilnil
- - ireturn
- - govet
- - forcetypeassert
- - cyclop
- - containedctx
- - revive
- - nosnakecase
- - exhaustruct
- - depguard
issues:
exclude-rules:
diff --git a/vendor/github.com/goccy/go-json/CHANGELOG.md b/vendor/github.com/goccy/go-json/CHANGELOG.md
index d09bb89..f69c814 100644
--- a/vendor/github.com/goccy/go-json/CHANGELOG.md
+++ b/vendor/github.com/goccy/go-json/CHANGELOG.md
@@ -1,168 +1,3 @@
-# v0.10.2 - 2023/03/20
-
-### New features
-
-* Support DebugDOT option for debugging encoder ( #440 )
-
-### Fix bugs
-
-* Fix combination of embedding structure and omitempty option ( #442 )
-
-# v0.10.1 - 2023/03/13
-
-### Fix bugs
-
-* Fix checkptr error for array decoder ( #415 )
-* Fix added buffer size check when decoding key ( #430 )
-* Fix handling of anonymous fields other than struct ( #431 )
-* Fix to not optimize when lower conversion can't handle byte-by-byte ( #432 )
-* Fix a problem that MarshalIndent does not work when UnorderedMap is specified ( #435 )
-* Fix mapDecoder.DecodeStream() for empty objects containing whitespace ( #425 )
-* Fix an issue that could not set the correct NextField for fields in the embedded structure ( #438 )
-
-# v0.10.0 - 2022/11/29
-
-### New features
-
-* Support JSON Path ( #250 )
-
-### Fix bugs
-
-* Fix marshaler for map's key ( #409 )
-
-# v0.9.11 - 2022/08/18
-
-### Fix bugs
-
-* Fix unexpected behavior when buffer ends with backslash ( #383 )
-* Fix stream decoding of escaped character ( #387 )
-
-# v0.9.10 - 2022/07/15
-
-### Fix bugs
-
-* Fix boundary exception of type caching ( #382 )
-
-# v0.9.9 - 2022/07/15
-
-### Fix bugs
-
-* Fix encoding of directed interface with typed nil ( #377 )
-* Fix embedded primitive type encoding using alias ( #378 )
-* Fix slice/array type encoding with types implementing MarshalJSON ( #379 )
-* Fix unicode decoding when the expected buffer state is not met after reading ( #380 )
-
-# v0.9.8 - 2022/06/30
-
-### Fix bugs
-
-* Fix decoding of surrogate-pair ( #365 )
-* Fix handling of embedded primitive type ( #366 )
-* Add validation of escape sequence for decoder ( #367 )
-* Fix stream tokenizing respecting UseNumber ( #369 )
-* Fix encoding when struct pointer type that implements Marshal JSON is embedded ( #375 )
-
-### Improve performance
-
-* Improve performance of linkRecursiveCode ( #368 )
-
-# v0.9.7 - 2022/04/22
-
-### Fix bugs
-
-#### Encoder
-
-* Add filtering process for encoding on slow path ( #355 )
-* Fix encoding of interface{} with pointer type ( #363 )
-
-#### Decoder
-
-* Fix map key decoder that implements UnmarshalJSON ( #353 )
-* Fix decoding of []uint8 type ( #361 )
-
-### New features
-
-* Add DebugWith option for encoder ( #356 )
-
-# v0.9.6 - 2022/03/22
-
-### Fix bugs
-
-* Correct the handling of the minimum value of int type for decoder ( #344 )
-* Fix bugs of stream decoder's bufferSize ( #349 )
-* Add a guard to use typeptr more safely ( #351 )
-
-### Improve decoder performance
-
-* Improve escapeString's performance ( #345 )
-
-### Others
-
-* Update go version for CI ( #347 )
-
-# v0.9.5 - 2022/03/04
-
-### Fix bugs
-
-* Fix panic when decoding time.Time with context ( #328 )
-* Fix reading the next character in buffer to nul consideration ( #338 )
-* Fix incorrect handling on skipValue ( #341 )
-
-### Improve decoder performance
-
-* Improve performance when a payload contains escape sequence ( #334 )
-
-# v0.9.4 - 2022/01/21
-
-* Fix IsNilForMarshaler for string type with omitempty ( #323 )
-* Fix the case where the embedded field is at the end ( #326 )
-
-# v0.9.3 - 2022/01/14
-
-* Fix logic of removing struct field for decoder ( #322 )
-
-# v0.9.2 - 2022/01/14
-
-* Add invalid decoder to delay type error judgment at decode ( #321 )
-
-# v0.9.1 - 2022/01/11
-
-* Fix encoding of MarshalText/MarshalJSON operation with head offset ( #319 )
-
-# v0.9.0 - 2022/01/05
-
-### New feature
-
-* Supports dynamic filtering of struct fields ( #314 )
-
-### Improve encoding performance
-
-* Improve map encoding performance ( #310 )
-* Optimize encoding path for escaped string ( #311 )
-* Add encoding option for performance ( #312 )
-
-### Fix bugs
-
-* Fix panic at encoding map value on 1.18 ( #310 )
-* Fix MarshalIndent for interface type ( #317 )
-
-# v0.8.1 - 2021/12/05
-
-* Fix operation conversion from PtrHead to Head in Recursive type ( #305 )
-
-# v0.8.0 - 2021/12/02
-
-* Fix embedded field conflict behavior ( #300 )
-* Refactor compiler for encoder ( #301 #302 )
-
-# v0.7.10 - 2021/10/16
-
-* Fix conversion from pointer to uint64 ( #294 )
-
-# v0.7.9 - 2021/09/28
-
-* Fix encoding of nil value about interface type that has method ( #291 )
-
# v0.7.8 - 2021/09/01
* Fix mapassign_faststr for indirect struct type ( #283 )
diff --git a/vendor/github.com/goccy/go-json/Makefile b/vendor/github.com/goccy/go-json/Makefile
index c030577..363563a 100644
--- a/vendor/github.com/goccy/go-json/Makefile
+++ b/vendor/github.com/goccy/go-json/Makefile
@@ -22,7 +22,7 @@ cover-html: cover
.PHONY: lint
lint: golangci-lint
- $(BIN_DIR)/golangci-lint run
+ golangci-lint run
golangci-lint: | $(BIN_DIR)
@{ \
@@ -30,7 +30,7 @@ golangci-lint: | $(BIN_DIR)
GOLANGCI_LINT_TMP_DIR=$$(mktemp -d); \
cd $$GOLANGCI_LINT_TMP_DIR; \
go mod init tmp; \
- GOBIN=$(BIN_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2; \
+ GOBIN=$(BIN_DIR) go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.36.0; \
rm -rf $$GOLANGCI_LINT_TMP_DIR; \
}
diff --git a/vendor/github.com/goccy/go-json/README.md b/vendor/github.com/goccy/go-json/README.md
index 7bacc54..418854e 100644
--- a/vendor/github.com/goccy/go-json/README.md
+++ b/vendor/github.com/goccy/go-json/README.md
@@ -13,7 +13,7 @@ Fast JSON encoder/decoder compatible with encoding/json for Go
```
* version ( expected release date )
-* v0.9.0
+* v0.7.0
|
| while maintaining compatibility with encoding/json, we will add convenient APIs
|
@@ -21,8 +21,9 @@ Fast JSON encoder/decoder compatible with encoding/json for Go
* v1.0.0
```
-We are accepting requests for features that will be implemented between v0.9.0 and v.1.0.0.
+We are accepting requests for features that will be implemented between v0.7.0 and v.1.0.0.
If you have the API you need, please submit your issue [here](https://github.com/goccy/go-json/issues).
+For example, I'm thinking of supporting `context.Context` of `json.Marshaler` and decoding using JSON Path.
# Features
@@ -31,7 +32,6 @@ If you have the API you need, please submit your issue [here](https://github.com
- Flexible customization with options
- Coloring the encoded string
- Can propagate context.Context to `MarshalJSON` or `UnmarshalJSON`
-- Can dynamically filter the fields of the structure type-safely
# Installation
@@ -184,7 +184,7 @@ func Marshal(v interface{}) ([]byte, error) {
`json.Marshal` and `json.Unmarshal` receive `interface{}` value and they perform type determination dynamically to process.
In normal case, you need to use the `reflect` library to determine the type dynamically, but since `reflect.Type` is defined as `interface`, when you call the method of `reflect.Type`, The reflect's argument is escaped.
-Therefore, the arguments for `Marshal` and `Unmarshal` are always escaped to the heap.
+Therefore, the arguments for `Marshal` and `Unmarshal` are always escape to the heap.
However, `go-json` can use the feature of `reflect.Type` while avoiding escaping.
`reflect.Type` is defined as `interface`, but in reality `reflect.Type` is implemented only by the structure `rtype` defined in the `reflect` package.
diff --git a/vendor/github.com/goccy/go-json/decode.go b/vendor/github.com/goccy/go-json/decode.go
index 74c6ac3..d99749d 100644
--- a/vendor/github.com/goccy/go-json/decode.go
+++ b/vendor/github.com/goccy/go-json/decode.go
@@ -83,37 +83,6 @@ func unmarshalContext(ctx context.Context, data []byte, v interface{}, optFuncs
return validateEndBuf(src, cursor)
}
-var (
- pathDecoder = decoder.NewPathDecoder()
-)
-
-func extractFromPath(path *Path, data []byte, optFuncs ...DecodeOptionFunc) ([][]byte, error) {
- if path.path.RootSelectorOnly {
- return [][]byte{data}, nil
- }
- src := make([]byte, len(data)+1) // append nul byte to the end
- copy(src, data)
-
- ctx := decoder.TakeRuntimeContext()
- ctx.Buf = src
- ctx.Option.Flags = 0
- ctx.Option.Flags |= decoder.PathOption
- ctx.Option.Path = path.path
- for _, optFunc := range optFuncs {
- optFunc(ctx.Option)
- }
- paths, cursor, err := pathDecoder.DecodePath(ctx, 0, 0)
- if err != nil {
- decoder.ReleaseRuntimeContext(ctx)
- return nil, err
- }
- decoder.ReleaseRuntimeContext(ctx)
- if err := validateEndBuf(src, cursor); err != nil {
- return nil, err
- }
- return paths, nil
-}
-
func unmarshalNoEscape(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error {
src := make([]byte, len(data)+1) // append nul byte to the end
copy(src, data)
diff --git a/vendor/github.com/goccy/go-json/docker-compose.yml b/vendor/github.com/goccy/go-json/docker-compose.yml
index db40c79..e510666 100644
--- a/vendor/github.com/goccy/go-json/docker-compose.yml
+++ b/vendor/github.com/goccy/go-json/docker-compose.yml
@@ -1,7 +1,7 @@
version: '2'
services:
go-json:
- image: golang:1.18
+ image: golang:1.16
volumes:
- '.:/go/src/go-json'
deploy:
diff --git a/vendor/github.com/goccy/go-json/encode.go b/vendor/github.com/goccy/go-json/encode.go
index c517382..7f198bd 100644
--- a/vendor/github.com/goccy/go-json/encode.go
+++ b/vendor/github.com/goccy/go-json/encode.go
@@ -3,7 +3,6 @@ package json
import (
"context"
"io"
- "os"
"unsafe"
"github.com/goccy/go-json/internal/encoder"
@@ -52,7 +51,7 @@ func (e *Encoder) EncodeContext(ctx context.Context, v interface{}, optFuncs ...
rctx.Option.Flag |= encoder.ContextOption
rctx.Option.Context = ctx
- err := e.encodeWithOption(rctx, v, optFuncs...) //nolint: contextcheck
+ err := e.encodeWithOption(rctx, v, optFuncs...)
encoder.ReleaseRuntimeContext(rctx)
return err
@@ -62,8 +61,6 @@ func (e *Encoder) encodeWithOption(ctx *encoder.RuntimeContext, v interface{}, o
if e.enabledHTMLEscape {
ctx.Option.Flag |= encoder.HTMLEscapeOption
}
- ctx.Option.Flag |= encoder.NormalizeUTF8Option
- ctx.Option.DebugOut = os.Stdout
for _, optFunc := range optFuncs {
optFunc(ctx.Option)
}
@@ -114,13 +111,13 @@ func (e *Encoder) SetIndent(prefix, indent string) {
func marshalContext(ctx context.Context, v interface{}, optFuncs ...EncodeOptionFunc) ([]byte, error) {
rctx := encoder.TakeRuntimeContext()
rctx.Option.Flag = 0
- rctx.Option.Flag = encoder.HTMLEscapeOption | encoder.NormalizeUTF8Option | encoder.ContextOption
+ rctx.Option.Flag = encoder.HTMLEscapeOption | encoder.ContextOption
rctx.Option.Context = ctx
for _, optFunc := range optFuncs {
optFunc(rctx.Option)
}
- buf, err := encode(rctx, v) //nolint: contextcheck
+ buf, err := encode(rctx, v)
if err != nil {
encoder.ReleaseRuntimeContext(rctx)
return nil, err
@@ -142,7 +139,7 @@ func marshal(v interface{}, optFuncs ...EncodeOptionFunc) ([]byte, error) {
ctx := encoder.TakeRuntimeContext()
ctx.Option.Flag = 0
- ctx.Option.Flag |= (encoder.HTMLEscapeOption | encoder.NormalizeUTF8Option)
+ ctx.Option.Flag |= encoder.HTMLEscapeOption
for _, optFunc := range optFuncs {
optFunc(ctx.Option)
}
@@ -169,7 +166,7 @@ func marshalNoEscape(v interface{}) ([]byte, error) {
ctx := encoder.TakeRuntimeContext()
ctx.Option.Flag = 0
- ctx.Option.Flag |= (encoder.HTMLEscapeOption | encoder.NormalizeUTF8Option)
+ ctx.Option.Flag |= encoder.HTMLEscapeOption
buf, err := encodeNoEscape(ctx, v)
if err != nil {
@@ -193,7 +190,7 @@ func marshalIndent(v interface{}, prefix, indent string, optFuncs ...EncodeOptio
ctx := encoder.TakeRuntimeContext()
ctx.Option.Flag = 0
- ctx.Option.Flag |= (encoder.HTMLEscapeOption | encoder.NormalizeUTF8Option | encoder.IndentOption)
+ ctx.Option.Flag |= (encoder.HTMLEscapeOption | encoder.IndentOption)
for _, optFunc := range optFuncs {
optFunc(ctx.Option)
}
@@ -223,7 +220,7 @@ func encode(ctx *encoder.RuntimeContext, v interface{}) ([]byte, error) {
typ := header.typ
typeptr := uintptr(unsafe.Pointer(typ))
- codeSet, err := encoder.CompileToGetCodeSet(ctx, typeptr)
+ codeSet, err := encoder.CompileToGetCodeSet(typeptr)
if err != nil {
return nil, err
}
@@ -251,7 +248,7 @@ func encodeNoEscape(ctx *encoder.RuntimeContext, v interface{}) ([]byte, error)
typ := header.typ
typeptr := uintptr(unsafe.Pointer(typ))
- codeSet, err := encoder.CompileToGetCodeSet(ctx, typeptr)
+ codeSet, err := encoder.CompileToGetCodeSet(typeptr)
if err != nil {
return nil, err
}
@@ -278,7 +275,7 @@ func encodeIndent(ctx *encoder.RuntimeContext, v interface{}, prefix, indent str
typ := header.typ
typeptr := uintptr(unsafe.Pointer(typ))
- codeSet, err := encoder.CompileToGetCodeSet(ctx, typeptr)
+ codeSet, err := encoder.CompileToGetCodeSet(typeptr)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/goccy/go-json/error.go b/vendor/github.com/goccy/go-json/error.go
index 5b2dcee..94c1339 100644
--- a/vendor/github.com/goccy/go-json/error.go
+++ b/vendor/github.com/goccy/go-json/error.go
@@ -37,5 +37,3 @@ type UnmarshalTypeError = errors.UnmarshalTypeError
type UnsupportedTypeError = errors.UnsupportedTypeError
type UnsupportedValueError = errors.UnsupportedValueError
-
-type PathError = errors.PathError
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go b/vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go
index b6876cf..030cb7a 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go
@@ -35,7 +35,3 @@ func (d *anonymousFieldDecoder) Decode(ctx *RuntimeContext, cursor, depth int64,
p = *(*unsafe.Pointer)(p)
return d.dec.Decode(ctx, cursor, depth, unsafe.Pointer(uintptr(p)+d.offset))
}
-
-func (d *anonymousFieldDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return d.dec.DecodePath(ctx, cursor, depth)
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/array.go b/vendor/github.com/goccy/go-json/internal/decoder/array.go
index 4b23ed4..21f1fd5 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/array.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/array.go
@@ -1,7 +1,6 @@
package decoder
import (
- "fmt"
"unsafe"
"github.com/goccy/go-json/internal/errors"
@@ -19,9 +18,7 @@ type arrayDecoder struct {
}
func newArrayDecoder(dec Decoder, elemType *runtime.Type, alen int, structName, fieldName string) *arrayDecoder {
- // workaround to avoid checkptr errors. cannot use `*(*unsafe.Pointer)(unsafe_New(elemType))` directly.
- zeroValuePtr := unsafe_New(elemType)
- zeroValue := **(**unsafe.Pointer)(unsafe.Pointer(&zeroValuePtr))
+ zeroValue := *(*unsafe.Pointer)(unsafe_New(elemType))
return &arrayDecoder{
valueDecoder: dec,
elemType: elemType,
@@ -170,7 +167,3 @@ func (d *arrayDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe
}
}
}
-
-func (d *arrayDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: array decoder does not support decode path")
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/assign.go b/vendor/github.com/goccy/go-json/internal/decoder/assign.go
deleted file mode 100644
index c53e6ad..0000000
--- a/vendor/github.com/goccy/go-json/internal/decoder/assign.go
+++ /dev/null
@@ -1,438 +0,0 @@
-package decoder
-
-import (
- "fmt"
- "reflect"
- "strconv"
-)
-
-var (
- nilValue = reflect.ValueOf(nil)
-)
-
-func AssignValue(src, dst reflect.Value) error {
- if dst.Type().Kind() != reflect.Ptr {
- return fmt.Errorf("invalid dst type. required pointer type: %T", dst.Type())
- }
- casted, err := castValue(dst.Elem().Type(), src)
- if err != nil {
- return err
- }
- dst.Elem().Set(casted)
- return nil
-}
-
-func castValue(t reflect.Type, v reflect.Value) (reflect.Value, error) {
- switch t.Kind() {
- case reflect.Int:
- vv, err := castInt(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(int(vv.Int())), nil
- case reflect.Int8:
- vv, err := castInt(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(int8(vv.Int())), nil
- case reflect.Int16:
- vv, err := castInt(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(int16(vv.Int())), nil
- case reflect.Int32:
- vv, err := castInt(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(int32(vv.Int())), nil
- case reflect.Int64:
- return castInt(v)
- case reflect.Uint:
- vv, err := castUint(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(uint(vv.Uint())), nil
- case reflect.Uint8:
- vv, err := castUint(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(uint8(vv.Uint())), nil
- case reflect.Uint16:
- vv, err := castUint(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(uint16(vv.Uint())), nil
- case reflect.Uint32:
- vv, err := castUint(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(uint32(vv.Uint())), nil
- case reflect.Uint64:
- return castUint(v)
- case reflect.Uintptr:
- vv, err := castUint(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(uintptr(vv.Uint())), nil
- case reflect.String:
- return castString(v)
- case reflect.Bool:
- return castBool(v)
- case reflect.Float32:
- vv, err := castFloat(v)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(float32(vv.Float())), nil
- case reflect.Float64:
- return castFloat(v)
- case reflect.Array:
- return castArray(t, v)
- case reflect.Slice:
- return castSlice(t, v)
- case reflect.Map:
- return castMap(t, v)
- case reflect.Struct:
- return castStruct(t, v)
- }
- return v, nil
-}
-
-func castInt(v reflect.Value) (reflect.Value, error) {
- switch v.Type().Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return v, nil
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return reflect.ValueOf(int64(v.Uint())), nil
- case reflect.String:
- i64, err := strconv.ParseInt(v.String(), 10, 64)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(i64), nil
- case reflect.Bool:
- if v.Bool() {
- return reflect.ValueOf(int64(1)), nil
- }
- return reflect.ValueOf(int64(0)), nil
- case reflect.Float32, reflect.Float64:
- return reflect.ValueOf(int64(v.Float())), nil
- case reflect.Array:
- if v.Len() > 0 {
- return castInt(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to int64 from empty array")
- case reflect.Slice:
- if v.Len() > 0 {
- return castInt(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to int64 from empty slice")
- case reflect.Interface:
- return castInt(reflect.ValueOf(v.Interface()))
- case reflect.Map:
- return nilValue, fmt.Errorf("failed to cast to int64 from map")
- case reflect.Struct:
- return nilValue, fmt.Errorf("failed to cast to int64 from struct")
- case reflect.Ptr:
- return castInt(v.Elem())
- }
- return nilValue, fmt.Errorf("failed to cast to int64 from %s", v.Type().Kind())
-}
-
-func castUint(v reflect.Value) (reflect.Value, error) {
- switch v.Type().Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return reflect.ValueOf(uint64(v.Int())), nil
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return v, nil
- case reflect.String:
- u64, err := strconv.ParseUint(v.String(), 10, 64)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(u64), nil
- case reflect.Bool:
- if v.Bool() {
- return reflect.ValueOf(uint64(1)), nil
- }
- return reflect.ValueOf(uint64(0)), nil
- case reflect.Float32, reflect.Float64:
- return reflect.ValueOf(uint64(v.Float())), nil
- case reflect.Array:
- if v.Len() > 0 {
- return castUint(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to uint64 from empty array")
- case reflect.Slice:
- if v.Len() > 0 {
- return castUint(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to uint64 from empty slice")
- case reflect.Interface:
- return castUint(reflect.ValueOf(v.Interface()))
- case reflect.Map:
- return nilValue, fmt.Errorf("failed to cast to uint64 from map")
- case reflect.Struct:
- return nilValue, fmt.Errorf("failed to cast to uint64 from struct")
- case reflect.Ptr:
- return castUint(v.Elem())
- }
- return nilValue, fmt.Errorf("failed to cast to uint64 from %s", v.Type().Kind())
-}
-
-func castString(v reflect.Value) (reflect.Value, error) {
- switch v.Type().Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return reflect.ValueOf(fmt.Sprint(v.Int())), nil
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return reflect.ValueOf(fmt.Sprint(v.Uint())), nil
- case reflect.String:
- return v, nil
- case reflect.Bool:
- if v.Bool() {
- return reflect.ValueOf("true"), nil
- }
- return reflect.ValueOf("false"), nil
- case reflect.Float32, reflect.Float64:
- return reflect.ValueOf(fmt.Sprint(v.Float())), nil
- case reflect.Array:
- if v.Len() > 0 {
- return castString(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to string from empty array")
- case reflect.Slice:
- if v.Len() > 0 {
- return castString(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to string from empty slice")
- case reflect.Interface:
- return castString(reflect.ValueOf(v.Interface()))
- case reflect.Map:
- return nilValue, fmt.Errorf("failed to cast to string from map")
- case reflect.Struct:
- return nilValue, fmt.Errorf("failed to cast to string from struct")
- case reflect.Ptr:
- return castString(v.Elem())
- }
- return nilValue, fmt.Errorf("failed to cast to string from %s", v.Type().Kind())
-}
-
-func castBool(v reflect.Value) (reflect.Value, error) {
- switch v.Type().Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- switch v.Int() {
- case 0:
- return reflect.ValueOf(false), nil
- case 1:
- return reflect.ValueOf(true), nil
- }
- return nilValue, fmt.Errorf("failed to cast to bool from %d", v.Int())
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- switch v.Uint() {
- case 0:
- return reflect.ValueOf(false), nil
- case 1:
- return reflect.ValueOf(true), nil
- }
- return nilValue, fmt.Errorf("failed to cast to bool from %d", v.Uint())
- case reflect.String:
- b, err := strconv.ParseBool(v.String())
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(b), nil
- case reflect.Bool:
- return v, nil
- case reflect.Float32, reflect.Float64:
- switch v.Float() {
- case 0:
- return reflect.ValueOf(false), nil
- case 1:
- return reflect.ValueOf(true), nil
- }
- return nilValue, fmt.Errorf("failed to cast to bool from %f", v.Float())
- case reflect.Array:
- if v.Len() > 0 {
- return castBool(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to string from empty array")
- case reflect.Slice:
- if v.Len() > 0 {
- return castBool(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to string from empty slice")
- case reflect.Interface:
- return castBool(reflect.ValueOf(v.Interface()))
- case reflect.Map:
- return nilValue, fmt.Errorf("failed to cast to string from map")
- case reflect.Struct:
- return nilValue, fmt.Errorf("failed to cast to string from struct")
- case reflect.Ptr:
- return castBool(v.Elem())
- }
- return nilValue, fmt.Errorf("failed to cast to bool from %s", v.Type().Kind())
-}
-
-func castFloat(v reflect.Value) (reflect.Value, error) {
- switch v.Type().Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return reflect.ValueOf(float64(v.Int())), nil
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return reflect.ValueOf(float64(v.Uint())), nil
- case reflect.String:
- f64, err := strconv.ParseFloat(v.String(), 64)
- if err != nil {
- return nilValue, err
- }
- return reflect.ValueOf(f64), nil
- case reflect.Bool:
- if v.Bool() {
- return reflect.ValueOf(float64(1)), nil
- }
- return reflect.ValueOf(float64(0)), nil
- case reflect.Float32, reflect.Float64:
- return v, nil
- case reflect.Array:
- if v.Len() > 0 {
- return castFloat(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to float64 from empty array")
- case reflect.Slice:
- if v.Len() > 0 {
- return castFloat(v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to float64 from empty slice")
- case reflect.Interface:
- return castFloat(reflect.ValueOf(v.Interface()))
- case reflect.Map:
- return nilValue, fmt.Errorf("failed to cast to float64 from map")
- case reflect.Struct:
- return nilValue, fmt.Errorf("failed to cast to float64 from struct")
- case reflect.Ptr:
- return castFloat(v.Elem())
- }
- return nilValue, fmt.Errorf("failed to cast to float64 from %s", v.Type().Kind())
-}
-
-func castArray(t reflect.Type, v reflect.Value) (reflect.Value, error) {
- kind := v.Type().Kind()
- if kind == reflect.Interface {
- return castArray(t, reflect.ValueOf(v.Interface()))
- }
- if kind != reflect.Slice && kind != reflect.Array {
- return nilValue, fmt.Errorf("failed to cast to array from %s", kind)
- }
- if t.Elem() == v.Type().Elem() {
- return v, nil
- }
- if t.Len() != v.Len() {
- return nilValue, fmt.Errorf("failed to cast [%d]array from slice of %d length", t.Len(), v.Len())
- }
- ret := reflect.New(t).Elem()
- for i := 0; i < v.Len(); i++ {
- vv, err := castValue(t.Elem(), v.Index(i))
- if err != nil {
- return nilValue, err
- }
- ret.Index(i).Set(vv)
- }
- return ret, nil
-}
-
-func castSlice(t reflect.Type, v reflect.Value) (reflect.Value, error) {
- kind := v.Type().Kind()
- if kind == reflect.Interface {
- return castSlice(t, reflect.ValueOf(v.Interface()))
- }
- if kind != reflect.Slice && kind != reflect.Array {
- return nilValue, fmt.Errorf("failed to cast to slice from %s", kind)
- }
- if t.Elem() == v.Type().Elem() {
- return v, nil
- }
- ret := reflect.MakeSlice(t, v.Len(), v.Len())
- for i := 0; i < v.Len(); i++ {
- vv, err := castValue(t.Elem(), v.Index(i))
- if err != nil {
- return nilValue, err
- }
- ret.Index(i).Set(vv)
- }
- return ret, nil
-}
-
-func castMap(t reflect.Type, v reflect.Value) (reflect.Value, error) {
- ret := reflect.MakeMap(t)
- switch v.Type().Kind() {
- case reflect.Map:
- iter := v.MapRange()
- for iter.Next() {
- key, err := castValue(t.Key(), iter.Key())
- if err != nil {
- return nilValue, err
- }
- value, err := castValue(t.Elem(), iter.Value())
- if err != nil {
- return nilValue, err
- }
- ret.SetMapIndex(key, value)
- }
- return ret, nil
- case reflect.Interface:
- return castMap(t, reflect.ValueOf(v.Interface()))
- case reflect.Slice:
- if v.Len() > 0 {
- return castMap(t, v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to map from empty slice")
- }
- return nilValue, fmt.Errorf("failed to cast to map from %s", v.Type().Kind())
-}
-
-func castStruct(t reflect.Type, v reflect.Value) (reflect.Value, error) {
- ret := reflect.New(t).Elem()
- switch v.Type().Kind() {
- case reflect.Map:
- iter := v.MapRange()
- for iter.Next() {
- key := iter.Key()
- k, err := castString(key)
- if err != nil {
- return nilValue, err
- }
- fieldName := k.String()
- field, ok := t.FieldByName(fieldName)
- if ok {
- value, err := castValue(field.Type, iter.Value())
- if err != nil {
- return nilValue, err
- }
- ret.FieldByName(fieldName).Set(value)
- }
- }
- return ret, nil
- case reflect.Struct:
- for i := 0; i < v.Type().NumField(); i++ {
- name := v.Type().Field(i).Name
- ret.FieldByName(name).Set(v.FieldByName(name))
- }
- return ret, nil
- case reflect.Interface:
- return castStruct(t, reflect.ValueOf(v.Interface()))
- case reflect.Slice:
- if v.Len() > 0 {
- return castStruct(t, v.Index(0))
- }
- return nilValue, fmt.Errorf("failed to cast to struct from empty slice")
- default:
- return nilValue, fmt.Errorf("failed to cast to struct from %s", v.Type().Kind())
- }
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/bool.go b/vendor/github.com/goccy/go-json/internal/decoder/bool.go
index ba6cf5b..455042a 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/bool.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/bool.go
@@ -1,7 +1,6 @@
package decoder
import (
- "fmt"
"unsafe"
"github.com/goccy/go-json/internal/errors"
@@ -77,7 +76,3 @@ func (d *boolDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.
}
return 0, errors.ErrUnexpectedEndOfJSON("bool", cursor)
}
-
-func (d *boolDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: bool decoder does not support decode path")
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/bytes.go b/vendor/github.com/goccy/go-json/internal/decoder/bytes.go
index 939bf43..01a37fe 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/bytes.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/bytes.go
@@ -2,7 +2,6 @@ package decoder
import (
"encoding/base64"
- "fmt"
"unsafe"
"github.com/goccy/go-json/internal/errors"
@@ -24,8 +23,9 @@ func byteUnmarshalerSliceDecoder(typ *runtime.Type, structName string, fieldName
unmarshalDecoder = newUnmarshalJSONDecoder(runtime.PtrTo(typ), structName, fieldName)
case runtime.PtrTo(typ).Implements(unmarshalTextType):
unmarshalDecoder = newUnmarshalTextDecoder(runtime.PtrTo(typ), structName, fieldName)
- default:
- unmarshalDecoder, _ = compileUint8(typ, structName, fieldName)
+ }
+ if unmarshalDecoder == nil {
+ return nil
}
return newSliceDecoder(unmarshalDecoder, typ, 1, structName, fieldName)
}
@@ -79,10 +79,6 @@ func (d *bytesDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe
return cursor, nil
}
-func (d *bytesDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: []byte decoder does not support decode path")
-}
-
func (d *bytesDecoder) decodeStreamBinary(s *Stream, depth int64, p unsafe.Pointer) ([]byte, error) {
c := s.skipWhiteSpace()
if c == '[' {
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/compile.go b/vendor/github.com/goccy/go-json/internal/decoder/compile.go
index 8ad5093..08dd044 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/compile.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/compile.go
@@ -5,11 +5,11 @@ import (
"fmt"
"reflect"
"strings"
- "sync"
"sync/atomic"
"unicode"
"unsafe"
+ "github.com/goccy/go-json/internal/errors"
"github.com/goccy/go-json/internal/runtime"
)
@@ -18,27 +18,22 @@ var (
typeAddr *runtime.TypeAddr
cachedDecoderMap unsafe.Pointer // map[uintptr]decoder
cachedDecoder []Decoder
- initOnce sync.Once
)
-func initDecoder() {
- initOnce.Do(func() {
- typeAddr = runtime.AnalyzeTypeAddr()
- if typeAddr == nil {
- typeAddr = &runtime.TypeAddr{}
- }
- cachedDecoder = make([]Decoder, typeAddr.AddrRange>>typeAddr.AddrShift+1)
- })
+func init() {
+ typeAddr = runtime.AnalyzeTypeAddr()
+ if typeAddr == nil {
+ typeAddr = &runtime.TypeAddr{}
+ }
+ cachedDecoder = make([]Decoder, typeAddr.AddrRange>>typeAddr.AddrShift)
}
func loadDecoderMap() map[uintptr]Decoder {
- initDecoder()
p := atomic.LoadPointer(&cachedDecoderMap)
return *(*map[uintptr]Decoder)(unsafe.Pointer(&p))
}
func storeDecoder(typ uintptr, dec Decoder, m map[uintptr]Decoder) {
- initDecoder()
newDecoderMap := make(map[uintptr]Decoder, len(m)+1)
newDecoderMap[typ] = dec
@@ -131,7 +126,13 @@ func compile(typ *runtime.Type, structName, fieldName string, structTypeToDecode
case reflect.Func:
return compileFunc(typ, structName, fieldName)
}
- return newInvalidDecoder(typ, structName, fieldName), nil
+ return nil, &errors.UnmarshalTypeError{
+ Value: "object",
+ Type: runtime.RType2Type(typ),
+ Offset: 0,
+ Struct: structName,
+ Field: fieldName,
+ }
}
func isStringTagSupportedType(typ *runtime.Type) bool {
@@ -160,9 +161,6 @@ func compileMapKey(typ *runtime.Type, structName, fieldName string, structTypeTo
if runtime.PtrTo(typ).Implements(unmarshalTextType) {
return newUnmarshalTextDecoder(runtime.PtrTo(typ), structName, fieldName), nil
}
- if typ.Kind() == reflect.String {
- return newStringDecoder(structName, fieldName), nil
- }
dec, err := compile(typ, structName, fieldName, structTypeToDecoder)
if err != nil {
return nil, err
@@ -176,9 +174,17 @@ func compileMapKey(typ *runtime.Type, structName, fieldName string, structTypeTo
case *ptrDecoder:
dec = t.dec
default:
- return newInvalidDecoder(typ, structName, fieldName), nil
+ goto ERROR
}
}
+ERROR:
+ return nil, &errors.UnmarshalTypeError{
+ Value: "object",
+ Type: runtime.RType2Type(typ),
+ Offset: 0,
+ Struct: structName,
+ Field: fieldName,
+ }
}
func compilePtr(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) {
@@ -316,21 +322,64 @@ func compileFunc(typ *runtime.Type, strutName, fieldName string) (Decoder, error
return newFuncDecoder(typ, strutName, fieldName), nil
}
-func typeToStructTags(typ *runtime.Type) runtime.StructTags {
- tags := runtime.StructTags{}
- fieldNum := typ.NumField()
- for i := 0; i < fieldNum; i++ {
- field := typ.Field(i)
- if runtime.IsIgnoredStructField(field) {
+func removeConflictFields(fieldMap map[string]*structFieldSet, conflictedMap map[string]struct{}, dec *structDecoder, field reflect.StructField) {
+ for k, v := range dec.fieldMap {
+ if _, exists := conflictedMap[k]; exists {
+ // already conflicted key
continue
}
- tags = append(tags, runtime.StructTagFromField(field))
+ set, exists := fieldMap[k]
+ if !exists {
+ fieldSet := &structFieldSet{
+ dec: v.dec,
+ offset: field.Offset + v.offset,
+ isTaggedKey: v.isTaggedKey,
+ key: k,
+ keyLen: int64(len(k)),
+ }
+ fieldMap[k] = fieldSet
+ lower := strings.ToLower(k)
+ if _, exists := fieldMap[lower]; !exists {
+ fieldMap[lower] = fieldSet
+ }
+ continue
+ }
+ if set.isTaggedKey {
+ if v.isTaggedKey {
+ // conflict tag key
+ delete(fieldMap, k)
+ delete(fieldMap, strings.ToLower(k))
+ conflictedMap[k] = struct{}{}
+ conflictedMap[strings.ToLower(k)] = struct{}{}
+ }
+ } else {
+ if v.isTaggedKey {
+ fieldSet := &structFieldSet{
+ dec: v.dec,
+ offset: field.Offset + v.offset,
+ isTaggedKey: v.isTaggedKey,
+ key: k,
+ keyLen: int64(len(k)),
+ }
+ fieldMap[k] = fieldSet
+ lower := strings.ToLower(k)
+ if _, exists := fieldMap[lower]; !exists {
+ fieldMap[lower] = fieldSet
+ }
+ } else {
+ // conflict tag key
+ delete(fieldMap, k)
+ delete(fieldMap, strings.ToLower(k))
+ conflictedMap[k] = struct{}{}
+ conflictedMap[strings.ToLower(k)] = struct{}{}
+ }
+ }
}
- return tags
}
func compileStruct(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) {
fieldNum := typ.NumField()
+ conflictedMap := map[string]struct{}{}
fieldMap := map[string]*structFieldSet{}
typeptr := uintptr(unsafe.Pointer(typ))
if dec, exists := structTypeToDecoder[typeptr]; exists {
@@ -339,8 +388,6 @@ func compileStruct(typ *runtime.Type, structName, fieldName string, structTypeTo
structDec := newStructDecoder(structName, fieldName, fieldMap)
structTypeToDecoder[typeptr] = structDec
structName = typ.Name()
- tags := typeToStructTags(typ)
- allFields := []*structFieldSet{}
for i := 0; i < fieldNum; i++ {
field := typ.Field(i)
if runtime.IsIgnoredStructField(field) {
@@ -358,19 +405,7 @@ func compileStruct(typ *runtime.Type, structName, fieldName string, structTypeTo
// recursive definition
continue
}
- for k, v := range stDec.fieldMap {
- if tags.ExistsKey(k) {
- continue
- }
- fieldSet := &structFieldSet{
- dec: v.dec,
- offset: field.Offset + v.offset,
- isTaggedKey: v.isTaggedKey,
- key: k,
- keyLen: int64(len(k)),
- }
- allFields = append(allFields, fieldSet)
- }
+ removeConflictFields(fieldMap, conflictedMap, stDec, field)
} else if pdec, ok := dec.(*ptrDecoder); ok {
contentDec := pdec.contentDecoder()
if pdec.typ == typ {
@@ -386,38 +421,60 @@ func compileStruct(typ *runtime.Type, structName, fieldName string, structTypeTo
}
if dec, ok := contentDec.(*structDecoder); ok {
for k, v := range dec.fieldMap {
- if tags.ExistsKey(k) {
+ if _, exists := conflictedMap[k]; exists {
+ // already conflicted key
continue
}
- fieldSet := &structFieldSet{
- dec: newAnonymousFieldDecoder(pdec.typ, v.offset, v.dec),
- offset: field.Offset,
- isTaggedKey: v.isTaggedKey,
- key: k,
- keyLen: int64(len(k)),
- err: fieldSetErr,
+ set, exists := fieldMap[k]
+ if !exists {
+ fieldSet := &structFieldSet{
+ dec: newAnonymousFieldDecoder(pdec.typ, v.offset, v.dec),
+ offset: field.Offset,
+ isTaggedKey: v.isTaggedKey,
+ key: k,
+ keyLen: int64(len(k)),
+ err: fieldSetErr,
+ }
+ fieldMap[k] = fieldSet
+ lower := strings.ToLower(k)
+ if _, exists := fieldMap[lower]; !exists {
+ fieldMap[lower] = fieldSet
+ }
+ continue
+ }
+ if set.isTaggedKey {
+ if v.isTaggedKey {
+ // conflict tag key
+ delete(fieldMap, k)
+ delete(fieldMap, strings.ToLower(k))
+ conflictedMap[k] = struct{}{}
+ conflictedMap[strings.ToLower(k)] = struct{}{}
+ }
+ } else {
+ if v.isTaggedKey {
+ fieldSet := &structFieldSet{
+ dec: newAnonymousFieldDecoder(pdec.typ, v.offset, v.dec),
+ offset: field.Offset,
+ isTaggedKey: v.isTaggedKey,
+ key: k,
+ keyLen: int64(len(k)),
+ err: fieldSetErr,
+ }
+ fieldMap[k] = fieldSet
+ lower := strings.ToLower(k)
+ if _, exists := fieldMap[lower]; !exists {
+ fieldMap[lower] = fieldSet
+ }
+ } else {
+ // conflict tag key
+ delete(fieldMap, k)
+ delete(fieldMap, strings.ToLower(k))
+ conflictedMap[k] = struct{}{}
+ conflictedMap[strings.ToLower(k)] = struct{}{}
+ }
}
- allFields = append(allFields, fieldSet)
}
- } else {
- fieldSet := &structFieldSet{
- dec: pdec,
- offset: field.Offset,
- isTaggedKey: tag.IsTaggedKey,
- key: field.Name,
- keyLen: int64(len(field.Name)),
- }
- allFields = append(allFields, fieldSet)
}
- } else {
- fieldSet := &structFieldSet{
- dec: dec,
- offset: field.Offset,
- isTaggedKey: tag.IsTaggedKey,
- key: field.Name,
- keyLen: int64(len(field.Name)),
- }
- allFields = append(allFields, fieldSet)
}
} else {
if tag.IsString && isStringTagSupportedType(runtime.Type2RType(field.Type)) {
@@ -436,15 +493,11 @@ func compileStruct(typ *runtime.Type, structName, fieldName string, structTypeTo
key: key,
keyLen: int64(len(key)),
}
- allFields = append(allFields, fieldSet)
- }
- }
- for _, set := range filterDuplicatedFields(allFields) {
- fieldMap[set.key] = set
- lower := strings.ToLower(set.key)
- if _, exists := fieldMap[lower]; !exists {
- // first win
- fieldMap[lower] = set
+ fieldMap[key] = fieldSet
+ lower := strings.ToLower(key)
+ if _, exists := fieldMap[lower]; !exists {
+ fieldMap[lower] = fieldSet
+ }
}
}
delete(structTypeToDecoder, typeptr)
@@ -452,42 +505,6 @@ func compileStruct(typ *runtime.Type, structName, fieldName string, structTypeTo
return structDec, nil
}
-func filterDuplicatedFields(allFields []*structFieldSet) []*structFieldSet {
- fieldMap := map[string][]*structFieldSet{}
- for _, field := range allFields {
- fieldMap[field.key] = append(fieldMap[field.key], field)
- }
- duplicatedFieldMap := map[string]struct{}{}
- for k, sets := range fieldMap {
- sets = filterFieldSets(sets)
- if len(sets) != 1 {
- duplicatedFieldMap[k] = struct{}{}
- }
- }
-
- filtered := make([]*structFieldSet, 0, len(allFields))
- for _, field := range allFields {
- if _, exists := duplicatedFieldMap[field.key]; exists {
- continue
- }
- filtered = append(filtered, field)
- }
- return filtered
-}
-
-func filterFieldSets(sets []*structFieldSet) []*structFieldSet {
- if len(sets) == 1 {
- return sets
- }
- filtered := make([]*structFieldSet, 0, len(sets))
- for _, set := range sets {
- if set.isTaggedKey {
- filtered = append(filtered, set)
- }
- }
- return filtered
-}
-
func implementsUnmarshalJSONType(typ *runtime.Type) bool {
return typ.Implements(unmarshalJSONType) || typ.Implements(unmarshalJSONContextType)
}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go b/vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go
index 025ca85..592f637 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go
@@ -1,4 +1,3 @@
-//go:build !race
// +build !race
package decoder
@@ -10,7 +9,6 @@ import (
)
func CompileToGetDecoder(typ *runtime.Type) (Decoder, error) {
- initDecoder()
typeptr := uintptr(unsafe.Pointer(typ))
if typeptr > typeAddr.MaxTypeAddr {
return compileToGetDecoderSlowPath(typeptr, typ)
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/compile_race.go b/vendor/github.com/goccy/go-json/internal/decoder/compile_race.go
index 023b817..b691bc9 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/compile_race.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/compile_race.go
@@ -1,4 +1,3 @@
-//go:build race
// +build race
package decoder
@@ -13,7 +12,6 @@ import (
var decMu sync.RWMutex
func CompileToGetDecoder(typ *runtime.Type) (Decoder, error) {
- initDecoder()
typeptr := uintptr(unsafe.Pointer(typ))
if typeptr > typeAddr.MaxTypeAddr {
return compileToGetDecoderSlowPath(typeptr, typ)
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/float.go b/vendor/github.com/goccy/go-json/internal/decoder/float.go
index 9b2eb8b..dfb7168 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/float.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/float.go
@@ -156,15 +156,3 @@ func (d *floatDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe
d.op(p, f64)
return cursor, nil
}
-
-func (d *floatDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- buf := ctx.Buf
- bytes, c, err := d.decodeByte(buf, cursor)
- if err != nil {
- return nil, 0, err
- }
- if bytes == nil {
- return [][]byte{nullbytes}, c, nil
- }
- return [][]byte{bytes}, c, nil
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/func.go b/vendor/github.com/goccy/go-json/internal/decoder/func.go
index 4cc12ca..ee35637 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/func.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/func.go
@@ -2,7 +2,6 @@ package decoder
import (
"bytes"
- "fmt"
"unsafe"
"github.com/goccy/go-json/internal/errors"
@@ -140,7 +139,3 @@ func (d *funcDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.
}
return cursor, errors.ErrInvalidBeginningOfValue(buf[cursor], cursor)
}
-
-func (d *funcDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: func decoder does not support decode path")
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/int.go b/vendor/github.com/goccy/go-json/internal/decoder/int.go
index 1a7f081..7edfb04 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/int.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/int.go
@@ -192,15 +192,15 @@ func (d *intDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) erro
}
switch d.kind {
case reflect.Int8:
- if i64 < -1*(1<<7) || (1<<7) <= i64 {
+ if i64 <= -1*(1<<7) || (1<<7) <= i64 {
return d.typeError(bytes, s.totalOffset())
}
case reflect.Int16:
- if i64 < -1*(1<<15) || (1<<15) <= i64 {
+ if i64 <= -1*(1<<15) || (1<<15) <= i64 {
return d.typeError(bytes, s.totalOffset())
}
case reflect.Int32:
- if i64 < -1*(1<<31) || (1<<31) <= i64 {
+ if i64 <= -1*(1<<31) || (1<<31) <= i64 {
return d.typeError(bytes, s.totalOffset())
}
}
@@ -225,22 +225,18 @@ func (d *intDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.P
}
switch d.kind {
case reflect.Int8:
- if i64 < -1*(1<<7) || (1<<7) <= i64 {
+ if i64 <= -1*(1<<7) || (1<<7) <= i64 {
return 0, d.typeError(bytes, cursor)
}
case reflect.Int16:
- if i64 < -1*(1<<15) || (1<<15) <= i64 {
+ if i64 <= -1*(1<<15) || (1<<15) <= i64 {
return 0, d.typeError(bytes, cursor)
}
case reflect.Int32:
- if i64 < -1*(1<<31) || (1<<31) <= i64 {
+ if i64 <= -1*(1<<31) || (1<<31) <= i64 {
return 0, d.typeError(bytes, cursor)
}
}
d.op(p, i64)
return cursor, nil
}
-
-func (d *intDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: int decoder does not support decode path")
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/interface.go b/vendor/github.com/goccy/go-json/internal/decoder/interface.go
index 45c69ab..4dbb4be 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/interface.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/interface.go
@@ -94,7 +94,6 @@ func (d *interfaceDecoder) numDecoder(s *Stream) Decoder {
var (
emptyInterfaceType = runtime.Type2RType(reflect.TypeOf((*interface{})(nil)).Elem())
- EmptyInterfaceType = emptyInterfaceType
interfaceMapType = runtime.Type2RType(
reflect.TypeOf((*map[string]interface{})(nil)).Elem(),
)
@@ -457,72 +456,3 @@ func (d *interfaceDecoder) decodeEmptyInterface(ctx *RuntimeContext, cursor, dep
}
return cursor, errors.ErrInvalidBeginningOfValue(buf[cursor], cursor)
}
-
-func NewPathDecoder() Decoder {
- ifaceDecoder := &interfaceDecoder{
- typ: emptyInterfaceType,
- structName: "",
- fieldName: "",
- floatDecoder: newFloatDecoder("", "", func(p unsafe.Pointer, v float64) {
- *(*interface{})(p) = v
- }),
- numberDecoder: newNumberDecoder("", "", func(p unsafe.Pointer, v json.Number) {
- *(*interface{})(p) = v
- }),
- stringDecoder: newStringDecoder("", ""),
- }
- ifaceDecoder.sliceDecoder = newSliceDecoder(
- ifaceDecoder,
- emptyInterfaceType,
- emptyInterfaceType.Size(),
- "", "",
- )
- ifaceDecoder.mapDecoder = newMapDecoder(
- interfaceMapType,
- stringType,
- ifaceDecoder.stringDecoder,
- interfaceMapType.Elem(),
- ifaceDecoder,
- "", "",
- )
- return ifaceDecoder
-}
-
-var (
- truebytes = []byte("true")
- falsebytes = []byte("false")
-)
-
-func (d *interfaceDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- buf := ctx.Buf
- cursor = skipWhiteSpace(buf, cursor)
- switch buf[cursor] {
- case '{':
- return d.mapDecoder.DecodePath(ctx, cursor, depth)
- case '[':
- return d.sliceDecoder.DecodePath(ctx, cursor, depth)
- case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
- return d.floatDecoder.DecodePath(ctx, cursor, depth)
- case '"':
- return d.stringDecoder.DecodePath(ctx, cursor, depth)
- case 't':
- if err := validateTrue(buf, cursor); err != nil {
- return nil, 0, err
- }
- cursor += 4
- return [][]byte{truebytes}, cursor, nil
- case 'f':
- if err := validateFalse(buf, cursor); err != nil {
- return nil, 0, err
- }
- cursor += 5
- return [][]byte{falsebytes}, cursor, nil
- case 'n':
- if err := validateNull(buf, cursor); err != nil {
- return nil, 0, err
- }
- cursor += 4
- return [][]byte{nullbytes}, cursor, nil
- }
- return nil, cursor, errors.ErrInvalidBeginningOfValue(buf[cursor], cursor)
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/invalid.go b/vendor/github.com/goccy/go-json/internal/decoder/invalid.go
deleted file mode 100644
index 4c9721b..0000000
--- a/vendor/github.com/goccy/go-json/internal/decoder/invalid.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package decoder
-
-import (
- "reflect"
- "unsafe"
-
- "github.com/goccy/go-json/internal/errors"
- "github.com/goccy/go-json/internal/runtime"
-)
-
-type invalidDecoder struct {
- typ *runtime.Type
- kind reflect.Kind
- structName string
- fieldName string
-}
-
-func newInvalidDecoder(typ *runtime.Type, structName, fieldName string) *invalidDecoder {
- return &invalidDecoder{
- typ: typ,
- kind: typ.Kind(),
- structName: structName,
- fieldName: fieldName,
- }
-}
-
-func (d *invalidDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error {
- return &errors.UnmarshalTypeError{
- Value: "object",
- Type: runtime.RType2Type(d.typ),
- Offset: s.totalOffset(),
- Struct: d.structName,
- Field: d.fieldName,
- }
-}
-
-func (d *invalidDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) {
- return 0, &errors.UnmarshalTypeError{
- Value: "object",
- Type: runtime.RType2Type(d.typ),
- Offset: cursor,
- Struct: d.structName,
- Field: d.fieldName,
- }
-}
-
-func (d *invalidDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, &errors.UnmarshalTypeError{
- Value: "object",
- Type: runtime.RType2Type(d.typ),
- Offset: cursor,
- Struct: d.structName,
- Field: d.fieldName,
- }
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/map.go b/vendor/github.com/goccy/go-json/internal/decoder/map.go
index 07a9cae..bb18ef9 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/map.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/map.go
@@ -87,13 +87,13 @@ func (d *mapDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) erro
if mapValue == nil {
mapValue = makemap(d.mapType, 0)
}
- s.cursor++
- if s.skipWhiteSpace() == '}' {
+ if s.buf[s.cursor+1] == '}' {
*(*unsafe.Pointer)(p) = mapValue
- s.cursor++
+ s.cursor += 2
return nil
}
for {
+ s.cursor++
k := unsafe_New(d.keyType)
if err := d.keyDecoder.DecodeStream(s, depth, k); err != nil {
return err
@@ -117,7 +117,6 @@ func (d *mapDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) erro
if !s.equalChar(',') {
return errors.ErrExpected("comma after object value", s.totalOffset())
}
- s.cursor++
}
}
@@ -185,96 +184,3 @@ func (d *mapDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.P
cursor++
}
}
-
-func (d *mapDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- buf := ctx.Buf
- depth++
- if depth > maxDecodeNestingDepth {
- return nil, 0, errors.ErrExceededMaxDepth(buf[cursor], cursor)
- }
-
- cursor = skipWhiteSpace(buf, cursor)
- buflen := int64(len(buf))
- if buflen < 2 {
- return nil, 0, errors.ErrExpected("{} for map", cursor)
- }
- switch buf[cursor] {
- case 'n':
- if err := validateNull(buf, cursor); err != nil {
- return nil, 0, err
- }
- cursor += 4
- return [][]byte{nullbytes}, cursor, nil
- case '{':
- default:
- return nil, 0, errors.ErrExpected("{ character for map value", cursor)
- }
- cursor++
- cursor = skipWhiteSpace(buf, cursor)
- if buf[cursor] == '}' {
- cursor++
- return nil, cursor, nil
- }
- keyDecoder, ok := d.keyDecoder.(*stringDecoder)
- if !ok {
- return nil, 0, &errors.UnmarshalTypeError{
- Value: "string",
- Type: reflect.TypeOf(""),
- Offset: cursor,
- Struct: d.structName,
- Field: d.fieldName,
- }
- }
- ret := [][]byte{}
- for {
- key, keyCursor, err := keyDecoder.decodeByte(buf, cursor)
- if err != nil {
- return nil, 0, err
- }
- cursor = skipWhiteSpace(buf, keyCursor)
- if buf[cursor] != ':' {
- return nil, 0, errors.ErrExpected("colon after object key", cursor)
- }
- cursor++
- child, found, err := ctx.Option.Path.Field(string(key))
- if err != nil {
- return nil, 0, err
- }
- if found {
- if child != nil {
- oldPath := ctx.Option.Path.node
- ctx.Option.Path.node = child
- paths, c, err := d.valueDecoder.DecodePath(ctx, cursor, depth)
- if err != nil {
- return nil, 0, err
- }
- ctx.Option.Path.node = oldPath
- ret = append(ret, paths...)
- cursor = c
- } else {
- start := cursor
- end, err := skipValue(buf, cursor, depth)
- if err != nil {
- return nil, 0, err
- }
- ret = append(ret, buf[start:end])
- cursor = end
- }
- } else {
- c, err := skipValue(buf, cursor, depth)
- if err != nil {
- return nil, 0, err
- }
- cursor = c
- }
- cursor = skipWhiteSpace(buf, cursor)
- if buf[cursor] == '}' {
- cursor++
- return ret, cursor, nil
- }
- if buf[cursor] != ',' {
- return nil, 0, errors.ErrExpected("comma after object value", cursor)
- }
- cursor++
- }
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/number.go b/vendor/github.com/goccy/go-json/internal/decoder/number.go
index 10e5435..bf63773 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/number.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/number.go
@@ -51,17 +51,6 @@ func (d *numberDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsaf
return cursor, nil
}
-func (d *numberDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- bytes, c, err := d.decodeByte(ctx.Buf, cursor)
- if err != nil {
- return nil, 0, err
- }
- if bytes == nil {
- return [][]byte{nullbytes}, c, nil
- }
- return [][]byte{bytes}, c, nil
-}
-
func (d *numberDecoder) decodeStreamByte(s *Stream) ([]byte, error) {
start := s.cursor
for {
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/option.go b/vendor/github.com/goccy/go-json/internal/decoder/option.go
index 502f772..e41f876 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/option.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/option.go
@@ -7,11 +7,9 @@ type OptionFlags uint8
const (
FirstWinOption OptionFlags = 1 << iota
ContextOption
- PathOption
)
type Option struct {
Flags OptionFlags
Context context.Context
- Path *Path
}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/path.go b/vendor/github.com/goccy/go-json/internal/decoder/path.go
deleted file mode 100644
index a15ff69..0000000
--- a/vendor/github.com/goccy/go-json/internal/decoder/path.go
+++ /dev/null
@@ -1,670 +0,0 @@
-package decoder
-
-import (
- "fmt"
- "reflect"
- "strconv"
-
- "github.com/goccy/go-json/internal/errors"
- "github.com/goccy/go-json/internal/runtime"
-)
-
-type PathString string
-
-func (s PathString) Build() (*Path, error) {
- builder := new(PathBuilder)
- return builder.Build([]rune(s))
-}
-
-type PathBuilder struct {
- root PathNode
- node PathNode
- singleQuotePathSelector bool
- doubleQuotePathSelector bool
-}
-
-func (b *PathBuilder) Build(buf []rune) (*Path, error) {
- node, err := b.build(buf)
- if err != nil {
- return nil, err
- }
- return &Path{
- node: node,
- RootSelectorOnly: node == nil,
- SingleQuotePathSelector: b.singleQuotePathSelector,
- DoubleQuotePathSelector: b.doubleQuotePathSelector,
- }, nil
-}
-
-func (b *PathBuilder) build(buf []rune) (PathNode, error) {
- if len(buf) == 0 {
- return nil, errors.ErrEmptyPath()
- }
- if buf[0] != '$' {
- return nil, errors.ErrInvalidPath("JSON Path must start with a $ character")
- }
- if len(buf) == 1 {
- return nil, nil
- }
- buf = buf[1:]
- offset, err := b.buildNext(buf)
- if err != nil {
- return nil, err
- }
- if len(buf) > offset {
- return nil, errors.ErrInvalidPath("remain invalid path %q", buf[offset:])
- }
- return b.root, nil
-}
-
-func (b *PathBuilder) buildNextCharIfExists(buf []rune, cursor int) (int, error) {
- if len(buf) > cursor {
- offset, err := b.buildNext(buf[cursor:])
- if err != nil {
- return 0, err
- }
- return cursor + 1 + offset, nil
- }
- return cursor, nil
-}
-
-func (b *PathBuilder) buildNext(buf []rune) (int, error) {
- switch buf[0] {
- case '.':
- if len(buf) == 1 {
- return 0, errors.ErrInvalidPath("JSON Path ends with dot character")
- }
- offset, err := b.buildSelector(buf[1:])
- if err != nil {
- return 0, err
- }
- return offset + 1, nil
- case '[':
- if len(buf) == 1 {
- return 0, errors.ErrInvalidPath("JSON Path ends with left bracket character")
- }
- offset, err := b.buildIndex(buf[1:])
- if err != nil {
- return 0, err
- }
- return offset + 1, nil
- default:
- return 0, errors.ErrInvalidPath("expect dot or left bracket character. but found %c character", buf[0])
- }
-}
-
-func (b *PathBuilder) buildSelector(buf []rune) (int, error) {
- switch buf[0] {
- case '.':
- if len(buf) == 1 {
- return 0, errors.ErrInvalidPath("JSON Path ends with double dot character")
- }
- offset, err := b.buildPathRecursive(buf[1:])
- if err != nil {
- return 0, err
- }
- return 1 + offset, nil
- case '[', ']', '$', '*':
- return 0, errors.ErrInvalidPath("found invalid path character %c after dot", buf[0])
- }
- for cursor := 0; cursor < len(buf); cursor++ {
- switch buf[cursor] {
- case '$', '*', ']':
- return 0, errors.ErrInvalidPath("found %c character in field selector context", buf[cursor])
- case '.':
- if cursor+1 >= len(buf) {
- return 0, errors.ErrInvalidPath("JSON Path ends with dot character")
- }
- selector := buf[:cursor]
- b.addSelectorNode(string(selector))
- offset, err := b.buildSelector(buf[cursor+1:])
- if err != nil {
- return 0, err
- }
- return cursor + 1 + offset, nil
- case '[':
- if cursor+1 >= len(buf) {
- return 0, errors.ErrInvalidPath("JSON Path ends with left bracket character")
- }
- selector := buf[:cursor]
- b.addSelectorNode(string(selector))
- offset, err := b.buildIndex(buf[cursor+1:])
- if err != nil {
- return 0, err
- }
- return cursor + 1 + offset, nil
- case '"':
- if cursor+1 >= len(buf) {
- return 0, errors.ErrInvalidPath("JSON Path ends with double quote character")
- }
- offset, err := b.buildQuoteSelector(buf[cursor+1:], DoubleQuotePathSelector)
- if err != nil {
- return 0, err
- }
- return cursor + 1 + offset, nil
- }
- }
- b.addSelectorNode(string(buf))
- return len(buf), nil
-}
-
-func (b *PathBuilder) buildQuoteSelector(buf []rune, sel QuotePathSelector) (int, error) {
- switch buf[0] {
- case '[', ']', '$', '.', '*', '\'', '"':
- return 0, errors.ErrInvalidPath("found invalid path character %c after quote", buf[0])
- }
- for cursor := 0; cursor < len(buf); cursor++ {
- switch buf[cursor] {
- case '\'':
- if sel != SingleQuotePathSelector {
- return 0, errors.ErrInvalidPath("found double quote character in field selector with single quote context")
- }
- if len(buf) <= cursor+1 {
- return 0, errors.ErrInvalidPath("JSON Path ends with single quote character in field selector context")
- }
- if buf[cursor+1] != ']' {
- return 0, errors.ErrInvalidPath("expect right bracket for field selector with single quote but found %c", buf[cursor+1])
- }
- selector := buf[:cursor]
- b.addSelectorNode(string(selector))
- b.singleQuotePathSelector = true
- return b.buildNextCharIfExists(buf, cursor+2)
- case '"':
- if sel != DoubleQuotePathSelector {
- return 0, errors.ErrInvalidPath("found single quote character in field selector with double quote context")
- }
- selector := buf[:cursor]
- b.addSelectorNode(string(selector))
- b.doubleQuotePathSelector = true
- return b.buildNextCharIfExists(buf, cursor+1)
- }
- }
- return 0, errors.ErrInvalidPath("couldn't find quote character in selector quote path context")
-}
-
-func (b *PathBuilder) buildPathRecursive(buf []rune) (int, error) {
- switch buf[0] {
- case '.', '[', ']', '$', '*':
- return 0, errors.ErrInvalidPath("found invalid path character %c after double dot", buf[0])
- }
- for cursor := 0; cursor < len(buf); cursor++ {
- switch buf[cursor] {
- case '$', '*', ']':
- return 0, errors.ErrInvalidPath("found %c character in field selector context", buf[cursor])
- case '.':
- if cursor+1 >= len(buf) {
- return 0, errors.ErrInvalidPath("JSON Path ends with dot character")
- }
- selector := buf[:cursor]
- b.addRecursiveNode(string(selector))
- offset, err := b.buildSelector(buf[cursor+1:])
- if err != nil {
- return 0, err
- }
- return cursor + 1 + offset, nil
- case '[':
- if cursor+1 >= len(buf) {
- return 0, errors.ErrInvalidPath("JSON Path ends with left bracket character")
- }
- selector := buf[:cursor]
- b.addRecursiveNode(string(selector))
- offset, err := b.buildIndex(buf[cursor+1:])
- if err != nil {
- return 0, err
- }
- return cursor + 1 + offset, nil
- }
- }
- b.addRecursiveNode(string(buf))
- return len(buf), nil
-}
-
-func (b *PathBuilder) buildIndex(buf []rune) (int, error) {
- switch buf[0] {
- case '.', '[', ']', '$':
- return 0, errors.ErrInvalidPath("found invalid path character %c after left bracket", buf[0])
- case '\'':
- if len(buf) == 1 {
- return 0, errors.ErrInvalidPath("JSON Path ends with single quote character")
- }
- offset, err := b.buildQuoteSelector(buf[1:], SingleQuotePathSelector)
- if err != nil {
- return 0, err
- }
- return 1 + offset, nil
- case '*':
- if len(buf) == 1 {
- return 0, errors.ErrInvalidPath("JSON Path ends with star character")
- }
- if buf[1] != ']' {
- return 0, errors.ErrInvalidPath("expect right bracket character for index all path but found %c character", buf[1])
- }
- b.addIndexAllNode()
- offset := len("*]")
- if len(buf) > 2 {
- buildOffset, err := b.buildNext(buf[2:])
- if err != nil {
- return 0, err
- }
- return offset + buildOffset, nil
- }
- return offset, nil
- }
-
- for cursor := 0; cursor < len(buf); cursor++ {
- switch buf[cursor] {
- case ']':
- index, err := strconv.ParseInt(string(buf[:cursor]), 10, 64)
- if err != nil {
- return 0, errors.ErrInvalidPath("%q is unexpected index path", buf[:cursor])
- }
- b.addIndexNode(int(index))
- return b.buildNextCharIfExists(buf, cursor+1)
- }
- }
- return 0, errors.ErrInvalidPath("couldn't find right bracket character in index path context")
-}
-
-func (b *PathBuilder) addIndexAllNode() {
- node := newPathIndexAllNode()
- if b.root == nil {
- b.root = node
- b.node = node
- } else {
- b.node = b.node.chain(node)
- }
-}
-
-func (b *PathBuilder) addRecursiveNode(selector string) {
- node := newPathRecursiveNode(selector)
- if b.root == nil {
- b.root = node
- b.node = node
- } else {
- b.node = b.node.chain(node)
- }
-}
-
-func (b *PathBuilder) addSelectorNode(name string) {
- node := newPathSelectorNode(name)
- if b.root == nil {
- b.root = node
- b.node = node
- } else {
- b.node = b.node.chain(node)
- }
-}
-
-func (b *PathBuilder) addIndexNode(idx int) {
- node := newPathIndexNode(idx)
- if b.root == nil {
- b.root = node
- b.node = node
- } else {
- b.node = b.node.chain(node)
- }
-}
-
-type QuotePathSelector int
-
-const (
- SingleQuotePathSelector QuotePathSelector = 1
- DoubleQuotePathSelector QuotePathSelector = 2
-)
-
-type Path struct {
- node PathNode
- RootSelectorOnly bool
- SingleQuotePathSelector bool
- DoubleQuotePathSelector bool
-}
-
-func (p *Path) Field(sel string) (PathNode, bool, error) {
- if p.node == nil {
- return nil, false, nil
- }
- return p.node.Field(sel)
-}
-
-func (p *Path) Get(src, dst reflect.Value) error {
- if p.node == nil {
- return nil
- }
- return p.node.Get(src, dst)
-}
-
-func (p *Path) String() string {
- if p.node == nil {
- return "$"
- }
- return p.node.String()
-}
-
-type PathNode interface {
- fmt.Stringer
- Index(idx int) (PathNode, bool, error)
- Field(fieldName string) (PathNode, bool, error)
- Get(src, dst reflect.Value) error
- chain(PathNode) PathNode
- target() bool
- single() bool
-}
-
-type BasePathNode struct {
- child PathNode
-}
-
-func (n *BasePathNode) chain(node PathNode) PathNode {
- n.child = node
- return node
-}
-
-func (n *BasePathNode) target() bool {
- return n.child == nil
-}
-
-func (n *BasePathNode) single() bool {
- return true
-}
-
-type PathSelectorNode struct {
- *BasePathNode
- selector string
-}
-
-func newPathSelectorNode(selector string) *PathSelectorNode {
- return &PathSelectorNode{
- BasePathNode: &BasePathNode{},
- selector: selector,
- }
-}
-
-func (n *PathSelectorNode) Index(idx int) (PathNode, bool, error) {
- return nil, false, &errors.PathError{}
-}
-
-func (n *PathSelectorNode) Field(fieldName string) (PathNode, bool, error) {
- if n.selector == fieldName {
- return n.child, true, nil
- }
- return nil, false, nil
-}
-
-func (n *PathSelectorNode) Get(src, dst reflect.Value) error {
- switch src.Type().Kind() {
- case reflect.Map:
- iter := src.MapRange()
- for iter.Next() {
- key, ok := iter.Key().Interface().(string)
- if !ok {
- return fmt.Errorf("invalid map key type %T", src.Type().Key())
- }
- child, found, err := n.Field(key)
- if err != nil {
- return err
- }
- if found {
- if child != nil {
- return child.Get(iter.Value(), dst)
- }
- return AssignValue(iter.Value(), dst)
- }
- }
- case reflect.Struct:
- typ := src.Type()
- for i := 0; i < typ.Len(); i++ {
- tag := runtime.StructTagFromField(typ.Field(i))
- child, found, err := n.Field(tag.Key)
- if err != nil {
- return err
- }
- if found {
- if child != nil {
- return child.Get(src.Field(i), dst)
- }
- return AssignValue(src.Field(i), dst)
- }
- }
- case reflect.Ptr:
- return n.Get(src.Elem(), dst)
- case reflect.Interface:
- return n.Get(reflect.ValueOf(src.Interface()), dst)
- case reflect.Float64, reflect.String, reflect.Bool:
- return AssignValue(src, dst)
- }
- return fmt.Errorf("failed to get %s value from %s", n.selector, src.Type())
-}
-
-func (n *PathSelectorNode) String() string {
- s := fmt.Sprintf(".%s", n.selector)
- if n.child != nil {
- s += n.child.String()
- }
- return s
-}
-
-type PathIndexNode struct {
- *BasePathNode
- selector int
-}
-
-func newPathIndexNode(selector int) *PathIndexNode {
- return &PathIndexNode{
- BasePathNode: &BasePathNode{},
- selector: selector,
- }
-}
-
-func (n *PathIndexNode) Index(idx int) (PathNode, bool, error) {
- if n.selector == idx {
- return n.child, true, nil
- }
- return nil, false, nil
-}
-
-func (n *PathIndexNode) Field(fieldName string) (PathNode, bool, error) {
- return nil, false, &errors.PathError{}
-}
-
-func (n *PathIndexNode) Get(src, dst reflect.Value) error {
- switch src.Type().Kind() {
- case reflect.Array, reflect.Slice:
- if src.Len() > n.selector {
- if n.child != nil {
- return n.child.Get(src.Index(n.selector), dst)
- }
- return AssignValue(src.Index(n.selector), dst)
- }
- case reflect.Ptr:
- return n.Get(src.Elem(), dst)
- case reflect.Interface:
- return n.Get(reflect.ValueOf(src.Interface()), dst)
- }
- return fmt.Errorf("failed to get [%d] value from %s", n.selector, src.Type())
-}
-
-func (n *PathIndexNode) String() string {
- s := fmt.Sprintf("[%d]", n.selector)
- if n.child != nil {
- s += n.child.String()
- }
- return s
-}
-
-type PathIndexAllNode struct {
- *BasePathNode
-}
-
-func newPathIndexAllNode() *PathIndexAllNode {
- return &PathIndexAllNode{
- BasePathNode: &BasePathNode{},
- }
-}
-
-func (n *PathIndexAllNode) Index(idx int) (PathNode, bool, error) {
- return n.child, true, nil
-}
-
-func (n *PathIndexAllNode) Field(fieldName string) (PathNode, bool, error) {
- return nil, false, &errors.PathError{}
-}
-
-func (n *PathIndexAllNode) Get(src, dst reflect.Value) error {
- switch src.Type().Kind() {
- case reflect.Array, reflect.Slice:
- var arr []interface{}
- for i := 0; i < src.Len(); i++ {
- var v interface{}
- rv := reflect.ValueOf(&v)
- if n.child != nil {
- if err := n.child.Get(src.Index(i), rv); err != nil {
- return err
- }
- } else {
- if err := AssignValue(src.Index(i), rv); err != nil {
- return err
- }
- }
- arr = append(arr, v)
- }
- if err := AssignValue(reflect.ValueOf(arr), dst); err != nil {
- return err
- }
- return nil
- case reflect.Ptr:
- return n.Get(src.Elem(), dst)
- case reflect.Interface:
- return n.Get(reflect.ValueOf(src.Interface()), dst)
- }
- return fmt.Errorf("failed to get all value from %s", src.Type())
-}
-
-func (n *PathIndexAllNode) String() string {
- s := "[*]"
- if n.child != nil {
- s += n.child.String()
- }
- return s
-}
-
-type PathRecursiveNode struct {
- *BasePathNode
- selector string
-}
-
-func newPathRecursiveNode(selector string) *PathRecursiveNode {
- node := newPathSelectorNode(selector)
- return &PathRecursiveNode{
- BasePathNode: &BasePathNode{
- child: node,
- },
- selector: selector,
- }
-}
-
-func (n *PathRecursiveNode) Field(fieldName string) (PathNode, bool, error) {
- if n.selector == fieldName {
- return n.child, true, nil
- }
- return nil, false, nil
-}
-
-func (n *PathRecursiveNode) Index(_ int) (PathNode, bool, error) {
- return n, true, nil
-}
-
-func valueToSliceValue(v interface{}) []interface{} {
- rv := reflect.ValueOf(v)
- ret := []interface{}{}
- if rv.Type().Kind() == reflect.Slice || rv.Type().Kind() == reflect.Array {
- for i := 0; i < rv.Len(); i++ {
- ret = append(ret, rv.Index(i).Interface())
- }
- return ret
- }
- return []interface{}{v}
-}
-
-func (n *PathRecursiveNode) Get(src, dst reflect.Value) error {
- if n.child == nil {
- return fmt.Errorf("failed to get by recursive path ..%s", n.selector)
- }
- var arr []interface{}
- switch src.Type().Kind() {
- case reflect.Map:
- iter := src.MapRange()
- for iter.Next() {
- key, ok := iter.Key().Interface().(string)
- if !ok {
- return fmt.Errorf("invalid map key type %T", src.Type().Key())
- }
- child, found, err := n.Field(key)
- if err != nil {
- return err
- }
- if found {
- var v interface{}
- rv := reflect.ValueOf(&v)
- _ = child.Get(iter.Value(), rv)
- arr = append(arr, valueToSliceValue(v)...)
- } else {
- var v interface{}
- rv := reflect.ValueOf(&v)
- _ = n.Get(iter.Value(), rv)
- if v != nil {
- arr = append(arr, valueToSliceValue(v)...)
- }
- }
- }
- _ = AssignValue(reflect.ValueOf(arr), dst)
- return nil
- case reflect.Struct:
- typ := src.Type()
- for i := 0; i < typ.Len(); i++ {
- tag := runtime.StructTagFromField(typ.Field(i))
- child, found, err := n.Field(tag.Key)
- if err != nil {
- return err
- }
- if found {
- var v interface{}
- rv := reflect.ValueOf(&v)
- _ = child.Get(src.Field(i), rv)
- arr = append(arr, valueToSliceValue(v)...)
- } else {
- var v interface{}
- rv := reflect.ValueOf(&v)
- _ = n.Get(src.Field(i), rv)
- if v != nil {
- arr = append(arr, valueToSliceValue(v)...)
- }
- }
- }
- _ = AssignValue(reflect.ValueOf(arr), dst)
- return nil
- case reflect.Array, reflect.Slice:
- for i := 0; i < src.Len(); i++ {
- var v interface{}
- rv := reflect.ValueOf(&v)
- _ = n.Get(src.Index(i), rv)
- if v != nil {
- arr = append(arr, valueToSliceValue(v)...)
- }
- }
- _ = AssignValue(reflect.ValueOf(arr), dst)
- return nil
- case reflect.Ptr:
- return n.Get(src.Elem(), dst)
- case reflect.Interface:
- return n.Get(reflect.ValueOf(src.Interface()), dst)
- }
- return fmt.Errorf("failed to get %s value from %s", n.selector, src.Type())
-}
-
-func (n *PathRecursiveNode) String() string {
- s := fmt.Sprintf("..%s", n.selector)
- if n.child != nil {
- s += n.child.String()
- }
- return s
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/ptr.go b/vendor/github.com/goccy/go-json/internal/decoder/ptr.go
index ae22994..2c83b9c 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/ptr.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/ptr.go
@@ -1,7 +1,6 @@
package decoder
import (
- "fmt"
"unsafe"
"github.com/goccy/go-json/internal/runtime"
@@ -35,10 +34,6 @@ func (d *ptrDecoder) contentDecoder() Decoder {
//go:linkname unsafe_New reflect.unsafe_New
func unsafe_New(*runtime.Type) unsafe.Pointer
-func UnsafeNew(t *runtime.Type) unsafe.Pointer {
- return unsafe_New(t)
-}
-
func (d *ptrDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error {
if s.skipWhiteSpace() == nul {
s.read()
@@ -85,13 +80,8 @@ func (d *ptrDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.P
}
c, err := d.dec.Decode(ctx, cursor, depth, newptr)
if err != nil {
- *(*unsafe.Pointer)(p) = nil
return 0, err
}
cursor = c
return cursor, nil
}
-
-func (d *ptrDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: ptr decoder does not support decode path")
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/slice.go b/vendor/github.com/goccy/go-json/internal/decoder/slice.go
index 30a23e4..85b6e11 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/slice.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/slice.go
@@ -299,82 +299,3 @@ func (d *sliceDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe
}
}
}
-
-func (d *sliceDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- buf := ctx.Buf
- depth++
- if depth > maxDecodeNestingDepth {
- return nil, 0, errors.ErrExceededMaxDepth(buf[cursor], cursor)
- }
-
- ret := [][]byte{}
- for {
- switch buf[cursor] {
- case ' ', '\n', '\t', '\r':
- cursor++
- continue
- case 'n':
- if err := validateNull(buf, cursor); err != nil {
- return nil, 0, err
- }
- cursor += 4
- return [][]byte{nullbytes}, cursor, nil
- case '[':
- cursor++
- cursor = skipWhiteSpace(buf, cursor)
- if buf[cursor] == ']' {
- cursor++
- return ret, cursor, nil
- }
- idx := 0
- for {
- child, found, err := ctx.Option.Path.node.Index(idx)
- if err != nil {
- return nil, 0, err
- }
- if found {
- if child != nil {
- oldPath := ctx.Option.Path.node
- ctx.Option.Path.node = child
- paths, c, err := d.valueDecoder.DecodePath(ctx, cursor, depth)
- if err != nil {
- return nil, 0, err
- }
- ctx.Option.Path.node = oldPath
- ret = append(ret, paths...)
- cursor = c
- } else {
- start := cursor
- end, err := skipValue(buf, cursor, depth)
- if err != nil {
- return nil, 0, err
- }
- ret = append(ret, buf[start:end])
- cursor = end
- }
- } else {
- c, err := skipValue(buf, cursor, depth)
- if err != nil {
- return nil, 0, err
- }
- cursor = c
- }
- cursor = skipWhiteSpace(buf, cursor)
- switch buf[cursor] {
- case ']':
- cursor++
- return ret, cursor, nil
- case ',':
- idx++
- default:
- return nil, 0, errors.ErrInvalidCharacter(buf[cursor], "slice", cursor)
- }
- cursor++
- }
- case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
- return nil, 0, d.errNumber(cursor)
- default:
- return nil, 0, errors.ErrUnexpectedEndOfJSON("slice", cursor)
- }
- }
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/stream.go b/vendor/github.com/goccy/go-json/internal/decoder/stream.go
index a383f72..c274683 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/stream.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/stream.go
@@ -103,7 +103,7 @@ func (s *Stream) statForRetry() ([]byte, int64, unsafe.Pointer) {
func (s *Stream) Reset() {
s.reset()
- s.bufSize = int64(len(s.buf))
+ s.bufSize = initBufSize
}
func (s *Stream) More() bool {
@@ -138,11 +138,8 @@ func (s *Stream) Token() (interface{}, error) {
s.cursor++
case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
bytes := floatBytes(s)
- str := *(*string)(unsafe.Pointer(&bytes))
- if s.UseNumber {
- return json.Number(str), nil
- }
- f64, err := strconv.ParseFloat(str, 64)
+ s := *(*string)(unsafe.Pointer(&bytes))
+ f64, err := strconv.ParseFloat(s, 64)
if err != nil {
return nil, err
}
@@ -280,7 +277,7 @@ func (s *Stream) skipObject(depth int64) error {
if char(p, cursor) == nul {
s.cursor = cursor
if s.read() {
- _, cursor, p = s.stat()
+ _, cursor, p = s.statForRetry()
continue
}
return errors.ErrUnexpectedEndOfJSON("string of object", cursor)
@@ -343,7 +340,7 @@ func (s *Stream) skipArray(depth int64) error {
if char(p, cursor) == nul {
s.cursor = cursor
if s.read() {
- _, cursor, p = s.stat()
+ _, cursor, p = s.statForRetry()
continue
}
return errors.ErrUnexpectedEndOfJSON("string of object", cursor)
@@ -401,7 +398,7 @@ func (s *Stream) skipValue(depth int64) error {
if char(p, cursor) == nul {
s.cursor = cursor
if s.read() {
- _, cursor, p = s.stat()
+ _, cursor, p = s.statForRetry()
continue
}
return errors.ErrUnexpectedEndOfJSON("value of string", s.totalOffset())
@@ -426,6 +423,7 @@ func (s *Stream) skipValue(depth int64) error {
continue
} else if c == nul {
if s.read() {
+ s.cursor-- // for retry current character
_, cursor, p = s.stat()
continue
}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/string.go b/vendor/github.com/goccy/go-json/internal/decoder/string.go
index 32602c9..65b1004 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/string.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/string.go
@@ -1,8 +1,6 @@
package decoder
import (
- "bytes"
- "fmt"
"reflect"
"unicode"
"unicode/utf16"
@@ -60,17 +58,6 @@ func (d *stringDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsaf
return cursor, nil
}
-func (d *stringDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- bytes, c, err := d.decodeByte(ctx.Buf, cursor)
- if err != nil {
- return nil, 0, err
- }
- if bytes == nil {
- return [][]byte{nullbytes}, c, nil
- }
- return [][]byte{bytes}, c, nil
-}
-
var (
hexToInt = [256]int{
'0': 0,
@@ -106,30 +93,24 @@ func unicodeToRune(code []byte) rune {
return r
}
-func readAtLeast(s *Stream, n int64, p *unsafe.Pointer) bool {
- for s.cursor+n >= s.length {
- if !s.read() {
- return false
- }
- *p = s.bufptr()
- }
- return true
-}
-
func decodeUnicodeRune(s *Stream, p unsafe.Pointer) (rune, int64, unsafe.Pointer, error) {
const defaultOffset = 5
const surrogateOffset = 11
- if !readAtLeast(s, defaultOffset, &p) {
- return rune(0), 0, nil, errors.ErrInvalidCharacter(s.char(), "escaped string", s.totalOffset())
+ if s.cursor+defaultOffset >= s.length {
+ if !s.read() {
+ return rune(0), 0, nil, errors.ErrInvalidCharacter(s.char(), "escaped string", s.totalOffset())
+ }
+ p = s.bufptr()
}
r := unicodeToRune(s.buf[s.cursor+1 : s.cursor+defaultOffset])
if utf16.IsSurrogate(r) {
- if !readAtLeast(s, surrogateOffset, &p) {
- return unicode.ReplacementChar, defaultOffset, p, nil
+ if s.cursor+surrogateOffset >= s.length {
+ s.read()
+ p = s.bufptr()
}
- if s.buf[s.cursor+defaultOffset] != '\\' || s.buf[s.cursor+defaultOffset+1] != 'u' {
+ if s.cursor+surrogateOffset >= s.length || s.buf[s.cursor+defaultOffset] != '\\' || s.buf[s.cursor+defaultOffset+1] != 'u' {
return unicode.ReplacementChar, defaultOffset, p, nil
}
r2 := unicodeToRune(s.buf[s.cursor+defaultOffset+2 : s.cursor+surrogateOffset])
@@ -182,7 +163,6 @@ RETRY:
if !s.read() {
return nil, errors.ErrInvalidCharacter(s.char(), "escaped string", s.totalOffset())
}
- p = s.bufptr()
goto RETRY
default:
return nil, errors.ErrUnexpectedEndOfJSON("string", s.totalOffset())
@@ -328,36 +308,49 @@ func (d *stringDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, err
cursor++
start := cursor
b := (*sliceHeader)(unsafe.Pointer(&buf)).data
- escaped := 0
for {
switch char(b, cursor) {
case '\\':
- escaped++
cursor++
switch char(b, cursor) {
- case '"', '\\', '/', 'b', 'f', 'n', 'r', 't':
- cursor++
+ case '"':
+ buf[cursor] = '"'
+ buf = append(buf[:cursor-1], buf[cursor:]...)
+ case '\\':
+ buf[cursor] = '\\'
+ buf = append(buf[:cursor-1], buf[cursor:]...)
+ case '/':
+ buf[cursor] = '/'
+ buf = append(buf[:cursor-1], buf[cursor:]...)
+ case 'b':
+ buf[cursor] = '\b'
+ buf = append(buf[:cursor-1], buf[cursor:]...)
+ case 'f':
+ buf[cursor] = '\f'
+ buf = append(buf[:cursor-1], buf[cursor:]...)
+ case 'n':
+ buf[cursor] = '\n'
+ buf = append(buf[:cursor-1], buf[cursor:]...)
+ case 'r':
+ buf[cursor] = '\r'
+ buf = append(buf[:cursor-1], buf[cursor:]...)
+ case 't':
+ buf[cursor] = '\t'
+ buf = append(buf[:cursor-1], buf[cursor:]...)
case 'u':
buflen := int64(len(buf))
if cursor+5 >= buflen {
return nil, 0, errors.ErrUnexpectedEndOfJSON("escaped string", cursor)
}
- for i := int64(1); i <= 4; i++ {
- c := char(b, cursor+i)
- if !(('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')) {
- return nil, 0, errors.ErrSyntax(fmt.Sprintf("json: invalid character %c in \\u hexadecimal character escape", c), cursor+i)
- }
- }
- cursor += 5
+ code := unicodeToRune(buf[cursor+1 : cursor+5])
+ unicode := []byte(string(code))
+ buf = append(append(buf[:cursor-1], unicode...), buf[cursor+5:]...)
default:
return nil, 0, errors.ErrUnexpectedEndOfJSON("escaped string", cursor)
}
continue
case '"':
literal := buf[start:cursor]
- if escaped > 0 {
- literal = literal[:unescapeString(literal)]
- }
cursor++
return literal, cursor, nil
case nul:
@@ -376,77 +369,3 @@ func (d *stringDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, err
}
}
}
-
-var unescapeMap = [256]byte{
- '"': '"',
- '\\': '\\',
- '/': '/',
- 'b': '\b',
- 'f': '\f',
- 'n': '\n',
- 'r': '\r',
- 't': '\t',
-}
-
-func unsafeAdd(ptr unsafe.Pointer, offset int) unsafe.Pointer {
- return unsafe.Pointer(uintptr(ptr) + uintptr(offset))
-}
-
-func unescapeString(buf []byte) int {
- p := (*sliceHeader)(unsafe.Pointer(&buf)).data
- end := unsafeAdd(p, len(buf))
- src := unsafeAdd(p, bytes.IndexByte(buf, '\\'))
- dst := src
- for src != end {
- c := char(src, 0)
- if c == '\\' {
- escapeChar := char(src, 1)
- if escapeChar != 'u' {
- *(*byte)(dst) = unescapeMap[escapeChar]
- src = unsafeAdd(src, 2)
- dst = unsafeAdd(dst, 1)
- } else {
- v1 := hexToInt[char(src, 2)]
- v2 := hexToInt[char(src, 3)]
- v3 := hexToInt[char(src, 4)]
- v4 := hexToInt[char(src, 5)]
- code := rune((v1 << 12) | (v2 << 8) | (v3 << 4) | v4)
- if code >= 0xd800 && code < 0xdc00 && uintptr(unsafeAdd(src, 11)) < uintptr(end) {
- if char(src, 6) == '\\' && char(src, 7) == 'u' {
- v1 := hexToInt[char(src, 8)]
- v2 := hexToInt[char(src, 9)]
- v3 := hexToInt[char(src, 10)]
- v4 := hexToInt[char(src, 11)]
- lo := rune((v1 << 12) | (v2 << 8) | (v3 << 4) | v4)
- if lo >= 0xdc00 && lo < 0xe000 {
- code = (code-0xd800)<<10 | (lo - 0xdc00) + 0x10000
- src = unsafeAdd(src, 6)
- }
- }
- }
- var b [utf8.UTFMax]byte
- n := utf8.EncodeRune(b[:], code)
- switch n {
- case 4:
- *(*byte)(unsafeAdd(dst, 3)) = b[3]
- fallthrough
- case 3:
- *(*byte)(unsafeAdd(dst, 2)) = b[2]
- fallthrough
- case 2:
- *(*byte)(unsafeAdd(dst, 1)) = b[1]
- fallthrough
- case 1:
- *(*byte)(unsafeAdd(dst, 0)) = b[0]
- }
- src = unsafeAdd(src, 6)
- dst = unsafeAdd(dst, n)
- }
- } else {
- *(*byte)(dst) = c
- src = unsafeAdd(src, 1)
- dst = unsafeAdd(dst, 1)
- }
- }
- return int(uintptr(dst) - uintptr(p))
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/struct.go b/vendor/github.com/goccy/go-json/internal/decoder/struct.go
index 313da15..2c64680 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/struct.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/struct.go
@@ -51,14 +51,6 @@ func init() {
}
}
-func toASCIILower(s string) string {
- b := []byte(s)
- for i := range b {
- b[i] = largeToSmallTable[b[i]]
- }
- return string(b)
-}
-
func newStructDecoder(structName, fieldName string, fieldMap map[string]*structFieldSet) *structDecoder {
return &structDecoder{
fieldMap: fieldMap,
@@ -99,10 +91,6 @@ func (d *structDecoder) tryOptimize() {
for k, v := range d.fieldMap {
key := strings.ToLower(k)
if key != k {
- if key != toASCIILower(k) {
- d.isTriedOptimize = true
- return
- }
// already exists same key (e.g. Hello and HELLO has same lower case key
if _, exists := conflicted[key]; exists {
d.isTriedOptimize = true
@@ -170,53 +158,49 @@ func (d *structDecoder) tryOptimize() {
}
// decode from '\uXXXX'
-func decodeKeyCharByUnicodeRune(buf []byte, cursor int64) ([]byte, int64, error) {
+func decodeKeyCharByUnicodeRune(buf []byte, cursor int64) ([]byte, int64) {
const defaultOffset = 4
const surrogateOffset = 6
- if cursor+defaultOffset >= int64(len(buf)) {
- return nil, 0, errors.ErrUnexpectedEndOfJSON("escaped string", cursor)
- }
-
r := unicodeToRune(buf[cursor : cursor+defaultOffset])
if utf16.IsSurrogate(r) {
cursor += defaultOffset
if cursor+surrogateOffset >= int64(len(buf)) || buf[cursor] != '\\' || buf[cursor+1] != 'u' {
- return []byte(string(unicode.ReplacementChar)), cursor + defaultOffset - 1, nil
+ return []byte(string(unicode.ReplacementChar)), cursor + defaultOffset - 1
}
cursor += 2
r2 := unicodeToRune(buf[cursor : cursor+defaultOffset])
if r := utf16.DecodeRune(r, r2); r != unicode.ReplacementChar {
- return []byte(string(r)), cursor + defaultOffset - 1, nil
+ return []byte(string(r)), cursor + defaultOffset - 1
}
}
- return []byte(string(r)), cursor + defaultOffset - 1, nil
+ return []byte(string(r)), cursor + defaultOffset - 1
}
-func decodeKeyCharByEscapedChar(buf []byte, cursor int64) ([]byte, int64, error) {
+func decodeKeyCharByEscapedChar(buf []byte, cursor int64) ([]byte, int64) {
c := buf[cursor]
cursor++
switch c {
case '"':
- return []byte{'"'}, cursor, nil
+ return []byte{'"'}, cursor
case '\\':
- return []byte{'\\'}, cursor, nil
+ return []byte{'\\'}, cursor
case '/':
- return []byte{'/'}, cursor, nil
+ return []byte{'/'}, cursor
case 'b':
- return []byte{'\b'}, cursor, nil
+ return []byte{'\b'}, cursor
case 'f':
- return []byte{'\f'}, cursor, nil
+ return []byte{'\f'}, cursor
case 'n':
- return []byte{'\n'}, cursor, nil
+ return []byte{'\n'}, cursor
case 'r':
- return []byte{'\r'}, cursor, nil
+ return []byte{'\r'}, cursor
case 't':
- return []byte{'\t'}, cursor, nil
+ return []byte{'\t'}, cursor
case 'u':
return decodeKeyCharByUnicodeRune(buf, cursor)
}
- return nil, cursor, nil
+ return nil, cursor
}
func decodeKeyByBitmapUint8(d *structDecoder, buf []byte, cursor int64) (int64, *structFieldSet, error) {
@@ -258,10 +242,7 @@ func decodeKeyByBitmapUint8(d *structDecoder, buf []byte, cursor int64) (int64,
return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor)
case '\\':
cursor++
- chars, nextCursor, err := decodeKeyCharByEscapedChar(buf, cursor)
- if err != nil {
- return 0, nil, err
- }
+ chars, nextCursor := decodeKeyCharByEscapedChar(buf, cursor)
for _, c := range chars {
curBit &= bitmap[keyIdx][largeToSmallTable[c]]
if curBit == 0 {
@@ -324,10 +305,7 @@ func decodeKeyByBitmapUint16(d *structDecoder, buf []byte, cursor int64) (int64,
return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor)
case '\\':
cursor++
- chars, nextCursor, err := decodeKeyCharByEscapedChar(buf, cursor)
- if err != nil {
- return 0, nil, err
- }
+ chars, nextCursor := decodeKeyCharByEscapedChar(buf, cursor)
for _, c := range chars {
curBit &= bitmap[keyIdx][largeToSmallTable[c]]
if curBit == 0 {
@@ -839,7 +817,3 @@ func (d *structDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsaf
cursor++
}
}
-
-func (d *structDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: struct decoder does not support decode path")
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/type.go b/vendor/github.com/goccy/go-json/internal/decoder/type.go
index beaf3ab..70e9907 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/type.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/type.go
@@ -10,7 +10,6 @@ import (
type Decoder interface {
Decode(*RuntimeContext, int64, int64, unsafe.Pointer) (int64, error)
- DecodePath(*RuntimeContext, int64, int64) ([][]byte, int64, error)
DecodeStream(*Stream, int64, unsafe.Pointer) error
}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/uint.go b/vendor/github.com/goccy/go-json/internal/decoder/uint.go
index 4131731..a62c514 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/uint.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/uint.go
@@ -188,7 +188,3 @@ func (d *uintDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.
d.op(p, u64)
return cursor, nil
}
-
-func (d *uintDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: uint decoder does not support decode path")
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go b/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go
index 4cd6dbd..d90f39c 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go
@@ -1,9 +1,7 @@
package decoder
import (
- "context"
"encoding/json"
- "fmt"
"unsafe"
"github.com/goccy/go-json/internal/errors"
@@ -48,20 +46,13 @@ func (d *unmarshalJSONDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Poi
typ: d.typ,
ptr: p,
}))
- switch v := v.(type) {
- case unmarshalerContext:
- var ctx context.Context
- if (s.Option.Flags & ContextOption) != 0 {
- ctx = s.Option.Context
- } else {
- ctx = context.Background()
- }
- if err := v.UnmarshalJSON(ctx, dst); err != nil {
+ if (s.Option.Flags & ContextOption) != 0 {
+ if err := v.(unmarshalerContext).UnmarshalJSON(s.Option.Context, dst); err != nil {
d.annotateError(s.cursor, err)
return err
}
- case json.Unmarshaler:
- if err := v.UnmarshalJSON(dst); err != nil {
+ } else {
+ if err := v.(json.Unmarshaler).UnmarshalJSON(dst); err != nil {
d.annotateError(s.cursor, err)
return err
}
@@ -98,7 +89,3 @@ func (d *unmarshalJSONDecoder) Decode(ctx *RuntimeContext, cursor, depth int64,
}
return end, nil
}
-
-func (d *unmarshalJSONDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: unmarshal json decoder does not support decode path")
-}
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go b/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go
index d711d0f..1ef2877 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go
@@ -3,7 +3,6 @@ package decoder
import (
"bytes"
"encoding"
- "fmt"
"unicode"
"unicode/utf16"
"unicode/utf8"
@@ -143,11 +142,7 @@ func (d *unmarshalTextDecoder) Decode(ctx *RuntimeContext, cursor, depth int64,
return end, nil
}
-func (d *unmarshalTextDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: unmarshal text decoder does not support decode path")
-}
-
-func unquoteBytes(s []byte) (t []byte, ok bool) { //nolint: nonamedreturns
+func unquoteBytes(s []byte) (t []byte, ok bool) {
length := len(s)
if length < 2 || s[0] != '"' || s[length-1] != '"' {
return
diff --git a/vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go b/vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go
index 0c4e2e6..66227ae 100644
--- a/vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go
+++ b/vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go
@@ -1,7 +1,6 @@
package decoder
import (
- "fmt"
"reflect"
"unsafe"
@@ -67,7 +66,3 @@ func (d *wrappedStringDecoder) Decode(ctx *RuntimeContext, cursor, depth int64,
ctx.Buf = oldBuf
return c, nil
}
-
-func (d *wrappedStringDecoder) DecodePath(ctx *RuntimeContext, cursor, depth int64) ([][]byte, int64, error) {
- return nil, 0, fmt.Errorf("json: wrapped string decoder does not support decode path")
-}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/code.go b/vendor/github.com/goccy/go-json/internal/encoder/code.go
deleted file mode 100644
index 5b08fae..0000000
--- a/vendor/github.com/goccy/go-json/internal/encoder/code.go
+++ /dev/null
@@ -1,1023 +0,0 @@
-package encoder
-
-import (
- "fmt"
- "reflect"
- "unsafe"
-
- "github.com/goccy/go-json/internal/runtime"
-)
-
-type Code interface {
- Kind() CodeKind
- ToOpcode(*compileContext) Opcodes
- Filter(*FieldQuery) Code
-}
-
-type AnonymousCode interface {
- ToAnonymousOpcode(*compileContext) Opcodes
-}
-
-type Opcodes []*Opcode
-
-func (o Opcodes) First() *Opcode {
- if len(o) == 0 {
- return nil
- }
- return o[0]
-}
-
-func (o Opcodes) Last() *Opcode {
- if len(o) == 0 {
- return nil
- }
- return o[len(o)-1]
-}
-
-func (o Opcodes) Add(codes ...*Opcode) Opcodes {
- return append(o, codes...)
-}
-
-type CodeKind int
-
-const (
- CodeKindInterface CodeKind = iota
- CodeKindPtr
- CodeKindInt
- CodeKindUint
- CodeKindFloat
- CodeKindString
- CodeKindBool
- CodeKindStruct
- CodeKindMap
- CodeKindSlice
- CodeKindArray
- CodeKindBytes
- CodeKindMarshalJSON
- CodeKindMarshalText
- CodeKindRecursive
-)
-
-type IntCode struct {
- typ *runtime.Type
- bitSize uint8
- isString bool
- isPtr bool
-}
-
-func (c *IntCode) Kind() CodeKind {
- return CodeKindInt
-}
-
-func (c *IntCode) ToOpcode(ctx *compileContext) Opcodes {
- var code *Opcode
- switch {
- case c.isPtr:
- code = newOpCode(ctx, c.typ, OpIntPtr)
- case c.isString:
- code = newOpCode(ctx, c.typ, OpIntString)
- default:
- code = newOpCode(ctx, c.typ, OpInt)
- }
- code.NumBitSize = c.bitSize
- ctx.incIndex()
- return Opcodes{code}
-}
-
-func (c *IntCode) Filter(_ *FieldQuery) Code {
- return c
-}
-
-type UintCode struct {
- typ *runtime.Type
- bitSize uint8
- isString bool
- isPtr bool
-}
-
-func (c *UintCode) Kind() CodeKind {
- return CodeKindUint
-}
-
-func (c *UintCode) ToOpcode(ctx *compileContext) Opcodes {
- var code *Opcode
- switch {
- case c.isPtr:
- code = newOpCode(ctx, c.typ, OpUintPtr)
- case c.isString:
- code = newOpCode(ctx, c.typ, OpUintString)
- default:
- code = newOpCode(ctx, c.typ, OpUint)
- }
- code.NumBitSize = c.bitSize
- ctx.incIndex()
- return Opcodes{code}
-}
-
-func (c *UintCode) Filter(_ *FieldQuery) Code {
- return c
-}
-
-type FloatCode struct {
- typ *runtime.Type
- bitSize uint8
- isPtr bool
-}
-
-func (c *FloatCode) Kind() CodeKind {
- return CodeKindFloat
-}
-
-func (c *FloatCode) ToOpcode(ctx *compileContext) Opcodes {
- var code *Opcode
- switch {
- case c.isPtr:
- switch c.bitSize {
- case 32:
- code = newOpCode(ctx, c.typ, OpFloat32Ptr)
- default:
- code = newOpCode(ctx, c.typ, OpFloat64Ptr)
- }
- default:
- switch c.bitSize {
- case 32:
- code = newOpCode(ctx, c.typ, OpFloat32)
- default:
- code = newOpCode(ctx, c.typ, OpFloat64)
- }
- }
- ctx.incIndex()
- return Opcodes{code}
-}
-
-func (c *FloatCode) Filter(_ *FieldQuery) Code {
- return c
-}
-
-type StringCode struct {
- typ *runtime.Type
- isPtr bool
-}
-
-func (c *StringCode) Kind() CodeKind {
- return CodeKindString
-}
-
-func (c *StringCode) ToOpcode(ctx *compileContext) Opcodes {
- isJSONNumberType := c.typ == runtime.Type2RType(jsonNumberType)
- var code *Opcode
- if c.isPtr {
- if isJSONNumberType {
- code = newOpCode(ctx, c.typ, OpNumberPtr)
- } else {
- code = newOpCode(ctx, c.typ, OpStringPtr)
- }
- } else {
- if isJSONNumberType {
- code = newOpCode(ctx, c.typ, OpNumber)
- } else {
- code = newOpCode(ctx, c.typ, OpString)
- }
- }
- ctx.incIndex()
- return Opcodes{code}
-}
-
-func (c *StringCode) Filter(_ *FieldQuery) Code {
- return c
-}
-
-type BoolCode struct {
- typ *runtime.Type
- isPtr bool
-}
-
-func (c *BoolCode) Kind() CodeKind {
- return CodeKindBool
-}
-
-func (c *BoolCode) ToOpcode(ctx *compileContext) Opcodes {
- var code *Opcode
- switch {
- case c.isPtr:
- code = newOpCode(ctx, c.typ, OpBoolPtr)
- default:
- code = newOpCode(ctx, c.typ, OpBool)
- }
- ctx.incIndex()
- return Opcodes{code}
-}
-
-func (c *BoolCode) Filter(_ *FieldQuery) Code {
- return c
-}
-
-type BytesCode struct {
- typ *runtime.Type
- isPtr bool
-}
-
-func (c *BytesCode) Kind() CodeKind {
- return CodeKindBytes
-}
-
-func (c *BytesCode) ToOpcode(ctx *compileContext) Opcodes {
- var code *Opcode
- switch {
- case c.isPtr:
- code = newOpCode(ctx, c.typ, OpBytesPtr)
- default:
- code = newOpCode(ctx, c.typ, OpBytes)
- }
- ctx.incIndex()
- return Opcodes{code}
-}
-
-func (c *BytesCode) Filter(_ *FieldQuery) Code {
- return c
-}
-
-type SliceCode struct {
- typ *runtime.Type
- value Code
-}
-
-func (c *SliceCode) Kind() CodeKind {
- return CodeKindSlice
-}
-
-func (c *SliceCode) ToOpcode(ctx *compileContext) Opcodes {
- // header => opcode => elem => end
- // ^ |
- // |________|
- size := c.typ.Elem().Size()
- header := newSliceHeaderCode(ctx, c.typ)
- ctx.incIndex()
-
- ctx.incIndent()
- codes := c.value.ToOpcode(ctx)
- ctx.decIndent()
-
- codes.First().Flags |= IndirectFlags
- elemCode := newSliceElemCode(ctx, c.typ.Elem(), header, size)
- ctx.incIndex()
- end := newOpCode(ctx, c.typ, OpSliceEnd)
- ctx.incIndex()
- header.End = end
- header.Next = codes.First()
- codes.Last().Next = elemCode
- elemCode.Next = codes.First()
- elemCode.End = end
- return Opcodes{header}.Add(codes...).Add(elemCode).Add(end)
-}
-
-func (c *SliceCode) Filter(_ *FieldQuery) Code {
- return c
-}
-
-type ArrayCode struct {
- typ *runtime.Type
- value Code
-}
-
-func (c *ArrayCode) Kind() CodeKind {
- return CodeKindArray
-}
-
-func (c *ArrayCode) ToOpcode(ctx *compileContext) Opcodes {
- // header => opcode => elem => end
- // ^ |
- // |________|
- elem := c.typ.Elem()
- alen := c.typ.Len()
- size := elem.Size()
-
- header := newArrayHeaderCode(ctx, c.typ, alen)
- ctx.incIndex()
-
- ctx.incIndent()
- codes := c.value.ToOpcode(ctx)
- ctx.decIndent()
-
- codes.First().Flags |= IndirectFlags
-
- elemCode := newArrayElemCode(ctx, elem, header, alen, size)
- ctx.incIndex()
-
- end := newOpCode(ctx, c.typ, OpArrayEnd)
- ctx.incIndex()
-
- header.End = end
- header.Next = codes.First()
- codes.Last().Next = elemCode
- elemCode.Next = codes.First()
- elemCode.End = end
-
- return Opcodes{header}.Add(codes...).Add(elemCode).Add(end)
-}
-
-func (c *ArrayCode) Filter(_ *FieldQuery) Code {
- return c
-}
-
-type MapCode struct {
- typ *runtime.Type
- key Code
- value Code
-}
-
-func (c *MapCode) Kind() CodeKind {
- return CodeKindMap
-}
-
-func (c *MapCode) ToOpcode(ctx *compileContext) Opcodes {
- // header => code => value => code => key => code => value => code => end
- // ^ |
- // |_______________________|
- header := newMapHeaderCode(ctx, c.typ)
- ctx.incIndex()
-
- keyCodes := c.key.ToOpcode(ctx)
-
- value := newMapValueCode(ctx, c.typ.Elem(), header)
- ctx.incIndex()
-
- ctx.incIndent()
- valueCodes := c.value.ToOpcode(ctx)
- ctx.decIndent()
-
- valueCodes.First().Flags |= IndirectFlags
-
- key := newMapKeyCode(ctx, c.typ.Key(), header)
- ctx.incIndex()
-
- end := newMapEndCode(ctx, c.typ, header)
- ctx.incIndex()
-
- header.Next = keyCodes.First()
- keyCodes.Last().Next = value
- value.Next = valueCodes.First()
- valueCodes.Last().Next = key
- key.Next = keyCodes.First()
-
- header.End = end
- key.End = end
- value.End = end
- return Opcodes{header}.Add(keyCodes...).Add(value).Add(valueCodes...).Add(key).Add(end)
-}
-
-func (c *MapCode) Filter(_ *FieldQuery) Code {
- return c
-}
-
-type StructCode struct {
- typ *runtime.Type
- fields []*StructFieldCode
- isPtr bool
- disableIndirectConversion bool
- isIndirect bool
- isRecursive bool
-}
-
-func (c *StructCode) Kind() CodeKind {
- return CodeKindStruct
-}
-
-func (c *StructCode) lastFieldCode(field *StructFieldCode, firstField *Opcode) *Opcode {
- if isEmbeddedStruct(field) {
- return c.lastAnonymousFieldCode(firstField)
- }
- lastField := firstField
- for lastField.NextField != nil {
- lastField = lastField.NextField
- }
- return lastField
-}
-
-func (c *StructCode) lastAnonymousFieldCode(firstField *Opcode) *Opcode {
- // firstField is special StructHead operation for anonymous structure.
- // So, StructHead's next operation is truly struct head operation.
- for firstField.Op == OpStructHead || firstField.Op == OpStructField {
- firstField = firstField.Next
- }
- lastField := firstField
- for lastField.NextField != nil {
- lastField = lastField.NextField
- }
- return lastField
-}
-
-func (c *StructCode) ToOpcode(ctx *compileContext) Opcodes {
- // header => code => structField => code => end
- // ^ |
- // |__________|
- if c.isRecursive {
- recursive := newRecursiveCode(ctx, c.typ, &CompiledCode{})
- recursive.Type = c.typ
- ctx.incIndex()
- *ctx.recursiveCodes = append(*ctx.recursiveCodes, recursive)
- return Opcodes{recursive}
- }
- codes := Opcodes{}
- var prevField *Opcode
- ctx.incIndent()
- for idx, field := range c.fields {
- isFirstField := idx == 0
- isEndField := idx == len(c.fields)-1
- fieldCodes := field.ToOpcode(ctx, isFirstField, isEndField)
- for _, code := range fieldCodes {
- if c.isIndirect {
- code.Flags |= IndirectFlags
- }
- }
- firstField := fieldCodes.First()
- if len(codes) > 0 {
- codes.Last().Next = firstField
- firstField.Idx = codes.First().Idx
- }
- if prevField != nil {
- prevField.NextField = firstField
- }
- if isEndField {
- endField := fieldCodes.Last()
- if len(codes) > 0 {
- codes.First().End = endField
- } else {
- firstField.End = endField
- }
- codes = codes.Add(fieldCodes...)
- break
- }
- prevField = c.lastFieldCode(field, firstField)
- codes = codes.Add(fieldCodes...)
- }
- if len(codes) == 0 {
- head := &Opcode{
- Op: OpStructHead,
- Idx: opcodeOffset(ctx.ptrIndex),
- Type: c.typ,
- DisplayIdx: ctx.opcodeIndex,
- Indent: ctx.indent,
- }
- ctx.incOpcodeIndex()
- end := &Opcode{
- Op: OpStructEnd,
- Idx: opcodeOffset(ctx.ptrIndex),
- DisplayIdx: ctx.opcodeIndex,
- Indent: ctx.indent,
- }
- head.NextField = end
- head.Next = end
- head.End = end
- codes = codes.Add(head, end)
- ctx.incIndex()
- }
- ctx.decIndent()
- ctx.structTypeToCodes[uintptr(unsafe.Pointer(c.typ))] = codes
- return codes
-}
-
-func (c *StructCode) ToAnonymousOpcode(ctx *compileContext) Opcodes {
- // header => code => structField => code => end
- // ^ |
- // |__________|
- if c.isRecursive {
- recursive := newRecursiveCode(ctx, c.typ, &CompiledCode{})
- recursive.Type = c.typ
- ctx.incIndex()
- *ctx.recursiveCodes = append(*ctx.recursiveCodes, recursive)
- return Opcodes{recursive}
- }
- codes := Opcodes{}
- var prevField *Opcode
- for idx, field := range c.fields {
- isFirstField := idx == 0
- isEndField := idx == len(c.fields)-1
- fieldCodes := field.ToAnonymousOpcode(ctx, isFirstField, isEndField)
- for _, code := range fieldCodes {
- if c.isIndirect {
- code.Flags |= IndirectFlags
- }
- }
- firstField := fieldCodes.First()
- if len(codes) > 0 {
- codes.Last().Next = firstField
- firstField.Idx = codes.First().Idx
- }
- if prevField != nil {
- prevField.NextField = firstField
- }
- if isEndField {
- lastField := fieldCodes.Last()
- if len(codes) > 0 {
- codes.First().End = lastField
- } else {
- firstField.End = lastField
- }
- }
- prevField = firstField
- codes = codes.Add(fieldCodes...)
- }
- return codes
-}
-
-func (c *StructCode) removeFieldsByTags(tags runtime.StructTags) {
- fields := make([]*StructFieldCode, 0, len(c.fields))
- for _, field := range c.fields {
- if field.isAnonymous {
- structCode := field.getAnonymousStruct()
- if structCode != nil && !structCode.isRecursive {
- structCode.removeFieldsByTags(tags)
- if len(structCode.fields) > 0 {
- fields = append(fields, field)
- }
- continue
- }
- }
- if tags.ExistsKey(field.key) {
- continue
- }
- fields = append(fields, field)
- }
- c.fields = fields
-}
-
-func (c *StructCode) enableIndirect() {
- if c.isIndirect {
- return
- }
- c.isIndirect = true
- if len(c.fields) == 0 {
- return
- }
- structCode := c.fields[0].getStruct()
- if structCode == nil {
- return
- }
- structCode.enableIndirect()
-}
-
-func (c *StructCode) Filter(query *FieldQuery) Code {
- fieldMap := map[string]*FieldQuery{}
- for _, field := range query.Fields {
- fieldMap[field.Name] = field
- }
- fields := make([]*StructFieldCode, 0, len(c.fields))
- for _, field := range c.fields {
- query, exists := fieldMap[field.key]
- if !exists {
- continue
- }
- fieldCode := &StructFieldCode{
- typ: field.typ,
- key: field.key,
- tag: field.tag,
- value: field.value,
- offset: field.offset,
- isAnonymous: field.isAnonymous,
- isTaggedKey: field.isTaggedKey,
- isNilableType: field.isNilableType,
- isNilCheck: field.isNilCheck,
- isAddrForMarshaler: field.isAddrForMarshaler,
- isNextOpPtrType: field.isNextOpPtrType,
- }
- if len(query.Fields) > 0 {
- fieldCode.value = fieldCode.value.Filter(query)
- }
- fields = append(fields, fieldCode)
- }
- return &StructCode{
- typ: c.typ,
- fields: fields,
- isPtr: c.isPtr,
- disableIndirectConversion: c.disableIndirectConversion,
- isIndirect: c.isIndirect,
- isRecursive: c.isRecursive,
- }
-}
-
-type StructFieldCode struct {
- typ *runtime.Type
- key string
- tag *runtime.StructTag
- value Code
- offset uintptr
- isAnonymous bool
- isTaggedKey bool
- isNilableType bool
- isNilCheck bool
- isAddrForMarshaler bool
- isNextOpPtrType bool
- isMarshalerContext bool
-}
-
-func (c *StructFieldCode) getStruct() *StructCode {
- value := c.value
- ptr, ok := value.(*PtrCode)
- if ok {
- value = ptr.value
- }
- structCode, ok := value.(*StructCode)
- if ok {
- return structCode
- }
- return nil
-}
-
-func (c *StructFieldCode) getAnonymousStruct() *StructCode {
- if !c.isAnonymous {
- return nil
- }
- return c.getStruct()
-}
-
-func optimizeStructHeader(code *Opcode, tag *runtime.StructTag) OpType {
- headType := code.ToHeaderType(tag.IsString)
- if tag.IsOmitEmpty {
- headType = headType.HeadToOmitEmptyHead()
- }
- return headType
-}
-
-func optimizeStructField(code *Opcode, tag *runtime.StructTag) OpType {
- fieldType := code.ToFieldType(tag.IsString)
- if tag.IsOmitEmpty {
- fieldType = fieldType.FieldToOmitEmptyField()
- }
- return fieldType
-}
-
-func (c *StructFieldCode) headerOpcodes(ctx *compileContext, field *Opcode, valueCodes Opcodes) Opcodes {
- value := valueCodes.First()
- op := optimizeStructHeader(value, c.tag)
- field.Op = op
- if value.Flags&MarshalerContextFlags != 0 {
- field.Flags |= MarshalerContextFlags
- }
- field.NumBitSize = value.NumBitSize
- field.PtrNum = value.PtrNum
- field.FieldQuery = value.FieldQuery
- fieldCodes := Opcodes{field}
- if op.IsMultipleOpHead() {
- field.Next = value
- fieldCodes = fieldCodes.Add(valueCodes...)
- } else {
- ctx.decIndex()
- }
- return fieldCodes
-}
-
-func (c *StructFieldCode) fieldOpcodes(ctx *compileContext, field *Opcode, valueCodes Opcodes) Opcodes {
- value := valueCodes.First()
- op := optimizeStructField(value, c.tag)
- field.Op = op
- if value.Flags&MarshalerContextFlags != 0 {
- field.Flags |= MarshalerContextFlags
- }
- field.NumBitSize = value.NumBitSize
- field.PtrNum = value.PtrNum
- field.FieldQuery = value.FieldQuery
-
- fieldCodes := Opcodes{field}
- if op.IsMultipleOpField() {
- field.Next = value
- fieldCodes = fieldCodes.Add(valueCodes...)
- } else {
- ctx.decIndex()
- }
- return fieldCodes
-}
-
-func (c *StructFieldCode) addStructEndCode(ctx *compileContext, codes Opcodes) Opcodes {
- end := &Opcode{
- Op: OpStructEnd,
- Idx: opcodeOffset(ctx.ptrIndex),
- DisplayIdx: ctx.opcodeIndex,
- Indent: ctx.indent,
- }
- codes.Last().Next = end
- code := codes.First()
- for code.Op == OpStructField || code.Op == OpStructHead {
- code = code.Next
- }
- for code.NextField != nil {
- code = code.NextField
- }
- code.NextField = end
-
- codes = codes.Add(end)
- ctx.incOpcodeIndex()
- return codes
-}
-
-func (c *StructFieldCode) structKey(ctx *compileContext) string {
- if ctx.escapeKey {
- rctx := &RuntimeContext{Option: &Option{Flag: HTMLEscapeOption}}
- return fmt.Sprintf(`%s:`, string(AppendString(rctx, []byte{}, c.key)))
- }
- return fmt.Sprintf(`"%s":`, c.key)
-}
-
-func (c *StructFieldCode) flags() OpFlags {
- var flags OpFlags
- if c.isTaggedKey {
- flags |= IsTaggedKeyFlags
- }
- if c.isNilableType {
- flags |= IsNilableTypeFlags
- }
- if c.isNilCheck {
- flags |= NilCheckFlags
- }
- if c.isAddrForMarshaler {
- flags |= AddrForMarshalerFlags
- }
- if c.isNextOpPtrType {
- flags |= IsNextOpPtrTypeFlags
- }
- if c.isAnonymous {
- flags |= AnonymousKeyFlags
- }
- if c.isMarshalerContext {
- flags |= MarshalerContextFlags
- }
- return flags
-}
-
-func (c *StructFieldCode) toValueOpcodes(ctx *compileContext) Opcodes {
- if c.isAnonymous {
- anonymCode, ok := c.value.(AnonymousCode)
- if ok {
- return anonymCode.ToAnonymousOpcode(ctx)
- }
- }
- return c.value.ToOpcode(ctx)
-}
-
-func (c *StructFieldCode) ToOpcode(ctx *compileContext, isFirstField, isEndField bool) Opcodes {
- field := &Opcode{
- Idx: opcodeOffset(ctx.ptrIndex),
- Flags: c.flags(),
- Key: c.structKey(ctx),
- Offset: uint32(c.offset),
- Type: c.typ,
- DisplayIdx: ctx.opcodeIndex,
- Indent: ctx.indent,
- DisplayKey: c.key,
- }
- ctx.incIndex()
- valueCodes := c.toValueOpcodes(ctx)
- if isFirstField {
- codes := c.headerOpcodes(ctx, field, valueCodes)
- if isEndField {
- codes = c.addStructEndCode(ctx, codes)
- }
- return codes
- }
- codes := c.fieldOpcodes(ctx, field, valueCodes)
- if isEndField {
- if isEnableStructEndOptimization(c.value) {
- field.Op = field.Op.FieldToEnd()
- } else {
- codes = c.addStructEndCode(ctx, codes)
- }
- }
- return codes
-}
-
-func (c *StructFieldCode) ToAnonymousOpcode(ctx *compileContext, isFirstField, isEndField bool) Opcodes {
- field := &Opcode{
- Idx: opcodeOffset(ctx.ptrIndex),
- Flags: c.flags() | AnonymousHeadFlags,
- Key: c.structKey(ctx),
- Offset: uint32(c.offset),
- Type: c.typ,
- DisplayIdx: ctx.opcodeIndex,
- Indent: ctx.indent,
- DisplayKey: c.key,
- }
- ctx.incIndex()
- valueCodes := c.toValueOpcodes(ctx)
- if isFirstField {
- return c.headerOpcodes(ctx, field, valueCodes)
- }
- return c.fieldOpcodes(ctx, field, valueCodes)
-}
-
-func isEnableStructEndOptimization(value Code) bool {
- switch value.Kind() {
- case CodeKindInt,
- CodeKindUint,
- CodeKindFloat,
- CodeKindString,
- CodeKindBool,
- CodeKindBytes:
- return true
- case CodeKindPtr:
- return isEnableStructEndOptimization(value.(*PtrCode).value)
- default:
- return false
- }
-}
-
-type InterfaceCode struct {
- typ *runtime.Type
- fieldQuery *FieldQuery
- isPtr bool
-}
-
-func (c *InterfaceCode) Kind() CodeKind {
- return CodeKindInterface
-}
-
-func (c *InterfaceCode) ToOpcode(ctx *compileContext) Opcodes {
- var code *Opcode
- switch {
- case c.isPtr:
- code = newOpCode(ctx, c.typ, OpInterfacePtr)
- default:
- code = newOpCode(ctx, c.typ, OpInterface)
- }
- code.FieldQuery = c.fieldQuery
- if c.typ.NumMethod() > 0 {
- code.Flags |= NonEmptyInterfaceFlags
- }
- ctx.incIndex()
- return Opcodes{code}
-}
-
-func (c *InterfaceCode) Filter(query *FieldQuery) Code {
- return &InterfaceCode{
- typ: c.typ,
- fieldQuery: query,
- isPtr: c.isPtr,
- }
-}
-
-type MarshalJSONCode struct {
- typ *runtime.Type
- fieldQuery *FieldQuery
- isAddrForMarshaler bool
- isNilableType bool
- isMarshalerContext bool
-}
-
-func (c *MarshalJSONCode) Kind() CodeKind {
- return CodeKindMarshalJSON
-}
-
-func (c *MarshalJSONCode) ToOpcode(ctx *compileContext) Opcodes {
- code := newOpCode(ctx, c.typ, OpMarshalJSON)
- code.FieldQuery = c.fieldQuery
- if c.isAddrForMarshaler {
- code.Flags |= AddrForMarshalerFlags
- }
- if c.isMarshalerContext {
- code.Flags |= MarshalerContextFlags
- }
- if c.isNilableType {
- code.Flags |= IsNilableTypeFlags
- } else {
- code.Flags &= ^IsNilableTypeFlags
- }
- ctx.incIndex()
- return Opcodes{code}
-}
-
-func (c *MarshalJSONCode) Filter(query *FieldQuery) Code {
- return &MarshalJSONCode{
- typ: c.typ,
- fieldQuery: query,
- isAddrForMarshaler: c.isAddrForMarshaler,
- isNilableType: c.isNilableType,
- isMarshalerContext: c.isMarshalerContext,
- }
-}
-
-type MarshalTextCode struct {
- typ *runtime.Type
- fieldQuery *FieldQuery
- isAddrForMarshaler bool
- isNilableType bool
-}
-
-func (c *MarshalTextCode) Kind() CodeKind {
- return CodeKindMarshalText
-}
-
-func (c *MarshalTextCode) ToOpcode(ctx *compileContext) Opcodes {
- code := newOpCode(ctx, c.typ, OpMarshalText)
- code.FieldQuery = c.fieldQuery
- if c.isAddrForMarshaler {
- code.Flags |= AddrForMarshalerFlags
- }
- if c.isNilableType {
- code.Flags |= IsNilableTypeFlags
- } else {
- code.Flags &= ^IsNilableTypeFlags
- }
- ctx.incIndex()
- return Opcodes{code}
-}
-
-func (c *MarshalTextCode) Filter(query *FieldQuery) Code {
- return &MarshalTextCode{
- typ: c.typ,
- fieldQuery: query,
- isAddrForMarshaler: c.isAddrForMarshaler,
- isNilableType: c.isNilableType,
- }
-}
-
-type PtrCode struct {
- typ *runtime.Type
- value Code
- ptrNum uint8
-}
-
-func (c *PtrCode) Kind() CodeKind {
- return CodeKindPtr
-}
-
-func (c *PtrCode) ToOpcode(ctx *compileContext) Opcodes {
- codes := c.value.ToOpcode(ctx)
- codes.First().Op = convertPtrOp(codes.First())
- codes.First().PtrNum = c.ptrNum
- return codes
-}
-
-func (c *PtrCode) ToAnonymousOpcode(ctx *compileContext) Opcodes {
- var codes Opcodes
- anonymCode, ok := c.value.(AnonymousCode)
- if ok {
- codes = anonymCode.ToAnonymousOpcode(ctx)
- } else {
- codes = c.value.ToOpcode(ctx)
- }
- codes.First().Op = convertPtrOp(codes.First())
- codes.First().PtrNum = c.ptrNum
- return codes
-}
-
-func (c *PtrCode) Filter(query *FieldQuery) Code {
- return &PtrCode{
- typ: c.typ,
- value: c.value.Filter(query),
- ptrNum: c.ptrNum,
- }
-}
-
-func convertPtrOp(code *Opcode) OpType {
- ptrHeadOp := code.Op.HeadToPtrHead()
- if code.Op != ptrHeadOp {
- if code.PtrNum > 0 {
- // ptr field and ptr head
- code.PtrNum--
- }
- return ptrHeadOp
- }
- switch code.Op {
- case OpInt:
- return OpIntPtr
- case OpUint:
- return OpUintPtr
- case OpFloat32:
- return OpFloat32Ptr
- case OpFloat64:
- return OpFloat64Ptr
- case OpString:
- return OpStringPtr
- case OpBool:
- return OpBoolPtr
- case OpBytes:
- return OpBytesPtr
- case OpNumber:
- return OpNumberPtr
- case OpArray:
- return OpArrayPtr
- case OpSlice:
- return OpSlicePtr
- case OpMap:
- return OpMapPtr
- case OpMarshalJSON:
- return OpMarshalJSONPtr
- case OpMarshalText:
- return OpMarshalTextPtr
- case OpInterface:
- return OpInterfacePtr
- case OpRecursive:
- return OpRecursivePtr
- }
- return code.Op
-}
-
-func isEmbeddedStruct(field *StructFieldCode) bool {
- if !field.isAnonymous {
- return false
- }
- t := field.typ
- if t.Kind() == reflect.Ptr {
- t = t.Elem()
- }
- return t.Kind() == reflect.Struct
-}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compact.go b/vendor/github.com/goccy/go-json/internal/encoder/compact.go
index e287a6c..0eb9545 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/compact.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/compact.go
@@ -213,8 +213,8 @@ func compactString(dst, src []byte, cursor int64, escape bool) ([]byte, int64, e
dst = append(dst, src[start:cursor]...)
dst = append(dst, `\u202`...)
dst = append(dst, hex[src[cursor+2]&0xF])
- start = cursor + 3
cursor += 2
+ start = cursor + 3
}
}
switch c {
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compiler.go b/vendor/github.com/goccy/go-json/internal/encoder/compiler.go
index b107636..c627ed3 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/compiler.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/compiler.go
@@ -4,8 +4,9 @@ import (
"context"
"encoding"
"encoding/json"
+ "fmt"
"reflect"
- "sync"
+ "strings"
"sync/atomic"
"unsafe"
@@ -25,17 +26,14 @@ var (
cachedOpcodeSets []*OpcodeSet
cachedOpcodeMap unsafe.Pointer // map[uintptr]*OpcodeSet
typeAddr *runtime.TypeAddr
- initEncoderOnce sync.Once
)
-func initEncoder() {
- initEncoderOnce.Do(func() {
- typeAddr = runtime.AnalyzeTypeAddr()
- if typeAddr == nil {
- typeAddr = &runtime.TypeAddr{}
- }
- cachedOpcodeSets = make([]*OpcodeSet, typeAddr.AddrRange>>typeAddr.AddrShift+1)
- })
+func init() {
+ typeAddr = runtime.AnalyzeTypeAddr()
+ if typeAddr == nil {
+ typeAddr = &runtime.TypeAddr{}
+ }
+ cachedOpcodeSets = make([]*OpcodeSet, typeAddr.AddrRange>>typeAddr.AddrShift)
}
func loadOpcodeMap() map[uintptr]*OpcodeSet {
@@ -59,68 +57,25 @@ func compileToGetCodeSetSlowPath(typeptr uintptr) (*OpcodeSet, error) {
if codeSet, exists := opcodeMap[typeptr]; exists {
return codeSet, nil
}
- codeSet, err := newCompiler().compile(typeptr)
- if err != nil {
- return nil, err
- }
- storeOpcodeSet(typeptr, codeSet, opcodeMap)
- return codeSet, nil
-}
-func getFilteredCodeSetIfNeeded(ctx *RuntimeContext, codeSet *OpcodeSet) (*OpcodeSet, error) {
- if (ctx.Option.Flag & ContextOption) == 0 {
- return codeSet, nil
- }
- query := FieldQueryFromContext(ctx.Option.Context)
- if query == nil {
- return codeSet, nil
- }
- ctx.Option.Flag |= FieldQueryOption
- cacheCodeSet := codeSet.getQueryCache(query.Hash())
- if cacheCodeSet != nil {
- return cacheCodeSet, nil
- }
- queryCodeSet, err := newCompiler().codeToOpcodeSet(codeSet.Type, codeSet.Code.Filter(query))
- if err != nil {
- return nil, err
- }
- codeSet.setQueryCache(query.Hash(), queryCodeSet)
- return queryCodeSet, nil
-}
-
-type Compiler struct {
- structTypeToCode map[uintptr]*StructCode
-}
-
-func newCompiler() *Compiler {
- return &Compiler{
- structTypeToCode: map[uintptr]*StructCode{},
- }
-}
-
-func (c *Compiler) compile(typeptr uintptr) (*OpcodeSet, error) {
// noescape trick for header.typ ( reflect.*rtype )
- typ := *(**runtime.Type)(unsafe.Pointer(&typeptr))
- code, err := c.typeToCode(typ)
+ copiedType := *(**runtime.Type)(unsafe.Pointer(&typeptr))
+
+ noescapeKeyCode, err := compileHead(&compileContext{
+ typ: copiedType,
+ structTypeToCompiledCode: map[uintptr]*CompiledCode{},
+ })
if err != nil {
return nil, err
}
- return c.codeToOpcodeSet(typ, code)
-}
-
-func (c *Compiler) codeToOpcodeSet(typ *runtime.Type, code Code) (*OpcodeSet, error) {
- noescapeKeyCode := c.codeToOpcode(&compileContext{
- structTypeToCodes: map[uintptr]Opcodes{},
- recursiveCodes: &Opcodes{},
- }, typ, code)
- if err := noescapeKeyCode.Validate(); err != nil {
+ escapeKeyCode, err := compileHead(&compileContext{
+ typ: copiedType,
+ structTypeToCompiledCode: map[uintptr]*CompiledCode{},
+ escapeKey: true,
+ })
+ if err != nil {
return nil, err
}
- escapeKeyCode := c.codeToOpcode(&compileContext{
- structTypeToCodes: map[uintptr]Opcodes{},
- recursiveCodes: &Opcodes{},
- escapeKey: true,
- }, typ, code)
noescapeKeyCode = copyOpcode(noescapeKeyCode)
escapeKeyCode = copyOpcode(escapeKeyCode)
setTotalLengthToInterfaceOp(noescapeKeyCode)
@@ -128,25 +83,26 @@ func (c *Compiler) codeToOpcodeSet(typ *runtime.Type, code Code) (*OpcodeSet, er
interfaceNoescapeKeyCode := copyToInterfaceOpcode(noescapeKeyCode)
interfaceEscapeKeyCode := copyToInterfaceOpcode(escapeKeyCode)
codeLength := noescapeKeyCode.TotalLength()
- return &OpcodeSet{
- Type: typ,
+ codeSet := &OpcodeSet{
+ Type: copiedType,
NoescapeKeyCode: noescapeKeyCode,
EscapeKeyCode: escapeKeyCode,
InterfaceNoescapeKeyCode: interfaceNoescapeKeyCode,
InterfaceEscapeKeyCode: interfaceEscapeKeyCode,
CodeLength: codeLength,
EndCode: ToEndCode(interfaceNoescapeKeyCode),
- Code: code,
- QueryCache: map[string]*OpcodeSet{},
- }, nil
+ }
+ storeOpcodeSet(typeptr, codeSet, opcodeMap)
+ return codeSet, nil
}
-func (c *Compiler) typeToCode(typ *runtime.Type) (Code, error) {
+func compileHead(ctx *compileContext) (*Opcode, error) {
+ typ := ctx.typ
switch {
- case c.implementsMarshalJSON(typ):
- return c.marshalJSONCode(typ)
- case c.implementsMarshalText(typ):
- return c.marshalTextCode(typ)
+ case implementsMarshalJSON(typ):
+ return compileMarshalJSON(ctx)
+ case implementsMarshalText(typ):
+ return compileMarshalText(ctx)
}
isPtr := false
@@ -156,700 +112,262 @@ func (c *Compiler) typeToCode(typ *runtime.Type) (Code, error) {
isPtr = true
}
switch {
- case c.implementsMarshalJSON(typ):
- return c.marshalJSONCode(orgType)
- case c.implementsMarshalText(typ):
- return c.marshalTextCode(orgType)
+ case implementsMarshalJSON(typ):
+ return compileMarshalJSON(ctx)
+ case implementsMarshalText(typ):
+ return compileMarshalText(ctx)
}
switch typ.Kind() {
case reflect.Slice:
+ ctx := ctx.withType(typ)
elem := typ.Elem()
if elem.Kind() == reflect.Uint8 {
p := runtime.PtrTo(elem)
- if !c.implementsMarshalJSONType(p) && !p.Implements(marshalTextType) {
- return c.bytesCode(typ, isPtr)
+ if !implementsMarshalJSONType(p) && !p.Implements(marshalTextType) {
+ if isPtr {
+ return compileBytesPtr(ctx)
+ }
+ return compileBytes(ctx)
}
}
- return c.sliceCode(typ)
+ code, err := compileSlice(ctx)
+ if err != nil {
+ return nil, err
+ }
+ optimizeStructEnd(code)
+ linkRecursiveCode(code)
+ return code, nil
case reflect.Map:
if isPtr {
- return c.ptrCode(runtime.PtrTo(typ))
+ return compilePtr(ctx.withType(runtime.PtrTo(typ)))
}
- return c.mapCode(typ)
+ code, err := compileMap(ctx.withType(typ))
+ if err != nil {
+ return nil, err
+ }
+ optimizeStructEnd(code)
+ linkRecursiveCode(code)
+ return code, nil
case reflect.Struct:
- return c.structCode(typ, isPtr)
+ code, err := compileStruct(ctx.withType(typ), isPtr)
+ if err != nil {
+ return nil, err
+ }
+ optimizeStructEnd(code)
+ linkRecursiveCode(code)
+ return code, nil
case reflect.Int:
- return c.intCode(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileIntPtr(ctx)
+ }
+ return compileInt(ctx)
case reflect.Int8:
- return c.int8Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileInt8Ptr(ctx)
+ }
+ return compileInt8(ctx)
case reflect.Int16:
- return c.int16Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileInt16Ptr(ctx)
+ }
+ return compileInt16(ctx)
case reflect.Int32:
- return c.int32Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileInt32Ptr(ctx)
+ }
+ return compileInt32(ctx)
case reflect.Int64:
- return c.int64Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileInt64Ptr(ctx)
+ }
+ return compileInt64(ctx)
case reflect.Uint, reflect.Uintptr:
- return c.uintCode(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileUintPtr(ctx)
+ }
+ return compileUint(ctx)
case reflect.Uint8:
- return c.uint8Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileUint8Ptr(ctx)
+ }
+ return compileUint8(ctx)
case reflect.Uint16:
- return c.uint16Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileUint16Ptr(ctx)
+ }
+ return compileUint16(ctx)
case reflect.Uint32:
- return c.uint32Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileUint32Ptr(ctx)
+ }
+ return compileUint32(ctx)
case reflect.Uint64:
- return c.uint64Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileUint64Ptr(ctx)
+ }
+ return compileUint64(ctx)
case reflect.Float32:
- return c.float32Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileFloat32Ptr(ctx)
+ }
+ return compileFloat32(ctx)
case reflect.Float64:
- return c.float64Code(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileFloat64Ptr(ctx)
+ }
+ return compileFloat64(ctx)
case reflect.String:
- return c.stringCode(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileStringPtr(ctx)
+ }
+ return compileString(ctx)
case reflect.Bool:
- return c.boolCode(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileBoolPtr(ctx)
+ }
+ return compileBool(ctx)
case reflect.Interface:
- return c.interfaceCode(typ, isPtr)
+ ctx := ctx.withType(typ)
+ if isPtr {
+ return compileInterfacePtr(ctx)
+ }
+ return compileInterface(ctx)
default:
if isPtr && typ.Implements(marshalTextType) {
typ = orgType
}
- return c.typeToCodeWithPtr(typ, isPtr)
- }
-}
-
-func (c *Compiler) typeToCodeWithPtr(typ *runtime.Type, isPtr bool) (Code, error) {
- switch {
- case c.implementsMarshalJSON(typ):
- return c.marshalJSONCode(typ)
- case c.implementsMarshalText(typ):
- return c.marshalTextCode(typ)
- }
- switch typ.Kind() {
- case reflect.Ptr:
- return c.ptrCode(typ)
- case reflect.Slice:
- elem := typ.Elem()
- if elem.Kind() == reflect.Uint8 {
- p := runtime.PtrTo(elem)
- if !c.implementsMarshalJSONType(p) && !p.Implements(marshalTextType) {
- return c.bytesCode(typ, false)
- }
- }
- return c.sliceCode(typ)
- case reflect.Array:
- return c.arrayCode(typ)
- case reflect.Map:
- return c.mapCode(typ)
- case reflect.Struct:
- return c.structCode(typ, isPtr)
- case reflect.Interface:
- return c.interfaceCode(typ, false)
- case reflect.Int:
- return c.intCode(typ, false)
- case reflect.Int8:
- return c.int8Code(typ, false)
- case reflect.Int16:
- return c.int16Code(typ, false)
- case reflect.Int32:
- return c.int32Code(typ, false)
- case reflect.Int64:
- return c.int64Code(typ, false)
- case reflect.Uint:
- return c.uintCode(typ, false)
- case reflect.Uint8:
- return c.uint8Code(typ, false)
- case reflect.Uint16:
- return c.uint16Code(typ, false)
- case reflect.Uint32:
- return c.uint32Code(typ, false)
- case reflect.Uint64:
- return c.uint64Code(typ, false)
- case reflect.Uintptr:
- return c.uintCode(typ, false)
- case reflect.Float32:
- return c.float32Code(typ, false)
- case reflect.Float64:
- return c.float64Code(typ, false)
- case reflect.String:
- return c.stringCode(typ, false)
- case reflect.Bool:
- return c.boolCode(typ, false)
- }
- return nil, &errors.UnsupportedTypeError{Type: runtime.RType2Type(typ)}
-}
-
-const intSize = 32 << (^uint(0) >> 63)
-
-//nolint:unparam
-func (c *Compiler) intCode(typ *runtime.Type, isPtr bool) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: intSize, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) int8Code(typ *runtime.Type, isPtr bool) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: 8, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) int16Code(typ *runtime.Type, isPtr bool) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: 16, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) int32Code(typ *runtime.Type, isPtr bool) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: 32, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) int64Code(typ *runtime.Type, isPtr bool) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: 64, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uintCode(typ *runtime.Type, isPtr bool) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: intSize, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uint8Code(typ *runtime.Type, isPtr bool) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: 8, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uint16Code(typ *runtime.Type, isPtr bool) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: 16, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uint32Code(typ *runtime.Type, isPtr bool) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: 32, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uint64Code(typ *runtime.Type, isPtr bool) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: 64, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) float32Code(typ *runtime.Type, isPtr bool) (*FloatCode, error) {
- return &FloatCode{typ: typ, bitSize: 32, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) float64Code(typ *runtime.Type, isPtr bool) (*FloatCode, error) {
- return &FloatCode{typ: typ, bitSize: 64, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) stringCode(typ *runtime.Type, isPtr bool) (*StringCode, error) {
- return &StringCode{typ: typ, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) boolCode(typ *runtime.Type, isPtr bool) (*BoolCode, error) {
- return &BoolCode{typ: typ, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) intStringCode(typ *runtime.Type) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: intSize, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) int8StringCode(typ *runtime.Type) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: 8, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) int16StringCode(typ *runtime.Type) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: 16, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) int32StringCode(typ *runtime.Type) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: 32, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) int64StringCode(typ *runtime.Type) (*IntCode, error) {
- return &IntCode{typ: typ, bitSize: 64, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uintStringCode(typ *runtime.Type) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: intSize, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uint8StringCode(typ *runtime.Type) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: 8, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uint16StringCode(typ *runtime.Type) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: 16, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uint32StringCode(typ *runtime.Type) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: 32, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) uint64StringCode(typ *runtime.Type) (*UintCode, error) {
- return &UintCode{typ: typ, bitSize: 64, isString: true}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) bytesCode(typ *runtime.Type, isPtr bool) (*BytesCode, error) {
- return &BytesCode{typ: typ, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) interfaceCode(typ *runtime.Type, isPtr bool) (*InterfaceCode, error) {
- return &InterfaceCode{typ: typ, isPtr: isPtr}, nil
-}
-
-//nolint:unparam
-func (c *Compiler) marshalJSONCode(typ *runtime.Type) (*MarshalJSONCode, error) {
- return &MarshalJSONCode{
- typ: typ,
- isAddrForMarshaler: c.isPtrMarshalJSONType(typ),
- isNilableType: c.isNilableType(typ),
- isMarshalerContext: typ.Implements(marshalJSONContextType) || runtime.PtrTo(typ).Implements(marshalJSONContextType),
- }, nil
-}
-
-//nolint:unparam
-func (c *Compiler) marshalTextCode(typ *runtime.Type) (*MarshalTextCode, error) {
- return &MarshalTextCode{
- typ: typ,
- isAddrForMarshaler: c.isPtrMarshalTextType(typ),
- isNilableType: c.isNilableType(typ),
- }, nil
-}
-
-func (c *Compiler) ptrCode(typ *runtime.Type) (*PtrCode, error) {
- code, err := c.typeToCodeWithPtr(typ.Elem(), true)
- if err != nil {
- return nil, err
- }
- ptr, ok := code.(*PtrCode)
- if ok {
- return &PtrCode{typ: typ, value: ptr.value, ptrNum: ptr.ptrNum + 1}, nil
- }
- return &PtrCode{typ: typ, value: code, ptrNum: 1}, nil
-}
-
-func (c *Compiler) sliceCode(typ *runtime.Type) (*SliceCode, error) {
- elem := typ.Elem()
- code, err := c.listElemCode(elem)
- if err != nil {
- return nil, err
- }
- if code.Kind() == CodeKindStruct {
- structCode := code.(*StructCode)
- structCode.enableIndirect()
- }
- return &SliceCode{typ: typ, value: code}, nil
-}
-
-func (c *Compiler) arrayCode(typ *runtime.Type) (*ArrayCode, error) {
- elem := typ.Elem()
- code, err := c.listElemCode(elem)
- if err != nil {
- return nil, err
- }
- if code.Kind() == CodeKindStruct {
- structCode := code.(*StructCode)
- structCode.enableIndirect()
- }
- return &ArrayCode{typ: typ, value: code}, nil
-}
-
-func (c *Compiler) mapCode(typ *runtime.Type) (*MapCode, error) {
- keyCode, err := c.mapKeyCode(typ.Key())
- if err != nil {
- return nil, err
- }
- valueCode, err := c.mapValueCode(typ.Elem())
- if err != nil {
- return nil, err
- }
- if valueCode.Kind() == CodeKindStruct {
- structCode := valueCode.(*StructCode)
- structCode.enableIndirect()
- }
- return &MapCode{typ: typ, key: keyCode, value: valueCode}, nil
-}
-
-func (c *Compiler) listElemCode(typ *runtime.Type) (Code, error) {
- switch {
- case c.implementsMarshalJSONType(typ) || c.implementsMarshalJSONType(runtime.PtrTo(typ)):
- return c.marshalJSONCode(typ)
- case !typ.Implements(marshalTextType) && runtime.PtrTo(typ).Implements(marshalTextType):
- return c.marshalTextCode(typ)
- case typ.Kind() == reflect.Map:
- return c.ptrCode(runtime.PtrTo(typ))
- default:
- // isPtr was originally used to indicate whether the type of top level is pointer.
- // However, since the slice/array element is a specification that can get the pointer address, explicitly set isPtr to true.
- // See here for related issues: https://github.com/goccy/go-json/issues/370
- code, err := c.typeToCodeWithPtr(typ, true)
+ code, err := compile(ctx.withType(typ), isPtr)
if err != nil {
return nil, err
}
- ptr, ok := code.(*PtrCode)
- if ok {
- if ptr.value.Kind() == CodeKindMap {
- ptr.ptrNum++
- }
- }
+ optimizeStructEnd(code)
+ linkRecursiveCode(code)
return code, nil
}
}
-func (c *Compiler) mapKeyCode(typ *runtime.Type) (Code, error) {
- switch {
- case c.implementsMarshalText(typ):
- return c.marshalTextCode(typ)
- }
- switch typ.Kind() {
- case reflect.Ptr:
- return c.ptrCode(typ)
- case reflect.String:
- return c.stringCode(typ, false)
- case reflect.Int:
- return c.intStringCode(typ)
- case reflect.Int8:
- return c.int8StringCode(typ)
- case reflect.Int16:
- return c.int16StringCode(typ)
- case reflect.Int32:
- return c.int32StringCode(typ)
- case reflect.Int64:
- return c.int64StringCode(typ)
- case reflect.Uint:
- return c.uintStringCode(typ)
- case reflect.Uint8:
- return c.uint8StringCode(typ)
- case reflect.Uint16:
- return c.uint16StringCode(typ)
- case reflect.Uint32:
- return c.uint32StringCode(typ)
- case reflect.Uint64:
- return c.uint64StringCode(typ)
- case reflect.Uintptr:
- return c.uintStringCode(typ)
- }
- return nil, &errors.UnsupportedTypeError{Type: runtime.RType2Type(typ)}
-}
-
-func (c *Compiler) mapValueCode(typ *runtime.Type) (Code, error) {
- switch typ.Kind() {
- case reflect.Map:
- return c.ptrCode(runtime.PtrTo(typ))
- default:
- code, err := c.typeToCodeWithPtr(typ, false)
- if err != nil {
- return nil, err
- }
- ptr, ok := code.(*PtrCode)
- if ok {
- if ptr.value.Kind() == CodeKindMap {
- ptr.ptrNum++
- }
- }
- return code, nil
- }
-}
-
-func (c *Compiler) structCode(typ *runtime.Type, isPtr bool) (*StructCode, error) {
- typeptr := uintptr(unsafe.Pointer(typ))
- if code, exists := c.structTypeToCode[typeptr]; exists {
- derefCode := *code
- derefCode.isRecursive = true
- return &derefCode, nil
- }
- indirect := runtime.IfaceIndir(typ)
- code := &StructCode{typ: typ, isPtr: isPtr, isIndirect: indirect}
- c.structTypeToCode[typeptr] = code
-
- fieldNum := typ.NumField()
- tags := c.typeToStructTags(typ)
- fields := []*StructFieldCode{}
- for i, tag := range tags {
- isOnlyOneFirstField := i == 0 && fieldNum == 1
- field, err := c.structFieldCode(code, tag, isPtr, isOnlyOneFirstField)
- if err != nil {
- return nil, err
- }
- if field.isAnonymous {
- structCode := field.getAnonymousStruct()
- if structCode != nil {
- structCode.removeFieldsByTags(tags)
- if c.isAssignableIndirect(field, isPtr) {
- if indirect {
- structCode.isIndirect = true
- } else {
- structCode.isIndirect = false
- }
- }
- }
- } else {
- structCode := field.getStruct()
- if structCode != nil {
- if indirect {
- // if parent is indirect type, set child indirect property to true
- structCode.isIndirect = true
- } else {
- // if parent is not indirect type, set child indirect property to false.
- // but if parent's indirect is false and isPtr is true, then indirect must be true.
- // Do this only if indirectConversion is enabled at the end of compileStruct.
- structCode.isIndirect = false
- }
- }
- }
- fields = append(fields, field)
- }
- fieldMap := c.getFieldMap(fields)
- duplicatedFieldMap := c.getDuplicatedFieldMap(fieldMap)
- code.fields = c.filteredDuplicatedFields(fields, duplicatedFieldMap)
- if !code.disableIndirectConversion && !indirect && isPtr {
- code.enableIndirect()
- }
- delete(c.structTypeToCode, typeptr)
- return code, nil
-}
-
-func toElemType(t *runtime.Type) *runtime.Type {
- for t.Kind() == reflect.Ptr {
- t = t.Elem()
- }
- return t
-}
-
-func (c *Compiler) structFieldCode(structCode *StructCode, tag *runtime.StructTag, isPtr, isOnlyOneFirstField bool) (*StructFieldCode, error) {
- field := tag.Field
- fieldType := runtime.Type2RType(field.Type)
- isIndirectSpecialCase := isPtr && isOnlyOneFirstField
- fieldCode := &StructFieldCode{
- typ: fieldType,
- key: tag.Key,
- tag: tag,
- offset: field.Offset,
- isAnonymous: field.Anonymous && !tag.IsTaggedKey && toElemType(fieldType).Kind() == reflect.Struct,
- isTaggedKey: tag.IsTaggedKey,
- isNilableType: c.isNilableType(fieldType),
- isNilCheck: true,
- }
- switch {
- case c.isMovePointerPositionFromHeadToFirstMarshalJSONFieldCase(fieldType, isIndirectSpecialCase):
- code, err := c.marshalJSONCode(fieldType)
- if err != nil {
- return nil, err
- }
- fieldCode.value = code
- fieldCode.isAddrForMarshaler = true
- fieldCode.isNilCheck = false
- structCode.isIndirect = false
- structCode.disableIndirectConversion = true
- case c.isMovePointerPositionFromHeadToFirstMarshalTextFieldCase(fieldType, isIndirectSpecialCase):
- code, err := c.marshalTextCode(fieldType)
- if err != nil {
- return nil, err
- }
- fieldCode.value = code
- fieldCode.isAddrForMarshaler = true
- fieldCode.isNilCheck = false
- structCode.isIndirect = false
- structCode.disableIndirectConversion = true
- case isPtr && c.isPtrMarshalJSONType(fieldType):
- // *struct{ field T }
- // func (*T) MarshalJSON() ([]byte, error)
- code, err := c.marshalJSONCode(fieldType)
- if err != nil {
- return nil, err
- }
- fieldCode.value = code
- fieldCode.isAddrForMarshaler = true
- fieldCode.isNilCheck = false
- case isPtr && c.isPtrMarshalTextType(fieldType):
- // *struct{ field T }
- // func (*T) MarshalText() ([]byte, error)
- code, err := c.marshalTextCode(fieldType)
- if err != nil {
- return nil, err
- }
- fieldCode.value = code
- fieldCode.isAddrForMarshaler = true
- fieldCode.isNilCheck = false
- default:
- code, err := c.typeToCodeWithPtr(fieldType, isPtr)
- if err != nil {
- return nil, err
- }
- switch code.Kind() {
- case CodeKindPtr, CodeKindInterface:
- fieldCode.isNextOpPtrType = true
- }
- fieldCode.value = code
- }
- return fieldCode, nil
-}
-
-func (c *Compiler) isAssignableIndirect(fieldCode *StructFieldCode, isPtr bool) bool {
- if isPtr {
- return false
- }
- codeType := fieldCode.value.Kind()
- if codeType == CodeKindMarshalJSON {
- return false
- }
- if codeType == CodeKindMarshalText {
- return false
- }
- return true
-}
-
-func (c *Compiler) getFieldMap(fields []*StructFieldCode) map[string][]*StructFieldCode {
- fieldMap := map[string][]*StructFieldCode{}
- for _, field := range fields {
- if field.isAnonymous {
- for k, v := range c.getAnonymousFieldMap(field) {
- fieldMap[k] = append(fieldMap[k], v...)
- }
- continue
- }
- fieldMap[field.key] = append(fieldMap[field.key], field)
- }
- return fieldMap
-}
-
-func (c *Compiler) getAnonymousFieldMap(field *StructFieldCode) map[string][]*StructFieldCode {
- fieldMap := map[string][]*StructFieldCode{}
- structCode := field.getAnonymousStruct()
- if structCode == nil || structCode.isRecursive {
- fieldMap[field.key] = append(fieldMap[field.key], field)
- return fieldMap
- }
- for k, v := range c.getFieldMapFromAnonymousParent(structCode.fields) {
- fieldMap[k] = append(fieldMap[k], v...)
- }
- return fieldMap
-}
-
-func (c *Compiler) getFieldMapFromAnonymousParent(fields []*StructFieldCode) map[string][]*StructFieldCode {
- fieldMap := map[string][]*StructFieldCode{}
- for _, field := range fields {
- if field.isAnonymous {
- for k, v := range c.getAnonymousFieldMap(field) {
- // Do not handle tagged key when embedding more than once
- for _, vv := range v {
- vv.isTaggedKey = false
- }
- fieldMap[k] = append(fieldMap[k], v...)
- }
- continue
- }
- fieldMap[field.key] = append(fieldMap[field.key], field)
- }
- return fieldMap
-}
-
-func (c *Compiler) getDuplicatedFieldMap(fieldMap map[string][]*StructFieldCode) map[*StructFieldCode]struct{} {
- duplicatedFieldMap := map[*StructFieldCode]struct{}{}
- for _, fields := range fieldMap {
- if len(fields) == 1 {
- continue
- }
- if c.isTaggedKeyOnly(fields) {
- for _, field := range fields {
- if field.isTaggedKey {
- continue
- }
- duplicatedFieldMap[field] = struct{}{}
- }
- } else {
- for _, field := range fields {
- duplicatedFieldMap[field] = struct{}{}
- }
- }
- }
- return duplicatedFieldMap
-}
-
-func (c *Compiler) filteredDuplicatedFields(fields []*StructFieldCode, duplicatedFieldMap map[*StructFieldCode]struct{}) []*StructFieldCode {
- filteredFields := make([]*StructFieldCode, 0, len(fields))
- for _, field := range fields {
- if field.isAnonymous {
- structCode := field.getAnonymousStruct()
- if structCode != nil && !structCode.isRecursive {
- structCode.fields = c.filteredDuplicatedFields(structCode.fields, duplicatedFieldMap)
- if len(structCode.fields) > 0 {
- filteredFields = append(filteredFields, field)
- }
+func linkRecursiveCode(c *Opcode) {
+ for code := c; code.Op != OpEnd && code.Op != OpRecursiveEnd; {
+ switch code.Op {
+ case OpRecursive, OpRecursivePtr:
+ if code.Jmp.Linked {
+ code = code.Next
continue
}
- }
- if _, exists := duplicatedFieldMap[field]; exists {
+ code.Jmp.Code = copyOpcode(code.Jmp.Code)
+
+ c := code.Jmp.Code
+ c.End.Next = newEndOp(&compileContext{})
+ c.Op = c.Op.PtrHeadToHead()
+
+ beforeLastCode := c.End
+ lastCode := beforeLastCode.Next
+
+ lastCode.Idx = beforeLastCode.Idx + uintptrSize
+ lastCode.ElemIdx = lastCode.Idx + uintptrSize
+ lastCode.Length = lastCode.Idx + 2*uintptrSize
+
+ // extend length to alloc slot for elemIdx + length
+ totalLength := uintptr(code.TotalLength() + 3)
+ nextTotalLength := uintptr(c.TotalLength() + 3)
+
+ c.End.Next.Op = OpRecursiveEnd
+
+ code.Jmp.CurLen = totalLength
+ code.Jmp.NextLen = nextTotalLength
+ code.Jmp.Linked = true
+
+ linkRecursiveCode(code.Jmp.Code)
+
+ code = code.Next
continue
}
- filteredFields = append(filteredFields, field)
- }
- return filteredFields
-}
-
-func (c *Compiler) isTaggedKeyOnly(fields []*StructFieldCode) bool {
- var taggedKeyFieldCount int
- for _, field := range fields {
- if field.isTaggedKey {
- taggedKeyFieldCount++
+ switch code.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ code = code.End
+ default:
+ code = code.Next
}
}
- return taggedKeyFieldCount == 1
}
-func (c *Compiler) typeToStructTags(typ *runtime.Type) runtime.StructTags {
- tags := runtime.StructTags{}
- fieldNum := typ.NumField()
- for i := 0; i < fieldNum; i++ {
- field := typ.Field(i)
- if runtime.IsIgnoredStructField(field) {
- continue
+func optimizeStructEnd(c *Opcode) {
+ for code := c; code.Op != OpEnd; {
+ if code.Op == OpRecursive || code.Op == OpRecursivePtr {
+ // ignore if exists recursive operation
+ return
+ }
+ switch code.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ code = code.End
+ default:
+ code = code.Next
+ }
+ }
+
+ for code := c; code.Op != OpEnd; {
+ switch code.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ code = code.End
+ case CodeStructEnd:
+ switch code.Op {
+ case OpStructEnd:
+ prev := code.PrevField
+ prevOp := prev.Op.String()
+ if strings.Contains(prevOp, "Head") ||
+ strings.Contains(prevOp, "Slice") ||
+ strings.Contains(prevOp, "Array") ||
+ strings.Contains(prevOp, "Map") ||
+ strings.Contains(prevOp, "MarshalJSON") ||
+ strings.Contains(prevOp, "MarshalText") {
+ // not exists field
+ code = code.Next
+ break
+ }
+ if prev.Op != prev.Op.FieldToEnd() {
+ prev.Op = prev.Op.FieldToEnd()
+ prev.Next = code.Next
+ }
+ code = code.Next
+ default:
+ code = code.Next
+ }
+ default:
+ code = code.Next
}
- tags = append(tags, runtime.StructTagFromField(field))
}
- return tags
}
-// *struct{ field T } => struct { field *T }
-// func (*T) MarshalJSON() ([]byte, error)
-func (c *Compiler) isMovePointerPositionFromHeadToFirstMarshalJSONFieldCase(typ *runtime.Type, isIndirectSpecialCase bool) bool {
- return isIndirectSpecialCase && !c.isNilableType(typ) && c.isPtrMarshalJSONType(typ)
-}
-
-// *struct{ field T } => struct { field *T }
-// func (*T) MarshalText() ([]byte, error)
-func (c *Compiler) isMovePointerPositionFromHeadToFirstMarshalTextFieldCase(typ *runtime.Type, isIndirectSpecialCase bool) bool {
- return isIndirectSpecialCase && !c.isNilableType(typ) && c.isPtrMarshalTextType(typ)
-}
-
-func (c *Compiler) implementsMarshalJSON(typ *runtime.Type) bool {
- if !c.implementsMarshalJSONType(typ) {
+func implementsMarshalJSON(typ *runtime.Type) bool {
+ if !implementsMarshalJSONType(typ) {
return false
}
if typ.Kind() != reflect.Ptr {
return true
}
// type kind is reflect.Ptr
- if !c.implementsMarshalJSONType(typ.Elem()) {
+ if !implementsMarshalJSONType(typ.Elem()) {
return true
}
// needs to dereference
return false
}
-func (c *Compiler) implementsMarshalText(typ *runtime.Type) bool {
+func implementsMarshalText(typ *runtime.Type) bool {
if !typ.Implements(marshalTextType) {
return false
}
@@ -864,10 +382,931 @@ func (c *Compiler) implementsMarshalText(typ *runtime.Type) bool {
return false
}
-func (c *Compiler) isNilableType(typ *runtime.Type) bool {
- if !runtime.IfaceIndir(typ) {
+func compile(ctx *compileContext, isPtr bool) (*Opcode, error) {
+ typ := ctx.typ
+ switch {
+ case implementsMarshalJSON(typ):
+ return compileMarshalJSON(ctx)
+ case implementsMarshalText(typ):
+ return compileMarshalText(ctx)
+ }
+ switch typ.Kind() {
+ case reflect.Ptr:
+ return compilePtr(ctx)
+ case reflect.Slice:
+ elem := typ.Elem()
+ if elem.Kind() == reflect.Uint8 {
+ p := runtime.PtrTo(elem)
+ if !implementsMarshalJSONType(p) && !p.Implements(marshalTextType) {
+ return compileBytes(ctx)
+ }
+ }
+ return compileSlice(ctx)
+ case reflect.Array:
+ return compileArray(ctx)
+ case reflect.Map:
+ return compileMap(ctx)
+ case reflect.Struct:
+ return compileStruct(ctx, isPtr)
+ case reflect.Interface:
+ return compileInterface(ctx)
+ case reflect.Int:
+ return compileInt(ctx)
+ case reflect.Int8:
+ return compileInt8(ctx)
+ case reflect.Int16:
+ return compileInt16(ctx)
+ case reflect.Int32:
+ return compileInt32(ctx)
+ case reflect.Int64:
+ return compileInt64(ctx)
+ case reflect.Uint:
+ return compileUint(ctx)
+ case reflect.Uint8:
+ return compileUint8(ctx)
+ case reflect.Uint16:
+ return compileUint16(ctx)
+ case reflect.Uint32:
+ return compileUint32(ctx)
+ case reflect.Uint64:
+ return compileUint64(ctx)
+ case reflect.Uintptr:
+ return compileUint(ctx)
+ case reflect.Float32:
+ return compileFloat32(ctx)
+ case reflect.Float64:
+ return compileFloat64(ctx)
+ case reflect.String:
+ return compileString(ctx)
+ case reflect.Bool:
+ return compileBool(ctx)
+ }
+ return nil, &errors.UnsupportedTypeError{Type: runtime.RType2Type(typ)}
+}
+
+func convertPtrOp(code *Opcode) OpType {
+ ptrHeadOp := code.Op.HeadToPtrHead()
+ if code.Op != ptrHeadOp {
+ if code.PtrNum > 0 {
+ // ptr field and ptr head
+ code.PtrNum--
+ }
+ return ptrHeadOp
+ }
+ switch code.Op {
+ case OpInt:
+ return OpIntPtr
+ case OpUint:
+ return OpUintPtr
+ case OpFloat32:
+ return OpFloat32Ptr
+ case OpFloat64:
+ return OpFloat64Ptr
+ case OpString:
+ return OpStringPtr
+ case OpBool:
+ return OpBoolPtr
+ case OpBytes:
+ return OpBytesPtr
+ case OpNumber:
+ return OpNumberPtr
+ case OpArray:
+ return OpArrayPtr
+ case OpSlice:
+ return OpSlicePtr
+ case OpMap:
+ return OpMapPtr
+ case OpMarshalJSON:
+ return OpMarshalJSONPtr
+ case OpMarshalText:
+ return OpMarshalTextPtr
+ case OpInterface:
+ return OpInterfacePtr
+ case OpRecursive:
+ return OpRecursivePtr
+ }
+ return code.Op
+}
+
+func compileKey(ctx *compileContext) (*Opcode, error) {
+ typ := ctx.typ
+ switch {
+ case implementsMarshalJSON(typ):
+ return compileMarshalJSON(ctx)
+ case implementsMarshalText(typ):
+ return compileMarshalText(ctx)
+ }
+ switch typ.Kind() {
+ case reflect.Ptr:
+ return compilePtr(ctx)
+ case reflect.String:
+ return compileString(ctx)
+ case reflect.Int:
+ return compileIntString(ctx)
+ case reflect.Int8:
+ return compileInt8String(ctx)
+ case reflect.Int16:
+ return compileInt16String(ctx)
+ case reflect.Int32:
+ return compileInt32String(ctx)
+ case reflect.Int64:
+ return compileInt64String(ctx)
+ case reflect.Uint:
+ return compileUintString(ctx)
+ case reflect.Uint8:
+ return compileUint8String(ctx)
+ case reflect.Uint16:
+ return compileUint16String(ctx)
+ case reflect.Uint32:
+ return compileUint32String(ctx)
+ case reflect.Uint64:
+ return compileUint64String(ctx)
+ case reflect.Uintptr:
+ return compileUintString(ctx)
+ }
+ return nil, &errors.UnsupportedTypeError{Type: runtime.RType2Type(typ)}
+}
+
+func compilePtr(ctx *compileContext) (*Opcode, error) {
+ code, err := compile(ctx.withType(ctx.typ.Elem()), true)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = convertPtrOp(code)
+ code.PtrNum++
+ return code, nil
+}
+
+func compileMarshalJSON(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpMarshalJSON)
+ typ := ctx.typ
+ if isPtrMarshalJSONType(typ) {
+ code.Flags |= AddrForMarshalerFlags
+ }
+ if typ.Implements(marshalJSONContextType) || runtime.PtrTo(typ).Implements(marshalJSONContextType) {
+ code.Flags |= MarshalerContextFlags
+ }
+ if isNilableType(typ) {
+ code.Flags |= IsNilableTypeFlags
+ } else {
+ code.Flags &= ^IsNilableTypeFlags
+ }
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileMarshalText(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpMarshalText)
+ typ := ctx.typ
+ if !typ.Implements(marshalTextType) && runtime.PtrTo(typ).Implements(marshalTextType) {
+ code.Flags |= AddrForMarshalerFlags
+ }
+ if isNilableType(typ) {
+ code.Flags |= IsNilableTypeFlags
+ } else {
+ code.Flags &= ^IsNilableTypeFlags
+ }
+ ctx.incIndex()
+ return code, nil
+}
+
+const intSize = 32 << (^uint(0) >> 63)
+
+func compileInt(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpInt)
+ code.NumBitSize = intSize
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileIntPtr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileInt(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpIntPtr
+ return code, nil
+}
+
+func compileInt8(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpInt)
+ code.NumBitSize = 8
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileInt8Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileInt8(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpIntPtr
+ return code, nil
+}
+
+func compileInt16(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpInt)
+ code.NumBitSize = 16
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileInt16Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileInt16(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpIntPtr
+ return code, nil
+}
+
+func compileInt32(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpInt)
+ code.NumBitSize = 32
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileInt32Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileInt32(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpIntPtr
+ return code, nil
+}
+
+func compileInt64(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpInt)
+ code.NumBitSize = 64
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileInt64Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileInt64(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpIntPtr
+ return code, nil
+}
+
+func compileUint(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUint)
+ code.NumBitSize = intSize
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUintPtr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileUint(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpUintPtr
+ return code, nil
+}
+
+func compileUint8(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUint)
+ code.NumBitSize = 8
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUint8Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileUint8(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpUintPtr
+ return code, nil
+}
+
+func compileUint16(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUint)
+ code.NumBitSize = 16
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUint16Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileUint16(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpUintPtr
+ return code, nil
+}
+
+func compileUint32(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUint)
+ code.NumBitSize = 32
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUint32Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileUint32(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpUintPtr
+ return code, nil
+}
+
+func compileUint64(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUint)
+ code.NumBitSize = 64
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUint64Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileUint64(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpUintPtr
+ return code, nil
+}
+
+func compileIntString(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpIntString)
+ code.NumBitSize = intSize
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileInt8String(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpIntString)
+ code.NumBitSize = 8
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileInt16String(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpIntString)
+ code.NumBitSize = 16
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileInt32String(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpIntString)
+ code.NumBitSize = 32
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileInt64String(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpIntString)
+ code.NumBitSize = 64
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUintString(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUintString)
+ code.NumBitSize = intSize
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUint8String(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUintString)
+ code.NumBitSize = 8
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUint16String(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUintString)
+ code.NumBitSize = 16
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUint32String(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUintString)
+ code.NumBitSize = 32
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileUint64String(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpUintString)
+ code.NumBitSize = 64
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileFloat32(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpFloat32)
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileFloat32Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileFloat32(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpFloat32Ptr
+ return code, nil
+}
+
+func compileFloat64(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpFloat64)
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileFloat64Ptr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileFloat64(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpFloat64Ptr
+ return code, nil
+}
+
+func compileString(ctx *compileContext) (*Opcode, error) {
+ var op OpType
+ if ctx.typ == runtime.Type2RType(jsonNumberType) {
+ op = OpNumber
+ } else {
+ op = OpString
+ }
+ code := newOpCode(ctx, op)
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileStringPtr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileString(ctx)
+ if err != nil {
+ return nil, err
+ }
+ if code.Op == OpNumber {
+ code.Op = OpNumberPtr
+ } else {
+ code.Op = OpStringPtr
+ }
+ return code, nil
+}
+
+func compileBool(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpBool)
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileBoolPtr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileBool(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpBoolPtr
+ return code, nil
+}
+
+func compileBytes(ctx *compileContext) (*Opcode, error) {
+ code := newOpCode(ctx, OpBytes)
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileBytesPtr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileBytes(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpBytesPtr
+ return code, nil
+}
+
+func compileInterface(ctx *compileContext) (*Opcode, error) {
+ code := newInterfaceCode(ctx)
+ ctx.incIndex()
+ return code, nil
+}
+
+func compileInterfacePtr(ctx *compileContext) (*Opcode, error) {
+ code, err := compileInterface(ctx)
+ if err != nil {
+ return nil, err
+ }
+ code.Op = OpInterfacePtr
+ return code, nil
+}
+
+func compileSlice(ctx *compileContext) (*Opcode, error) {
+ elem := ctx.typ.Elem()
+ size := elem.Size()
+
+ header := newSliceHeaderCode(ctx)
+ ctx.incIndex()
+
+ code, err := compileListElem(ctx.withType(elem).incIndent())
+ if err != nil {
+ return nil, err
+ }
+ code.Flags |= IndirectFlags
+
+ // header => opcode => elem => end
+ // ^ |
+ // |________|
+
+ elemCode := newSliceElemCode(ctx, header, size)
+ ctx.incIndex()
+
+ end := newOpCode(ctx, OpSliceEnd)
+ ctx.incIndex()
+
+ header.End = end
+ header.Next = code
+ code.BeforeLastCode().Next = (*Opcode)(unsafe.Pointer(elemCode))
+ elemCode.Next = code
+ elemCode.End = end
+ return (*Opcode)(unsafe.Pointer(header)), nil
+}
+
+func compileListElem(ctx *compileContext) (*Opcode, error) {
+ typ := ctx.typ
+ switch {
+ case isPtrMarshalJSONType(typ):
+ return compileMarshalJSON(ctx)
+ case !typ.Implements(marshalTextType) && runtime.PtrTo(typ).Implements(marshalTextType):
+ return compileMarshalText(ctx)
+ case typ.Kind() == reflect.Map:
+ return compilePtr(ctx.withType(runtime.PtrTo(typ)))
+ default:
+ code, err := compile(ctx, false)
+ if err != nil {
+ return nil, err
+ }
+ if code.Op == OpMapPtr {
+ code.PtrNum++
+ }
+ return code, nil
+ }
+}
+
+func compileArray(ctx *compileContext) (*Opcode, error) {
+ typ := ctx.typ
+ elem := typ.Elem()
+ alen := typ.Len()
+ size := elem.Size()
+
+ header := newArrayHeaderCode(ctx, alen)
+ ctx.incIndex()
+
+ code, err := compileListElem(ctx.withType(elem).incIndent())
+ if err != nil {
+ return nil, err
+ }
+ code.Flags |= IndirectFlags
+ // header => opcode => elem => end
+ // ^ |
+ // |________|
+
+ elemCode := newArrayElemCode(ctx, header, alen, size)
+ ctx.incIndex()
+
+ end := newOpCode(ctx, OpArrayEnd)
+ ctx.incIndex()
+
+ header.End = end
+ header.Next = code
+ code.BeforeLastCode().Next = (*Opcode)(unsafe.Pointer(elemCode))
+ elemCode.Next = code
+ elemCode.End = end
+ return (*Opcode)(unsafe.Pointer(header)), nil
+}
+
+func compileMap(ctx *compileContext) (*Opcode, error) {
+ // header => code => value => code => key => code => value => code => end
+ // ^ |
+ // |_______________________|
+ ctx = ctx.incIndent()
+ header := newMapHeaderCode(ctx)
+ ctx.incIndex()
+
+ typ := ctx.typ
+ keyType := ctx.typ.Key()
+ keyCode, err := compileKey(ctx.withType(keyType))
+ if err != nil {
+ return nil, err
+ }
+
+ value := newMapValueCode(ctx, header)
+ ctx.incIndex()
+
+ valueCode, err := compileMapValue(ctx.withType(typ.Elem()))
+ if err != nil {
+ return nil, err
+ }
+ valueCode.Flags |= IndirectFlags
+
+ key := newMapKeyCode(ctx, header)
+ ctx.incIndex()
+
+ ctx = ctx.decIndent()
+
+ end := newMapEndCode(ctx, header)
+ ctx.incIndex()
+
+ header.Next = keyCode
+ keyCode.BeforeLastCode().Next = (*Opcode)(unsafe.Pointer(value))
+ value.Next = valueCode
+ valueCode.BeforeLastCode().Next = (*Opcode)(unsafe.Pointer(key))
+ key.Next = keyCode
+
+ header.End = end
+ key.End = end
+ value.End = end
+
+ return (*Opcode)(unsafe.Pointer(header)), nil
+}
+
+func compileMapValue(ctx *compileContext) (*Opcode, error) {
+ switch ctx.typ.Kind() {
+ case reflect.Map:
+ return compilePtr(ctx.withType(runtime.PtrTo(ctx.typ)))
+ default:
+ code, err := compile(ctx, false)
+ if err != nil {
+ return nil, err
+ }
+ if code.Op == OpMapPtr {
+ code.PtrNum++
+ }
+ return code, nil
+ }
+}
+
+func optimizeStructHeader(code *Opcode, tag *runtime.StructTag) OpType {
+ headType := code.ToHeaderType(tag.IsString)
+ if tag.IsOmitEmpty {
+ headType = headType.HeadToOmitEmptyHead()
+ }
+ return headType
+}
+
+func optimizeStructField(code *Opcode, tag *runtime.StructTag) OpType {
+ fieldType := code.ToFieldType(tag.IsString)
+ if tag.IsOmitEmpty {
+ fieldType = fieldType.FieldToOmitEmptyField()
+ }
+ return fieldType
+}
+
+func recursiveCode(ctx *compileContext, jmp *CompiledCode) *Opcode {
+ code := newRecursiveCode(ctx, jmp)
+ ctx.incIndex()
+ return code
+}
+
+func compiledCode(ctx *compileContext) *Opcode {
+ typ := ctx.typ
+ typeptr := uintptr(unsafe.Pointer(typ))
+ if cc, exists := ctx.structTypeToCompiledCode[typeptr]; exists {
+ return recursiveCode(ctx, cc)
+ }
+ return nil
+}
+
+func structHeader(ctx *compileContext, fieldCode *Opcode, valueCode *Opcode, tag *runtime.StructTag) *Opcode {
+ op := optimizeStructHeader(valueCode, tag)
+ fieldCode.Op = op
+ fieldCode.NumBitSize = valueCode.NumBitSize
+ fieldCode.PtrNum = valueCode.PtrNum
+ if op.IsMultipleOpHead() {
+ return valueCode.BeforeLastCode()
+ }
+ ctx.decOpcodeIndex()
+ return fieldCode
+}
+
+func structField(ctx *compileContext, fieldCode *Opcode, valueCode *Opcode, tag *runtime.StructTag) *Opcode {
+ op := optimizeStructField(valueCode, tag)
+ fieldCode.Op = op
+ fieldCode.NumBitSize = valueCode.NumBitSize
+ fieldCode.PtrNum = valueCode.PtrNum
+ if op.IsMultipleOpField() {
+ return valueCode.BeforeLastCode()
+ }
+ ctx.decIndex()
+ return fieldCode
+}
+
+func isNotExistsField(head *Opcode) bool {
+ if head == nil {
+ return false
+ }
+ if head.Op != OpStructHead {
+ return false
+ }
+ if (head.Flags & AnonymousHeadFlags) == 0 {
+ return false
+ }
+ if head.Next == nil {
+ return false
+ }
+ if head.NextField == nil {
+ return false
+ }
+ if head.NextField.Op != OpStructAnonymousEnd {
+ return false
+ }
+ if head.Next.Op == OpStructAnonymousEnd {
return true
}
+ if head.Next.Op.CodeType() != CodeStructField {
+ return false
+ }
+ return isNotExistsField(head.Next)
+}
+
+func optimizeAnonymousFields(head *Opcode) {
+ code := head
+ var prev *Opcode
+ removedFields := map[*Opcode]struct{}{}
+ for {
+ if code.Op == OpStructEnd {
+ break
+ }
+ if code.Op == OpStructField {
+ codeType := code.Next.Op.CodeType()
+ if codeType == CodeStructField {
+ if isNotExistsField(code.Next) {
+ code.Next = code.NextField
+ diff := code.Next.DisplayIdx - code.DisplayIdx
+ for i := uint32(0); i < diff; i++ {
+ code.Next.decOpcodeIndex()
+ }
+ linkPrevToNextField(code, removedFields)
+ code = prev
+ }
+ }
+ }
+ prev = code
+ code = code.NextField
+ }
+}
+
+type structFieldPair struct {
+ prevField *Opcode
+ curField *Opcode
+ isTaggedKey bool
+ linked bool
+}
+
+func anonymousStructFieldPairMap(tags runtime.StructTags, named string, valueCode *Opcode) map[string][]structFieldPair {
+ anonymousFields := map[string][]structFieldPair{}
+ f := valueCode
+ var prevAnonymousField *Opcode
+ removedFields := map[*Opcode]struct{}{}
+ for {
+ existsKey := tags.ExistsKey(f.DisplayKey)
+ isHeadOp := strings.Contains(f.Op.String(), "Head")
+ if existsKey && f.Next != nil && strings.Contains(f.Next.Op.String(), "Recursive") {
+ // through
+ } else if isHeadOp && (f.Flags&AnonymousHeadFlags) == 0 {
+ if existsKey {
+ // TODO: need to remove this head
+ f.Op = OpStructHead
+ f.Flags |= AnonymousKeyFlags
+ f.Flags |= AnonymousHeadFlags
+ } else if named == "" {
+ f.Flags |= AnonymousHeadFlags
+ }
+ } else if named == "" && f.Op == OpStructEnd {
+ f.Op = OpStructAnonymousEnd
+ } else if existsKey {
+ diff := f.NextField.DisplayIdx - f.DisplayIdx
+ for i := uint32(0); i < diff; i++ {
+ f.NextField.decOpcodeIndex()
+ }
+ linkPrevToNextField(f, removedFields)
+ }
+
+ if f.DisplayKey == "" {
+ if f.NextField == nil {
+ break
+ }
+ prevAnonymousField = f
+ f = f.NextField
+ continue
+ }
+
+ key := fmt.Sprintf("%s.%s", named, f.DisplayKey)
+ anonymousFields[key] = append(anonymousFields[key], structFieldPair{
+ prevField: prevAnonymousField,
+ curField: f,
+ isTaggedKey: (f.Flags & IsTaggedKeyFlags) != 0,
+ })
+ if f.Next != nil && f.NextField != f.Next && f.Next.Op.CodeType() == CodeStructField {
+ for k, v := range anonymousFieldPairRecursively(named, f.Next) {
+ anonymousFields[k] = append(anonymousFields[k], v...)
+ }
+ }
+ if f.NextField == nil {
+ break
+ }
+ prevAnonymousField = f
+ f = f.NextField
+ }
+ return anonymousFields
+}
+
+func anonymousFieldPairRecursively(named string, valueCode *Opcode) map[string][]structFieldPair {
+ anonymousFields := map[string][]structFieldPair{}
+ f := valueCode
+ var prevAnonymousField *Opcode
+ for {
+ if f.DisplayKey != "" && (f.Flags&AnonymousHeadFlags) != 0 {
+ key := fmt.Sprintf("%s.%s", named, f.DisplayKey)
+ anonymousFields[key] = append(anonymousFields[key], structFieldPair{
+ prevField: prevAnonymousField,
+ curField: f,
+ isTaggedKey: (f.Flags & IsTaggedKeyFlags) != 0,
+ })
+ if f.Next != nil && f.NextField != f.Next && f.Next.Op.CodeType() == CodeStructField {
+ for k, v := range anonymousFieldPairRecursively(named, f.Next) {
+ anonymousFields[k] = append(anonymousFields[k], v...)
+ }
+ }
+ }
+ if f.NextField == nil {
+ break
+ }
+ prevAnonymousField = f
+ f = f.NextField
+ }
+ return anonymousFields
+}
+
+func optimizeConflictAnonymousFields(anonymousFields map[string][]structFieldPair) {
+ removedFields := map[*Opcode]struct{}{}
+ for _, fieldPairs := range anonymousFields {
+ if len(fieldPairs) == 1 {
+ continue
+ }
+ // conflict anonymous fields
+ taggedPairs := []structFieldPair{}
+ for _, fieldPair := range fieldPairs {
+ if fieldPair.isTaggedKey {
+ taggedPairs = append(taggedPairs, fieldPair)
+ } else {
+ if !fieldPair.linked {
+ if fieldPair.prevField == nil {
+ // head operation
+ fieldPair.curField.Op = OpStructHead
+ fieldPair.curField.Flags |= AnonymousHeadFlags
+ fieldPair.curField.Flags |= AnonymousKeyFlags
+ } else {
+ diff := fieldPair.curField.NextField.DisplayIdx - fieldPair.curField.DisplayIdx
+ for i := uint32(0); i < diff; i++ {
+ fieldPair.curField.NextField.decOpcodeIndex()
+ }
+ removedFields[fieldPair.curField] = struct{}{}
+ linkPrevToNextField(fieldPair.curField, removedFields)
+ }
+ fieldPair.linked = true
+ }
+ }
+ }
+ if len(taggedPairs) > 1 {
+ for _, fieldPair := range taggedPairs {
+ if !fieldPair.linked {
+ if fieldPair.prevField == nil {
+ // head operation
+ fieldPair.curField.Op = OpStructHead
+ fieldPair.curField.Flags |= AnonymousHeadFlags
+ fieldPair.curField.Flags |= AnonymousKeyFlags
+ } else {
+ diff := fieldPair.curField.NextField.DisplayIdx - fieldPair.curField.DisplayIdx
+ removedFields[fieldPair.curField] = struct{}{}
+ for i := uint32(0); i < diff; i++ {
+ fieldPair.curField.NextField.decOpcodeIndex()
+ }
+ linkPrevToNextField(fieldPair.curField, removedFields)
+ }
+ fieldPair.linked = true
+ }
+ }
+ } else {
+ for _, fieldPair := range taggedPairs {
+ fieldPair.curField.Flags &= ^IsTaggedKeyFlags
+ }
+ }
+ }
+}
+
+func isNilableType(typ *runtime.Type) bool {
switch typ.Kind() {
case reflect.Ptr:
return true
@@ -880,60 +1319,252 @@ func (c *Compiler) isNilableType(typ *runtime.Type) bool {
}
}
-func (c *Compiler) implementsMarshalJSONType(typ *runtime.Type) bool {
+func compileStruct(ctx *compileContext, isPtr bool) (*Opcode, error) {
+ if code := compiledCode(ctx); code != nil {
+ return code, nil
+ }
+ typ := ctx.typ
+ typeptr := uintptr(unsafe.Pointer(typ))
+ compiled := &CompiledCode{}
+ ctx.structTypeToCompiledCode[typeptr] = compiled
+ // header => code => structField => code => end
+ // ^ |
+ // |__________|
+ fieldNum := typ.NumField()
+ indirect := runtime.IfaceIndir(typ)
+ fieldIdx := 0
+ disableIndirectConversion := false
+ var (
+ head *Opcode
+ code *Opcode
+ prevField *Opcode
+ )
+ ctx = ctx.incIndent()
+ tags := runtime.StructTags{}
+ anonymousFields := map[string][]structFieldPair{}
+ for i := 0; i < fieldNum; i++ {
+ field := typ.Field(i)
+ if runtime.IsIgnoredStructField(field) {
+ continue
+ }
+ tags = append(tags, runtime.StructTagFromField(field))
+ }
+ for i, tag := range tags {
+ field := tag.Field
+ fieldType := runtime.Type2RType(field.Type)
+ fieldOpcodeIndex := ctx.opcodeIndex
+ fieldPtrIndex := ctx.ptrIndex
+ ctx.incIndex()
+
+ nilcheck := true
+ addrForMarshaler := false
+ isIndirectSpecialCase := isPtr && i == 0 && fieldNum == 1
+ isNilableType := isNilableType(fieldType)
+
+ var valueCode *Opcode
+ switch {
+ case isIndirectSpecialCase && !isNilableType && isPtrMarshalJSONType(fieldType):
+ // *struct{ field T } => struct { field *T }
+ // func (*T) MarshalJSON() ([]byte, error)
+ // move pointer position from head to first field
+ code, err := compileMarshalJSON(ctx.withType(fieldType))
+ if err != nil {
+ return nil, err
+ }
+ addrForMarshaler = true
+ valueCode = code
+ nilcheck = false
+ indirect = false
+ disableIndirectConversion = true
+ case isIndirectSpecialCase && !isNilableType && isPtrMarshalTextType(fieldType):
+ // *struct{ field T } => struct { field *T }
+ // func (*T) MarshalText() ([]byte, error)
+ // move pointer position from head to first field
+ code, err := compileMarshalText(ctx.withType(fieldType))
+ if err != nil {
+ return nil, err
+ }
+ addrForMarshaler = true
+ valueCode = code
+ nilcheck = false
+ indirect = false
+ disableIndirectConversion = true
+ case isPtr && isPtrMarshalJSONType(fieldType):
+ // *struct{ field T }
+ // func (*T) MarshalJSON() ([]byte, error)
+ code, err := compileMarshalJSON(ctx.withType(fieldType))
+ if err != nil {
+ return nil, err
+ }
+ addrForMarshaler = true
+ nilcheck = false
+ valueCode = code
+ case isPtr && isPtrMarshalTextType(fieldType):
+ // *struct{ field T }
+ // func (*T) MarshalText() ([]byte, error)
+ code, err := compileMarshalText(ctx.withType(fieldType))
+ if err != nil {
+ return nil, err
+ }
+ addrForMarshaler = true
+ nilcheck = false
+ valueCode = code
+ default:
+ code, err := compile(ctx.withType(fieldType), isPtr)
+ if err != nil {
+ return nil, err
+ }
+ valueCode = code
+ }
+
+ if field.Anonymous && !tag.IsTaggedKey {
+ tagKey := ""
+ if tag.IsTaggedKey {
+ tagKey = tag.Key
+ }
+ for k, v := range anonymousStructFieldPairMap(tags, tagKey, valueCode) {
+ anonymousFields[k] = append(anonymousFields[k], v...)
+ }
+
+ valueCode.decIndent()
+
+ // fix issue144
+ if !(isPtr && strings.Contains(valueCode.Op.String(), "Marshal")) {
+ if indirect {
+ valueCode.Flags |= IndirectFlags
+ } else {
+ valueCode.Flags &= ^IndirectFlags
+ }
+ }
+ } else {
+ if indirect {
+ // if parent is indirect type, set child indirect property to true
+ valueCode.Flags |= IndirectFlags
+ } else {
+ // if parent is not indirect type, set child indirect property to false.
+ // but if parent's indirect is false and isPtr is true, then indirect must be true.
+ // Do this only if indirectConversion is enabled at the end of compileStruct.
+ if i == 0 {
+ valueCode.Flags &= ^IndirectFlags
+ }
+ }
+ }
+ var flags OpFlags
+ if indirect {
+ flags |= IndirectFlags
+ }
+ if field.Anonymous {
+ flags |= AnonymousKeyFlags
+ }
+ if tag.IsTaggedKey {
+ flags |= IsTaggedKeyFlags
+ }
+ if nilcheck {
+ flags |= NilCheckFlags
+ }
+ if addrForMarshaler {
+ flags |= AddrForMarshalerFlags
+ }
+ if strings.Contains(valueCode.Op.String(), "Ptr") || valueCode.Op == OpInterface {
+ flags |= IsNextOpPtrTypeFlags
+ }
+ if isNilableType {
+ flags |= IsNilableTypeFlags
+ }
+ var key string
+ if ctx.escapeKey {
+ rctx := &RuntimeContext{Option: &Option{Flag: HTMLEscapeOption}}
+ key = fmt.Sprintf(`%s:`, string(AppendString(rctx, []byte{}, tag.Key)))
+ } else {
+ key = fmt.Sprintf(`"%s":`, tag.Key)
+ }
+ fieldCode := &Opcode{
+ Idx: opcodeOffset(fieldPtrIndex),
+ Next: valueCode,
+ Flags: flags,
+ Key: key,
+ Offset: uint32(field.Offset),
+ Type: valueCode.Type,
+ DisplayIdx: fieldOpcodeIndex,
+ Indent: ctx.indent,
+ DisplayKey: tag.Key,
+ }
+ if fieldIdx == 0 {
+ code = structHeader(ctx, fieldCode, valueCode, tag)
+ head = fieldCode
+ prevField = fieldCode
+ } else {
+ fieldCode.Idx = head.Idx
+ code.Next = fieldCode
+ code = structField(ctx, fieldCode, valueCode, tag)
+ prevField.NextField = fieldCode
+ fieldCode.PrevField = prevField
+ prevField = fieldCode
+ }
+ fieldIdx++
+ }
+
+ structEndCode := &Opcode{
+ Op: OpStructEnd,
+ Type: nil,
+ Indent: ctx.indent,
+ }
+
+ ctx = ctx.decIndent()
+
+ // no struct field
+ if head == nil {
+ head = &Opcode{
+ Op: OpStructHead,
+ Idx: opcodeOffset(ctx.ptrIndex),
+ NextField: structEndCode,
+ Type: typ,
+ DisplayIdx: ctx.opcodeIndex,
+ Indent: ctx.indent,
+ }
+ structEndCode.PrevField = head
+ ctx.incIndex()
+ code = head
+ }
+
+ structEndCode.DisplayIdx = ctx.opcodeIndex
+ structEndCode.Idx = opcodeOffset(ctx.ptrIndex)
+ ctx.incIndex()
+ structEndCode.Next = newEndOp(ctx)
+
+ if prevField != nil && prevField.NextField == nil {
+ prevField.NextField = structEndCode
+ structEndCode.PrevField = prevField
+ }
+
+ head.End = structEndCode
+ code.Next = structEndCode
+ optimizeConflictAnonymousFields(anonymousFields)
+ optimizeAnonymousFields(head)
+ ret := (*Opcode)(unsafe.Pointer(head))
+ compiled.Code = ret
+
+ delete(ctx.structTypeToCompiledCode, typeptr)
+
+ if !disableIndirectConversion && (head.Flags&IndirectFlags == 0) && isPtr {
+ headCode := head
+ for strings.Contains(headCode.Op.String(), "Head") {
+ headCode.Flags |= IndirectFlags
+ headCode = headCode.Next
+ }
+ }
+
+ return ret, nil
+}
+
+func implementsMarshalJSONType(typ *runtime.Type) bool {
return typ.Implements(marshalJSONType) || typ.Implements(marshalJSONContextType)
}
-func (c *Compiler) isPtrMarshalJSONType(typ *runtime.Type) bool {
- return !c.implementsMarshalJSONType(typ) && c.implementsMarshalJSONType(runtime.PtrTo(typ))
+func isPtrMarshalJSONType(typ *runtime.Type) bool {
+ return !implementsMarshalJSONType(typ) && implementsMarshalJSONType(runtime.PtrTo(typ))
}
-func (c *Compiler) isPtrMarshalTextType(typ *runtime.Type) bool {
+func isPtrMarshalTextType(typ *runtime.Type) bool {
return !typ.Implements(marshalTextType) && runtime.PtrTo(typ).Implements(marshalTextType)
}
-
-func (c *Compiler) codeToOpcode(ctx *compileContext, typ *runtime.Type, code Code) *Opcode {
- codes := code.ToOpcode(ctx)
- codes.Last().Next = newEndOp(ctx, typ)
- c.linkRecursiveCode(ctx)
- return codes.First()
-}
-
-func (c *Compiler) linkRecursiveCode(ctx *compileContext) {
- recursiveCodes := map[uintptr]*CompiledCode{}
- for _, recursive := range *ctx.recursiveCodes {
- typeptr := uintptr(unsafe.Pointer(recursive.Type))
- codes := ctx.structTypeToCodes[typeptr]
- if recursiveCode, ok := recursiveCodes[typeptr]; ok {
- *recursive.Jmp = *recursiveCode
- continue
- }
-
- code := copyOpcode(codes.First())
- code.Op = code.Op.PtrHeadToHead()
- lastCode := newEndOp(&compileContext{}, recursive.Type)
- lastCode.Op = OpRecursiveEnd
-
- // OpRecursiveEnd must set before call TotalLength
- code.End.Next = lastCode
-
- totalLength := code.TotalLength()
-
- // Idx, ElemIdx, Length must set after call TotalLength
- lastCode.Idx = uint32((totalLength + 1) * uintptrSize)
- lastCode.ElemIdx = lastCode.Idx + uintptrSize
- lastCode.Length = lastCode.Idx + 2*uintptrSize
-
- // extend length to alloc slot for elemIdx + length
- curTotalLength := uintptr(recursive.TotalLength()) + 3
- nextTotalLength := uintptr(totalLength) + 3
-
- compiled := recursive.Jmp
- compiled.Code = code
- compiled.CurLen = curTotalLength
- compiled.NextLen = nextTotalLength
- compiled.Linked = true
-
- recursiveCodes[typeptr] = compiled
- }
-}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go b/vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go
index b6f45a4..9d337f1 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go
@@ -1,33 +1,56 @@
-//go:build !race
// +build !race
package encoder
-func CompileToGetCodeSet(ctx *RuntimeContext, typeptr uintptr) (*OpcodeSet, error) {
- initEncoder()
- if typeptr > typeAddr.MaxTypeAddr || typeptr < typeAddr.BaseTypeAddr {
- codeSet, err := compileToGetCodeSetSlowPath(typeptr)
- if err != nil {
- return nil, err
- }
- return getFilteredCodeSetIfNeeded(ctx, codeSet)
+import (
+ "unsafe"
+
+ "github.com/goccy/go-json/internal/runtime"
+)
+
+func CompileToGetCodeSet(typeptr uintptr) (*OpcodeSet, error) {
+ if typeptr > typeAddr.MaxTypeAddr {
+ return compileToGetCodeSetSlowPath(typeptr)
}
index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift
if codeSet := cachedOpcodeSets[index]; codeSet != nil {
- filtered, err := getFilteredCodeSetIfNeeded(ctx, codeSet)
- if err != nil {
- return nil, err
- }
- return filtered, nil
+ return codeSet, nil
}
- codeSet, err := newCompiler().compile(typeptr)
+
+ // noescape trick for header.typ ( reflect.*rtype )
+ copiedType := *(**runtime.Type)(unsafe.Pointer(&typeptr))
+
+ noescapeKeyCode, err := compileHead(&compileContext{
+ typ: copiedType,
+ structTypeToCompiledCode: map[uintptr]*CompiledCode{},
+ })
if err != nil {
return nil, err
}
- filtered, err := getFilteredCodeSetIfNeeded(ctx, codeSet)
+ escapeKeyCode, err := compileHead(&compileContext{
+ typ: copiedType,
+ structTypeToCompiledCode: map[uintptr]*CompiledCode{},
+ escapeKey: true,
+ })
if err != nil {
return nil, err
}
+ noescapeKeyCode = copyOpcode(noescapeKeyCode)
+ escapeKeyCode = copyOpcode(escapeKeyCode)
+ setTotalLengthToInterfaceOp(noescapeKeyCode)
+ setTotalLengthToInterfaceOp(escapeKeyCode)
+ interfaceNoescapeKeyCode := copyToInterfaceOpcode(noescapeKeyCode)
+ interfaceEscapeKeyCode := copyToInterfaceOpcode(escapeKeyCode)
+ codeLength := noescapeKeyCode.TotalLength()
+ codeSet := &OpcodeSet{
+ Type: copiedType,
+ NoescapeKeyCode: noescapeKeyCode,
+ EscapeKeyCode: escapeKeyCode,
+ InterfaceNoescapeKeyCode: interfaceNoescapeKeyCode,
+ InterfaceEscapeKeyCode: interfaceEscapeKeyCode,
+ CodeLength: codeLength,
+ EndCode: ToEndCode(interfaceNoescapeKeyCode),
+ }
cachedOpcodeSets[index] = codeSet
- return filtered, nil
+ return codeSet, nil
}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go b/vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go
index 47b482f..3a239e9 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go
@@ -1,46 +1,65 @@
-//go:build race
// +build race
package encoder
import (
"sync"
+ "unsafe"
+
+ "github.com/goccy/go-json/internal/runtime"
)
var setsMu sync.RWMutex
-func CompileToGetCodeSet(ctx *RuntimeContext, typeptr uintptr) (*OpcodeSet, error) {
- initEncoder()
- if typeptr > typeAddr.MaxTypeAddr || typeptr < typeAddr.BaseTypeAddr {
- codeSet, err := compileToGetCodeSetSlowPath(typeptr)
- if err != nil {
- return nil, err
- }
- return getFilteredCodeSetIfNeeded(ctx, codeSet)
+func CompileToGetCodeSet(typeptr uintptr) (*OpcodeSet, error) {
+ if typeptr > typeAddr.MaxTypeAddr {
+ return compileToGetCodeSetSlowPath(typeptr)
}
index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift
setsMu.RLock()
if codeSet := cachedOpcodeSets[index]; codeSet != nil {
- filtered, err := getFilteredCodeSetIfNeeded(ctx, codeSet)
- if err != nil {
- setsMu.RUnlock()
- return nil, err
- }
setsMu.RUnlock()
- return filtered, nil
+ return codeSet, nil
}
setsMu.RUnlock()
- codeSet, err := newCompiler().compile(typeptr)
+ // noescape trick for header.typ ( reflect.*rtype )
+ copiedType := *(**runtime.Type)(unsafe.Pointer(&typeptr))
+
+ noescapeKeyCode, err := compileHead(&compileContext{
+ typ: copiedType,
+ structTypeToCompiledCode: map[uintptr]*CompiledCode{},
+ })
if err != nil {
return nil, err
}
- filtered, err := getFilteredCodeSetIfNeeded(ctx, codeSet)
+ escapeKeyCode, err := compileHead(&compileContext{
+ typ: copiedType,
+ structTypeToCompiledCode: map[uintptr]*CompiledCode{},
+ escapeKey: true,
+ })
if err != nil {
return nil, err
}
+
+ noescapeKeyCode = copyOpcode(noescapeKeyCode)
+ escapeKeyCode = copyOpcode(escapeKeyCode)
+ setTotalLengthToInterfaceOp(noescapeKeyCode)
+ setTotalLengthToInterfaceOp(escapeKeyCode)
+ interfaceNoescapeKeyCode := copyToInterfaceOpcode(noescapeKeyCode)
+ interfaceEscapeKeyCode := copyToInterfaceOpcode(escapeKeyCode)
+ codeLength := noescapeKeyCode.TotalLength()
+ codeSet := &OpcodeSet{
+ Type: copiedType,
+ NoescapeKeyCode: noescapeKeyCode,
+ EscapeKeyCode: escapeKeyCode,
+ InterfaceNoescapeKeyCode: interfaceNoescapeKeyCode,
+ InterfaceEscapeKeyCode: interfaceEscapeKeyCode,
+ CodeLength: codeLength,
+ EndCode: ToEndCode(interfaceNoescapeKeyCode),
+ }
setsMu.Lock()
cachedOpcodeSets[index] = codeSet
setsMu.Unlock()
- return filtered, nil
+ return codeSet, nil
}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/context.go b/vendor/github.com/goccy/go-json/internal/encoder/context.go
index 3833d0c..61b8908 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/context.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/context.go
@@ -9,20 +9,44 @@ import (
)
type compileContext struct {
- opcodeIndex uint32
- ptrIndex int
- indent uint32
- escapeKey bool
- structTypeToCodes map[uintptr]Opcodes
- recursiveCodes *Opcodes
+ typ *runtime.Type
+ opcodeIndex uint32
+ ptrIndex int
+ indent uint32
+ escapeKey bool
+ structTypeToCompiledCode map[uintptr]*CompiledCode
+
+ parent *compileContext
}
-func (c *compileContext) incIndent() {
- c.indent++
+func (c *compileContext) context() *compileContext {
+ return &compileContext{
+ typ: c.typ,
+ opcodeIndex: c.opcodeIndex,
+ ptrIndex: c.ptrIndex,
+ indent: c.indent,
+ escapeKey: c.escapeKey,
+ structTypeToCompiledCode: c.structTypeToCompiledCode,
+ parent: c,
+ }
}
-func (c *compileContext) decIndent() {
- c.indent--
+func (c *compileContext) withType(typ *runtime.Type) *compileContext {
+ ctx := c.context()
+ ctx.typ = typ
+ return ctx
+}
+
+func (c *compileContext) incIndent() *compileContext {
+ ctx := c.context()
+ ctx.indent++
+ return ctx
+}
+
+func (c *compileContext) decIndent() *compileContext {
+ ctx := c.context()
+ ctx.indent--
+ return ctx
}
func (c *compileContext) incIndex() {
@@ -37,18 +61,30 @@ func (c *compileContext) decIndex() {
func (c *compileContext) incOpcodeIndex() {
c.opcodeIndex++
+ if c.parent != nil {
+ c.parent.incOpcodeIndex()
+ }
}
func (c *compileContext) decOpcodeIndex() {
c.opcodeIndex--
+ if c.parent != nil {
+ c.parent.decOpcodeIndex()
+ }
}
func (c *compileContext) incPtrIndex() {
c.ptrIndex++
+ if c.parent != nil {
+ c.parent.incPtrIndex()
+ }
}
func (c *compileContext) decPtrIndex() {
c.ptrIndex--
+ if c.parent != nil {
+ c.parent.decPtrIndex()
+ }
}
const (
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/decode_rune.go b/vendor/github.com/goccy/go-json/internal/encoder/decode_rune.go
deleted file mode 100644
index 35c959d..0000000
--- a/vendor/github.com/goccy/go-json/internal/encoder/decode_rune.go
+++ /dev/null
@@ -1,126 +0,0 @@
-package encoder
-
-import "unicode/utf8"
-
-const (
- // The default lowest and highest continuation byte.
- locb = 128 //0b10000000
- hicb = 191 //0b10111111
-
- // These names of these constants are chosen to give nice alignment in the
- // table below. The first nibble is an index into acceptRanges or F for
- // special one-byte cases. The second nibble is the Rune length or the
- // Status for the special one-byte case.
- xx = 0xF1 // invalid: size 1
- as = 0xF0 // ASCII: size 1
- s1 = 0x02 // accept 0, size 2
- s2 = 0x13 // accept 1, size 3
- s3 = 0x03 // accept 0, size 3
- s4 = 0x23 // accept 2, size 3
- s5 = 0x34 // accept 3, size 4
- s6 = 0x04 // accept 0, size 4
- s7 = 0x44 // accept 4, size 4
-)
-
-// first is information about the first byte in a UTF-8 sequence.
-var first = [256]uint8{
- // 1 2 3 4 5 6 7 8 9 A B C D E F
- as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x00-0x0F
- as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x10-0x1F
- as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x20-0x2F
- as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x30-0x3F
- as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x40-0x4F
- as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x50-0x5F
- as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x60-0x6F
- as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, // 0x70-0x7F
- // 1 2 3 4 5 6 7 8 9 A B C D E F
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0x80-0x8F
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0x90-0x9F
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0xA0-0xAF
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0xB0-0xBF
- xx, xx, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, // 0xC0-0xCF
- s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, // 0xD0-0xDF
- s2, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s4, s3, s3, // 0xE0-0xEF
- s5, s6, s6, s6, s7, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, // 0xF0-0xFF
-}
-
-const (
- lineSep = byte(168) //'\u2028'
- paragraphSep = byte(169) //'\u2029'
-)
-
-type decodeRuneState int
-
-const (
- validUTF8State decodeRuneState = iota
- runeErrorState
- lineSepState
- paragraphSepState
-)
-
-func decodeRuneInString(s string) (decodeRuneState, int) {
- n := len(s)
- s0 := s[0]
- x := first[s0]
- if x >= as {
- // The following code simulates an additional check for x == xx and
- // handling the ASCII and invalid cases accordingly. This mask-and-or
- // approach prevents an additional branch.
- mask := rune(x) << 31 >> 31 // Create 0x0000 or 0xFFFF.
- if rune(s[0])&^mask|utf8.RuneError&mask == utf8.RuneError {
- return runeErrorState, 1
- }
- return validUTF8State, 1
- }
- sz := int(x & 7)
- if n < sz {
- return runeErrorState, 1
- }
- s1 := s[1]
- switch x >> 4 {
- case 0:
- if s1 < locb || hicb < s1 {
- return runeErrorState, 1
- }
- case 1:
- if s1 < 0xA0 || hicb < s1 {
- return runeErrorState, 1
- }
- case 2:
- if s1 < locb || 0x9F < s1 {
- return runeErrorState, 1
- }
- case 3:
- if s1 < 0x90 || hicb < s1 {
- return runeErrorState, 1
- }
- case 4:
- if s1 < locb || 0x8F < s1 {
- return runeErrorState, 1
- }
- }
- if sz <= 2 {
- return validUTF8State, 2
- }
- s2 := s[2]
- if s2 < locb || hicb < s2 {
- return runeErrorState, 1
- }
- if sz <= 3 {
- // separator character prefixes: [2]byte{226, 128}
- if s0 == 226 && s1 == 128 {
- switch s2 {
- case lineSep:
- return lineSepState, 3
- case paragraphSep:
- return paragraphSepState, 3
- }
- }
- return validUTF8State, 3
- }
- s3 := s[3]
- if s3 < locb || hicb < s3 {
- return runeErrorState, 1
- }
- return validUTF8State, 4
-}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/encoder.go b/vendor/github.com/goccy/go-json/internal/encoder/encoder.go
index b436f5b..b7fa99a 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/encoder.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/encoder.go
@@ -101,22 +101,6 @@ type OpcodeSet struct {
InterfaceEscapeKeyCode *Opcode
CodeLength int
EndCode *Opcode
- Code Code
- QueryCache map[string]*OpcodeSet
- cacheMu sync.RWMutex
-}
-
-func (s *OpcodeSet) getQueryCache(hash string) *OpcodeSet {
- s.cacheMu.RLock()
- codeSet := s.QueryCache[hash]
- s.cacheMu.RUnlock()
- return codeSet
-}
-
-func (s *OpcodeSet) setQueryCache(hash string, codeSet *OpcodeSet) {
- s.cacheMu.Lock()
- s.QueryCache[hash] = codeSet
- s.cacheMu.Unlock()
}
type CompiledCode struct {
@@ -238,56 +222,33 @@ func (m *Mapslice) Swap(i, j int) {
m.Items[i], m.Items[j] = m.Items[j], m.Items[i]
}
-//nolint:structcheck,unused
-type mapIter struct {
- key unsafe.Pointer
- elem unsafe.Pointer
- t unsafe.Pointer
- h unsafe.Pointer
- buckets unsafe.Pointer
- bptr unsafe.Pointer
- overflow unsafe.Pointer
- oldoverflow unsafe.Pointer
- startBucket uintptr
- offset uint8
- wrapped bool
- B uint8
- i uint8
- bucket uintptr
- checkBucket uintptr
-}
-
type MapContext struct {
- Start int
- First int
- Idx int
+ Pos []int
Slice *Mapslice
Buf []byte
- Len int
- Iter mapIter
}
var mapContextPool = sync.Pool{
New: func() interface{} {
- return &MapContext{
- Slice: &Mapslice{},
- }
+ return &MapContext{}
},
}
-func NewMapContext(mapLen int, unorderedMap bool) *MapContext {
+func NewMapContext(mapLen int) *MapContext {
ctx := mapContextPool.Get().(*MapContext)
- if !unorderedMap {
- if len(ctx.Slice.Items) < mapLen {
- ctx.Slice.Items = make([]MapItem, mapLen)
- } else {
- ctx.Slice.Items = ctx.Slice.Items[:mapLen]
+ if ctx.Slice == nil {
+ ctx.Slice = &Mapslice{
+ Items: make([]MapItem, 0, mapLen),
}
}
+ if cap(ctx.Pos) < (mapLen*2 + 1) {
+ ctx.Pos = make([]int, 0, mapLen*2+1)
+ ctx.Slice.Items = make([]MapItem, 0, mapLen)
+ } else {
+ ctx.Pos = ctx.Pos[:0]
+ ctx.Slice.Items = ctx.Slice.Items[:0]
+ }
ctx.Buf = ctx.Buf[:0]
- ctx.Iter = mapIter{}
- ctx.Idx = 0
- ctx.Len = mapLen
return ctx
}
@@ -295,17 +256,17 @@ func ReleaseMapContext(c *MapContext) {
mapContextPool.Put(c)
}
-//go:linkname MapIterInit runtime.mapiterinit
+//go:linkname MapIterInit reflect.mapiterinit
//go:noescape
-func MapIterInit(mapType *runtime.Type, m unsafe.Pointer, it *mapIter)
+func MapIterInit(mapType *runtime.Type, m unsafe.Pointer) unsafe.Pointer
//go:linkname MapIterKey reflect.mapiterkey
//go:noescape
-func MapIterKey(it *mapIter) unsafe.Pointer
+func MapIterKey(it unsafe.Pointer) unsafe.Pointer
//go:linkname MapIterNext reflect.mapiternext
//go:noescape
-func MapIterNext(it *mapIter)
+func MapIterNext(it unsafe.Pointer)
//go:linkname MapLen reflect.maplen
//go:noescape
@@ -406,11 +367,6 @@ func AppendMarshalJSON(ctx *RuntimeContext, code *Opcode, b []byte, v interface{
rv = newV
}
}
-
- if rv.Kind() == reflect.Ptr && rv.IsNil() {
- return AppendNull(ctx, b), nil
- }
-
v = rv.Interface()
var bb []byte
if (code.Flags & MarshalerContextFlags) != 0 {
@@ -418,11 +374,7 @@ func AppendMarshalJSON(ctx *RuntimeContext, code *Opcode, b []byte, v interface{
if !ok {
return AppendNull(ctx, b), nil
}
- stdctx := ctx.Option.Context
- if ctx.Option.Flag&FieldQueryOption != 0 {
- stdctx = SetFieldQueryToContext(stdctx, code.FieldQuery)
- }
- b, err := marshaler.MarshalJSON(stdctx)
+ b, err := marshaler.MarshalJSON(ctx.Option.Context)
if err != nil {
return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err}
}
@@ -594,8 +546,6 @@ func IsNilForMarshaler(v interface{}) bool {
return rv.IsNil()
case reflect.Slice:
return rv.IsNil() || rv.Len() == 0
- case reflect.String:
- return rv.Len() == 0
}
return false
}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/int.go b/vendor/github.com/goccy/go-json/internal/encoder/int.go
index 8b5febe..3a3482d 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/int.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/int.go
@@ -1,27 +1,3 @@
-// This files's processing codes are inspired by https://github.com/segmentio/encoding.
-// The license notation is as follows.
-//
-// # MIT License
-//
-// Copyright (c) 2019 Segment.io, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
package encoder
import (
@@ -77,18 +53,7 @@ func numMask(numBitSize uint8) uint64 {
return 1<>(code.NumBitSize-1))&1 == 1
@@ -131,18 +96,7 @@ func AppendInt(_ *RuntimeContext, out []byte, p uintptr, code *Opcode) []byte {
return append(out, b[i:]...)
}
-func AppendUint(_ *RuntimeContext, out []byte, p uintptr, code *Opcode) []byte {
- var u64 uint64
- switch code.NumBitSize {
- case 8:
- u64 = (uint64)(**(**uint8)(unsafe.Pointer(&p)))
- case 16:
- u64 = (uint64)(**(**uint16)(unsafe.Pointer(&p)))
- case 32:
- u64 = (uint64)(**(**uint32)(unsafe.Pointer(&p)))
- case 64:
- u64 = **(**uint64)(unsafe.Pointer(&p))
- }
+func AppendUint(_ *RuntimeContext, out []byte, u64 uint64, code *Opcode) []byte {
mask := numMask(code.NumBitSize)
n := u64 & mask
if n < 10 {
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/map112.go b/vendor/github.com/goccy/go-json/internal/encoder/map112.go
index e96ffad..31858d0 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/map112.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/map112.go
@@ -1,4 +1,3 @@
-//go:build !go1.13
// +build !go1.13
package encoder
@@ -6,4 +5,4 @@ package encoder
import "unsafe"
//go:linkname MapIterValue reflect.mapitervalue
-func MapIterValue(it *mapIter) unsafe.Pointer
+func MapIterValue(it unsafe.Pointer) unsafe.Pointer
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/map113.go b/vendor/github.com/goccy/go-json/internal/encoder/map113.go
index 9b69dcc..f49c27b 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/map113.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/map113.go
@@ -1,4 +1,3 @@
-//go:build go1.13
// +build go1.13
package encoder
@@ -6,4 +5,4 @@ package encoder
import "unsafe"
//go:linkname MapIterValue reflect.mapiterelem
-func MapIterValue(it *mapIter) unsafe.Pointer
+func MapIterValue(it unsafe.Pointer) unsafe.Pointer
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/opcode.go b/vendor/github.com/goccy/go-json/internal/encoder/opcode.go
index df22f55..7c50eef 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/opcode.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/opcode.go
@@ -1,9 +1,7 @@
package encoder
import (
- "bytes"
"fmt"
- "sort"
"strings"
"unsafe"
@@ -40,58 +38,26 @@ type Opcode struct {
Flags OpFlags
Type *runtime.Type // go type
+ PrevField *Opcode // prev struct field
Jmp *CompiledCode // for recursive call
- FieldQuery *FieldQuery // field query for Interface / MarshalJSON / MarshalText
- ElemIdx uint32 // offset to access array/slice elem
- Length uint32 // offset to access slice length or array length
+ ElemIdx uint32 // offset to access array/slice/map elem
+ Length uint32 // offset to access slice/map length or array length
+ MapIter uint32 // offset to access map iterator
+ MapPos uint32 // offset to access position list for sorted map
Indent uint32 // indent number
Size uint32 // array/slice elem size
DisplayIdx uint32 // opcode index
DisplayKey string // key text to display
}
-func (c *Opcode) Validate() error {
- var prevIdx uint32
- for code := c; !code.IsEnd(); {
- if prevIdx != 0 {
- if code.DisplayIdx != prevIdx+1 {
- return fmt.Errorf(
- "invalid index. previous display index is %d but next is %d. dump = %s",
- prevIdx, code.DisplayIdx, c.Dump(),
- )
- }
- }
- prevIdx = code.DisplayIdx
- code = code.IterNext()
- }
- return nil
-}
-
-func (c *Opcode) IterNext() *Opcode {
- if c == nil {
- return nil
- }
- switch c.Op.CodeType() {
- case CodeArrayElem, CodeSliceElem, CodeMapKey:
- return c.End
- default:
- return c.Next
- }
-}
-
-func (c *Opcode) IsEnd() bool {
- if c == nil {
- return true
- }
- return c.Op == OpEnd || c.Op == OpInterfaceEnd || c.Op == OpRecursiveEnd
-}
-
func (c *Opcode) MaxIdx() uint32 {
max := uint32(0)
for _, value := range []uint32{
c.Idx,
c.ElemIdx,
c.Length,
+ c.MapIter,
+ c.MapPos,
c.Size,
} {
if max < value {
@@ -307,75 +273,43 @@ func (c *Opcode) ToFieldType(isString bool) OpType {
return OpStructField
}
-func newOpCode(ctx *compileContext, typ *runtime.Type, op OpType) *Opcode {
- return newOpCodeWithNext(ctx, typ, op, newEndOp(ctx, typ))
+func newOpCode(ctx *compileContext, op OpType) *Opcode {
+ return newOpCodeWithNext(ctx, op, newEndOp(ctx))
}
func opcodeOffset(idx int) uint32 {
return uint32(idx) * uintptrSize
}
-func getCodeAddrByIdx(head *Opcode, idx uint32) *Opcode {
- addr := uintptr(unsafe.Pointer(head)) + uintptr(idx)*unsafe.Sizeof(Opcode{})
- return *(**Opcode)(unsafe.Pointer(&addr))
-}
-
func copyOpcode(code *Opcode) *Opcode {
- codeNum := ToEndCode(code).DisplayIdx + 1
- codeSlice := make([]Opcode, codeNum)
- head := (*Opcode)((*runtime.SliceHeader)(unsafe.Pointer(&codeSlice)).Data)
- ptr := head
- c := code
- for {
- *ptr = Opcode{
- Op: c.Op,
- Key: c.Key,
- PtrNum: c.PtrNum,
- NumBitSize: c.NumBitSize,
- Flags: c.Flags,
- Idx: c.Idx,
- Offset: c.Offset,
- Type: c.Type,
- FieldQuery: c.FieldQuery,
- DisplayIdx: c.DisplayIdx,
- DisplayKey: c.DisplayKey,
- ElemIdx: c.ElemIdx,
- Length: c.Length,
- Size: c.Size,
- Indent: c.Indent,
- Jmp: c.Jmp,
- }
- if c.End != nil {
- ptr.End = getCodeAddrByIdx(head, c.End.DisplayIdx)
- }
- if c.NextField != nil {
- ptr.NextField = getCodeAddrByIdx(head, c.NextField.DisplayIdx)
- }
- if c.Next != nil {
- ptr.Next = getCodeAddrByIdx(head, c.Next.DisplayIdx)
- }
- if c.IsEnd() {
- break
- }
- ptr = getCodeAddrByIdx(head, c.DisplayIdx+1)
- c = c.IterNext()
- }
- return head
+ codeMap := map[uintptr]*Opcode{}
+ return code.copy(codeMap)
}
func setTotalLengthToInterfaceOp(code *Opcode) {
- for c := code; !c.IsEnd(); {
- if c.Op == OpInterface || c.Op == OpInterfacePtr {
+ c := code
+ for c.Op != OpEnd && c.Op != OpInterfaceEnd {
+ if c.Op == OpInterface {
c.Length = uint32(code.TotalLength())
}
- c = c.IterNext()
+ switch c.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ c = c.End
+ default:
+ c = c.Next
+ }
}
}
func ToEndCode(code *Opcode) *Opcode {
c := code
- for !c.IsEnd() {
- c = c.IterNext()
+ for c.Op != OpEnd && c.Op != OpInterfaceEnd {
+ switch c.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ c = c.End
+ default:
+ c = c.Next
+ }
}
return c
}
@@ -391,25 +325,77 @@ func copyToInterfaceOpcode(code *Opcode) *Opcode {
return copied
}
-func newOpCodeWithNext(ctx *compileContext, typ *runtime.Type, op OpType, next *Opcode) *Opcode {
+func newOpCodeWithNext(ctx *compileContext, op OpType, next *Opcode) *Opcode {
return &Opcode{
Op: op,
Idx: opcodeOffset(ctx.ptrIndex),
Next: next,
- Type: typ,
+ Type: ctx.typ,
DisplayIdx: ctx.opcodeIndex,
Indent: ctx.indent,
}
}
-func newEndOp(ctx *compileContext, typ *runtime.Type) *Opcode {
- return newOpCodeWithNext(ctx, typ, OpEnd, nil)
+func newEndOp(ctx *compileContext) *Opcode {
+ return newOpCodeWithNext(ctx, OpEnd, nil)
+}
+
+func (c *Opcode) copy(codeMap map[uintptr]*Opcode) *Opcode {
+ if c == nil {
+ return nil
+ }
+ addr := uintptr(unsafe.Pointer(c))
+ if code, exists := codeMap[addr]; exists {
+ return code
+ }
+ copied := &Opcode{
+ Op: c.Op,
+ Key: c.Key,
+ PtrNum: c.PtrNum,
+ NumBitSize: c.NumBitSize,
+ Flags: c.Flags,
+ Idx: c.Idx,
+ Offset: c.Offset,
+ Type: c.Type,
+ DisplayIdx: c.DisplayIdx,
+ DisplayKey: c.DisplayKey,
+ ElemIdx: c.ElemIdx,
+ Length: c.Length,
+ MapIter: c.MapIter,
+ MapPos: c.MapPos,
+ Size: c.Size,
+ Indent: c.Indent,
+ }
+ codeMap[addr] = copied
+ copied.End = c.End.copy(codeMap)
+ copied.PrevField = c.PrevField.copy(codeMap)
+ copied.NextField = c.NextField.copy(codeMap)
+ copied.Next = c.Next.copy(codeMap)
+ copied.Jmp = c.Jmp
+ return copied
+}
+
+func (c *Opcode) BeforeLastCode() *Opcode {
+ code := c
+ for {
+ var nextCode *Opcode
+ switch code.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ nextCode = code.End
+ default:
+ nextCode = code.Next
+ }
+ if nextCode.Op == OpEnd {
+ return code
+ }
+ code = nextCode
+ }
}
func (c *Opcode) TotalLength() int {
var idx int
code := c
- for !code.IsEnd() {
+ for code.Op != OpEnd && code.Op != OpInterfaceEnd {
maxIdx := int(code.MaxIdx() / uintptrSize)
if idx < maxIdx {
idx = maxIdx
@@ -417,7 +403,12 @@ func (c *Opcode) TotalLength() int {
if code.Op == OpRecursiveEnd {
break
}
- code = code.IterNext()
+ switch code.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ code = code.End
+ default:
+ code = code.Next
+ }
}
maxIdx := int(code.MaxIdx() / uintptrSize)
if idx < maxIdx {
@@ -426,6 +417,42 @@ func (c *Opcode) TotalLength() int {
return idx + 1
}
+func (c *Opcode) decOpcodeIndex() {
+ for code := c; code.Op != OpEnd; {
+ code.DisplayIdx--
+ if code.Idx > 0 {
+ code.Idx -= uintptrSize
+ }
+ if code.ElemIdx > 0 {
+ code.ElemIdx -= uintptrSize
+ }
+ if code.MapIter > 0 {
+ code.MapIter -= uintptrSize
+ }
+ if code.Length > 0 && code.Op.CodeType() != CodeArrayHead && code.Op.CodeType() != CodeArrayElem {
+ code.Length -= uintptrSize
+ }
+ switch code.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ code = code.End
+ default:
+ code = code.Next
+ }
+ }
+}
+
+func (c *Opcode) decIndent() {
+ for code := c; code.Op != OpEnd; {
+ code.Indent--
+ switch code.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ code = code.End
+ default:
+ code = code.Next
+ }
+ }
+}
+
func (c *Opcode) dumpHead(code *Opcode) string {
var length uint32
if code.Op.CodeType() == CodeArrayHead {
@@ -434,7 +461,7 @@ func (c *Opcode) dumpHead(code *Opcode) string {
length = code.Length / uintptrSize
}
return fmt.Sprintf(
- `[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d])`,
+ `[%d]%s%s ([idx:%d][elemIdx:%d][length:%d])`,
code.DisplayIdx,
strings.Repeat("-", int(code.Indent)),
code.Op,
@@ -446,21 +473,26 @@ func (c *Opcode) dumpHead(code *Opcode) string {
func (c *Opcode) dumpMapHead(code *Opcode) string {
return fmt.Sprintf(
- `[%03d]%s%s ([idx:%d])`,
+ `[%d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`,
code.DisplayIdx,
strings.Repeat("-", int(code.Indent)),
code.Op,
code.Idx/uintptrSize,
+ code.ElemIdx/uintptrSize,
+ code.Length/uintptrSize,
+ code.MapIter/uintptrSize,
)
}
func (c *Opcode) dumpMapEnd(code *Opcode) string {
return fmt.Sprintf(
- `[%03d]%s%s ([idx:%d])`,
+ `[%d]%s%s ([idx:%d][mapPos:%d][length:%d])`,
code.DisplayIdx,
strings.Repeat("-", int(code.Indent)),
code.Op,
code.Idx/uintptrSize,
+ code.MapPos/uintptrSize,
+ code.Length/uintptrSize,
)
}
@@ -472,7 +504,7 @@ func (c *Opcode) dumpElem(code *Opcode) string {
length = code.Length / uintptrSize
}
return fmt.Sprintf(
- `[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d][size:%d])`,
+ `[%d]%s%s ([idx:%d][elemIdx:%d][length:%d][size:%d])`,
code.DisplayIdx,
strings.Repeat("-", int(code.Indent)),
code.Op,
@@ -485,7 +517,7 @@ func (c *Opcode) dumpElem(code *Opcode) string {
func (c *Opcode) dumpField(code *Opcode) string {
return fmt.Sprintf(
- `[%03d]%s%s ([idx:%d][key:%s][offset:%d])`,
+ `[%d]%s%s ([idx:%d][key:%s][offset:%d])`,
code.DisplayIdx,
strings.Repeat("-", int(code.Indent)),
code.Op,
@@ -497,27 +529,31 @@ func (c *Opcode) dumpField(code *Opcode) string {
func (c *Opcode) dumpKey(code *Opcode) string {
return fmt.Sprintf(
- `[%03d]%s%s ([idx:%d])`,
+ `[%d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`,
code.DisplayIdx,
strings.Repeat("-", int(code.Indent)),
code.Op,
code.Idx/uintptrSize,
+ code.ElemIdx/uintptrSize,
+ code.Length/uintptrSize,
+ code.MapIter/uintptrSize,
)
}
func (c *Opcode) dumpValue(code *Opcode) string {
return fmt.Sprintf(
- `[%03d]%s%s ([idx:%d])`,
+ `[%d]%s%s ([idx:%d][mapIter:%d])`,
code.DisplayIdx,
strings.Repeat("-", int(code.Indent)),
code.Op,
code.Idx/uintptrSize,
+ code.MapIter/uintptrSize,
)
}
func (c *Opcode) Dump() string {
codes := []string{}
- for code := c; !code.IsEnd(); {
+ for code := c; code.Op != OpEnd && code.Op != OpInterfaceEnd; {
switch code.Op.CodeType() {
case CodeSliceHead:
codes = append(codes, c.dumpHead(code))
@@ -545,7 +581,7 @@ func (c *Opcode) Dump() string {
code = code.Next
default:
codes = append(codes, fmt.Sprintf(
- "[%03d]%s%s ([idx:%d])",
+ "[%d]%s%s ([idx:%d])",
code.DisplayIdx,
strings.Repeat("-", int(code.Indent)),
code.Op,
@@ -557,88 +593,44 @@ func (c *Opcode) Dump() string {
return strings.Join(codes, "\n")
}
-func (c *Opcode) DumpDOT() string {
- type edge struct {
- from, to *Opcode
- label string
- weight int
+func prevField(code *Opcode, removedFields map[*Opcode]struct{}) *Opcode {
+ if _, exists := removedFields[code]; exists {
+ return prevField(code.PrevField, removedFields)
}
- var edges []edge
-
- b := &bytes.Buffer{}
- fmt.Fprintf(b, "digraph \"%p\" {\n", c.Type)
- fmt.Fprintln(b, "mclimit=1.5;\nrankdir=TD;\nordering=out;\nnode[shape=box];")
- for code := c; !code.IsEnd(); {
- label := code.Op.String()
- fmt.Fprintf(b, "\"%p\" [label=%q];\n", code, label)
- if p := code.Next; p != nil {
- edges = append(edges, edge{
- from: code,
- to: p,
- label: "Next",
- weight: 10,
- })
- }
- if p := code.NextField; p != nil {
- edges = append(edges, edge{
- from: code,
- to: p,
- label: "NextField",
- weight: 2,
- })
- }
- if p := code.End; p != nil {
- edges = append(edges, edge{
- from: code,
- to: p,
- label: "End",
- weight: 1,
- })
- }
- if p := code.Jmp; p != nil {
- edges = append(edges, edge{
- from: code,
- to: p.Code,
- label: "Jmp",
- weight: 1,
- })
- }
-
- switch code.Op.CodeType() {
- case CodeSliceHead:
- code = code.Next
- case CodeMapHead:
- code = code.Next
- case CodeArrayElem, CodeSliceElem:
- code = code.End
- case CodeMapKey:
- code = code.End
- case CodeMapValue:
- code = code.Next
- case CodeMapEnd:
- code = code.Next
- case CodeStructField:
- code = code.Next
- case CodeStructEnd:
- code = code.Next
- default:
- code = code.Next
- }
- if code.IsEnd() {
- fmt.Fprintf(b, "\"%p\" [label=%q];\n", code, code.Op.String())
- }
- }
- sort.Slice(edges, func(i, j int) bool {
- return edges[i].to.DisplayIdx < edges[j].to.DisplayIdx
- })
- for _, e := range edges {
- fmt.Fprintf(b, "\"%p\" -> \"%p\" [label=%q][weight=%d];\n", e.from, e.to, e.label, e.weight)
- }
- fmt.Fprint(b, "}")
- return b.String()
+ return code
}
-func newSliceHeaderCode(ctx *compileContext, typ *runtime.Type) *Opcode {
+func nextField(code *Opcode, removedFields map[*Opcode]struct{}) *Opcode {
+ if _, exists := removedFields[code]; exists {
+ return nextField(code.NextField, removedFields)
+ }
+ return code
+}
+
+func linkPrevToNextField(cur *Opcode, removedFields map[*Opcode]struct{}) {
+ prev := prevField(cur.PrevField, removedFields)
+ prev.NextField = nextField(cur.NextField, removedFields)
+ code := prev
+ fcode := cur
+ for {
+ var nextCode *Opcode
+ switch code.Op.CodeType() {
+ case CodeArrayElem, CodeSliceElem, CodeMapKey:
+ nextCode = code.End
+ default:
+ nextCode = code.Next
+ }
+ if nextCode == fcode {
+ code.Next = fcode.Next
+ break
+ } else if nextCode.Op == OpEnd {
+ break
+ }
+ code = nextCode
+ }
+}
+
+func newSliceHeaderCode(ctx *compileContext) *Opcode {
idx := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex()
elemIdx := opcodeOffset(ctx.ptrIndex)
@@ -646,7 +638,6 @@ func newSliceHeaderCode(ctx *compileContext, typ *runtime.Type) *Opcode {
length := opcodeOffset(ctx.ptrIndex)
return &Opcode{
Op: OpSlice,
- Type: typ,
Idx: idx,
DisplayIdx: ctx.opcodeIndex,
ElemIdx: elemIdx,
@@ -655,10 +646,9 @@ func newSliceHeaderCode(ctx *compileContext, typ *runtime.Type) *Opcode {
}
}
-func newSliceElemCode(ctx *compileContext, typ *runtime.Type, head *Opcode, size uintptr) *Opcode {
+func newSliceElemCode(ctx *compileContext, head *Opcode, size uintptr) *Opcode {
return &Opcode{
Op: OpSliceElem,
- Type: typ,
Idx: head.Idx,
DisplayIdx: ctx.opcodeIndex,
ElemIdx: head.ElemIdx,
@@ -668,13 +658,12 @@ func newSliceElemCode(ctx *compileContext, typ *runtime.Type, head *Opcode, size
}
}
-func newArrayHeaderCode(ctx *compileContext, typ *runtime.Type, alen int) *Opcode {
+func newArrayHeaderCode(ctx *compileContext, alen int) *Opcode {
idx := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex()
elemIdx := opcodeOffset(ctx.ptrIndex)
return &Opcode{
Op: OpArray,
- Type: typ,
Idx: idx,
DisplayIdx: ctx.opcodeIndex,
ElemIdx: elemIdx,
@@ -683,10 +672,9 @@ func newArrayHeaderCode(ctx *compileContext, typ *runtime.Type, alen int) *Opcod
}
}
-func newArrayElemCode(ctx *compileContext, typ *runtime.Type, head *Opcode, length int, size uintptr) *Opcode {
+func newArrayElemCode(ctx *compileContext, head *Opcode, length int, size uintptr) *Opcode {
return &Opcode{
Op: OpArrayElem,
- Type: typ,
Idx: head.Idx,
DisplayIdx: ctx.opcodeIndex,
ElemIdx: head.ElemIdx,
@@ -696,55 +684,87 @@ func newArrayElemCode(ctx *compileContext, typ *runtime.Type, head *Opcode, leng
}
}
-func newMapHeaderCode(ctx *compileContext, typ *runtime.Type) *Opcode {
+func newMapHeaderCode(ctx *compileContext) *Opcode {
idx := opcodeOffset(ctx.ptrIndex)
ctx.incPtrIndex()
+ elemIdx := opcodeOffset(ctx.ptrIndex)
+ ctx.incPtrIndex()
+ length := opcodeOffset(ctx.ptrIndex)
+ ctx.incPtrIndex()
+ mapIter := opcodeOffset(ctx.ptrIndex)
return &Opcode{
Op: OpMap,
- Type: typ,
Idx: idx,
+ Type: ctx.typ,
DisplayIdx: ctx.opcodeIndex,
+ ElemIdx: elemIdx,
+ Length: length,
+ MapIter: mapIter,
Indent: ctx.indent,
}
}
-func newMapKeyCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opcode {
+func newMapKeyCode(ctx *compileContext, head *Opcode) *Opcode {
return &Opcode{
Op: OpMapKey,
- Type: typ,
- Idx: head.Idx,
+ Idx: opcodeOffset(ctx.ptrIndex),
DisplayIdx: ctx.opcodeIndex,
+ ElemIdx: head.ElemIdx,
+ Length: head.Length,
+ MapIter: head.MapIter,
Indent: ctx.indent,
}
}
-func newMapValueCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opcode {
+func newMapValueCode(ctx *compileContext, head *Opcode) *Opcode {
return &Opcode{
Op: OpMapValue,
- Type: typ,
- Idx: head.Idx,
+ Idx: opcodeOffset(ctx.ptrIndex),
DisplayIdx: ctx.opcodeIndex,
+ ElemIdx: head.ElemIdx,
+ Length: head.Length,
+ MapIter: head.MapIter,
Indent: ctx.indent,
}
}
-func newMapEndCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opcode {
+func newMapEndCode(ctx *compileContext, head *Opcode) *Opcode {
+ mapPos := opcodeOffset(ctx.ptrIndex)
+ ctx.incPtrIndex()
+ idx := opcodeOffset(ctx.ptrIndex)
return &Opcode{
Op: OpMapEnd,
- Type: typ,
- Idx: head.Idx,
+ Idx: idx,
+ Next: newEndOp(ctx),
DisplayIdx: ctx.opcodeIndex,
+ Length: head.Length,
+ MapPos: mapPos,
Indent: ctx.indent,
- Next: newEndOp(ctx, typ),
}
}
-func newRecursiveCode(ctx *compileContext, typ *runtime.Type, jmp *CompiledCode) *Opcode {
+func newInterfaceCode(ctx *compileContext) *Opcode {
+ var flag OpFlags
+ if ctx.typ.NumMethod() > 0 {
+ flag |= NonEmptyInterfaceFlags
+ }
+ return &Opcode{
+ Op: OpInterface,
+ Idx: opcodeOffset(ctx.ptrIndex),
+ Next: newEndOp(ctx),
+ Type: ctx.typ,
+ DisplayIdx: ctx.opcodeIndex,
+ Indent: ctx.indent,
+ Flags: flag,
+ }
+}
+
+func newRecursiveCode(ctx *compileContext, jmp *CompiledCode) *Opcode {
return &Opcode{
Op: OpRecursive,
- Type: typ,
Idx: opcodeOffset(ctx.ptrIndex),
- Next: newEndOp(ctx, typ),
+ Next: newEndOp(ctx),
+ Type: ctx.typ,
DisplayIdx: ctx.opcodeIndex,
Indent: ctx.indent,
Jmp: jmp,
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/option.go b/vendor/github.com/goccy/go-json/internal/encoder/option.go
index 12c58e4..f5f1f04 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/option.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/option.go
@@ -1,9 +1,6 @@
package encoder
-import (
- "context"
- "io"
-)
+import "context"
type OptionFlag uint8
@@ -14,16 +11,12 @@ const (
DebugOption
ColorizeOption
ContextOption
- NormalizeUTF8Option
- FieldQueryOption
)
type Option struct {
Flag OptionFlag
ColorScheme *ColorScheme
Context context.Context
- DebugOut io.Writer
- DebugDOTOut io.WriteCloser
}
type EncodeFormat struct {
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/optype.go b/vendor/github.com/goccy/go-json/internal/encoder/optype.go
index 5c1241b..335fc04 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/optype.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/optype.go
@@ -22,7 +22,7 @@ const (
CodeStructEnd CodeType = 11
)
-var opTypeStrings = [400]string{
+var opTypeStrings = [401]string{
"End",
"Interface",
"Ptr",
@@ -37,6 +37,7 @@ var opTypeStrings = [400]string{
"RecursivePtr",
"RecursiveEnd",
"InterfaceEnd",
+ "StructAnonymousEnd",
"Int",
"Uint",
"Float32",
@@ -442,396 +443,397 @@ const (
OpRecursivePtr OpType = 11
OpRecursiveEnd OpType = 12
OpInterfaceEnd OpType = 13
- OpInt OpType = 14
- OpUint OpType = 15
- OpFloat32 OpType = 16
- OpFloat64 OpType = 17
- OpBool OpType = 18
- OpString OpType = 19
- OpBytes OpType = 20
- OpNumber OpType = 21
- OpArray OpType = 22
- OpMap OpType = 23
- OpSlice OpType = 24
- OpStruct OpType = 25
- OpMarshalJSON OpType = 26
- OpMarshalText OpType = 27
- OpIntString OpType = 28
- OpUintString OpType = 29
- OpFloat32String OpType = 30
- OpFloat64String OpType = 31
- OpBoolString OpType = 32
- OpStringString OpType = 33
- OpNumberString OpType = 34
- OpIntPtr OpType = 35
- OpUintPtr OpType = 36
- OpFloat32Ptr OpType = 37
- OpFloat64Ptr OpType = 38
- OpBoolPtr OpType = 39
- OpStringPtr OpType = 40
- OpBytesPtr OpType = 41
- OpNumberPtr OpType = 42
- OpArrayPtr OpType = 43
- OpMapPtr OpType = 44
- OpSlicePtr OpType = 45
- OpMarshalJSONPtr OpType = 46
- OpMarshalTextPtr OpType = 47
- OpInterfacePtr OpType = 48
- OpIntPtrString OpType = 49
- OpUintPtrString OpType = 50
- OpFloat32PtrString OpType = 51
- OpFloat64PtrString OpType = 52
- OpBoolPtrString OpType = 53
- OpStringPtrString OpType = 54
- OpNumberPtrString OpType = 55
- OpStructHeadInt OpType = 56
- OpStructHeadOmitEmptyInt OpType = 57
- OpStructPtrHeadInt OpType = 58
- OpStructPtrHeadOmitEmptyInt OpType = 59
- OpStructHeadUint OpType = 60
- OpStructHeadOmitEmptyUint OpType = 61
- OpStructPtrHeadUint OpType = 62
- OpStructPtrHeadOmitEmptyUint OpType = 63
- OpStructHeadFloat32 OpType = 64
- OpStructHeadOmitEmptyFloat32 OpType = 65
- OpStructPtrHeadFloat32 OpType = 66
- OpStructPtrHeadOmitEmptyFloat32 OpType = 67
- OpStructHeadFloat64 OpType = 68
- OpStructHeadOmitEmptyFloat64 OpType = 69
- OpStructPtrHeadFloat64 OpType = 70
- OpStructPtrHeadOmitEmptyFloat64 OpType = 71
- OpStructHeadBool OpType = 72
- OpStructHeadOmitEmptyBool OpType = 73
- OpStructPtrHeadBool OpType = 74
- OpStructPtrHeadOmitEmptyBool OpType = 75
- OpStructHeadString OpType = 76
- OpStructHeadOmitEmptyString OpType = 77
- OpStructPtrHeadString OpType = 78
- OpStructPtrHeadOmitEmptyString OpType = 79
- OpStructHeadBytes OpType = 80
- OpStructHeadOmitEmptyBytes OpType = 81
- OpStructPtrHeadBytes OpType = 82
- OpStructPtrHeadOmitEmptyBytes OpType = 83
- OpStructHeadNumber OpType = 84
- OpStructHeadOmitEmptyNumber OpType = 85
- OpStructPtrHeadNumber OpType = 86
- OpStructPtrHeadOmitEmptyNumber OpType = 87
- OpStructHeadArray OpType = 88
- OpStructHeadOmitEmptyArray OpType = 89
- OpStructPtrHeadArray OpType = 90
- OpStructPtrHeadOmitEmptyArray OpType = 91
- OpStructHeadMap OpType = 92
- OpStructHeadOmitEmptyMap OpType = 93
- OpStructPtrHeadMap OpType = 94
- OpStructPtrHeadOmitEmptyMap OpType = 95
- OpStructHeadSlice OpType = 96
- OpStructHeadOmitEmptySlice OpType = 97
- OpStructPtrHeadSlice OpType = 98
- OpStructPtrHeadOmitEmptySlice OpType = 99
- OpStructHeadStruct OpType = 100
- OpStructHeadOmitEmptyStruct OpType = 101
- OpStructPtrHeadStruct OpType = 102
- OpStructPtrHeadOmitEmptyStruct OpType = 103
- OpStructHeadMarshalJSON OpType = 104
- OpStructHeadOmitEmptyMarshalJSON OpType = 105
- OpStructPtrHeadMarshalJSON OpType = 106
- OpStructPtrHeadOmitEmptyMarshalJSON OpType = 107
- OpStructHeadMarshalText OpType = 108
- OpStructHeadOmitEmptyMarshalText OpType = 109
- OpStructPtrHeadMarshalText OpType = 110
- OpStructPtrHeadOmitEmptyMarshalText OpType = 111
- OpStructHeadIntString OpType = 112
- OpStructHeadOmitEmptyIntString OpType = 113
- OpStructPtrHeadIntString OpType = 114
- OpStructPtrHeadOmitEmptyIntString OpType = 115
- OpStructHeadUintString OpType = 116
- OpStructHeadOmitEmptyUintString OpType = 117
- OpStructPtrHeadUintString OpType = 118
- OpStructPtrHeadOmitEmptyUintString OpType = 119
- OpStructHeadFloat32String OpType = 120
- OpStructHeadOmitEmptyFloat32String OpType = 121
- OpStructPtrHeadFloat32String OpType = 122
- OpStructPtrHeadOmitEmptyFloat32String OpType = 123
- OpStructHeadFloat64String OpType = 124
- OpStructHeadOmitEmptyFloat64String OpType = 125
- OpStructPtrHeadFloat64String OpType = 126
- OpStructPtrHeadOmitEmptyFloat64String OpType = 127
- OpStructHeadBoolString OpType = 128
- OpStructHeadOmitEmptyBoolString OpType = 129
- OpStructPtrHeadBoolString OpType = 130
- OpStructPtrHeadOmitEmptyBoolString OpType = 131
- OpStructHeadStringString OpType = 132
- OpStructHeadOmitEmptyStringString OpType = 133
- OpStructPtrHeadStringString OpType = 134
- OpStructPtrHeadOmitEmptyStringString OpType = 135
- OpStructHeadNumberString OpType = 136
- OpStructHeadOmitEmptyNumberString OpType = 137
- OpStructPtrHeadNumberString OpType = 138
- OpStructPtrHeadOmitEmptyNumberString OpType = 139
- OpStructHeadIntPtr OpType = 140
- OpStructHeadOmitEmptyIntPtr OpType = 141
- OpStructPtrHeadIntPtr OpType = 142
- OpStructPtrHeadOmitEmptyIntPtr OpType = 143
- OpStructHeadUintPtr OpType = 144
- OpStructHeadOmitEmptyUintPtr OpType = 145
- OpStructPtrHeadUintPtr OpType = 146
- OpStructPtrHeadOmitEmptyUintPtr OpType = 147
- OpStructHeadFloat32Ptr OpType = 148
- OpStructHeadOmitEmptyFloat32Ptr OpType = 149
- OpStructPtrHeadFloat32Ptr OpType = 150
- OpStructPtrHeadOmitEmptyFloat32Ptr OpType = 151
- OpStructHeadFloat64Ptr OpType = 152
- OpStructHeadOmitEmptyFloat64Ptr OpType = 153
- OpStructPtrHeadFloat64Ptr OpType = 154
- OpStructPtrHeadOmitEmptyFloat64Ptr OpType = 155
- OpStructHeadBoolPtr OpType = 156
- OpStructHeadOmitEmptyBoolPtr OpType = 157
- OpStructPtrHeadBoolPtr OpType = 158
- OpStructPtrHeadOmitEmptyBoolPtr OpType = 159
- OpStructHeadStringPtr OpType = 160
- OpStructHeadOmitEmptyStringPtr OpType = 161
- OpStructPtrHeadStringPtr OpType = 162
- OpStructPtrHeadOmitEmptyStringPtr OpType = 163
- OpStructHeadBytesPtr OpType = 164
- OpStructHeadOmitEmptyBytesPtr OpType = 165
- OpStructPtrHeadBytesPtr OpType = 166
- OpStructPtrHeadOmitEmptyBytesPtr OpType = 167
- OpStructHeadNumberPtr OpType = 168
- OpStructHeadOmitEmptyNumberPtr OpType = 169
- OpStructPtrHeadNumberPtr OpType = 170
- OpStructPtrHeadOmitEmptyNumberPtr OpType = 171
- OpStructHeadArrayPtr OpType = 172
- OpStructHeadOmitEmptyArrayPtr OpType = 173
- OpStructPtrHeadArrayPtr OpType = 174
- OpStructPtrHeadOmitEmptyArrayPtr OpType = 175
- OpStructHeadMapPtr OpType = 176
- OpStructHeadOmitEmptyMapPtr OpType = 177
- OpStructPtrHeadMapPtr OpType = 178
- OpStructPtrHeadOmitEmptyMapPtr OpType = 179
- OpStructHeadSlicePtr OpType = 180
- OpStructHeadOmitEmptySlicePtr OpType = 181
- OpStructPtrHeadSlicePtr OpType = 182
- OpStructPtrHeadOmitEmptySlicePtr OpType = 183
- OpStructHeadMarshalJSONPtr OpType = 184
- OpStructHeadOmitEmptyMarshalJSONPtr OpType = 185
- OpStructPtrHeadMarshalJSONPtr OpType = 186
- OpStructPtrHeadOmitEmptyMarshalJSONPtr OpType = 187
- OpStructHeadMarshalTextPtr OpType = 188
- OpStructHeadOmitEmptyMarshalTextPtr OpType = 189
- OpStructPtrHeadMarshalTextPtr OpType = 190
- OpStructPtrHeadOmitEmptyMarshalTextPtr OpType = 191
- OpStructHeadInterfacePtr OpType = 192
- OpStructHeadOmitEmptyInterfacePtr OpType = 193
- OpStructPtrHeadInterfacePtr OpType = 194
- OpStructPtrHeadOmitEmptyInterfacePtr OpType = 195
- OpStructHeadIntPtrString OpType = 196
- OpStructHeadOmitEmptyIntPtrString OpType = 197
- OpStructPtrHeadIntPtrString OpType = 198
- OpStructPtrHeadOmitEmptyIntPtrString OpType = 199
- OpStructHeadUintPtrString OpType = 200
- OpStructHeadOmitEmptyUintPtrString OpType = 201
- OpStructPtrHeadUintPtrString OpType = 202
- OpStructPtrHeadOmitEmptyUintPtrString OpType = 203
- OpStructHeadFloat32PtrString OpType = 204
- OpStructHeadOmitEmptyFloat32PtrString OpType = 205
- OpStructPtrHeadFloat32PtrString OpType = 206
- OpStructPtrHeadOmitEmptyFloat32PtrString OpType = 207
- OpStructHeadFloat64PtrString OpType = 208
- OpStructHeadOmitEmptyFloat64PtrString OpType = 209
- OpStructPtrHeadFloat64PtrString OpType = 210
- OpStructPtrHeadOmitEmptyFloat64PtrString OpType = 211
- OpStructHeadBoolPtrString OpType = 212
- OpStructHeadOmitEmptyBoolPtrString OpType = 213
- OpStructPtrHeadBoolPtrString OpType = 214
- OpStructPtrHeadOmitEmptyBoolPtrString OpType = 215
- OpStructHeadStringPtrString OpType = 216
- OpStructHeadOmitEmptyStringPtrString OpType = 217
- OpStructPtrHeadStringPtrString OpType = 218
- OpStructPtrHeadOmitEmptyStringPtrString OpType = 219
- OpStructHeadNumberPtrString OpType = 220
- OpStructHeadOmitEmptyNumberPtrString OpType = 221
- OpStructPtrHeadNumberPtrString OpType = 222
- OpStructPtrHeadOmitEmptyNumberPtrString OpType = 223
- OpStructHead OpType = 224
- OpStructHeadOmitEmpty OpType = 225
- OpStructPtrHead OpType = 226
- OpStructPtrHeadOmitEmpty OpType = 227
- OpStructFieldInt OpType = 228
- OpStructFieldOmitEmptyInt OpType = 229
- OpStructEndInt OpType = 230
- OpStructEndOmitEmptyInt OpType = 231
- OpStructFieldUint OpType = 232
- OpStructFieldOmitEmptyUint OpType = 233
- OpStructEndUint OpType = 234
- OpStructEndOmitEmptyUint OpType = 235
- OpStructFieldFloat32 OpType = 236
- OpStructFieldOmitEmptyFloat32 OpType = 237
- OpStructEndFloat32 OpType = 238
- OpStructEndOmitEmptyFloat32 OpType = 239
- OpStructFieldFloat64 OpType = 240
- OpStructFieldOmitEmptyFloat64 OpType = 241
- OpStructEndFloat64 OpType = 242
- OpStructEndOmitEmptyFloat64 OpType = 243
- OpStructFieldBool OpType = 244
- OpStructFieldOmitEmptyBool OpType = 245
- OpStructEndBool OpType = 246
- OpStructEndOmitEmptyBool OpType = 247
- OpStructFieldString OpType = 248
- OpStructFieldOmitEmptyString OpType = 249
- OpStructEndString OpType = 250
- OpStructEndOmitEmptyString OpType = 251
- OpStructFieldBytes OpType = 252
- OpStructFieldOmitEmptyBytes OpType = 253
- OpStructEndBytes OpType = 254
- OpStructEndOmitEmptyBytes OpType = 255
- OpStructFieldNumber OpType = 256
- OpStructFieldOmitEmptyNumber OpType = 257
- OpStructEndNumber OpType = 258
- OpStructEndOmitEmptyNumber OpType = 259
- OpStructFieldArray OpType = 260
- OpStructFieldOmitEmptyArray OpType = 261
- OpStructEndArray OpType = 262
- OpStructEndOmitEmptyArray OpType = 263
- OpStructFieldMap OpType = 264
- OpStructFieldOmitEmptyMap OpType = 265
- OpStructEndMap OpType = 266
- OpStructEndOmitEmptyMap OpType = 267
- OpStructFieldSlice OpType = 268
- OpStructFieldOmitEmptySlice OpType = 269
- OpStructEndSlice OpType = 270
- OpStructEndOmitEmptySlice OpType = 271
- OpStructFieldStruct OpType = 272
- OpStructFieldOmitEmptyStruct OpType = 273
- OpStructEndStruct OpType = 274
- OpStructEndOmitEmptyStruct OpType = 275
- OpStructFieldMarshalJSON OpType = 276
- OpStructFieldOmitEmptyMarshalJSON OpType = 277
- OpStructEndMarshalJSON OpType = 278
- OpStructEndOmitEmptyMarshalJSON OpType = 279
- OpStructFieldMarshalText OpType = 280
- OpStructFieldOmitEmptyMarshalText OpType = 281
- OpStructEndMarshalText OpType = 282
- OpStructEndOmitEmptyMarshalText OpType = 283
- OpStructFieldIntString OpType = 284
- OpStructFieldOmitEmptyIntString OpType = 285
- OpStructEndIntString OpType = 286
- OpStructEndOmitEmptyIntString OpType = 287
- OpStructFieldUintString OpType = 288
- OpStructFieldOmitEmptyUintString OpType = 289
- OpStructEndUintString OpType = 290
- OpStructEndOmitEmptyUintString OpType = 291
- OpStructFieldFloat32String OpType = 292
- OpStructFieldOmitEmptyFloat32String OpType = 293
- OpStructEndFloat32String OpType = 294
- OpStructEndOmitEmptyFloat32String OpType = 295
- OpStructFieldFloat64String OpType = 296
- OpStructFieldOmitEmptyFloat64String OpType = 297
- OpStructEndFloat64String OpType = 298
- OpStructEndOmitEmptyFloat64String OpType = 299
- OpStructFieldBoolString OpType = 300
- OpStructFieldOmitEmptyBoolString OpType = 301
- OpStructEndBoolString OpType = 302
- OpStructEndOmitEmptyBoolString OpType = 303
- OpStructFieldStringString OpType = 304
- OpStructFieldOmitEmptyStringString OpType = 305
- OpStructEndStringString OpType = 306
- OpStructEndOmitEmptyStringString OpType = 307
- OpStructFieldNumberString OpType = 308
- OpStructFieldOmitEmptyNumberString OpType = 309
- OpStructEndNumberString OpType = 310
- OpStructEndOmitEmptyNumberString OpType = 311
- OpStructFieldIntPtr OpType = 312
- OpStructFieldOmitEmptyIntPtr OpType = 313
- OpStructEndIntPtr OpType = 314
- OpStructEndOmitEmptyIntPtr OpType = 315
- OpStructFieldUintPtr OpType = 316
- OpStructFieldOmitEmptyUintPtr OpType = 317
- OpStructEndUintPtr OpType = 318
- OpStructEndOmitEmptyUintPtr OpType = 319
- OpStructFieldFloat32Ptr OpType = 320
- OpStructFieldOmitEmptyFloat32Ptr OpType = 321
- OpStructEndFloat32Ptr OpType = 322
- OpStructEndOmitEmptyFloat32Ptr OpType = 323
- OpStructFieldFloat64Ptr OpType = 324
- OpStructFieldOmitEmptyFloat64Ptr OpType = 325
- OpStructEndFloat64Ptr OpType = 326
- OpStructEndOmitEmptyFloat64Ptr OpType = 327
- OpStructFieldBoolPtr OpType = 328
- OpStructFieldOmitEmptyBoolPtr OpType = 329
- OpStructEndBoolPtr OpType = 330
- OpStructEndOmitEmptyBoolPtr OpType = 331
- OpStructFieldStringPtr OpType = 332
- OpStructFieldOmitEmptyStringPtr OpType = 333
- OpStructEndStringPtr OpType = 334
- OpStructEndOmitEmptyStringPtr OpType = 335
- OpStructFieldBytesPtr OpType = 336
- OpStructFieldOmitEmptyBytesPtr OpType = 337
- OpStructEndBytesPtr OpType = 338
- OpStructEndOmitEmptyBytesPtr OpType = 339
- OpStructFieldNumberPtr OpType = 340
- OpStructFieldOmitEmptyNumberPtr OpType = 341
- OpStructEndNumberPtr OpType = 342
- OpStructEndOmitEmptyNumberPtr OpType = 343
- OpStructFieldArrayPtr OpType = 344
- OpStructFieldOmitEmptyArrayPtr OpType = 345
- OpStructEndArrayPtr OpType = 346
- OpStructEndOmitEmptyArrayPtr OpType = 347
- OpStructFieldMapPtr OpType = 348
- OpStructFieldOmitEmptyMapPtr OpType = 349
- OpStructEndMapPtr OpType = 350
- OpStructEndOmitEmptyMapPtr OpType = 351
- OpStructFieldSlicePtr OpType = 352
- OpStructFieldOmitEmptySlicePtr OpType = 353
- OpStructEndSlicePtr OpType = 354
- OpStructEndOmitEmptySlicePtr OpType = 355
- OpStructFieldMarshalJSONPtr OpType = 356
- OpStructFieldOmitEmptyMarshalJSONPtr OpType = 357
- OpStructEndMarshalJSONPtr OpType = 358
- OpStructEndOmitEmptyMarshalJSONPtr OpType = 359
- OpStructFieldMarshalTextPtr OpType = 360
- OpStructFieldOmitEmptyMarshalTextPtr OpType = 361
- OpStructEndMarshalTextPtr OpType = 362
- OpStructEndOmitEmptyMarshalTextPtr OpType = 363
- OpStructFieldInterfacePtr OpType = 364
- OpStructFieldOmitEmptyInterfacePtr OpType = 365
- OpStructEndInterfacePtr OpType = 366
- OpStructEndOmitEmptyInterfacePtr OpType = 367
- OpStructFieldIntPtrString OpType = 368
- OpStructFieldOmitEmptyIntPtrString OpType = 369
- OpStructEndIntPtrString OpType = 370
- OpStructEndOmitEmptyIntPtrString OpType = 371
- OpStructFieldUintPtrString OpType = 372
- OpStructFieldOmitEmptyUintPtrString OpType = 373
- OpStructEndUintPtrString OpType = 374
- OpStructEndOmitEmptyUintPtrString OpType = 375
- OpStructFieldFloat32PtrString OpType = 376
- OpStructFieldOmitEmptyFloat32PtrString OpType = 377
- OpStructEndFloat32PtrString OpType = 378
- OpStructEndOmitEmptyFloat32PtrString OpType = 379
- OpStructFieldFloat64PtrString OpType = 380
- OpStructFieldOmitEmptyFloat64PtrString OpType = 381
- OpStructEndFloat64PtrString OpType = 382
- OpStructEndOmitEmptyFloat64PtrString OpType = 383
- OpStructFieldBoolPtrString OpType = 384
- OpStructFieldOmitEmptyBoolPtrString OpType = 385
- OpStructEndBoolPtrString OpType = 386
- OpStructEndOmitEmptyBoolPtrString OpType = 387
- OpStructFieldStringPtrString OpType = 388
- OpStructFieldOmitEmptyStringPtrString OpType = 389
- OpStructEndStringPtrString OpType = 390
- OpStructEndOmitEmptyStringPtrString OpType = 391
- OpStructFieldNumberPtrString OpType = 392
- OpStructFieldOmitEmptyNumberPtrString OpType = 393
- OpStructEndNumberPtrString OpType = 394
- OpStructEndOmitEmptyNumberPtrString OpType = 395
- OpStructField OpType = 396
- OpStructFieldOmitEmpty OpType = 397
- OpStructEnd OpType = 398
- OpStructEndOmitEmpty OpType = 399
+ OpStructAnonymousEnd OpType = 14
+ OpInt OpType = 15
+ OpUint OpType = 16
+ OpFloat32 OpType = 17
+ OpFloat64 OpType = 18
+ OpBool OpType = 19
+ OpString OpType = 20
+ OpBytes OpType = 21
+ OpNumber OpType = 22
+ OpArray OpType = 23
+ OpMap OpType = 24
+ OpSlice OpType = 25
+ OpStruct OpType = 26
+ OpMarshalJSON OpType = 27
+ OpMarshalText OpType = 28
+ OpIntString OpType = 29
+ OpUintString OpType = 30
+ OpFloat32String OpType = 31
+ OpFloat64String OpType = 32
+ OpBoolString OpType = 33
+ OpStringString OpType = 34
+ OpNumberString OpType = 35
+ OpIntPtr OpType = 36
+ OpUintPtr OpType = 37
+ OpFloat32Ptr OpType = 38
+ OpFloat64Ptr OpType = 39
+ OpBoolPtr OpType = 40
+ OpStringPtr OpType = 41
+ OpBytesPtr OpType = 42
+ OpNumberPtr OpType = 43
+ OpArrayPtr OpType = 44
+ OpMapPtr OpType = 45
+ OpSlicePtr OpType = 46
+ OpMarshalJSONPtr OpType = 47
+ OpMarshalTextPtr OpType = 48
+ OpInterfacePtr OpType = 49
+ OpIntPtrString OpType = 50
+ OpUintPtrString OpType = 51
+ OpFloat32PtrString OpType = 52
+ OpFloat64PtrString OpType = 53
+ OpBoolPtrString OpType = 54
+ OpStringPtrString OpType = 55
+ OpNumberPtrString OpType = 56
+ OpStructHeadInt OpType = 57
+ OpStructHeadOmitEmptyInt OpType = 58
+ OpStructPtrHeadInt OpType = 59
+ OpStructPtrHeadOmitEmptyInt OpType = 60
+ OpStructHeadUint OpType = 61
+ OpStructHeadOmitEmptyUint OpType = 62
+ OpStructPtrHeadUint OpType = 63
+ OpStructPtrHeadOmitEmptyUint OpType = 64
+ OpStructHeadFloat32 OpType = 65
+ OpStructHeadOmitEmptyFloat32 OpType = 66
+ OpStructPtrHeadFloat32 OpType = 67
+ OpStructPtrHeadOmitEmptyFloat32 OpType = 68
+ OpStructHeadFloat64 OpType = 69
+ OpStructHeadOmitEmptyFloat64 OpType = 70
+ OpStructPtrHeadFloat64 OpType = 71
+ OpStructPtrHeadOmitEmptyFloat64 OpType = 72
+ OpStructHeadBool OpType = 73
+ OpStructHeadOmitEmptyBool OpType = 74
+ OpStructPtrHeadBool OpType = 75
+ OpStructPtrHeadOmitEmptyBool OpType = 76
+ OpStructHeadString OpType = 77
+ OpStructHeadOmitEmptyString OpType = 78
+ OpStructPtrHeadString OpType = 79
+ OpStructPtrHeadOmitEmptyString OpType = 80
+ OpStructHeadBytes OpType = 81
+ OpStructHeadOmitEmptyBytes OpType = 82
+ OpStructPtrHeadBytes OpType = 83
+ OpStructPtrHeadOmitEmptyBytes OpType = 84
+ OpStructHeadNumber OpType = 85
+ OpStructHeadOmitEmptyNumber OpType = 86
+ OpStructPtrHeadNumber OpType = 87
+ OpStructPtrHeadOmitEmptyNumber OpType = 88
+ OpStructHeadArray OpType = 89
+ OpStructHeadOmitEmptyArray OpType = 90
+ OpStructPtrHeadArray OpType = 91
+ OpStructPtrHeadOmitEmptyArray OpType = 92
+ OpStructHeadMap OpType = 93
+ OpStructHeadOmitEmptyMap OpType = 94
+ OpStructPtrHeadMap OpType = 95
+ OpStructPtrHeadOmitEmptyMap OpType = 96
+ OpStructHeadSlice OpType = 97
+ OpStructHeadOmitEmptySlice OpType = 98
+ OpStructPtrHeadSlice OpType = 99
+ OpStructPtrHeadOmitEmptySlice OpType = 100
+ OpStructHeadStruct OpType = 101
+ OpStructHeadOmitEmptyStruct OpType = 102
+ OpStructPtrHeadStruct OpType = 103
+ OpStructPtrHeadOmitEmptyStruct OpType = 104
+ OpStructHeadMarshalJSON OpType = 105
+ OpStructHeadOmitEmptyMarshalJSON OpType = 106
+ OpStructPtrHeadMarshalJSON OpType = 107
+ OpStructPtrHeadOmitEmptyMarshalJSON OpType = 108
+ OpStructHeadMarshalText OpType = 109
+ OpStructHeadOmitEmptyMarshalText OpType = 110
+ OpStructPtrHeadMarshalText OpType = 111
+ OpStructPtrHeadOmitEmptyMarshalText OpType = 112
+ OpStructHeadIntString OpType = 113
+ OpStructHeadOmitEmptyIntString OpType = 114
+ OpStructPtrHeadIntString OpType = 115
+ OpStructPtrHeadOmitEmptyIntString OpType = 116
+ OpStructHeadUintString OpType = 117
+ OpStructHeadOmitEmptyUintString OpType = 118
+ OpStructPtrHeadUintString OpType = 119
+ OpStructPtrHeadOmitEmptyUintString OpType = 120
+ OpStructHeadFloat32String OpType = 121
+ OpStructHeadOmitEmptyFloat32String OpType = 122
+ OpStructPtrHeadFloat32String OpType = 123
+ OpStructPtrHeadOmitEmptyFloat32String OpType = 124
+ OpStructHeadFloat64String OpType = 125
+ OpStructHeadOmitEmptyFloat64String OpType = 126
+ OpStructPtrHeadFloat64String OpType = 127
+ OpStructPtrHeadOmitEmptyFloat64String OpType = 128
+ OpStructHeadBoolString OpType = 129
+ OpStructHeadOmitEmptyBoolString OpType = 130
+ OpStructPtrHeadBoolString OpType = 131
+ OpStructPtrHeadOmitEmptyBoolString OpType = 132
+ OpStructHeadStringString OpType = 133
+ OpStructHeadOmitEmptyStringString OpType = 134
+ OpStructPtrHeadStringString OpType = 135
+ OpStructPtrHeadOmitEmptyStringString OpType = 136
+ OpStructHeadNumberString OpType = 137
+ OpStructHeadOmitEmptyNumberString OpType = 138
+ OpStructPtrHeadNumberString OpType = 139
+ OpStructPtrHeadOmitEmptyNumberString OpType = 140
+ OpStructHeadIntPtr OpType = 141
+ OpStructHeadOmitEmptyIntPtr OpType = 142
+ OpStructPtrHeadIntPtr OpType = 143
+ OpStructPtrHeadOmitEmptyIntPtr OpType = 144
+ OpStructHeadUintPtr OpType = 145
+ OpStructHeadOmitEmptyUintPtr OpType = 146
+ OpStructPtrHeadUintPtr OpType = 147
+ OpStructPtrHeadOmitEmptyUintPtr OpType = 148
+ OpStructHeadFloat32Ptr OpType = 149
+ OpStructHeadOmitEmptyFloat32Ptr OpType = 150
+ OpStructPtrHeadFloat32Ptr OpType = 151
+ OpStructPtrHeadOmitEmptyFloat32Ptr OpType = 152
+ OpStructHeadFloat64Ptr OpType = 153
+ OpStructHeadOmitEmptyFloat64Ptr OpType = 154
+ OpStructPtrHeadFloat64Ptr OpType = 155
+ OpStructPtrHeadOmitEmptyFloat64Ptr OpType = 156
+ OpStructHeadBoolPtr OpType = 157
+ OpStructHeadOmitEmptyBoolPtr OpType = 158
+ OpStructPtrHeadBoolPtr OpType = 159
+ OpStructPtrHeadOmitEmptyBoolPtr OpType = 160
+ OpStructHeadStringPtr OpType = 161
+ OpStructHeadOmitEmptyStringPtr OpType = 162
+ OpStructPtrHeadStringPtr OpType = 163
+ OpStructPtrHeadOmitEmptyStringPtr OpType = 164
+ OpStructHeadBytesPtr OpType = 165
+ OpStructHeadOmitEmptyBytesPtr OpType = 166
+ OpStructPtrHeadBytesPtr OpType = 167
+ OpStructPtrHeadOmitEmptyBytesPtr OpType = 168
+ OpStructHeadNumberPtr OpType = 169
+ OpStructHeadOmitEmptyNumberPtr OpType = 170
+ OpStructPtrHeadNumberPtr OpType = 171
+ OpStructPtrHeadOmitEmptyNumberPtr OpType = 172
+ OpStructHeadArrayPtr OpType = 173
+ OpStructHeadOmitEmptyArrayPtr OpType = 174
+ OpStructPtrHeadArrayPtr OpType = 175
+ OpStructPtrHeadOmitEmptyArrayPtr OpType = 176
+ OpStructHeadMapPtr OpType = 177
+ OpStructHeadOmitEmptyMapPtr OpType = 178
+ OpStructPtrHeadMapPtr OpType = 179
+ OpStructPtrHeadOmitEmptyMapPtr OpType = 180
+ OpStructHeadSlicePtr OpType = 181
+ OpStructHeadOmitEmptySlicePtr OpType = 182
+ OpStructPtrHeadSlicePtr OpType = 183
+ OpStructPtrHeadOmitEmptySlicePtr OpType = 184
+ OpStructHeadMarshalJSONPtr OpType = 185
+ OpStructHeadOmitEmptyMarshalJSONPtr OpType = 186
+ OpStructPtrHeadMarshalJSONPtr OpType = 187
+ OpStructPtrHeadOmitEmptyMarshalJSONPtr OpType = 188
+ OpStructHeadMarshalTextPtr OpType = 189
+ OpStructHeadOmitEmptyMarshalTextPtr OpType = 190
+ OpStructPtrHeadMarshalTextPtr OpType = 191
+ OpStructPtrHeadOmitEmptyMarshalTextPtr OpType = 192
+ OpStructHeadInterfacePtr OpType = 193
+ OpStructHeadOmitEmptyInterfacePtr OpType = 194
+ OpStructPtrHeadInterfacePtr OpType = 195
+ OpStructPtrHeadOmitEmptyInterfacePtr OpType = 196
+ OpStructHeadIntPtrString OpType = 197
+ OpStructHeadOmitEmptyIntPtrString OpType = 198
+ OpStructPtrHeadIntPtrString OpType = 199
+ OpStructPtrHeadOmitEmptyIntPtrString OpType = 200
+ OpStructHeadUintPtrString OpType = 201
+ OpStructHeadOmitEmptyUintPtrString OpType = 202
+ OpStructPtrHeadUintPtrString OpType = 203
+ OpStructPtrHeadOmitEmptyUintPtrString OpType = 204
+ OpStructHeadFloat32PtrString OpType = 205
+ OpStructHeadOmitEmptyFloat32PtrString OpType = 206
+ OpStructPtrHeadFloat32PtrString OpType = 207
+ OpStructPtrHeadOmitEmptyFloat32PtrString OpType = 208
+ OpStructHeadFloat64PtrString OpType = 209
+ OpStructHeadOmitEmptyFloat64PtrString OpType = 210
+ OpStructPtrHeadFloat64PtrString OpType = 211
+ OpStructPtrHeadOmitEmptyFloat64PtrString OpType = 212
+ OpStructHeadBoolPtrString OpType = 213
+ OpStructHeadOmitEmptyBoolPtrString OpType = 214
+ OpStructPtrHeadBoolPtrString OpType = 215
+ OpStructPtrHeadOmitEmptyBoolPtrString OpType = 216
+ OpStructHeadStringPtrString OpType = 217
+ OpStructHeadOmitEmptyStringPtrString OpType = 218
+ OpStructPtrHeadStringPtrString OpType = 219
+ OpStructPtrHeadOmitEmptyStringPtrString OpType = 220
+ OpStructHeadNumberPtrString OpType = 221
+ OpStructHeadOmitEmptyNumberPtrString OpType = 222
+ OpStructPtrHeadNumberPtrString OpType = 223
+ OpStructPtrHeadOmitEmptyNumberPtrString OpType = 224
+ OpStructHead OpType = 225
+ OpStructHeadOmitEmpty OpType = 226
+ OpStructPtrHead OpType = 227
+ OpStructPtrHeadOmitEmpty OpType = 228
+ OpStructFieldInt OpType = 229
+ OpStructFieldOmitEmptyInt OpType = 230
+ OpStructEndInt OpType = 231
+ OpStructEndOmitEmptyInt OpType = 232
+ OpStructFieldUint OpType = 233
+ OpStructFieldOmitEmptyUint OpType = 234
+ OpStructEndUint OpType = 235
+ OpStructEndOmitEmptyUint OpType = 236
+ OpStructFieldFloat32 OpType = 237
+ OpStructFieldOmitEmptyFloat32 OpType = 238
+ OpStructEndFloat32 OpType = 239
+ OpStructEndOmitEmptyFloat32 OpType = 240
+ OpStructFieldFloat64 OpType = 241
+ OpStructFieldOmitEmptyFloat64 OpType = 242
+ OpStructEndFloat64 OpType = 243
+ OpStructEndOmitEmptyFloat64 OpType = 244
+ OpStructFieldBool OpType = 245
+ OpStructFieldOmitEmptyBool OpType = 246
+ OpStructEndBool OpType = 247
+ OpStructEndOmitEmptyBool OpType = 248
+ OpStructFieldString OpType = 249
+ OpStructFieldOmitEmptyString OpType = 250
+ OpStructEndString OpType = 251
+ OpStructEndOmitEmptyString OpType = 252
+ OpStructFieldBytes OpType = 253
+ OpStructFieldOmitEmptyBytes OpType = 254
+ OpStructEndBytes OpType = 255
+ OpStructEndOmitEmptyBytes OpType = 256
+ OpStructFieldNumber OpType = 257
+ OpStructFieldOmitEmptyNumber OpType = 258
+ OpStructEndNumber OpType = 259
+ OpStructEndOmitEmptyNumber OpType = 260
+ OpStructFieldArray OpType = 261
+ OpStructFieldOmitEmptyArray OpType = 262
+ OpStructEndArray OpType = 263
+ OpStructEndOmitEmptyArray OpType = 264
+ OpStructFieldMap OpType = 265
+ OpStructFieldOmitEmptyMap OpType = 266
+ OpStructEndMap OpType = 267
+ OpStructEndOmitEmptyMap OpType = 268
+ OpStructFieldSlice OpType = 269
+ OpStructFieldOmitEmptySlice OpType = 270
+ OpStructEndSlice OpType = 271
+ OpStructEndOmitEmptySlice OpType = 272
+ OpStructFieldStruct OpType = 273
+ OpStructFieldOmitEmptyStruct OpType = 274
+ OpStructEndStruct OpType = 275
+ OpStructEndOmitEmptyStruct OpType = 276
+ OpStructFieldMarshalJSON OpType = 277
+ OpStructFieldOmitEmptyMarshalJSON OpType = 278
+ OpStructEndMarshalJSON OpType = 279
+ OpStructEndOmitEmptyMarshalJSON OpType = 280
+ OpStructFieldMarshalText OpType = 281
+ OpStructFieldOmitEmptyMarshalText OpType = 282
+ OpStructEndMarshalText OpType = 283
+ OpStructEndOmitEmptyMarshalText OpType = 284
+ OpStructFieldIntString OpType = 285
+ OpStructFieldOmitEmptyIntString OpType = 286
+ OpStructEndIntString OpType = 287
+ OpStructEndOmitEmptyIntString OpType = 288
+ OpStructFieldUintString OpType = 289
+ OpStructFieldOmitEmptyUintString OpType = 290
+ OpStructEndUintString OpType = 291
+ OpStructEndOmitEmptyUintString OpType = 292
+ OpStructFieldFloat32String OpType = 293
+ OpStructFieldOmitEmptyFloat32String OpType = 294
+ OpStructEndFloat32String OpType = 295
+ OpStructEndOmitEmptyFloat32String OpType = 296
+ OpStructFieldFloat64String OpType = 297
+ OpStructFieldOmitEmptyFloat64String OpType = 298
+ OpStructEndFloat64String OpType = 299
+ OpStructEndOmitEmptyFloat64String OpType = 300
+ OpStructFieldBoolString OpType = 301
+ OpStructFieldOmitEmptyBoolString OpType = 302
+ OpStructEndBoolString OpType = 303
+ OpStructEndOmitEmptyBoolString OpType = 304
+ OpStructFieldStringString OpType = 305
+ OpStructFieldOmitEmptyStringString OpType = 306
+ OpStructEndStringString OpType = 307
+ OpStructEndOmitEmptyStringString OpType = 308
+ OpStructFieldNumberString OpType = 309
+ OpStructFieldOmitEmptyNumberString OpType = 310
+ OpStructEndNumberString OpType = 311
+ OpStructEndOmitEmptyNumberString OpType = 312
+ OpStructFieldIntPtr OpType = 313
+ OpStructFieldOmitEmptyIntPtr OpType = 314
+ OpStructEndIntPtr OpType = 315
+ OpStructEndOmitEmptyIntPtr OpType = 316
+ OpStructFieldUintPtr OpType = 317
+ OpStructFieldOmitEmptyUintPtr OpType = 318
+ OpStructEndUintPtr OpType = 319
+ OpStructEndOmitEmptyUintPtr OpType = 320
+ OpStructFieldFloat32Ptr OpType = 321
+ OpStructFieldOmitEmptyFloat32Ptr OpType = 322
+ OpStructEndFloat32Ptr OpType = 323
+ OpStructEndOmitEmptyFloat32Ptr OpType = 324
+ OpStructFieldFloat64Ptr OpType = 325
+ OpStructFieldOmitEmptyFloat64Ptr OpType = 326
+ OpStructEndFloat64Ptr OpType = 327
+ OpStructEndOmitEmptyFloat64Ptr OpType = 328
+ OpStructFieldBoolPtr OpType = 329
+ OpStructFieldOmitEmptyBoolPtr OpType = 330
+ OpStructEndBoolPtr OpType = 331
+ OpStructEndOmitEmptyBoolPtr OpType = 332
+ OpStructFieldStringPtr OpType = 333
+ OpStructFieldOmitEmptyStringPtr OpType = 334
+ OpStructEndStringPtr OpType = 335
+ OpStructEndOmitEmptyStringPtr OpType = 336
+ OpStructFieldBytesPtr OpType = 337
+ OpStructFieldOmitEmptyBytesPtr OpType = 338
+ OpStructEndBytesPtr OpType = 339
+ OpStructEndOmitEmptyBytesPtr OpType = 340
+ OpStructFieldNumberPtr OpType = 341
+ OpStructFieldOmitEmptyNumberPtr OpType = 342
+ OpStructEndNumberPtr OpType = 343
+ OpStructEndOmitEmptyNumberPtr OpType = 344
+ OpStructFieldArrayPtr OpType = 345
+ OpStructFieldOmitEmptyArrayPtr OpType = 346
+ OpStructEndArrayPtr OpType = 347
+ OpStructEndOmitEmptyArrayPtr OpType = 348
+ OpStructFieldMapPtr OpType = 349
+ OpStructFieldOmitEmptyMapPtr OpType = 350
+ OpStructEndMapPtr OpType = 351
+ OpStructEndOmitEmptyMapPtr OpType = 352
+ OpStructFieldSlicePtr OpType = 353
+ OpStructFieldOmitEmptySlicePtr OpType = 354
+ OpStructEndSlicePtr OpType = 355
+ OpStructEndOmitEmptySlicePtr OpType = 356
+ OpStructFieldMarshalJSONPtr OpType = 357
+ OpStructFieldOmitEmptyMarshalJSONPtr OpType = 358
+ OpStructEndMarshalJSONPtr OpType = 359
+ OpStructEndOmitEmptyMarshalJSONPtr OpType = 360
+ OpStructFieldMarshalTextPtr OpType = 361
+ OpStructFieldOmitEmptyMarshalTextPtr OpType = 362
+ OpStructEndMarshalTextPtr OpType = 363
+ OpStructEndOmitEmptyMarshalTextPtr OpType = 364
+ OpStructFieldInterfacePtr OpType = 365
+ OpStructFieldOmitEmptyInterfacePtr OpType = 366
+ OpStructEndInterfacePtr OpType = 367
+ OpStructEndOmitEmptyInterfacePtr OpType = 368
+ OpStructFieldIntPtrString OpType = 369
+ OpStructFieldOmitEmptyIntPtrString OpType = 370
+ OpStructEndIntPtrString OpType = 371
+ OpStructEndOmitEmptyIntPtrString OpType = 372
+ OpStructFieldUintPtrString OpType = 373
+ OpStructFieldOmitEmptyUintPtrString OpType = 374
+ OpStructEndUintPtrString OpType = 375
+ OpStructEndOmitEmptyUintPtrString OpType = 376
+ OpStructFieldFloat32PtrString OpType = 377
+ OpStructFieldOmitEmptyFloat32PtrString OpType = 378
+ OpStructEndFloat32PtrString OpType = 379
+ OpStructEndOmitEmptyFloat32PtrString OpType = 380
+ OpStructFieldFloat64PtrString OpType = 381
+ OpStructFieldOmitEmptyFloat64PtrString OpType = 382
+ OpStructEndFloat64PtrString OpType = 383
+ OpStructEndOmitEmptyFloat64PtrString OpType = 384
+ OpStructFieldBoolPtrString OpType = 385
+ OpStructFieldOmitEmptyBoolPtrString OpType = 386
+ OpStructEndBoolPtrString OpType = 387
+ OpStructEndOmitEmptyBoolPtrString OpType = 388
+ OpStructFieldStringPtrString OpType = 389
+ OpStructFieldOmitEmptyStringPtrString OpType = 390
+ OpStructEndStringPtrString OpType = 391
+ OpStructEndOmitEmptyStringPtrString OpType = 392
+ OpStructFieldNumberPtrString OpType = 393
+ OpStructFieldOmitEmptyNumberPtrString OpType = 394
+ OpStructEndNumberPtrString OpType = 395
+ OpStructEndOmitEmptyNumberPtrString OpType = 396
+ OpStructField OpType = 397
+ OpStructFieldOmitEmpty OpType = 398
+ OpStructEnd OpType = 399
+ OpStructEndOmitEmpty OpType = 400
)
func (t OpType) String() string {
- if int(t) >= 400 {
+ if int(t) >= 401 {
return ""
}
return opTypeStrings[int(t)]
@@ -894,7 +896,7 @@ func (t OpType) HeadToOmitEmptyHead() OpType {
}
func (t OpType) PtrHeadToHead() OpType {
- idx := strings.Index(t.String(), "PtrHead")
+ idx := strings.Index(t.String(), "Ptr")
if idx == -1 {
return t
}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/query.go b/vendor/github.com/goccy/go-json/internal/encoder/query.go
deleted file mode 100644
index 1e1850c..0000000
--- a/vendor/github.com/goccy/go-json/internal/encoder/query.go
+++ /dev/null
@@ -1,135 +0,0 @@
-package encoder
-
-import (
- "context"
- "fmt"
- "reflect"
-)
-
-var (
- Marshal func(interface{}) ([]byte, error)
- Unmarshal func([]byte, interface{}) error
-)
-
-type FieldQuery struct {
- Name string
- Fields []*FieldQuery
- hash string
-}
-
-func (q *FieldQuery) Hash() string {
- if q.hash != "" {
- return q.hash
- }
- b, _ := Marshal(q)
- q.hash = string(b)
- return q.hash
-}
-
-func (q *FieldQuery) MarshalJSON() ([]byte, error) {
- if q.Name != "" {
- if len(q.Fields) > 0 {
- return Marshal(map[string][]*FieldQuery{q.Name: q.Fields})
- }
- return Marshal(q.Name)
- }
- return Marshal(q.Fields)
-}
-
-func (q *FieldQuery) QueryString() (FieldQueryString, error) {
- b, err := Marshal(q)
- if err != nil {
- return "", err
- }
- return FieldQueryString(b), nil
-}
-
-type FieldQueryString string
-
-func (s FieldQueryString) Build() (*FieldQuery, error) {
- var query interface{}
- if err := Unmarshal([]byte(s), &query); err != nil {
- return nil, err
- }
- return s.build(reflect.ValueOf(query))
-}
-
-func (s FieldQueryString) build(v reflect.Value) (*FieldQuery, error) {
- switch v.Type().Kind() {
- case reflect.String:
- return s.buildString(v)
- case reflect.Map:
- return s.buildMap(v)
- case reflect.Slice:
- return s.buildSlice(v)
- case reflect.Interface:
- return s.build(reflect.ValueOf(v.Interface()))
- }
- return nil, fmt.Errorf("failed to build field query")
-}
-
-func (s FieldQueryString) buildString(v reflect.Value) (*FieldQuery, error) {
- b := []byte(v.String())
- switch b[0] {
- case '[', '{':
- var query interface{}
- if err := Unmarshal(b, &query); err != nil {
- return nil, err
- }
- if str, ok := query.(string); ok {
- return &FieldQuery{Name: str}, nil
- }
- return s.build(reflect.ValueOf(query))
- }
- return &FieldQuery{Name: string(b)}, nil
-}
-
-func (s FieldQueryString) buildSlice(v reflect.Value) (*FieldQuery, error) {
- fields := make([]*FieldQuery, 0, v.Len())
- for i := 0; i < v.Len(); i++ {
- def, err := s.build(v.Index(i))
- if err != nil {
- return nil, err
- }
- fields = append(fields, def)
- }
- return &FieldQuery{Fields: fields}, nil
-}
-
-func (s FieldQueryString) buildMap(v reflect.Value) (*FieldQuery, error) {
- keys := v.MapKeys()
- if len(keys) != 1 {
- return nil, fmt.Errorf("failed to build field query object")
- }
- key := keys[0]
- if key.Type().Kind() != reflect.String {
- return nil, fmt.Errorf("failed to build field query. invalid object key type")
- }
- name := key.String()
- def, err := s.build(v.MapIndex(key))
- if err != nil {
- return nil, err
- }
- return &FieldQuery{
- Name: name,
- Fields: def.Fields,
- }, nil
-}
-
-type queryKey struct{}
-
-func FieldQueryFromContext(ctx context.Context) *FieldQuery {
- query := ctx.Value(queryKey{})
- if query == nil {
- return nil
- }
- q, ok := query.(*FieldQuery)
- if !ok {
- return nil
- }
- return q
-}
-
-func SetFieldQueryToContext(ctx context.Context, query *FieldQuery) context.Context {
- return context.WithValue(ctx, queryKey{}, query)
-}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/string.go b/vendor/github.com/goccy/go-json/internal/encoder/string.go
index 4abb841..a699dba 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/string.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/string.go
@@ -1,32 +1,9 @@
-// This files's string processing codes are inspired by https://github.com/segmentio/encoding.
-// The license notation is as follows.
-//
-// # MIT License
-//
-// Copyright (c) 2019 Segment.io, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
package encoder
import (
"math/bits"
"reflect"
+ "unicode/utf8"
"unsafe"
)
@@ -35,8 +12,390 @@ const (
msb = 0x8080808080808080
)
+var needEscapeWithHTML = [256]bool{
+ '"': true,
+ '&': true,
+ '<': true,
+ '>': true,
+ '\\': true,
+ 0x00: true,
+ 0x01: true,
+ 0x02: true,
+ 0x03: true,
+ 0x04: true,
+ 0x05: true,
+ 0x06: true,
+ 0x07: true,
+ 0x08: true,
+ 0x09: true,
+ 0x0a: true,
+ 0x0b: true,
+ 0x0c: true,
+ 0x0d: true,
+ 0x0e: true,
+ 0x0f: true,
+ 0x10: true,
+ 0x11: true,
+ 0x12: true,
+ 0x13: true,
+ 0x14: true,
+ 0x15: true,
+ 0x16: true,
+ 0x17: true,
+ 0x18: true,
+ 0x19: true,
+ 0x1a: true,
+ 0x1b: true,
+ 0x1c: true,
+ 0x1d: true,
+ 0x1e: true,
+ 0x1f: true,
+ /* 0x20 - 0x7f */
+ 0x80: true,
+ 0x81: true,
+ 0x82: true,
+ 0x83: true,
+ 0x84: true,
+ 0x85: true,
+ 0x86: true,
+ 0x87: true,
+ 0x88: true,
+ 0x89: true,
+ 0x8a: true,
+ 0x8b: true,
+ 0x8c: true,
+ 0x8d: true,
+ 0x8e: true,
+ 0x8f: true,
+ 0x90: true,
+ 0x91: true,
+ 0x92: true,
+ 0x93: true,
+ 0x94: true,
+ 0x95: true,
+ 0x96: true,
+ 0x97: true,
+ 0x98: true,
+ 0x99: true,
+ 0x9a: true,
+ 0x9b: true,
+ 0x9c: true,
+ 0x9d: true,
+ 0x9e: true,
+ 0x9f: true,
+ 0xa0: true,
+ 0xa1: true,
+ 0xa2: true,
+ 0xa3: true,
+ 0xa4: true,
+ 0xa5: true,
+ 0xa6: true,
+ 0xa7: true,
+ 0xa8: true,
+ 0xa9: true,
+ 0xaa: true,
+ 0xab: true,
+ 0xac: true,
+ 0xad: true,
+ 0xae: true,
+ 0xaf: true,
+ 0xb0: true,
+ 0xb1: true,
+ 0xb2: true,
+ 0xb3: true,
+ 0xb4: true,
+ 0xb5: true,
+ 0xb6: true,
+ 0xb7: true,
+ 0xb8: true,
+ 0xb9: true,
+ 0xba: true,
+ 0xbb: true,
+ 0xbc: true,
+ 0xbd: true,
+ 0xbe: true,
+ 0xbf: true,
+ 0xc0: true,
+ 0xc1: true,
+ 0xc2: true,
+ 0xc3: true,
+ 0xc4: true,
+ 0xc5: true,
+ 0xc6: true,
+ 0xc7: true,
+ 0xc8: true,
+ 0xc9: true,
+ 0xca: true,
+ 0xcb: true,
+ 0xcc: true,
+ 0xcd: true,
+ 0xce: true,
+ 0xcf: true,
+ 0xd0: true,
+ 0xd1: true,
+ 0xd2: true,
+ 0xd3: true,
+ 0xd4: true,
+ 0xd5: true,
+ 0xd6: true,
+ 0xd7: true,
+ 0xd8: true,
+ 0xd9: true,
+ 0xda: true,
+ 0xdb: true,
+ 0xdc: true,
+ 0xdd: true,
+ 0xde: true,
+ 0xdf: true,
+ 0xe0: true,
+ 0xe1: true,
+ 0xe2: true,
+ 0xe3: true,
+ 0xe4: true,
+ 0xe5: true,
+ 0xe6: true,
+ 0xe7: true,
+ 0xe8: true,
+ 0xe9: true,
+ 0xea: true,
+ 0xeb: true,
+ 0xec: true,
+ 0xed: true,
+ 0xee: true,
+ 0xef: true,
+ 0xf0: true,
+ 0xf1: true,
+ 0xf2: true,
+ 0xf3: true,
+ 0xf4: true,
+ 0xf5: true,
+ 0xf6: true,
+ 0xf7: true,
+ 0xf8: true,
+ 0xf9: true,
+ 0xfa: true,
+ 0xfb: true,
+ 0xfc: true,
+ 0xfd: true,
+ 0xfe: true,
+ 0xff: true,
+}
+
+var needEscape = [256]bool{
+ '"': true,
+ '\\': true,
+ 0x00: true,
+ 0x01: true,
+ 0x02: true,
+ 0x03: true,
+ 0x04: true,
+ 0x05: true,
+ 0x06: true,
+ 0x07: true,
+ 0x08: true,
+ 0x09: true,
+ 0x0a: true,
+ 0x0b: true,
+ 0x0c: true,
+ 0x0d: true,
+ 0x0e: true,
+ 0x0f: true,
+ 0x10: true,
+ 0x11: true,
+ 0x12: true,
+ 0x13: true,
+ 0x14: true,
+ 0x15: true,
+ 0x16: true,
+ 0x17: true,
+ 0x18: true,
+ 0x19: true,
+ 0x1a: true,
+ 0x1b: true,
+ 0x1c: true,
+ 0x1d: true,
+ 0x1e: true,
+ 0x1f: true,
+ /* 0x20 - 0x7f */
+ 0x80: true,
+ 0x81: true,
+ 0x82: true,
+ 0x83: true,
+ 0x84: true,
+ 0x85: true,
+ 0x86: true,
+ 0x87: true,
+ 0x88: true,
+ 0x89: true,
+ 0x8a: true,
+ 0x8b: true,
+ 0x8c: true,
+ 0x8d: true,
+ 0x8e: true,
+ 0x8f: true,
+ 0x90: true,
+ 0x91: true,
+ 0x92: true,
+ 0x93: true,
+ 0x94: true,
+ 0x95: true,
+ 0x96: true,
+ 0x97: true,
+ 0x98: true,
+ 0x99: true,
+ 0x9a: true,
+ 0x9b: true,
+ 0x9c: true,
+ 0x9d: true,
+ 0x9e: true,
+ 0x9f: true,
+ 0xa0: true,
+ 0xa1: true,
+ 0xa2: true,
+ 0xa3: true,
+ 0xa4: true,
+ 0xa5: true,
+ 0xa6: true,
+ 0xa7: true,
+ 0xa8: true,
+ 0xa9: true,
+ 0xaa: true,
+ 0xab: true,
+ 0xac: true,
+ 0xad: true,
+ 0xae: true,
+ 0xaf: true,
+ 0xb0: true,
+ 0xb1: true,
+ 0xb2: true,
+ 0xb3: true,
+ 0xb4: true,
+ 0xb5: true,
+ 0xb6: true,
+ 0xb7: true,
+ 0xb8: true,
+ 0xb9: true,
+ 0xba: true,
+ 0xbb: true,
+ 0xbc: true,
+ 0xbd: true,
+ 0xbe: true,
+ 0xbf: true,
+ 0xc0: true,
+ 0xc1: true,
+ 0xc2: true,
+ 0xc3: true,
+ 0xc4: true,
+ 0xc5: true,
+ 0xc6: true,
+ 0xc7: true,
+ 0xc8: true,
+ 0xc9: true,
+ 0xca: true,
+ 0xcb: true,
+ 0xcc: true,
+ 0xcd: true,
+ 0xce: true,
+ 0xcf: true,
+ 0xd0: true,
+ 0xd1: true,
+ 0xd2: true,
+ 0xd3: true,
+ 0xd4: true,
+ 0xd5: true,
+ 0xd6: true,
+ 0xd7: true,
+ 0xd8: true,
+ 0xd9: true,
+ 0xda: true,
+ 0xdb: true,
+ 0xdc: true,
+ 0xdd: true,
+ 0xde: true,
+ 0xdf: true,
+ 0xe0: true,
+ 0xe1: true,
+ 0xe2: true,
+ 0xe3: true,
+ 0xe4: true,
+ 0xe5: true,
+ 0xe6: true,
+ 0xe7: true,
+ 0xe8: true,
+ 0xe9: true,
+ 0xea: true,
+ 0xeb: true,
+ 0xec: true,
+ 0xed: true,
+ 0xee: true,
+ 0xef: true,
+ 0xf0: true,
+ 0xf1: true,
+ 0xf2: true,
+ 0xf3: true,
+ 0xf4: true,
+ 0xf5: true,
+ 0xf6: true,
+ 0xf7: true,
+ 0xf8: true,
+ 0xf9: true,
+ 0xfa: true,
+ 0xfb: true,
+ 0xfc: true,
+ 0xfd: true,
+ 0xfe: true,
+ 0xff: true,
+}
+
var hex = "0123456789abcdef"
+// escapeIndex finds the index of the first char in `s` that requires escaping.
+// A char requires escaping if it's outside of the range of [0x20, 0x7F] or if
+// it includes a double quote or backslash.
+// If no chars in `s` require escaping, the return value is -1.
+func escapeIndex(s string) int {
+ chunks := stringToUint64Slice(s)
+ for _, n := range chunks {
+ // combine masks before checking for the MSB of each byte. We include
+ // `n` in the mask to check whether any of the *input* byte MSBs were
+ // set (i.e. the byte was outside the ASCII range).
+ mask := n | below(n, 0x20) | contains(n, '"') | contains(n, '\\')
+ if (mask & msb) != 0 {
+ return bits.TrailingZeros64(mask&msb) / 8
+ }
+ }
+
+ valLen := len(s)
+ for i := len(chunks) * 8; i < valLen; i++ {
+ if needEscape[s[i]] {
+ return i
+ }
+ }
+
+ return -1
+}
+
+// below return a mask that can be used to determine if any of the bytes
+// in `n` are below `b`. If a byte's MSB is set in the mask then that byte was
+// below `b`. The result is only valid if `b`, and each byte in `n`, is below
+// 0x80.
+func below(n uint64, b byte) uint64 {
+ return n - expand(b)
+}
+
+// contains returns a mask that can be used to determine if any of the
+// bytes in `n` are equal to `b`. If a byte's MSB is set in the mask then
+// that byte is equal to `b`. The result is only valid if `b`, and each
+// byte in `n`, is below 0x80.
+func contains(n uint64, b byte) uint64 {
+ return (n ^ expand(b)) - lsb
+}
+
+// expand puts the specified byte into each of the 8 bytes of a uint64.
+func expand(b byte) uint64 {
+ return lsb * uint64(b)
+}
+
//nolint:govet
func stringToUint64Slice(s string) []uint64 {
return *(*[]uint64)(unsafe.Pointer(&reflect.SliceHeader{
@@ -47,19 +406,9 @@ func stringToUint64Slice(s string) []uint64 {
}
func AppendString(ctx *RuntimeContext, buf []byte, s string) []byte {
- if ctx.Option.Flag&HTMLEscapeOption != 0 {
- if ctx.Option.Flag&NormalizeUTF8Option != 0 {
- return appendNormalizedHTMLString(buf, s)
- }
- return appendHTMLString(buf, s)
+ if ctx.Option.Flag&HTMLEscapeOption == 0 {
+ return appendString(buf, s)
}
- if ctx.Option.Flag&NormalizeUTF8Option != 0 {
- return appendNormalizedString(buf, s)
- }
- return appendString(buf, s)
-}
-
-func appendNormalizedHTMLString(buf []byte, s string) []byte {
valLen := len(s)
if valLen == 0 {
return append(buf, `""`...)
@@ -86,7 +435,7 @@ func appendNormalizedHTMLString(buf []byte, s string) []byte {
}
}
for i := len(chunks) * 8; i < valLen; i++ {
- if needEscapeHTMLNormalizeUTF8[s[i]] {
+ if needEscapeWithHTML[s[i]] {
j = i
goto ESCAPE_END
}
@@ -98,7 +447,7 @@ ESCAPE_END:
for j < valLen {
c := s[j]
- if !needEscapeHTMLNormalizeUTF8[c] {
+ if !needEscapeWithHTML[c] {
// fast path: most of the time, printable ascii characters are used
j++
continue
@@ -140,9 +489,10 @@ ESCAPE_END:
i = j + 1
j = j + 1
continue
+ }
- case 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x0B, 0x0C, 0x0E, 0x0F, // 0x00-0x0F
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F: // 0x10-0x1F
+ // This encodes bytes < 0x20 except for \t, \n and \r.
+ if c < 0x20 {
buf = append(buf, s[i:j]...)
buf = append(buf, `\u00`...)
buf = append(buf, hex[c>>4], hex[c&0xF])
@@ -150,14 +500,19 @@ ESCAPE_END:
j = j + 1
continue
}
- state, size := decodeRuneInString(s[j:])
- switch state {
- case runeErrorState:
+
+ r, size := utf8.DecodeRuneInString(s[j:])
+
+ if r == utf8.RuneError && size == 1 {
buf = append(buf, s[i:j]...)
buf = append(buf, `\ufffd`...)
- i = j + 1
- j = j + 1
+ i = j + size
+ j = j + size
continue
+ }
+
+ switch r {
+ case '\u2028', '\u2029':
// U+2028 is LINE SEPARATOR.
// U+2029 is PARAGRAPH SEPARATOR.
// They are both technically valid characters in JSON strings,
@@ -165,231 +520,14 @@ ESCAPE_END:
// and can lead to security holes there. It is valid JSON to
// escape them, so we do so unconditionally.
// See http://timelessrepo.com/json-isnt-a-javascript-subset for discussion.
- case lineSepState:
buf = append(buf, s[i:j]...)
- buf = append(buf, `\u2028`...)
- i = j + 3
- j = j + 3
- continue
- case paragraphSepState:
- buf = append(buf, s[i:j]...)
- buf = append(buf, `\u2029`...)
- i = j + 3
- j = j + 3
- continue
- }
- j += size
- }
-
- return append(append(buf, s[i:]...), '"')
-}
-
-func appendHTMLString(buf []byte, s string) []byte {
- valLen := len(s)
- if valLen == 0 {
- return append(buf, `""`...)
- }
- buf = append(buf, '"')
- var (
- i, j int
- )
- if valLen >= 8 {
- chunks := stringToUint64Slice(s)
- for _, n := range chunks {
- // combine masks before checking for the MSB of each byte. We include
- // `n` in the mask to check whether any of the *input* byte MSBs were
- // set (i.e. the byte was outside the ASCII range).
- mask := n | (n - (lsb * 0x20)) |
- ((n ^ (lsb * '"')) - lsb) |
- ((n ^ (lsb * '\\')) - lsb) |
- ((n ^ (lsb * '<')) - lsb) |
- ((n ^ (lsb * '>')) - lsb) |
- ((n ^ (lsb * '&')) - lsb)
- if (mask & msb) != 0 {
- j = bits.TrailingZeros64(mask&msb) / 8
- goto ESCAPE_END
- }
- }
- for i := len(chunks) * 8; i < valLen; i++ {
- if needEscapeHTML[s[i]] {
- j = i
- goto ESCAPE_END
- }
- }
- // no found any escape characters.
- return append(append(buf, s...), '"')
- }
-ESCAPE_END:
- for j < valLen {
- c := s[j]
-
- if !needEscapeHTML[c] {
- // fast path: most of the time, printable ascii characters are used
- j++
+ buf = append(buf, `\u202`...)
+ buf = append(buf, hex[r&0xF])
+ i = j + size
+ j = j + size
continue
}
- switch c {
- case '\\', '"':
- buf = append(buf, s[i:j]...)
- buf = append(buf, '\\', c)
- i = j + 1
- j = j + 1
- continue
-
- case '\n':
- buf = append(buf, s[i:j]...)
- buf = append(buf, '\\', 'n')
- i = j + 1
- j = j + 1
- continue
-
- case '\r':
- buf = append(buf, s[i:j]...)
- buf = append(buf, '\\', 'r')
- i = j + 1
- j = j + 1
- continue
-
- case '\t':
- buf = append(buf, s[i:j]...)
- buf = append(buf, '\\', 't')
- i = j + 1
- j = j + 1
- continue
-
- case '<', '>', '&':
- buf = append(buf, s[i:j]...)
- buf = append(buf, `\u00`...)
- buf = append(buf, hex[c>>4], hex[c&0xF])
- i = j + 1
- j = j + 1
- continue
-
- case 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x0B, 0x0C, 0x0E, 0x0F, // 0x00-0x0F
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F: // 0x10-0x1F
- buf = append(buf, s[i:j]...)
- buf = append(buf, `\u00`...)
- buf = append(buf, hex[c>>4], hex[c&0xF])
- i = j + 1
- j = j + 1
- continue
- }
- j++
- }
-
- return append(append(buf, s[i:]...), '"')
-}
-
-func appendNormalizedString(buf []byte, s string) []byte {
- valLen := len(s)
- if valLen == 0 {
- return append(buf, `""`...)
- }
- buf = append(buf, '"')
- var (
- i, j int
- )
- if valLen >= 8 {
- chunks := stringToUint64Slice(s)
- for _, n := range chunks {
- // combine masks before checking for the MSB of each byte. We include
- // `n` in the mask to check whether any of the *input* byte MSBs were
- // set (i.e. the byte was outside the ASCII range).
- mask := n | (n - (lsb * 0x20)) |
- ((n ^ (lsb * '"')) - lsb) |
- ((n ^ (lsb * '\\')) - lsb)
- if (mask & msb) != 0 {
- j = bits.TrailingZeros64(mask&msb) / 8
- goto ESCAPE_END
- }
- }
- valLen := len(s)
- for i := len(chunks) * 8; i < valLen; i++ {
- if needEscapeNormalizeUTF8[s[i]] {
- j = i
- goto ESCAPE_END
- }
- }
- return append(append(buf, s...), '"')
- }
-ESCAPE_END:
- for j < valLen {
- c := s[j]
-
- if !needEscapeNormalizeUTF8[c] {
- // fast path: most of the time, printable ascii characters are used
- j++
- continue
- }
-
- switch c {
- case '\\', '"':
- buf = append(buf, s[i:j]...)
- buf = append(buf, '\\', c)
- i = j + 1
- j = j + 1
- continue
-
- case '\n':
- buf = append(buf, s[i:j]...)
- buf = append(buf, '\\', 'n')
- i = j + 1
- j = j + 1
- continue
-
- case '\r':
- buf = append(buf, s[i:j]...)
- buf = append(buf, '\\', 'r')
- i = j + 1
- j = j + 1
- continue
-
- case '\t':
- buf = append(buf, s[i:j]...)
- buf = append(buf, '\\', 't')
- i = j + 1
- j = j + 1
- continue
-
- case 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x0B, 0x0C, 0x0E, 0x0F, // 0x00-0x0F
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F: // 0x10-0x1F
- buf = append(buf, s[i:j]...)
- buf = append(buf, `\u00`...)
- buf = append(buf, hex[c>>4], hex[c&0xF])
- i = j + 1
- j = j + 1
- continue
- }
-
- state, size := decodeRuneInString(s[j:])
- switch state {
- case runeErrorState:
- buf = append(buf, s[i:j]...)
- buf = append(buf, `\ufffd`...)
- i = j + 1
- j = j + 1
- continue
- // U+2028 is LINE SEPARATOR.
- // U+2029 is PARAGRAPH SEPARATOR.
- // They are both technically valid characters in JSON strings,
- // but don't work in JSONP, which has to be evaluated as JavaScript,
- // and can lead to security holes there. It is valid JSON to
- // escape them, so we do so unconditionally.
- // See http://timelessrepo.com/json-isnt-a-javascript-subset for discussion.
- case lineSepState:
- buf = append(buf, s[i:j]...)
- buf = append(buf, `\u2028`...)
- i = j + 3
- j = j + 3
- continue
- case paragraphSepState:
- buf = append(buf, s[i:j]...)
- buf = append(buf, `\u2029`...)
- i = j + 3
- j = j + 3
- continue
- }
j += size
}
@@ -402,37 +540,19 @@ func appendString(buf []byte, s string) []byte {
return append(buf, `""`...)
}
buf = append(buf, '"')
- var (
- i, j int
- )
+ var escapeIdx int
if valLen >= 8 {
- chunks := stringToUint64Slice(s)
- for _, n := range chunks {
- // combine masks before checking for the MSB of each byte. We include
- // `n` in the mask to check whether any of the *input* byte MSBs were
- // set (i.e. the byte was outside the ASCII range).
- mask := n | (n - (lsb * 0x20)) |
- ((n ^ (lsb * '"')) - lsb) |
- ((n ^ (lsb * '\\')) - lsb)
- if (mask & msb) != 0 {
- j = bits.TrailingZeros64(mask&msb) / 8
- goto ESCAPE_END
- }
+ if escapeIdx = escapeIndex(s); escapeIdx < 0 {
+ return append(append(buf, s...), '"')
}
- valLen := len(s)
- for i := len(chunks) * 8; i < valLen; i++ {
- if needEscape[s[i]] {
- j = i
- goto ESCAPE_END
- }
- }
- return append(append(buf, s...), '"')
}
-ESCAPE_END:
+
+ i := 0
+ j := escapeIdx
for j < valLen {
c := s[j]
- if !needEscape[c] {
+ if c >= 0x20 && c <= 0x7f && c != '\\' && c != '"' {
// fast path: most of the time, printable ascii characters are used
j++
continue
@@ -467,8 +587,7 @@ ESCAPE_END:
j = j + 1
continue
- case 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x0B, 0x0C, 0x0E, 0x0F, // 0x00-0x0F
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F: // 0x10-0x1F
+ case '<', '>', '&':
buf = append(buf, s[i:j]...)
buf = append(buf, `\u00`...)
buf = append(buf, hex[c>>4], hex[c&0xF])
@@ -476,7 +595,45 @@ ESCAPE_END:
j = j + 1
continue
}
- j++
+
+ // This encodes bytes < 0x20 except for \t, \n and \r.
+ if c < 0x20 {
+ buf = append(buf, s[i:j]...)
+ buf = append(buf, `\u00`...)
+ buf = append(buf, hex[c>>4], hex[c&0xF])
+ i = j + 1
+ j = j + 1
+ continue
+ }
+
+ r, size := utf8.DecodeRuneInString(s[j:])
+
+ if r == utf8.RuneError && size == 1 {
+ buf = append(buf, s[i:j]...)
+ buf = append(buf, `\ufffd`...)
+ i = j + size
+ j = j + size
+ continue
+ }
+
+ switch r {
+ case '\u2028', '\u2029':
+ // U+2028 is LINE SEPARATOR.
+ // U+2029 is PARAGRAPH SEPARATOR.
+ // They are both technically valid characters in JSON strings,
+ // but don't work in JSONP, which has to be evaluated as JavaScript,
+ // and can lead to security holes there. It is valid JSON to
+ // escape them, so we do so unconditionally.
+ // See http://timelessrepo.com/json-isnt-a-javascript-subset for discussion.
+ buf = append(buf, s[i:j]...)
+ buf = append(buf, `\u202`...)
+ buf = append(buf, hex[r&0xF])
+ i = j + size
+ j = j + size
+ continue
+ }
+
+ j += size
}
return append(append(buf, s[i:]...), '"')
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/string_table.go b/vendor/github.com/goccy/go-json/internal/encoder/string_table.go
deleted file mode 100644
index ebe42c9..0000000
--- a/vendor/github.com/goccy/go-json/internal/encoder/string_table.go
+++ /dev/null
@@ -1,415 +0,0 @@
-package encoder
-
-var needEscapeHTMLNormalizeUTF8 = [256]bool{
- '"': true,
- '&': true,
- '<': true,
- '>': true,
- '\\': true,
- 0x00: true,
- 0x01: true,
- 0x02: true,
- 0x03: true,
- 0x04: true,
- 0x05: true,
- 0x06: true,
- 0x07: true,
- 0x08: true,
- 0x09: true,
- 0x0a: true,
- 0x0b: true,
- 0x0c: true,
- 0x0d: true,
- 0x0e: true,
- 0x0f: true,
- 0x10: true,
- 0x11: true,
- 0x12: true,
- 0x13: true,
- 0x14: true,
- 0x15: true,
- 0x16: true,
- 0x17: true,
- 0x18: true,
- 0x19: true,
- 0x1a: true,
- 0x1b: true,
- 0x1c: true,
- 0x1d: true,
- 0x1e: true,
- 0x1f: true,
- /* 0x20 - 0x7f */
- 0x80: true,
- 0x81: true,
- 0x82: true,
- 0x83: true,
- 0x84: true,
- 0x85: true,
- 0x86: true,
- 0x87: true,
- 0x88: true,
- 0x89: true,
- 0x8a: true,
- 0x8b: true,
- 0x8c: true,
- 0x8d: true,
- 0x8e: true,
- 0x8f: true,
- 0x90: true,
- 0x91: true,
- 0x92: true,
- 0x93: true,
- 0x94: true,
- 0x95: true,
- 0x96: true,
- 0x97: true,
- 0x98: true,
- 0x99: true,
- 0x9a: true,
- 0x9b: true,
- 0x9c: true,
- 0x9d: true,
- 0x9e: true,
- 0x9f: true,
- 0xa0: true,
- 0xa1: true,
- 0xa2: true,
- 0xa3: true,
- 0xa4: true,
- 0xa5: true,
- 0xa6: true,
- 0xa7: true,
- 0xa8: true,
- 0xa9: true,
- 0xaa: true,
- 0xab: true,
- 0xac: true,
- 0xad: true,
- 0xae: true,
- 0xaf: true,
- 0xb0: true,
- 0xb1: true,
- 0xb2: true,
- 0xb3: true,
- 0xb4: true,
- 0xb5: true,
- 0xb6: true,
- 0xb7: true,
- 0xb8: true,
- 0xb9: true,
- 0xba: true,
- 0xbb: true,
- 0xbc: true,
- 0xbd: true,
- 0xbe: true,
- 0xbf: true,
- 0xc0: true,
- 0xc1: true,
- 0xc2: true,
- 0xc3: true,
- 0xc4: true,
- 0xc5: true,
- 0xc6: true,
- 0xc7: true,
- 0xc8: true,
- 0xc9: true,
- 0xca: true,
- 0xcb: true,
- 0xcc: true,
- 0xcd: true,
- 0xce: true,
- 0xcf: true,
- 0xd0: true,
- 0xd1: true,
- 0xd2: true,
- 0xd3: true,
- 0xd4: true,
- 0xd5: true,
- 0xd6: true,
- 0xd7: true,
- 0xd8: true,
- 0xd9: true,
- 0xda: true,
- 0xdb: true,
- 0xdc: true,
- 0xdd: true,
- 0xde: true,
- 0xdf: true,
- 0xe0: true,
- 0xe1: true,
- 0xe2: true,
- 0xe3: true,
- 0xe4: true,
- 0xe5: true,
- 0xe6: true,
- 0xe7: true,
- 0xe8: true,
- 0xe9: true,
- 0xea: true,
- 0xeb: true,
- 0xec: true,
- 0xed: true,
- 0xee: true,
- 0xef: true,
- 0xf0: true,
- 0xf1: true,
- 0xf2: true,
- 0xf3: true,
- 0xf4: true,
- 0xf5: true,
- 0xf6: true,
- 0xf7: true,
- 0xf8: true,
- 0xf9: true,
- 0xfa: true,
- 0xfb: true,
- 0xfc: true,
- 0xfd: true,
- 0xfe: true,
- 0xff: true,
-}
-
-var needEscapeNormalizeUTF8 = [256]bool{
- '"': true,
- '\\': true,
- 0x00: true,
- 0x01: true,
- 0x02: true,
- 0x03: true,
- 0x04: true,
- 0x05: true,
- 0x06: true,
- 0x07: true,
- 0x08: true,
- 0x09: true,
- 0x0a: true,
- 0x0b: true,
- 0x0c: true,
- 0x0d: true,
- 0x0e: true,
- 0x0f: true,
- 0x10: true,
- 0x11: true,
- 0x12: true,
- 0x13: true,
- 0x14: true,
- 0x15: true,
- 0x16: true,
- 0x17: true,
- 0x18: true,
- 0x19: true,
- 0x1a: true,
- 0x1b: true,
- 0x1c: true,
- 0x1d: true,
- 0x1e: true,
- 0x1f: true,
- /* 0x20 - 0x7f */
- 0x80: true,
- 0x81: true,
- 0x82: true,
- 0x83: true,
- 0x84: true,
- 0x85: true,
- 0x86: true,
- 0x87: true,
- 0x88: true,
- 0x89: true,
- 0x8a: true,
- 0x8b: true,
- 0x8c: true,
- 0x8d: true,
- 0x8e: true,
- 0x8f: true,
- 0x90: true,
- 0x91: true,
- 0x92: true,
- 0x93: true,
- 0x94: true,
- 0x95: true,
- 0x96: true,
- 0x97: true,
- 0x98: true,
- 0x99: true,
- 0x9a: true,
- 0x9b: true,
- 0x9c: true,
- 0x9d: true,
- 0x9e: true,
- 0x9f: true,
- 0xa0: true,
- 0xa1: true,
- 0xa2: true,
- 0xa3: true,
- 0xa4: true,
- 0xa5: true,
- 0xa6: true,
- 0xa7: true,
- 0xa8: true,
- 0xa9: true,
- 0xaa: true,
- 0xab: true,
- 0xac: true,
- 0xad: true,
- 0xae: true,
- 0xaf: true,
- 0xb0: true,
- 0xb1: true,
- 0xb2: true,
- 0xb3: true,
- 0xb4: true,
- 0xb5: true,
- 0xb6: true,
- 0xb7: true,
- 0xb8: true,
- 0xb9: true,
- 0xba: true,
- 0xbb: true,
- 0xbc: true,
- 0xbd: true,
- 0xbe: true,
- 0xbf: true,
- 0xc0: true,
- 0xc1: true,
- 0xc2: true,
- 0xc3: true,
- 0xc4: true,
- 0xc5: true,
- 0xc6: true,
- 0xc7: true,
- 0xc8: true,
- 0xc9: true,
- 0xca: true,
- 0xcb: true,
- 0xcc: true,
- 0xcd: true,
- 0xce: true,
- 0xcf: true,
- 0xd0: true,
- 0xd1: true,
- 0xd2: true,
- 0xd3: true,
- 0xd4: true,
- 0xd5: true,
- 0xd6: true,
- 0xd7: true,
- 0xd8: true,
- 0xd9: true,
- 0xda: true,
- 0xdb: true,
- 0xdc: true,
- 0xdd: true,
- 0xde: true,
- 0xdf: true,
- 0xe0: true,
- 0xe1: true,
- 0xe2: true,
- 0xe3: true,
- 0xe4: true,
- 0xe5: true,
- 0xe6: true,
- 0xe7: true,
- 0xe8: true,
- 0xe9: true,
- 0xea: true,
- 0xeb: true,
- 0xec: true,
- 0xed: true,
- 0xee: true,
- 0xef: true,
- 0xf0: true,
- 0xf1: true,
- 0xf2: true,
- 0xf3: true,
- 0xf4: true,
- 0xf5: true,
- 0xf6: true,
- 0xf7: true,
- 0xf8: true,
- 0xf9: true,
- 0xfa: true,
- 0xfb: true,
- 0xfc: true,
- 0xfd: true,
- 0xfe: true,
- 0xff: true,
-}
-
-var needEscapeHTML = [256]bool{
- '"': true,
- '&': true,
- '<': true,
- '>': true,
- '\\': true,
- 0x00: true,
- 0x01: true,
- 0x02: true,
- 0x03: true,
- 0x04: true,
- 0x05: true,
- 0x06: true,
- 0x07: true,
- 0x08: true,
- 0x09: true,
- 0x0a: true,
- 0x0b: true,
- 0x0c: true,
- 0x0d: true,
- 0x0e: true,
- 0x0f: true,
- 0x10: true,
- 0x11: true,
- 0x12: true,
- 0x13: true,
- 0x14: true,
- 0x15: true,
- 0x16: true,
- 0x17: true,
- 0x18: true,
- 0x19: true,
- 0x1a: true,
- 0x1b: true,
- 0x1c: true,
- 0x1d: true,
- 0x1e: true,
- 0x1f: true,
- /* 0x20 - 0xff */
-}
-
-var needEscape = [256]bool{
- '"': true,
- '\\': true,
- 0x00: true,
- 0x01: true,
- 0x02: true,
- 0x03: true,
- 0x04: true,
- 0x05: true,
- 0x06: true,
- 0x07: true,
- 0x08: true,
- 0x09: true,
- 0x0a: true,
- 0x0b: true,
- 0x0c: true,
- 0x0d: true,
- 0x0e: true,
- 0x0f: true,
- 0x10: true,
- 0x11: true,
- 0x12: true,
- 0x13: true,
- 0x14: true,
- 0x15: true,
- 0x16: true,
- 0x17: true,
- 0x18: true,
- 0x19: true,
- 0x1a: true,
- 0x1b: true,
- 0x1c: true,
- 0x1d: true,
- 0x1e: true,
- 0x1f: true,
- /* 0x20 - 0xff */
-}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go
index 82b6dd4..05509fe 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go
@@ -2,7 +2,6 @@ package vm
import (
"fmt"
- "io"
"github.com/goccy/go-json/internal/encoder"
)
@@ -15,24 +14,18 @@ func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet)
} else {
code = codeSet.NoescapeKeyCode
}
- if wc := ctx.Option.DebugDOTOut; wc != nil {
- _, _ = io.WriteString(wc, code.DumpDOT())
- wc.Close()
- ctx.Option.DebugDOTOut = nil
- }
if err := recover(); err != nil {
- w := ctx.Option.DebugOut
- fmt.Fprintln(w, "=============[DEBUG]===============")
- fmt.Fprintln(w, "* [TYPE]")
- fmt.Fprintln(w, codeSet.Type)
- fmt.Fprintf(w, "\n")
- fmt.Fprintln(w, "* [ALL OPCODE]")
- fmt.Fprintln(w, code.Dump())
- fmt.Fprintf(w, "\n")
- fmt.Fprintln(w, "* [CONTEXT]")
- fmt.Fprintf(w, "%+v\n", ctx)
- fmt.Fprintln(w, "===================================")
+ fmt.Println("=============[DEBUG]===============")
+ fmt.Println("* [TYPE]")
+ fmt.Println(codeSet.Type)
+ fmt.Printf("\n")
+ fmt.Println("* [ALL OPCODE]")
+ fmt.Println(code.Dump())
+ fmt.Printf("\n")
+ fmt.Println("* [CONTEXT]")
+ fmt.Printf("%+v\n", ctx)
+ fmt.Println("===================================")
panic(err)
}
}()
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm/util.go
index 86291d7..f06f9c8 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm/util.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm/util.go
@@ -68,19 +68,7 @@ func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr {
return p
}
-func ptrToUint64(p uintptr, bitSize uint8) uint64 {
- switch bitSize {
- case 8:
- return (uint64)(**(**uint8)(unsafe.Pointer(&p)))
- case 16:
- return (uint64)(**(**uint16)(unsafe.Pointer(&p)))
- case 32:
- return (uint64)(**(**uint32)(unsafe.Pointer(&p)))
- case 64:
- return **(**uint64)(unsafe.Pointer(&p))
- }
- return 0
-}
+func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) }
func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) }
func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) }
func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) }
@@ -126,10 +114,6 @@ func appendComma(_ *encoder.RuntimeContext, b []byte) []byte {
return append(b, ',')
}
-func appendNullComma(_ *encoder.RuntimeContext, b []byte) []byte {
- return append(b, "null,"...)
-}
-
func appendColon(_ *encoder.RuntimeContext, b []byte) []byte {
last := len(b) - 1
b[last] = ':'
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go
index 645d20f..5857249 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go
@@ -3,7 +3,6 @@ package vm
import (
"math"
- "reflect"
"sort"
"unsafe"
@@ -33,38 +32,40 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpIntPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
store(ctxptr, code.Idx, p)
fallthrough
case encoder.OpInt:
- b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpUintPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
store(ctxptr, code.Idx, p)
fallthrough
case encoder.OpUint:
- b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpIntString:
b = append(b, '"')
- b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpUintString:
b = append(b, '"')
- b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -85,7 +86,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpFloat64Ptr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -102,7 +104,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStringPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -115,7 +118,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpBoolPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -128,7 +132,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpBytesPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -141,7 +146,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpNumberPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -157,7 +163,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpInterfacePtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -166,7 +173,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpInterface:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -186,24 +194,20 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr
- if iface.itab != nil {
- typ = iface.itab.typ
- }
+ typ = iface.itab.typ
} else {
iface := (*emptyInterface)(up)
ifacePtr = iface.ptr
typ = iface.typ
}
if ifacePtr == nil {
- isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
- if !isDirectedNil {
- b = appendNullComma(ctx, b)
- code = code.Next
- break
- }
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
+ code = code.Next
+ break
}
ctx.KeepRefs = append(ctx.KeepRefs, up)
- ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
+ ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
if err != nil {
return nil, err
}
@@ -222,7 +226,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
oldOffset := ptrOffset
ptrOffset += totalLength * uintptrSize
oldBaseIndent := ctx.BaseIndent
- ctx.BaseIndent += code.Indent
+ indentDiffFromTop := c.Indent - 1
+ ctx.BaseIndent += code.Indent - indentDiffFromTop
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
@@ -252,7 +257,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalJSONPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -261,7 +267,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -277,7 +284,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalTextPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -303,7 +311,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpSlicePtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -313,7 +322,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
slice := ptrToSlice(p)
if p == 0 || slice.Data == nil {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -346,7 +356,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpArrayPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -355,7 +366,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpArray:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -385,7 +397,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMapPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -394,7 +407,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMap:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -406,42 +420,48 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
break
}
b = appendStructHead(ctx, b)
- unorderedMap := (ctx.Option.Flag & encoder.UnorderedMapOption) != 0
- mapCtx := encoder.NewMapContext(mlen, unorderedMap)
- mapiterinit(code.Type, uptr, &mapCtx.Iter)
- store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
- ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
- if unorderedMap {
+ iter := mapiterinit(code.Type, uptr)
+ ctx.KeepRefs = append(ctx.KeepRefs, iter)
+ store(ctxptr, code.ElemIdx, 0)
+ store(ctxptr, code.Length, uintptr(mlen))
+ store(ctxptr, code.MapIter, uintptr(iter))
+ if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendMapKeyIndent(ctx, code.Next, b)
} else {
- mapCtx.Start = len(b)
- mapCtx.First = len(b)
+ mapCtx := encoder.NewMapContext(mlen)
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
+ ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
+ store(ctxptr, code.End.MapPos, uintptr(unsafe.Pointer(mapCtx)))
}
- key := mapiterkey(&mapCtx.Iter)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
case encoder.OpMapKey:
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
- idx := mapCtx.Idx
+ idx := load(ctxptr, code.ElemIdx)
+ length := load(ctxptr, code.Length)
idx++
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
- if idx < mapCtx.Len {
+ if idx < length {
b = appendMapKeyIndent(ctx, code, b)
- mapCtx.Idx = int(idx)
- key := mapiterkey(&mapCtx.Iter)
+ store(ctxptr, code.ElemIdx, idx)
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
b = appendObjectEnd(ctx, code, b)
- encoder.ReleaseMapContext(mapCtx)
code = code.End.Next
}
} else {
- mapCtx.Slice.Items[mapCtx.Idx].Value = b[mapCtx.Start:len(b)]
- if idx < mapCtx.Len {
- mapCtx.Idx = int(idx)
- mapCtx.Start = len(b)
- key := mapiterkey(&mapCtx.Iter)
+ ptr := load(ctxptr, code.End.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
+ if idx < length {
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ store(ctxptr, code.ElemIdx, idx)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
@@ -449,27 +469,46 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
}
case encoder.OpMapValue:
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b)
} else {
- mapCtx.Slice.Items[mapCtx.Idx].Key = b[mapCtx.Start:len(b)]
- mapCtx.Start = len(b)
+ ptr := load(ctxptr, code.End.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
}
- value := mapitervalue(&mapCtx.Iter)
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ value := mapitervalue(iter)
store(ctxptr, code.Next.Idx, uintptr(value))
- mapiternext(&mapCtx.Iter)
+ mapiternext(iter)
code = code.Next
case encoder.OpMapEnd:
// this operation only used by sorted map.
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
+ length := int(load(ctxptr, code.Length))
+ ptr := load(ctxptr, code.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ pos := mapCtx.Pos
+ for i := 0; i < length; i++ {
+ startKey := pos[i*2]
+ startValue := pos[i*2+1]
+ var endValue int
+ if i+1 < length {
+ endValue = pos[i*2+2]
+ } else {
+ endValue = len(b)
+ }
+ mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{
+ Key: b[startKey:startValue],
+ Value: b[startValue:endValue],
+ })
+ }
sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items {
buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value)
}
buf = appendMapEnd(ctx, code, buf)
- b = b[:mapCtx.First]
+ b = b[:pos[0]]
b = append(b, buf...)
mapCtx.Buf = buf
encoder.ReleaseMapContext(mapCtx)
@@ -531,7 +570,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -542,7 +582,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -562,7 +603,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -573,7 +615,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -594,7 +637,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -606,7 +650,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -615,7 +660,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyInt:
@@ -623,7 +668,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -635,7 +681,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -643,13 +690,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendComma(ctx, b)
code = code.Next
}
@@ -658,7 +705,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -670,7 +718,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -680,7 +729,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -689,7 +738,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -701,7 +751,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -709,15 +760,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
- u64 := ptrToUint64(p, code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -726,7 +776,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -737,7 +788,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -752,7 +804,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -760,7 +812,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -771,7 +824,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -784,7 +838,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -792,7 +846,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -803,7 +858,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -819,7 +875,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -828,7 +884,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -839,7 +896,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -853,7 +911,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -863,7 +921,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -875,7 +934,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -884,7 +944,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyUint:
@@ -892,7 +952,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -904,7 +965,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -912,13 +974,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendComma(ctx, b)
code = code.Next
}
@@ -927,7 +989,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -939,7 +1002,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -949,7 +1013,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -958,7 +1022,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -970,7 +1035,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -978,14 +1044,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -994,7 +1060,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1005,7 +1072,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1020,7 +1088,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -1028,7 +1096,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1039,7 +1108,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1052,7 +1122,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -1060,7 +1130,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1071,7 +1142,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1087,7 +1159,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -1096,7 +1168,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1107,7 +1180,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1121,7 +1195,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -1131,7 +1205,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1143,7 +1218,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1160,7 +1236,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1172,7 +1249,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1194,7 +1272,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1206,7 +1285,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1225,7 +1305,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1237,7 +1318,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1260,7 +1342,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1271,7 +1354,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1294,7 +1378,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1305,7 +1390,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1326,7 +1412,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1337,7 +1424,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1362,7 +1450,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1373,7 +1462,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1397,7 +1487,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1409,7 +1500,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1430,7 +1522,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1442,7 +1535,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1467,7 +1561,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1479,7 +1574,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1502,7 +1598,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1514,7 +1611,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1540,7 +1638,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1551,7 +1650,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1578,7 +1678,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1589,7 +1690,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1614,7 +1716,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1625,7 +1728,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1654,7 +1758,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1665,7 +1770,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1693,7 +1799,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1723,7 +1830,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1735,7 +1843,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1757,7 +1866,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1769,7 +1879,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1786,7 +1897,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1798,7 +1910,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1819,7 +1932,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1830,7 +1944,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1853,7 +1968,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1864,7 +1980,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1885,7 +2002,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1896,7 +2014,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1919,7 +2038,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1930,7 +2050,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1952,7 +2073,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1964,7 +2086,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1981,7 +2104,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1993,7 +2117,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2015,7 +2140,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2027,7 +2153,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2046,7 +2173,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2058,7 +2186,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2081,7 +2210,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2092,7 +2222,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2115,7 +2246,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2126,7 +2258,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2147,7 +2280,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2158,7 +2292,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2183,7 +2318,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2194,7 +2330,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2218,7 +2355,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2230,7 +2368,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2247,7 +2386,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2259,7 +2399,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2280,7 +2421,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2291,7 +2433,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2314,7 +2457,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2325,7 +2469,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2347,7 +2492,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2359,7 +2505,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2379,7 +2526,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2391,7 +2539,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2416,7 +2565,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2428,7 +2578,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2450,7 +2601,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2462,7 +2614,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2488,7 +2641,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2499,7 +2653,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2526,7 +2681,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2537,7 +2693,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2561,7 +2718,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2572,7 +2730,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2600,7 +2759,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2611,7 +2771,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2638,7 +2799,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2650,7 +2812,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2667,7 +2830,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2679,7 +2843,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2696,7 +2861,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2708,7 +2874,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2729,7 +2896,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2740,7 +2908,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2753,7 +2922,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
} else {
code = code.Next
@@ -2763,7 +2933,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2774,7 +2945,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2796,7 +2968,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2807,7 +2980,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2825,7 +2999,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2836,7 +3011,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2858,7 +3034,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2869,7 +3046,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2879,13 +3057,15 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
break
}
p = ptrToPtr(p + uintptr(code.Offset))
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
} else {
if (code.Flags & encoder.IndirectFlags) != 0 {
@@ -2898,7 +3078,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2909,7 +3090,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2936,7 +3118,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2949,7 +3132,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2958,10 +3142,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -2979,7 +3162,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2992,7 +3176,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3000,10 +3185,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
iface := ptrToInterface(code, p)
@@ -3023,7 +3207,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3034,7 +3219,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3061,7 +3247,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3072,7 +3259,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3099,7 +3287,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3112,7 +3301,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3121,10 +3311,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -3142,7 +3331,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3155,7 +3345,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3163,10 +3354,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -3185,7 +3375,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3196,7 +3387,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3223,7 +3415,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3234,7 +3427,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3277,16 +3471,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructFieldInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyInt:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3294,18 +3488,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyIntString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3317,7 +3511,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -3326,7 +3520,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3338,7 +3532,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -3349,7 +3543,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3357,16 +3551,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructFieldUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyUint:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3374,18 +3568,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyUintString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3397,7 +3591,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -3406,7 +3600,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3418,7 +3612,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -3429,7 +3623,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3565,7 +3759,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -4152,22 +4347,24 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next
store(ctxptr, code.Idx, p)
}
+ case encoder.OpStructAnonymousEnd:
+ code = code.Next
case encoder.OpStructEnd:
b = appendStructEndSkipLast(ctx, code, b)
code = code.Next
case encoder.OpStructEndInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyInt:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4177,18 +4374,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyIntString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4202,7 +4399,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendStructEnd(ctx, code, b)
code = code.Next
@@ -4211,7 +4408,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4225,7 +4422,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
@@ -4236,7 +4433,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4246,16 +4443,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructEndUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyUint:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4265,18 +4462,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyUintString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4290,7 +4487,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendStructEnd(ctx, code, b)
code = code.Next
@@ -4299,7 +4496,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4313,7 +4510,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
@@ -4324,7 +4521,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go
index 925f61e..6a6a33d 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go
@@ -16,17 +16,16 @@ func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet)
defer func() {
if err := recover(); err != nil {
- w := ctx.Option.DebugOut
- fmt.Fprintln(w, "=============[DEBUG]===============")
- fmt.Fprintln(w, "* [TYPE]")
- fmt.Fprintln(w, codeSet.Type)
- fmt.Fprintf(w, "\n")
- fmt.Fprintln(w, "* [ALL OPCODE]")
- fmt.Fprintln(w, code.Dump())
- fmt.Fprintf(w, "\n")
- fmt.Fprintln(w, "* [CONTEXT]")
- fmt.Fprintf(w, "%+v\n", ctx)
- fmt.Fprintln(w, "===================================")
+ fmt.Println("=============[DEBUG]===============")
+ fmt.Println("* [TYPE]")
+ fmt.Println(codeSet.Type)
+ fmt.Printf("\n")
+ fmt.Println("* [ALL OPCODE]")
+ fmt.Println(code.Dump())
+ fmt.Printf("\n")
+ fmt.Println("* [CONTEXT]")
+ fmt.Printf("%+v\n", ctx)
+ fmt.Println("===================================")
panic(err)
}
}()
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go
index 33f29ae..710087f 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go
@@ -61,19 +61,7 @@ func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr {
return p
}
-func ptrToUint64(p uintptr, bitSize uint8) uint64 {
- switch bitSize {
- case 8:
- return (uint64)(**(**uint8)(unsafe.Pointer(&p)))
- case 16:
- return (uint64)(**(**uint16)(unsafe.Pointer(&p)))
- case 32:
- return (uint64)(**(**uint32)(unsafe.Pointer(&p)))
- case 64:
- return **(**uint64)(unsafe.Pointer(&p))
- }
- return 0
-}
+func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) }
func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) }
func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) }
func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) }
@@ -104,17 +92,17 @@ func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} {
}))
}
-func appendInt(ctx *encoder.RuntimeContext, b []byte, p uintptr, code *encoder.Opcode) []byte {
+func appendInt(ctx *encoder.RuntimeContext, b []byte, v uint64, code *encoder.Opcode) []byte {
format := ctx.Option.ColorScheme.Int
b = append(b, format.Header...)
- b = encoder.AppendInt(ctx, b, p, code)
+ b = encoder.AppendInt(ctx, b, v, code)
return append(b, format.Footer...)
}
-func appendUint(ctx *encoder.RuntimeContext, b []byte, p uintptr, code *encoder.Opcode) []byte {
+func appendUint(ctx *encoder.RuntimeContext, b []byte, v uint64, code *encoder.Opcode) []byte {
format := ctx.Option.ColorScheme.Uint
b = append(b, format.Header...)
- b = encoder.AppendUint(ctx, b, p, code)
+ b = encoder.AppendUint(ctx, b, v, code)
return append(b, format.Footer...)
}
@@ -178,13 +166,6 @@ func appendComma(_ *encoder.RuntimeContext, b []byte) []byte {
return append(b, ',')
}
-func appendNullComma(ctx *encoder.RuntimeContext, b []byte) []byte {
- format := ctx.Option.ColorScheme.Null
- b = append(b, format.Header...)
- b = append(b, "null"...)
- return append(append(b, format.Footer...), ',')
-}
-
func appendColon(_ *encoder.RuntimeContext, b []byte) []byte {
last := len(b) - 1
b[last] = ':'
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go
index a63e83e..73af884 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go
@@ -3,7 +3,6 @@ package vm_color
import (
"math"
- "reflect"
"sort"
"unsafe"
@@ -33,38 +32,40 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpIntPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
store(ctxptr, code.Idx, p)
fallthrough
case encoder.OpInt:
- b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpUintPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
store(ctxptr, code.Idx, p)
fallthrough
case encoder.OpUint:
- b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpIntString:
b = append(b, '"')
- b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpUintString:
b = append(b, '"')
- b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -85,7 +86,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpFloat64Ptr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -102,7 +104,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStringPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -115,7 +118,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpBoolPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -128,7 +132,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpBytesPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -141,7 +146,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpNumberPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -157,7 +163,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpInterfacePtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -166,7 +173,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpInterface:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -186,24 +194,20 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr
- if iface.itab != nil {
- typ = iface.itab.typ
- }
+ typ = iface.itab.typ
} else {
iface := (*emptyInterface)(up)
ifacePtr = iface.ptr
typ = iface.typ
}
if ifacePtr == nil {
- isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
- if !isDirectedNil {
- b = appendNullComma(ctx, b)
- code = code.Next
- break
- }
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
+ code = code.Next
+ break
}
ctx.KeepRefs = append(ctx.KeepRefs, up)
- ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
+ ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
if err != nil {
return nil, err
}
@@ -222,7 +226,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
oldOffset := ptrOffset
ptrOffset += totalLength * uintptrSize
oldBaseIndent := ctx.BaseIndent
- ctx.BaseIndent += code.Indent
+ indentDiffFromTop := c.Indent - 1
+ ctx.BaseIndent += code.Indent - indentDiffFromTop
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
@@ -252,7 +257,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalJSONPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -261,7 +267,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -277,7 +284,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalTextPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -303,7 +311,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpSlicePtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -313,7 +322,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
slice := ptrToSlice(p)
if p == 0 || slice.Data == nil {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -346,7 +356,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpArrayPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -355,7 +366,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpArray:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -385,7 +397,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMapPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -394,7 +407,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMap:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -406,42 +420,48 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
break
}
b = appendStructHead(ctx, b)
- unorderedMap := (ctx.Option.Flag & encoder.UnorderedMapOption) != 0
- mapCtx := encoder.NewMapContext(mlen, unorderedMap)
- mapiterinit(code.Type, uptr, &mapCtx.Iter)
- store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
- ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
- if unorderedMap {
+ iter := mapiterinit(code.Type, uptr)
+ ctx.KeepRefs = append(ctx.KeepRefs, iter)
+ store(ctxptr, code.ElemIdx, 0)
+ store(ctxptr, code.Length, uintptr(mlen))
+ store(ctxptr, code.MapIter, uintptr(iter))
+ if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendMapKeyIndent(ctx, code.Next, b)
} else {
- mapCtx.Start = len(b)
- mapCtx.First = len(b)
+ mapCtx := encoder.NewMapContext(mlen)
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
+ ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
+ store(ctxptr, code.End.MapPos, uintptr(unsafe.Pointer(mapCtx)))
}
- key := mapiterkey(&mapCtx.Iter)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
case encoder.OpMapKey:
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
- idx := mapCtx.Idx
+ idx := load(ctxptr, code.ElemIdx)
+ length := load(ctxptr, code.Length)
idx++
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
- if idx < mapCtx.Len {
+ if idx < length {
b = appendMapKeyIndent(ctx, code, b)
- mapCtx.Idx = int(idx)
- key := mapiterkey(&mapCtx.Iter)
+ store(ctxptr, code.ElemIdx, idx)
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
b = appendObjectEnd(ctx, code, b)
- encoder.ReleaseMapContext(mapCtx)
code = code.End.Next
}
} else {
- mapCtx.Slice.Items[mapCtx.Idx].Value = b[mapCtx.Start:len(b)]
- if idx < mapCtx.Len {
- mapCtx.Idx = int(idx)
- mapCtx.Start = len(b)
- key := mapiterkey(&mapCtx.Iter)
+ ptr := load(ctxptr, code.End.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
+ if idx < length {
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ store(ctxptr, code.ElemIdx, idx)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
@@ -449,27 +469,46 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
}
case encoder.OpMapValue:
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b)
} else {
- mapCtx.Slice.Items[mapCtx.Idx].Key = b[mapCtx.Start:len(b)]
- mapCtx.Start = len(b)
+ ptr := load(ctxptr, code.End.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
}
- value := mapitervalue(&mapCtx.Iter)
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ value := mapitervalue(iter)
store(ctxptr, code.Next.Idx, uintptr(value))
- mapiternext(&mapCtx.Iter)
+ mapiternext(iter)
code = code.Next
case encoder.OpMapEnd:
// this operation only used by sorted map.
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
+ length := int(load(ctxptr, code.Length))
+ ptr := load(ctxptr, code.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ pos := mapCtx.Pos
+ for i := 0; i < length; i++ {
+ startKey := pos[i*2]
+ startValue := pos[i*2+1]
+ var endValue int
+ if i+1 < length {
+ endValue = pos[i*2+2]
+ } else {
+ endValue = len(b)
+ }
+ mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{
+ Key: b[startKey:startValue],
+ Value: b[startValue:endValue],
+ })
+ }
sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items {
buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value)
}
buf = appendMapEnd(ctx, code, buf)
- b = b[:mapCtx.First]
+ b = b[:pos[0]]
b = append(b, buf...)
mapCtx.Buf = buf
encoder.ReleaseMapContext(mapCtx)
@@ -531,7 +570,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -542,7 +582,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -562,7 +603,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -573,7 +615,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -594,7 +637,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -606,7 +650,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -615,7 +660,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyInt:
@@ -623,7 +668,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -635,7 +681,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -643,13 +690,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendComma(ctx, b)
code = code.Next
}
@@ -658,7 +705,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -670,7 +718,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -680,7 +729,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -689,7 +738,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -701,7 +751,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -709,15 +760,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
- u64 := ptrToUint64(p, code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -726,7 +776,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -737,7 +788,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -752,7 +804,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -760,7 +812,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -771,7 +824,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -784,7 +838,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -792,7 +846,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -803,7 +858,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -819,7 +875,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -828,7 +884,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -839,7 +896,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -853,7 +911,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -863,7 +921,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -875,7 +934,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -884,7 +944,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyUint:
@@ -892,7 +952,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -904,7 +965,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -912,13 +974,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendComma(ctx, b)
code = code.Next
}
@@ -927,7 +989,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -939,7 +1002,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -949,7 +1013,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -958,7 +1022,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -970,7 +1035,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -978,14 +1044,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -994,7 +1060,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1005,7 +1072,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1020,7 +1088,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -1028,7 +1096,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1039,7 +1108,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1052,7 +1122,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -1060,7 +1130,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1071,7 +1142,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1087,7 +1159,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -1096,7 +1168,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1107,7 +1180,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1121,7 +1195,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -1131,7 +1205,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1143,7 +1218,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1160,7 +1236,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1172,7 +1249,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1194,7 +1272,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1206,7 +1285,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1225,7 +1305,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1237,7 +1318,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1260,7 +1342,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1271,7 +1354,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1294,7 +1378,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1305,7 +1390,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1326,7 +1412,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1337,7 +1424,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1362,7 +1450,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1373,7 +1462,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1397,7 +1487,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1409,7 +1500,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1430,7 +1522,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1442,7 +1535,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1467,7 +1561,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1479,7 +1574,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1502,7 +1598,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1514,7 +1611,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1540,7 +1638,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1551,7 +1650,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1578,7 +1678,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1589,7 +1690,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1614,7 +1716,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1625,7 +1728,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1654,7 +1758,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1665,7 +1770,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1693,7 +1799,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1723,7 +1830,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1735,7 +1843,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1757,7 +1866,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1769,7 +1879,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1786,7 +1897,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1798,7 +1910,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1819,7 +1932,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1830,7 +1944,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1853,7 +1968,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1864,7 +1980,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1885,7 +2002,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1896,7 +2014,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1919,7 +2038,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1930,7 +2050,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1952,7 +2073,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1964,7 +2086,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1981,7 +2104,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1993,7 +2117,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2015,7 +2140,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2027,7 +2153,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2046,7 +2173,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2058,7 +2186,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2081,7 +2210,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2092,7 +2222,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2115,7 +2246,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2126,7 +2258,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2147,7 +2280,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2158,7 +2292,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2183,7 +2318,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2194,7 +2330,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2218,7 +2355,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2230,7 +2368,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2247,7 +2386,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2259,7 +2399,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2280,7 +2421,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2291,7 +2433,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2314,7 +2457,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2325,7 +2469,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2347,7 +2492,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2359,7 +2505,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2379,7 +2526,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2391,7 +2539,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2416,7 +2565,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2428,7 +2578,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2450,7 +2601,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2462,7 +2614,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2488,7 +2641,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2499,7 +2653,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2526,7 +2681,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2537,7 +2693,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2561,7 +2718,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2572,7 +2730,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2600,7 +2759,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2611,7 +2771,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2638,7 +2799,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2650,7 +2812,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2667,7 +2830,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2679,7 +2843,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2696,7 +2861,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2708,7 +2874,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2729,7 +2896,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2740,7 +2908,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2753,7 +2922,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
} else {
code = code.Next
@@ -2763,7 +2933,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2774,7 +2945,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2796,7 +2968,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2807,7 +2980,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2825,7 +2999,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2836,7 +3011,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2858,7 +3034,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2869,7 +3046,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2879,13 +3057,15 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
break
}
p = ptrToPtr(p + uintptr(code.Offset))
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
} else {
if (code.Flags & encoder.IndirectFlags) != 0 {
@@ -2898,7 +3078,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2909,7 +3090,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2936,7 +3118,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2949,7 +3132,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2958,10 +3142,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -2979,7 +3162,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2992,7 +3176,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3000,10 +3185,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
iface := ptrToInterface(code, p)
@@ -3023,7 +3207,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3034,7 +3219,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3061,7 +3247,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3072,7 +3259,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3099,7 +3287,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3112,7 +3301,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3121,10 +3311,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -3142,7 +3331,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3155,7 +3345,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3163,10 +3354,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -3185,7 +3375,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3196,7 +3387,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3223,7 +3415,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3234,7 +3427,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3277,16 +3471,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructFieldInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyInt:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3294,18 +3488,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyIntString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3317,7 +3511,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -3326,7 +3520,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3338,7 +3532,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -3349,7 +3543,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3357,16 +3551,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructFieldUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyUint:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3374,18 +3568,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyUintString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3397,7 +3591,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -3406,7 +3600,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3418,7 +3612,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -3429,7 +3623,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3565,7 +3759,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -4152,22 +4347,24 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next
store(ctxptr, code.Idx, p)
}
+ case encoder.OpStructAnonymousEnd:
+ code = code.Next
case encoder.OpStructEnd:
b = appendStructEndSkipLast(ctx, code, b)
code = code.Next
case encoder.OpStructEndInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyInt:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4177,18 +4374,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyIntString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4202,7 +4399,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendStructEnd(ctx, code, b)
code = code.Next
@@ -4211,7 +4408,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4225,7 +4422,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
@@ -4236,7 +4433,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4246,16 +4443,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructEndUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyUint:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4265,18 +4462,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyUintString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4290,7 +4487,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendStructEnd(ctx, code, b)
code = code.Next
@@ -4299,7 +4496,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4313,7 +4510,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
@@ -4324,7 +4521,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go
index dd4cd48..a68bbf6 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go
@@ -16,17 +16,16 @@ func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet)
defer func() {
if err := recover(); err != nil {
- w := ctx.Option.DebugOut
- fmt.Fprintln(w, "=============[DEBUG]===============")
- fmt.Fprintln(w, "* [TYPE]")
- fmt.Fprintln(w, codeSet.Type)
- fmt.Fprintf(w, "\n")
- fmt.Fprintln(w, "* [ALL OPCODE]")
- fmt.Fprintln(w, code.Dump())
- fmt.Fprintf(w, "\n")
- fmt.Fprintln(w, "* [CONTEXT]")
- fmt.Fprintf(w, "%+v\n", ctx)
- fmt.Fprintln(w, "===================================")
+ fmt.Println("=============[DEBUG]===============")
+ fmt.Println("* [TYPE]")
+ fmt.Println(codeSet.Type)
+ fmt.Printf("\n")
+ fmt.Println("* [ALL OPCODE]")
+ fmt.Println(code.Dump())
+ fmt.Printf("\n")
+ fmt.Println("* [CONTEXT]")
+ fmt.Printf("%+v\n", ctx)
+ fmt.Println("===================================")
panic(err)
}
}()
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go
index 2395abe..1399a25 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go
@@ -63,20 +63,7 @@ func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr {
return p
}
-func ptrToUint64(p uintptr, bitSize uint8) uint64 {
- switch bitSize {
- case 8:
- return (uint64)(**(**uint8)(unsafe.Pointer(&p)))
- case 16:
- return (uint64)(**(**uint16)(unsafe.Pointer(&p)))
- case 32:
- return (uint64)(**(**uint32)(unsafe.Pointer(&p)))
- case 64:
- return **(**uint64)(unsafe.Pointer(&p))
- }
- return 0
-}
-
+func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) }
func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) }
func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) }
func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) }
@@ -107,17 +94,17 @@ func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} {
}))
}
-func appendInt(ctx *encoder.RuntimeContext, b []byte, p uintptr, code *encoder.Opcode) []byte {
+func appendInt(ctx *encoder.RuntimeContext, b []byte, v uint64, code *encoder.Opcode) []byte {
format := ctx.Option.ColorScheme.Int
b = append(b, format.Header...)
- b = encoder.AppendInt(ctx, b, p, code)
+ b = encoder.AppendInt(ctx, b, v, code)
return append(b, format.Footer...)
}
-func appendUint(ctx *encoder.RuntimeContext, b []byte, p uintptr, code *encoder.Opcode) []byte {
+func appendUint(ctx *encoder.RuntimeContext, b []byte, v uint64, code *encoder.Opcode) []byte {
format := ctx.Option.ColorScheme.Uint
b = append(b, format.Header...)
- b = encoder.AppendUint(ctx, b, p, code)
+ b = encoder.AppendUint(ctx, b, v, code)
return append(b, format.Footer...)
}
@@ -181,15 +168,8 @@ func appendComma(_ *encoder.RuntimeContext, b []byte) []byte {
return append(b, ',', '\n')
}
-func appendNullComma(ctx *encoder.RuntimeContext, b []byte) []byte {
- format := ctx.Option.ColorScheme.Null
- b = append(b, format.Header...)
- b = append(b, "null"...)
- return append(append(b, format.Footer...), ',', '\n')
-}
-
func appendColon(_ *encoder.RuntimeContext, b []byte) []byte {
- return append(b[:len(b)-2], ':', ' ')
+ return append(b, ':', ' ')
}
func appendMapKeyValue(ctx *encoder.RuntimeContext, code *encoder.Opcode, b, key, value []byte) []byte {
@@ -229,9 +209,8 @@ func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte {
func appendObjectEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
last := len(b) - 1
- // replace comma to newline
- b[last-1] = '\n'
- b = appendIndent(ctx, b[:last], code.Indent)
+ b[last] = '\n'
+ b = appendIndent(ctx, b, code.Indent-1)
return append(b, '}', ',', '\n')
}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go
index 3b4e22e..7b7844e 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go
@@ -3,7 +3,6 @@ package vm_color_indent
import (
"math"
- "reflect"
"sort"
"unsafe"
@@ -33,38 +32,40 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpIntPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
store(ctxptr, code.Idx, p)
fallthrough
case encoder.OpInt:
- b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpUintPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
store(ctxptr, code.Idx, p)
fallthrough
case encoder.OpUint:
- b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpIntString:
b = append(b, '"')
- b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpUintString:
b = append(b, '"')
- b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -85,7 +86,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpFloat64Ptr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -102,7 +104,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStringPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -115,7 +118,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpBoolPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -128,7 +132,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpBytesPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -141,7 +146,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpNumberPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -157,7 +163,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpInterfacePtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -166,7 +173,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpInterface:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -186,24 +194,20 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr
- if iface.itab != nil {
- typ = iface.itab.typ
- }
+ typ = iface.itab.typ
} else {
iface := (*emptyInterface)(up)
ifacePtr = iface.ptr
typ = iface.typ
}
if ifacePtr == nil {
- isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
- if !isDirectedNil {
- b = appendNullComma(ctx, b)
- code = code.Next
- break
- }
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
+ code = code.Next
+ break
}
ctx.KeepRefs = append(ctx.KeepRefs, up)
- ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
+ ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
if err != nil {
return nil, err
}
@@ -222,7 +226,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
oldOffset := ptrOffset
ptrOffset += totalLength * uintptrSize
oldBaseIndent := ctx.BaseIndent
- ctx.BaseIndent += code.Indent
+ indentDiffFromTop := c.Indent - 1
+ ctx.BaseIndent += code.Indent - indentDiffFromTop
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
@@ -252,7 +257,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalJSONPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -261,7 +267,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -277,7 +284,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalTextPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -303,7 +311,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpSlicePtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -313,7 +322,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
slice := ptrToSlice(p)
if p == 0 || slice.Data == nil {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -346,7 +356,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpArrayPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -355,7 +366,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpArray:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -385,7 +397,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMapPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -394,7 +407,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMap:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -406,42 +420,48 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
break
}
b = appendStructHead(ctx, b)
- unorderedMap := (ctx.Option.Flag & encoder.UnorderedMapOption) != 0
- mapCtx := encoder.NewMapContext(mlen, unorderedMap)
- mapiterinit(code.Type, uptr, &mapCtx.Iter)
- store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
- ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
- if unorderedMap {
+ iter := mapiterinit(code.Type, uptr)
+ ctx.KeepRefs = append(ctx.KeepRefs, iter)
+ store(ctxptr, code.ElemIdx, 0)
+ store(ctxptr, code.Length, uintptr(mlen))
+ store(ctxptr, code.MapIter, uintptr(iter))
+ if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendMapKeyIndent(ctx, code.Next, b)
} else {
- mapCtx.Start = len(b)
- mapCtx.First = len(b)
+ mapCtx := encoder.NewMapContext(mlen)
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
+ ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
+ store(ctxptr, code.End.MapPos, uintptr(unsafe.Pointer(mapCtx)))
}
- key := mapiterkey(&mapCtx.Iter)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
case encoder.OpMapKey:
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
- idx := mapCtx.Idx
+ idx := load(ctxptr, code.ElemIdx)
+ length := load(ctxptr, code.Length)
idx++
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
- if idx < mapCtx.Len {
+ if idx < length {
b = appendMapKeyIndent(ctx, code, b)
- mapCtx.Idx = int(idx)
- key := mapiterkey(&mapCtx.Iter)
+ store(ctxptr, code.ElemIdx, idx)
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
b = appendObjectEnd(ctx, code, b)
- encoder.ReleaseMapContext(mapCtx)
code = code.End.Next
}
} else {
- mapCtx.Slice.Items[mapCtx.Idx].Value = b[mapCtx.Start:len(b)]
- if idx < mapCtx.Len {
- mapCtx.Idx = int(idx)
- mapCtx.Start = len(b)
- key := mapiterkey(&mapCtx.Iter)
+ ptr := load(ctxptr, code.End.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
+ if idx < length {
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ store(ctxptr, code.ElemIdx, idx)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
@@ -449,27 +469,46 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
}
case encoder.OpMapValue:
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b)
} else {
- mapCtx.Slice.Items[mapCtx.Idx].Key = b[mapCtx.Start:len(b)]
- mapCtx.Start = len(b)
+ ptr := load(ctxptr, code.End.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
}
- value := mapitervalue(&mapCtx.Iter)
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ value := mapitervalue(iter)
store(ctxptr, code.Next.Idx, uintptr(value))
- mapiternext(&mapCtx.Iter)
+ mapiternext(iter)
code = code.Next
case encoder.OpMapEnd:
// this operation only used by sorted map.
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
+ length := int(load(ctxptr, code.Length))
+ ptr := load(ctxptr, code.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ pos := mapCtx.Pos
+ for i := 0; i < length; i++ {
+ startKey := pos[i*2]
+ startValue := pos[i*2+1]
+ var endValue int
+ if i+1 < length {
+ endValue = pos[i*2+2]
+ } else {
+ endValue = len(b)
+ }
+ mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{
+ Key: b[startKey:startValue],
+ Value: b[startValue:endValue],
+ })
+ }
sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items {
buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value)
}
buf = appendMapEnd(ctx, code, buf)
- b = b[:mapCtx.First]
+ b = b[:pos[0]]
b = append(b, buf...)
mapCtx.Buf = buf
encoder.ReleaseMapContext(mapCtx)
@@ -531,7 +570,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -542,7 +582,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -562,7 +603,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -573,7 +615,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -594,7 +637,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -606,7 +650,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -615,7 +660,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyInt:
@@ -623,7 +668,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -635,7 +681,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -643,13 +690,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendComma(ctx, b)
code = code.Next
}
@@ -658,7 +705,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -670,7 +718,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -680,7 +729,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -689,7 +738,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -701,7 +751,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -709,15 +760,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
- u64 := ptrToUint64(p, code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -726,7 +776,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -737,7 +788,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -752,7 +804,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -760,7 +812,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -771,7 +824,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -784,7 +838,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -792,7 +846,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -803,7 +858,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -819,7 +875,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -828,7 +884,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -839,7 +896,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -853,7 +911,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -863,7 +921,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -875,7 +934,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -884,7 +944,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyUint:
@@ -892,7 +952,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -904,7 +965,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -912,13 +974,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendComma(ctx, b)
code = code.Next
}
@@ -927,7 +989,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -939,7 +1002,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -949,7 +1013,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -958,7 +1022,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -970,7 +1035,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -978,14 +1044,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -994,7 +1060,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1005,7 +1072,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1020,7 +1088,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -1028,7 +1096,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1039,7 +1108,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1052,7 +1122,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -1060,7 +1130,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1071,7 +1142,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1087,7 +1159,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -1096,7 +1168,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1107,7 +1180,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1121,7 +1195,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -1131,7 +1205,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1143,7 +1218,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1160,7 +1236,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1172,7 +1249,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1194,7 +1272,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1206,7 +1285,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1225,7 +1305,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1237,7 +1318,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1260,7 +1342,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1271,7 +1354,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1294,7 +1378,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1305,7 +1390,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1326,7 +1412,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1337,7 +1424,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1362,7 +1450,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1373,7 +1462,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1397,7 +1487,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1409,7 +1500,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1430,7 +1522,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1442,7 +1535,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1467,7 +1561,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1479,7 +1574,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1502,7 +1598,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1514,7 +1611,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1540,7 +1638,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1551,7 +1650,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1578,7 +1678,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1589,7 +1690,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1614,7 +1716,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1625,7 +1728,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1654,7 +1758,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1665,7 +1770,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1693,7 +1799,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1723,7 +1830,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1735,7 +1843,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1757,7 +1866,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1769,7 +1879,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1786,7 +1897,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1798,7 +1910,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1819,7 +1932,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1830,7 +1944,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1853,7 +1968,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1864,7 +1980,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1885,7 +2002,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1896,7 +2014,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1919,7 +2038,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1930,7 +2050,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1952,7 +2073,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1964,7 +2086,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1981,7 +2104,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1993,7 +2117,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2015,7 +2140,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2027,7 +2153,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2046,7 +2173,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2058,7 +2186,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2081,7 +2210,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2092,7 +2222,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2115,7 +2246,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2126,7 +2258,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2147,7 +2280,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2158,7 +2292,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2183,7 +2318,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2194,7 +2330,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2218,7 +2355,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2230,7 +2368,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2247,7 +2386,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2259,7 +2399,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2280,7 +2421,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2291,7 +2433,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2314,7 +2457,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2325,7 +2469,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2347,7 +2492,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2359,7 +2505,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2379,7 +2526,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2391,7 +2539,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2416,7 +2565,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2428,7 +2578,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2450,7 +2601,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2462,7 +2614,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2488,7 +2641,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2499,7 +2653,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2526,7 +2681,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2537,7 +2693,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2561,7 +2718,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2572,7 +2730,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2600,7 +2759,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2611,7 +2771,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2638,7 +2799,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2650,7 +2812,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2667,7 +2830,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2679,7 +2843,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2696,7 +2861,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2708,7 +2874,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2729,7 +2896,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2740,7 +2908,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2753,7 +2922,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
} else {
code = code.Next
@@ -2763,7 +2933,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2774,7 +2945,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2796,7 +2968,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2807,7 +2980,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2825,7 +2999,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2836,7 +3011,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2858,7 +3034,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2869,7 +3046,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2879,13 +3057,15 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
break
}
p = ptrToPtr(p + uintptr(code.Offset))
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
} else {
if (code.Flags & encoder.IndirectFlags) != 0 {
@@ -2898,7 +3078,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2909,7 +3090,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2936,7 +3118,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2949,7 +3132,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2958,10 +3142,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -2979,7 +3162,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2992,7 +3176,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3000,10 +3185,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
iface := ptrToInterface(code, p)
@@ -3023,7 +3207,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3034,7 +3219,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3061,7 +3247,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3072,7 +3259,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3099,7 +3287,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3112,7 +3301,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3121,10 +3311,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -3142,7 +3331,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3155,7 +3345,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3163,10 +3354,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -3185,7 +3375,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3196,7 +3387,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3223,7 +3415,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3234,7 +3427,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3277,16 +3471,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructFieldInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyInt:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3294,18 +3488,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyIntString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3317,7 +3511,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -3326,7 +3520,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3338,7 +3532,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -3349,7 +3543,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3357,16 +3551,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructFieldUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyUint:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3374,18 +3568,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyUintString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3397,7 +3591,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -3406,7 +3600,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3418,7 +3612,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -3429,7 +3623,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3565,7 +3759,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -4152,22 +4347,24 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next
store(ctxptr, code.Idx, p)
}
+ case encoder.OpStructAnonymousEnd:
+ code = code.Next
case encoder.OpStructEnd:
b = appendStructEndSkipLast(ctx, code, b)
code = code.Next
case encoder.OpStructEndInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyInt:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4177,18 +4374,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyIntString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4202,7 +4399,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendStructEnd(ctx, code, b)
code = code.Next
@@ -4211,7 +4408,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4225,7 +4422,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
@@ -4236,7 +4433,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4246,16 +4443,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructEndUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyUint:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4265,18 +4462,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyUintString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4290,7 +4487,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendStructEnd(ctx, code, b)
code = code.Next
@@ -4299,7 +4496,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4313,7 +4510,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
@@ -4324,7 +4521,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go
index 9939538..4cfd17a 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go
@@ -16,17 +16,16 @@ func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet)
defer func() {
if err := recover(); err != nil {
- w := ctx.Option.DebugOut
- fmt.Fprintln(w, "=============[DEBUG]===============")
- fmt.Fprintln(w, "* [TYPE]")
- fmt.Fprintln(w, codeSet.Type)
- fmt.Fprintf(w, "\n")
- fmt.Fprintln(w, "* [ALL OPCODE]")
- fmt.Fprintln(w, code.Dump())
- fmt.Fprintf(w, "\n")
- fmt.Fprintln(w, "* [CONTEXT]")
- fmt.Fprintf(w, "%+v\n", ctx)
- fmt.Fprintln(w, "===================================")
+ fmt.Println("=============[DEBUG]===============")
+ fmt.Println("* [TYPE]")
+ fmt.Println(codeSet.Type)
+ fmt.Printf("\n")
+ fmt.Println("* [ALL OPCODE]")
+ fmt.Println(code.Dump())
+ fmt.Printf("\n")
+ fmt.Println("* [CONTEXT]")
+ fmt.Printf("%+v\n", ctx)
+ fmt.Println("===================================")
panic(err)
}
}()
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go
index 6cb745e..2e3c35f 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go
@@ -70,19 +70,7 @@ func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr {
return p
}
-func ptrToUint64(p uintptr, bitSize uint8) uint64 {
- switch bitSize {
- case 8:
- return (uint64)(**(**uint8)(unsafe.Pointer(&p)))
- case 16:
- return (uint64)(**(**uint16)(unsafe.Pointer(&p)))
- case 32:
- return (uint64)(**(**uint32)(unsafe.Pointer(&p)))
- case 64:
- return **(**uint64)(unsafe.Pointer(&p))
- }
- return 0
-}
+func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) }
func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) }
func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) }
func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) }
@@ -128,12 +116,8 @@ func appendComma(_ *encoder.RuntimeContext, b []byte) []byte {
return append(b, ',', '\n')
}
-func appendNullComma(_ *encoder.RuntimeContext, b []byte) []byte {
- return append(b, "null,\n"...)
-}
-
func appendColon(_ *encoder.RuntimeContext, b []byte) []byte {
- return append(b[:len(b)-2], ':', ' ')
+ return append(b, ':', ' ')
}
func appendMapKeyValue(ctx *encoder.RuntimeContext, code *encoder.Opcode, b, key, value []byte) []byte {
@@ -173,9 +157,8 @@ func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte {
func appendObjectEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte {
last := len(b) - 1
- // replace comma to newline
- b[last-1] = '\n'
- b = appendIndent(ctx, b[:last], code.Indent)
+ b[last] = '\n'
+ b = appendIndent(ctx, b, code.Indent-1)
return append(b, '}', ',', '\n')
}
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go
index 836c5c8..6e05155 100644
--- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go
+++ b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go
@@ -3,7 +3,6 @@ package vm_indent
import (
"math"
- "reflect"
"sort"
"unsafe"
@@ -33,38 +32,40 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpIntPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
store(ctxptr, code.Idx, p)
fallthrough
case encoder.OpInt:
- b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpUintPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
store(ctxptr, code.Idx, p)
fallthrough
case encoder.OpUint:
- b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpIntString:
b = append(b, '"')
- b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpUintString:
b = append(b, '"')
- b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
+ b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -85,7 +86,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpFloat64Ptr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -102,7 +104,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStringPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -115,7 +118,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpBoolPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -128,7 +132,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpBytesPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -141,7 +146,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpNumberPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -157,7 +163,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpInterfacePtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -166,7 +173,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpInterface:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -186,24 +194,20 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr
- if iface.itab != nil {
- typ = iface.itab.typ
- }
+ typ = iface.itab.typ
} else {
iface := (*emptyInterface)(up)
ifacePtr = iface.ptr
typ = iface.typ
}
if ifacePtr == nil {
- isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
- if !isDirectedNil {
- b = appendNullComma(ctx, b)
- code = code.Next
- break
- }
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
+ code = code.Next
+ break
}
ctx.KeepRefs = append(ctx.KeepRefs, up)
- ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
+ ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
if err != nil {
return nil, err
}
@@ -222,7 +226,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
oldOffset := ptrOffset
ptrOffset += totalLength * uintptrSize
oldBaseIndent := ctx.BaseIndent
- ctx.BaseIndent += code.Indent
+ indentDiffFromTop := c.Indent - 1
+ ctx.BaseIndent += code.Indent - indentDiffFromTop
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
@@ -252,7 +257,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalJSONPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -261,7 +267,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -277,7 +284,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMarshalTextPtr:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -303,7 +311,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpSlicePtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -313,7 +322,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
slice := ptrToSlice(p)
if p == 0 || slice.Data == nil {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -346,7 +356,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpArrayPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -355,7 +366,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpArray:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -385,7 +397,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMapPtr:
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -394,7 +407,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpMap:
p := load(ctxptr, code.Idx)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.End.Next
break
}
@@ -406,42 +420,48 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
break
}
b = appendStructHead(ctx, b)
- unorderedMap := (ctx.Option.Flag & encoder.UnorderedMapOption) != 0
- mapCtx := encoder.NewMapContext(mlen, unorderedMap)
- mapiterinit(code.Type, uptr, &mapCtx.Iter)
- store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
- ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
- if unorderedMap {
+ iter := mapiterinit(code.Type, uptr)
+ ctx.KeepRefs = append(ctx.KeepRefs, iter)
+ store(ctxptr, code.ElemIdx, 0)
+ store(ctxptr, code.Length, uintptr(mlen))
+ store(ctxptr, code.MapIter, uintptr(iter))
+ if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendMapKeyIndent(ctx, code.Next, b)
} else {
- mapCtx.Start = len(b)
- mapCtx.First = len(b)
+ mapCtx := encoder.NewMapContext(mlen)
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
+ ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
+ store(ctxptr, code.End.MapPos, uintptr(unsafe.Pointer(mapCtx)))
}
- key := mapiterkey(&mapCtx.Iter)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
case encoder.OpMapKey:
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
- idx := mapCtx.Idx
+ idx := load(ctxptr, code.ElemIdx)
+ length := load(ctxptr, code.Length)
idx++
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
- if idx < mapCtx.Len {
+ if idx < length {
b = appendMapKeyIndent(ctx, code, b)
- mapCtx.Idx = int(idx)
- key := mapiterkey(&mapCtx.Iter)
+ store(ctxptr, code.ElemIdx, idx)
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
b = appendObjectEnd(ctx, code, b)
- encoder.ReleaseMapContext(mapCtx)
code = code.End.Next
}
} else {
- mapCtx.Slice.Items[mapCtx.Idx].Value = b[mapCtx.Start:len(b)]
- if idx < mapCtx.Len {
- mapCtx.Idx = int(idx)
- mapCtx.Start = len(b)
- key := mapiterkey(&mapCtx.Iter)
+ ptr := load(ctxptr, code.End.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
+ if idx < length {
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ store(ctxptr, code.ElemIdx, idx)
+ key := mapiterkey(iter)
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
@@ -449,27 +469,46 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
}
case encoder.OpMapValue:
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b)
} else {
- mapCtx.Slice.Items[mapCtx.Idx].Key = b[mapCtx.Start:len(b)]
- mapCtx.Start = len(b)
+ ptr := load(ctxptr, code.End.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ mapCtx.Pos = append(mapCtx.Pos, len(b))
}
- value := mapitervalue(&mapCtx.Iter)
+ ptr := load(ctxptr, code.MapIter)
+ iter := ptrToUnsafePtr(ptr)
+ value := mapitervalue(iter)
store(ctxptr, code.Next.Idx, uintptr(value))
- mapiternext(&mapCtx.Iter)
+ mapiternext(iter)
code = code.Next
case encoder.OpMapEnd:
// this operation only used by sorted map.
- mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
+ length := int(load(ctxptr, code.Length))
+ ptr := load(ctxptr, code.MapPos)
+ mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
+ pos := mapCtx.Pos
+ for i := 0; i < length; i++ {
+ startKey := pos[i*2]
+ startValue := pos[i*2+1]
+ var endValue int
+ if i+1 < length {
+ endValue = pos[i*2+2]
+ } else {
+ endValue = len(b)
+ }
+ mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{
+ Key: b[startKey:startValue],
+ Value: b[startValue:endValue],
+ })
+ }
sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items {
buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value)
}
buf = appendMapEnd(ctx, code, buf)
- b = b[:mapCtx.First]
+ b = b[:pos[0]]
b = append(b, buf...)
mapCtx.Buf = buf
encoder.ReleaseMapContext(mapCtx)
@@ -531,7 +570,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -542,7 +582,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -562,7 +603,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -573,7 +615,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -594,7 +637,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -606,7 +650,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -615,7 +660,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyInt:
@@ -623,7 +668,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -635,7 +681,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -643,13 +690,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendComma(ctx, b)
code = code.Next
}
@@ -658,7 +705,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -670,7 +718,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -680,7 +729,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -689,7 +738,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -701,7 +751,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -709,15 +760,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
- u64 := ptrToUint64(p, code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -726,7 +776,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -737,7 +788,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -752,7 +804,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -760,7 +812,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -771,7 +824,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -784,7 +838,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -792,7 +846,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -803,7 +858,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -819,7 +875,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -828,7 +884,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -839,7 +896,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -853,7 +911,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -863,7 +921,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -875,7 +934,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -884,7 +944,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyUint:
@@ -892,7 +952,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -904,7 +965,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -912,13 +974,13 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendComma(ctx, b)
code = code.Next
}
@@ -927,7 +989,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -939,7 +1002,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -949,7 +1013,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -958,7 +1022,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -970,7 +1035,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -978,14 +1044,14 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
@@ -994,7 +1060,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1005,7 +1072,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1020,7 +1088,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -1028,7 +1096,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1039,7 +1108,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1052,7 +1122,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -1060,7 +1130,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1071,7 +1142,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1087,7 +1159,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -1096,7 +1168,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1107,7 +1180,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1121,7 +1195,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -1131,7 +1205,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1143,7 +1218,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1160,7 +1236,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1172,7 +1249,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1194,7 +1272,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1206,7 +1285,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1225,7 +1305,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1237,7 +1318,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1260,7 +1342,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1271,7 +1354,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1294,7 +1378,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1305,7 +1390,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1326,7 +1412,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1337,7 +1424,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1362,7 +1450,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1373,7 +1462,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1397,7 +1487,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1409,7 +1500,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1430,7 +1522,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1442,7 +1535,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1467,7 +1561,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1479,7 +1574,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1502,7 +1598,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1514,7 +1611,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1540,7 +1638,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1551,7 +1650,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1578,7 +1678,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1589,7 +1690,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1614,7 +1716,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1625,7 +1728,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1654,7 +1758,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1665,7 +1770,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1693,7 +1799,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1723,7 +1830,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1735,7 +1843,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1757,7 +1866,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1769,7 +1879,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1786,7 +1897,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1798,7 +1910,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1819,7 +1932,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1830,7 +1944,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1853,7 +1968,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1864,7 +1980,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1885,7 +2002,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1896,7 +2014,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1919,7 +2038,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1930,7 +2050,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1952,7 +2073,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1964,7 +2086,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1981,7 +2104,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -1993,7 +2117,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2015,7 +2140,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2027,7 +2153,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2046,7 +2173,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2058,7 +2186,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2081,7 +2210,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2092,7 +2222,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2115,7 +2246,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2126,7 +2258,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2147,7 +2280,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2158,7 +2292,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2183,7 +2318,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2194,7 +2330,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2218,7 +2355,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2230,7 +2368,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2247,7 +2386,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2259,7 +2399,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2280,7 +2421,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2291,7 +2433,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2314,7 +2457,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2325,7 +2469,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2347,7 +2492,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2359,7 +2505,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2379,7 +2526,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2391,7 +2539,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2416,7 +2565,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2428,7 +2578,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2450,7 +2601,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2462,7 +2614,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2488,7 +2641,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2499,7 +2653,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2526,7 +2681,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2537,7 +2693,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2561,7 +2718,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2572,7 +2730,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2600,7 +2759,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2611,7 +2771,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2638,7 +2799,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2650,7 +2812,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2667,7 +2830,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2679,7 +2843,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2696,7 +2861,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2708,7 +2874,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2729,7 +2896,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2740,7 +2908,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2753,7 +2922,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
} else {
code = code.Next
@@ -2763,7 +2933,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2774,7 +2945,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2796,7 +2968,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2807,7 +2980,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2825,7 +2999,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2836,7 +3011,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2858,7 +3034,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2869,7 +3046,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2879,13 +3057,15 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
}
b = appendStructKey(ctx, code, b)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
break
}
p = ptrToPtr(p + uintptr(code.Offset))
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.NextField
} else {
if (code.Flags & encoder.IndirectFlags) != 0 {
@@ -2898,7 +3078,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2909,7 +3090,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2936,7 +3118,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2949,7 +3132,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2958,10 +3142,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -2979,7 +3162,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -2992,7 +3176,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3000,10 +3185,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
iface := ptrToInterface(code, p)
@@ -3023,7 +3207,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3034,7 +3219,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3061,7 +3247,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3072,7 +3259,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3099,7 +3287,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3112,7 +3301,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3121,10 +3311,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendStructHead(ctx, b)
}
b = appendStructKey(ctx, code, b)
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -3142,7 +3331,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3155,7 +3345,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3163,10 +3354,9 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
- p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText {
- p = ptrToPtr(p)
+ p = ptrToPtr(p + uintptr(code.Offset))
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
@@ -3185,7 +3375,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3196,7 +3387,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3223,7 +3415,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3234,7 +3427,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
}
code = code.End.Next
break
@@ -3277,16 +3471,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructFieldInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyInt:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3294,18 +3488,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyIntString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3317,7 +3511,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -3326,7 +3520,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3338,7 +3532,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -3349,7 +3543,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3357,16 +3551,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructFieldUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyUint:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3374,18 +3568,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
case encoder.OpStructFieldOmitEmptyUintString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3397,7 +3591,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendComma(ctx, b)
code = code.Next
@@ -3406,7 +3600,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendComma(ctx, b)
}
code = code.Next
@@ -3418,7 +3612,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendComma(ctx, b)
@@ -3429,7 +3623,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
@@ -3565,7 +3759,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
if p == 0 {
- b = appendNullComma(ctx, b)
+ b = appendNull(ctx, b)
+ b = appendComma(ctx, b)
code = code.Next
break
}
@@ -4152,22 +4347,24 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
code = code.Next
store(ctxptr, code.Idx, p)
}
+ case encoder.OpStructAnonymousEnd:
+ code = code.Next
case encoder.OpStructEnd:
b = appendStructEndSkipLast(ctx, code, b)
code = code.Next
case encoder.OpStructEndInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyInt:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4177,18 +4374,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyIntString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p+uintptr(code.Offset), code)
+ b = appendInt(ctx, b, u64, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4202,7 +4399,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
}
b = appendStructEnd(ctx, code, b)
code = code.Next
@@ -4211,7 +4408,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4225,7 +4422,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
@@ -4236,7 +4433,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendInt(ctx, b, p, code)
+ b = appendInt(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4246,16 +4443,16 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
case encoder.OpStructEndUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyUint:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4265,18 +4462,18 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
code = code.Next
case encoder.OpStructEndOmitEmptyUintString:
p := load(ctxptr, code.Idx)
- u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
+ u64 := ptrToUint64(p + uintptr(code.Offset))
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p+uintptr(code.Offset), code)
+ b = appendUint(ctx, b, u64, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
@@ -4290,7 +4487,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p == 0 {
b = appendNull(ctx, b)
} else {
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
}
b = appendStructEnd(ctx, code, b)
code = code.Next
@@ -4299,7 +4496,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
@@ -4313,7 +4510,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
b = appendNull(ctx, b)
} else {
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
@@ -4324,7 +4521,7 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
- b = appendUint(ctx, b, p, code)
+ b = appendUint(ctx, b, ptrToUint64(p), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
diff --git a/vendor/github.com/goccy/go-json/internal/errors/error.go b/vendor/github.com/goccy/go-json/internal/errors/error.go
index 9207d0f..d58e39f 100644
--- a/vendor/github.com/goccy/go-json/internal/errors/error.go
+++ b/vendor/github.com/goccy/go-json/internal/errors/error.go
@@ -162,22 +162,3 @@ func ErrInvalidBeginningOfValue(c byte, cursor int64) *SyntaxError {
Offset: cursor,
}
}
-
-type PathError struct {
- msg string
-}
-
-func (e *PathError) Error() string {
- return fmt.Sprintf("json: invalid path format: %s", e.msg)
-}
-
-func ErrInvalidPath(msg string, args ...interface{}) *PathError {
- if len(args) != 0 {
- return &PathError{msg: fmt.Sprintf(msg, args...)}
- }
- return &PathError{msg: msg}
-}
-
-func ErrEmptyPath() *PathError {
- return &PathError{msg: "path is empty"}
-}
diff --git a/vendor/github.com/goccy/go-json/internal/runtime/rtype.go b/vendor/github.com/goccy/go-json/internal/runtime/rtype.go
index 37cfe35..4db10de 100644
--- a/vendor/github.com/goccy/go-json/internal/runtime/rtype.go
+++ b/vendor/github.com/goccy/go-json/internal/runtime/rtype.go
@@ -252,6 +252,7 @@ func IfaceIndir(*Type) bool
//go:noescape
func RType2Type(t *Type) reflect.Type
+//go:nolint structcheck
type emptyInterface struct {
_ *Type
ptr unsafe.Pointer
diff --git a/vendor/github.com/goccy/go-json/internal/runtime/struct_field.go b/vendor/github.com/goccy/go-json/internal/runtime/struct_field.go
index baab0c5..c321180 100644
--- a/vendor/github.com/goccy/go-json/internal/runtime/struct_field.go
+++ b/vendor/github.com/goccy/go-json/internal/runtime/struct_field.go
@@ -13,11 +13,7 @@ func getTag(field reflect.StructField) string {
func IsIgnoredStructField(field reflect.StructField) bool {
if field.PkgPath != "" {
if field.Anonymous {
- t := field.Type
- if t.Kind() == reflect.Ptr {
- t = t.Elem()
- }
- if t.Kind() != reflect.Struct {
+ if !(field.Type.Kind() == reflect.Ptr && field.Type.Elem().Kind() == reflect.Struct) && field.Type.Kind() != reflect.Struct {
return true
}
} else {
diff --git a/vendor/github.com/goccy/go-json/internal/runtime/type.go b/vendor/github.com/goccy/go-json/internal/runtime/type.go
index 4b693cb..0167cd2 100644
--- a/vendor/github.com/goccy/go-json/internal/runtime/type.go
+++ b/vendor/github.com/goccy/go-json/internal/runtime/type.go
@@ -2,7 +2,6 @@ package runtime
import (
"reflect"
- "sync"
"unsafe"
)
@@ -24,8 +23,8 @@ type TypeAddr struct {
}
var (
- typeAddr *TypeAddr
- once sync.Once
+ typeAddr *TypeAddr
+ alreadyAnalyzed bool
)
//go:linkname typelinks reflect.typelinks
@@ -35,64 +34,67 @@ func typelinks() ([]unsafe.Pointer, [][]int32)
func rtypeOff(unsafe.Pointer, int32) unsafe.Pointer
func AnalyzeTypeAddr() *TypeAddr {
- once.Do(func() {
- sections, offsets := typelinks()
- if len(sections) != 1 {
- return
+ defer func() {
+ alreadyAnalyzed = true
+ }()
+ if alreadyAnalyzed {
+ return typeAddr
+ }
+ sections, offsets := typelinks()
+ if len(sections) != 1 {
+ return nil
+ }
+ if len(offsets) != 1 {
+ return nil
+ }
+ section := sections[0]
+ offset := offsets[0]
+ var (
+ min uintptr = uintptr(^uint(0))
+ max uintptr = 0
+ isAligned64 = true
+ isAligned32 = true
+ )
+ for i := 0; i < len(offset); i++ {
+ typ := (*Type)(rtypeOff(section, offset[i]))
+ addr := uintptr(unsafe.Pointer(typ))
+ if min > addr {
+ min = addr
}
- if len(offsets) != 1 {
- return
+ if max < addr {
+ max = addr
}
- section := sections[0]
- offset := offsets[0]
- var (
- min uintptr = uintptr(^uint(0))
- max uintptr = 0
- isAligned64 = true
- isAligned32 = true
- )
- for i := 0; i < len(offset); i++ {
- typ := (*Type)(rtypeOff(section, offset[i]))
- addr := uintptr(unsafe.Pointer(typ))
+ if typ.Kind() == reflect.Ptr {
+ addr = uintptr(unsafe.Pointer(typ.Elem()))
if min > addr {
min = addr
}
if max < addr {
max = addr
}
- if typ.Kind() == reflect.Ptr {
- addr = uintptr(unsafe.Pointer(typ.Elem()))
- if min > addr {
- min = addr
- }
- if max < addr {
- max = addr
- }
- }
- isAligned64 = isAligned64 && (addr-min)&63 == 0
- isAligned32 = isAligned32 && (addr-min)&31 == 0
}
- addrRange := max - min
- if addrRange == 0 {
- return
- }
- var addrShift uintptr
- if isAligned64 {
- addrShift = 6
- } else if isAligned32 {
- addrShift = 5
- }
- cacheSize := addrRange >> addrShift
- if cacheSize > maxAcceptableTypeAddrRange {
- return
- }
- typeAddr = &TypeAddr{
- BaseTypeAddr: min,
- MaxTypeAddr: max,
- AddrRange: addrRange,
- AddrShift: addrShift,
- }
- })
-
+ isAligned64 = isAligned64 && (addr-min)&63 == 0
+ isAligned32 = isAligned32 && (addr-min)&31 == 0
+ }
+ addrRange := max - min
+ if addrRange == 0 {
+ return nil
+ }
+ var addrShift uintptr
+ if isAligned64 {
+ addrShift = 6
+ } else if isAligned32 {
+ addrShift = 5
+ }
+ cacheSize := addrRange >> addrShift
+ if cacheSize > maxAcceptableTypeAddrRange {
+ return nil
+ }
+ typeAddr = &TypeAddr{
+ BaseTypeAddr: min,
+ MaxTypeAddr: max,
+ AddrRange: addrRange,
+ AddrShift: addrShift,
+ }
return typeAddr
}
diff --git a/vendor/github.com/goccy/go-json/json.go b/vendor/github.com/goccy/go-json/json.go
index fb18065..5c9448d 100644
--- a/vendor/github.com/goccy/go-json/json.go
+++ b/vendor/github.com/goccy/go-json/json.go
@@ -89,31 +89,31 @@ type UnmarshalerContext interface {
//
// Examples of struct field tags and their meanings:
//
-// // Field appears in JSON as key "myName".
-// Field int `json:"myName"`
+// // Field appears in JSON as key "myName".
+// Field int `json:"myName"`
//
-// // Field appears in JSON as key "myName" and
-// // the field is omitted from the object if its value is empty,
-// // as defined above.
-// Field int `json:"myName,omitempty"`
+// // Field appears in JSON as key "myName" and
+// // the field is omitted from the object if its value is empty,
+// // as defined above.
+// Field int `json:"myName,omitempty"`
//
-// // Field appears in JSON as key "Field" (the default), but
-// // the field is skipped if empty.
-// // Note the leading comma.
-// Field int `json:",omitempty"`
+// // Field appears in JSON as key "Field" (the default), but
+// // the field is skipped if empty.
+// // Note the leading comma.
+// Field int `json:",omitempty"`
//
-// // Field is ignored by this package.
-// Field int `json:"-"`
+// // Field is ignored by this package.
+// Field int `json:"-"`
//
-// // Field appears in JSON as key "-".
-// Field int `json:"-,"`
+// // Field appears in JSON as key "-".
+// Field int `json:"-,"`
//
// The "string" option signals that a field is stored as JSON inside a
// JSON-encoded string. It applies only to fields of string, floating point,
// integer, or boolean types. This extra level of encoding is sometimes used
// when communicating with JavaScript programs:
//
-// Int64String int64 `json:",string"`
+// Int64String int64 `json:",string"`
//
// The key name will be used if it's a non-empty string consisting of
// only Unicode letters, digits, and ASCII punctuation except quotation
@@ -166,6 +166,7 @@ type UnmarshalerContext interface {
// JSON cannot represent cyclic data structures and Marshal does not
// handle them. Passing cyclic structures to Marshal will result in
// an infinite recursion.
+//
func Marshal(v interface{}) ([]byte, error) {
return MarshalWithOption(v)
}
@@ -263,13 +264,14 @@ func MarshalIndentWithOption(v interface{}, prefix, indent string, optFuncs ...E
//
// The JSON null value unmarshals into an interface, map, pointer, or slice
// by setting that Go value to nil. Because null is often used in JSON to mean
-// “not present,†unmarshaling a JSON null into any other Go type has no effect
+// ``not present,'' unmarshaling a JSON null into any other Go type has no effect
// on the value and produces no error.
//
// When unmarshaling quoted strings, invalid UTF-8 or
// invalid UTF-16 surrogate pairs are not treated as an error.
// Instead, they are replaced by the Unicode replacement
// character U+FFFD.
+//
func Unmarshal(data []byte, v interface{}) error {
return unmarshal(data, v)
}
@@ -297,6 +299,7 @@ func UnmarshalNoEscape(data []byte, v interface{}, optFuncs ...DecodeOptionFunc)
// Number, for JSON numbers
// string, for JSON string literals
// nil, for JSON null
+//
type Token = json.Token
// A Number represents a JSON number literal.
@@ -361,8 +364,3 @@ func Valid(data []byte) bool {
}
return decoder.InputOffset() >= int64(len(data))
}
-
-func init() {
- encoder.Marshal = Marshal
- encoder.Unmarshal = Unmarshal
-}
diff --git a/vendor/github.com/goccy/go-json/option.go b/vendor/github.com/goccy/go-json/option.go
index 378031a..ad65091 100644
--- a/vendor/github.com/goccy/go-json/option.go
+++ b/vendor/github.com/goccy/go-json/option.go
@@ -1,8 +1,6 @@
package json
import (
- "io"
-
"github.com/goccy/go-json/internal/decoder"
"github.com/goccy/go-json/internal/encoder"
)
@@ -17,23 +15,6 @@ func UnorderedMap() EncodeOptionFunc {
}
}
-// DisableHTMLEscape disables escaping of HTML characters ( '&', '<', '>' ) when encoding string.
-func DisableHTMLEscape() EncodeOptionFunc {
- return func(opt *EncodeOption) {
- opt.Flag &= ^encoder.HTMLEscapeOption
- }
-}
-
-// DisableNormalizeUTF8
-// By default, when encoding string, UTF8 characters in the range of 0x80 - 0xFF are processed by applying \ufffd for invalid code and escaping for \u2028 and \u2029.
-// This option disables this behaviour. You can expect faster speeds by applying this option, but be careful.
-// encoding/json implements here: https://github.com/golang/go/blob/6178d25fc0b28724b1b5aec2b1b74fc06d9294c7/src/encoding/json/encode.go#L1067-L1093.
-func DisableNormalizeUTF8() EncodeOptionFunc {
- return func(opt *EncodeOption) {
- opt.Flag &= ^encoder.NormalizeUTF8Option
- }
-}
-
// Debug outputs debug information when panic occurs during encoding.
func Debug() EncodeOptionFunc {
return func(opt *EncodeOption) {
@@ -41,20 +22,6 @@ func Debug() EncodeOptionFunc {
}
}
-// DebugWith sets the destination to write debug messages.
-func DebugWith(w io.Writer) EncodeOptionFunc {
- return func(opt *EncodeOption) {
- opt.DebugOut = w
- }
-}
-
-// DebugDOT sets the destination to write opcodes graph.
-func DebugDOT(w io.WriteCloser) EncodeOptionFunc {
- return func(opt *EncodeOption) {
- opt.DebugDOTOut = w
- }
-}
-
// Colorize add an identifier for coloring to the string of the encoded result.
func Colorize(scheme *ColorScheme) EncodeOptionFunc {
return func(opt *EncodeOption) {
diff --git a/vendor/github.com/goccy/go-json/path.go b/vendor/github.com/goccy/go-json/path.go
deleted file mode 100644
index 38abce7..0000000
--- a/vendor/github.com/goccy/go-json/path.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package json
-
-import (
- "reflect"
-
- "github.com/goccy/go-json/internal/decoder"
-)
-
-// CreatePath creates JSON Path.
-//
-// JSON Path rule
-// $ : root object or element. The JSON Path format must start with this operator, which refers to the outermost level of the JSON-formatted string.
-// . : child operator. You can identify child values using dot-notation.
-// .. : recursive descent.
-// [] : subscript operator. If the JSON object is an array, you can use brackets to specify the array index.
-// [*] : all objects/elements for array.
-//
-// Reserved words must be properly escaped when included in Path.
-//
-// Escape Rule
-// single quote style escape: e.g.) `$['a.b'].c`
-// double quote style escape: e.g.) `$."a.b".c`
-func CreatePath(p string) (*Path, error) {
- path, err := decoder.PathString(p).Build()
- if err != nil {
- return nil, err
- }
- return &Path{path: path}, nil
-}
-
-// Path represents JSON Path.
-type Path struct {
- path *decoder.Path
-}
-
-// RootSelectorOnly whether only the root selector ($) is used.
-func (p *Path) RootSelectorOnly() bool {
- return p.path.RootSelectorOnly
-}
-
-// UsedSingleQuotePathSelector whether single quote-based escaping was done when building the JSON Path.
-func (p *Path) UsedSingleQuotePathSelector() bool {
- return p.path.SingleQuotePathSelector
-}
-
-// UsedSingleQuotePathSelector whether double quote-based escaping was done when building the JSON Path.
-func (p *Path) UsedDoubleQuotePathSelector() bool {
- return p.path.DoubleQuotePathSelector
-}
-
-// Extract extracts a specific JSON string.
-func (p *Path) Extract(data []byte, optFuncs ...DecodeOptionFunc) ([][]byte, error) {
- return extractFromPath(p, data, optFuncs...)
-}
-
-// PathString returns original JSON Path string.
-func (p *Path) PathString() string {
- return p.path.String()
-}
-
-// Unmarshal extract and decode the value of the part corresponding to JSON Path from the input data.
-func (p *Path) Unmarshal(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error {
- contents, err := extractFromPath(p, data, optFuncs...)
- if err != nil {
- return err
- }
- results := make([]interface{}, 0, len(contents))
- for _, content := range contents {
- var result interface{}
- if err := Unmarshal(content, &result); err != nil {
- return err
- }
- results = append(results, result)
- }
- if err := decoder.AssignValue(reflect.ValueOf(results), reflect.ValueOf(v)); err != nil {
- return err
- }
- return nil
-}
-
-// Get extract and substitute the value of the part corresponding to JSON Path from the input value.
-func (p *Path) Get(src, dst interface{}) error {
- return p.path.Get(reflect.ValueOf(src), reflect.ValueOf(dst))
-}
diff --git a/vendor/github.com/goccy/go-json/query.go b/vendor/github.com/goccy/go-json/query.go
deleted file mode 100644
index 4b11cf2..0000000
--- a/vendor/github.com/goccy/go-json/query.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package json
-
-import (
- "github.com/goccy/go-json/internal/encoder"
-)
-
-type (
- // FieldQuery you can dynamically filter the fields in the structure by creating a FieldQuery,
- // adding it to context.Context using SetFieldQueryToContext and then passing it to MarshalContext.
- // This is a type-safe operation, so it is faster than filtering using map[string]interface{}.
- FieldQuery = encoder.FieldQuery
- FieldQueryString = encoder.FieldQueryString
-)
-
-var (
- // FieldQueryFromContext get current FieldQuery from context.Context.
- FieldQueryFromContext = encoder.FieldQueryFromContext
- // SetFieldQueryToContext set current FieldQuery to context.Context.
- SetFieldQueryToContext = encoder.SetFieldQueryToContext
-)
-
-// BuildFieldQuery builds FieldQuery by fieldName or sub field query.
-// First, specify the field name that you want to keep in structure type.
-// If the field you want to keep is a structure type, by creating a sub field query using BuildSubFieldQuery,
-// you can select the fields you want to keep in the structure.
-// This description can be written recursively.
-func BuildFieldQuery(fields ...FieldQueryString) (*FieldQuery, error) {
- query, err := Marshal(fields)
- if err != nil {
- return nil, err
- }
- return FieldQueryString(query).Build()
-}
-
-// BuildSubFieldQuery builds sub field query.
-func BuildSubFieldQuery(name string) *SubFieldQuery {
- return &SubFieldQuery{name: name}
-}
-
-type SubFieldQuery struct {
- name string
-}
-
-func (q *SubFieldQuery) Fields(fields ...FieldQueryString) FieldQueryString {
- query, _ := Marshal(map[string][]FieldQueryString{q.name: fields})
- return FieldQueryString(query)
-}
diff --git a/vendor/github.com/golang-jwt/jwt/.gitignore b/vendor/github.com/golang-jwt/jwt/.gitignore
new file mode 100644
index 0000000..09573e0
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/.gitignore
@@ -0,0 +1,4 @@
+.DS_Store
+bin
+.idea/
+
diff --git a/vendor/github.com/golang-jwt/jwt/LICENSE b/vendor/github.com/golang-jwt/jwt/LICENSE
new file mode 100644
index 0000000..35dbc25
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/LICENSE
@@ -0,0 +1,9 @@
+Copyright (c) 2012 Dave Grijalva
+Copyright (c) 2021 golang-jwt maintainers
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/vendor/github.com/golang-jwt/jwt/MIGRATION_GUIDE.md b/vendor/github.com/golang-jwt/jwt/MIGRATION_GUIDE.md
new file mode 100644
index 0000000..c4efbd2
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/MIGRATION_GUIDE.md
@@ -0,0 +1,22 @@
+## Migration Guide (v3.2.1)
+
+Starting from [v3.2.1](https://github.com/golang-jwt/jwt/releases/tag/v3.2.1]), the import path has changed from `github.com/dgrijalva/jwt-go` to `github.com/golang-jwt/jwt`. Future releases will be using the `github.com/golang-jwt/jwt` import path and continue the existing versioning scheme of `v3.x.x+incompatible`. Backwards-compatible patches and fixes will be done on the `v3` release branch, where as new build-breaking features will be developed in a `v4` release, possibly including a SIV-style import path.
+
+### go.mod replacement
+
+In a first step, the easiest way is to use `go mod edit` to issue a replacement.
+
+```
+go mod edit -replace github.com/dgrijalva/jwt-go=github.com/golang-jwt/jwt@v3.2.1+incompatible
+go mod tidy
+```
+
+This will still keep the old import path in your code but replace it with the new package and also introduce a new indirect dependency to `github.com/golang-jwt/jwt`. Try to compile your project; it should still work.
+
+### Cleanup
+
+If your code still consistently builds, you can replace all occurences of `github.com/dgrijalva/jwt-go` with `github.com/golang-jwt/jwt`, either manually or by using tools such as `sed`. Finally, the `replace` directive in the `go.mod` file can be removed.
+
+## Older releases (before v3.2.0)
+
+The original migration guide for older releases can be found at https://github.com/dgrijalva/jwt-go/blob/master/MIGRATION_GUIDE.md.
\ No newline at end of file
diff --git a/vendor/github.com/golang-jwt/jwt/README.md b/vendor/github.com/golang-jwt/jwt/README.md
new file mode 100644
index 0000000..9b653e4
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/README.md
@@ -0,0 +1,113 @@
+# jwt-go
+
+[](https://github.com/golang-jwt/jwt/actions/workflows/build.yml)
+[](https://pkg.go.dev/github.com/golang-jwt/jwt)
+
+A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](https://datatracker.ietf.org/doc/html/rfc7519).
+
+**IMPORT PATH CHANGE:** Starting from [v3.2.1](https://github.com/golang-jwt/jwt/releases/tag/v3.2.1), the import path has changed from `github.com/dgrijalva/jwt-go` to `github.com/golang-jwt/jwt`. After the original author of the library suggested migrating the maintenance of `jwt-go`, a dedicated team of open source maintainers decided to clone the existing library into this repository. See [dgrijalva/jwt-go#462](https://github.com/dgrijalva/jwt-go/issues/462) for a detailed discussion on this topic.
+
+Future releases will be using the `github.com/golang-jwt/jwt` import path and continue the existing versioning scheme of `v3.x.x+incompatible`. Backwards-compatible patches and fixes will be done on the `v3` release branch, where as new build-breaking features will be developed in a `v4` release, possibly including a SIV-style import path.
+
+**SECURITY NOTICE:** Some older versions of Go have a security issue in the crypto/elliptic. Recommendation is to upgrade to at least 1.15 See issue [dgrijalva/jwt-go#216](https://github.com/dgrijalva/jwt-go/issues/216) for more detail.
+
+**SECURITY NOTICE:** It's important that you [validate the `alg` presented is what you expect](https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/). This library attempts to make it easy to do the right thing by requiring key types match the expected alg, but you should take the extra step to verify it in your usage. See the examples provided.
+
+### Supported Go versions
+
+Our support of Go versions is aligned with Go's [version release policy](https://golang.org/doc/devel/release#policy).
+So we will support a major version of Go until there are two newer major releases.
+We no longer support building jwt-go with unsupported Go versions, as these contain security vulnerabilities
+which will not be fixed.
+
+## What the heck is a JWT?
+
+JWT.io has [a great introduction](https://jwt.io/introduction) to JSON Web Tokens.
+
+In short, it's a signed JSON object that does something useful (for example, authentication). It's commonly used for `Bearer` tokens in Oauth 2. A token is made of three parts, separated by `.`'s. The first two parts are JSON objects, that have been [base64url](https://datatracker.ietf.org/doc/html/rfc4648) encoded. The last part is the signature, encoded the same way.
+
+The first part is called the header. It contains the necessary information for verifying the last part, the signature. For example, which encryption method was used for signing and what key was used.
+
+The part in the middle is the interesting bit. It's called the Claims and contains the actual stuff you care about. Refer to [RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519) for information about reserved keys and the proper way to add your own.
+
+## What's in the box?
+
+This library supports the parsing and verification as well as the generation and signing of JWTs. Current supported signing algorithms are HMAC SHA, RSA, RSA-PSS, and ECDSA, though hooks are present for adding your own.
+
+## Examples
+
+See [the project documentation](https://pkg.go.dev/github.com/golang-jwt/jwt) for examples of usage:
+
+* [Simple example of parsing and validating a token](https://pkg.go.dev/github.com/golang-jwt/jwt#example-Parse-Hmac)
+* [Simple example of building and signing a token](https://pkg.go.dev/github.com/golang-jwt/jwt#example-New-Hmac)
+* [Directory of Examples](https://pkg.go.dev/github.com/golang-jwt/jwt#pkg-examples)
+
+## Extensions
+
+This library publishes all the necessary components for adding your own signing methods. Simply implement the `SigningMethod` interface and register a factory method using `RegisterSigningMethod`.
+
+Here's an example of an extension that integrates with multiple Google Cloud Platform signing tools (AppEngine, IAM API, Cloud KMS): https://github.com/someone1/gcp-jwt-go
+
+## Compliance
+
+This library was last reviewed to comply with [RTF 7519](https://datatracker.ietf.org/doc/html/rfc7519) dated May 2015 with a few notable differences:
+
+* In order to protect against accidental use of [Unsecured JWTs](https://datatracker.ietf.org/doc/html/rfc7519#section-6), tokens using `alg=none` will only be accepted if the constant `jwt.UnsafeAllowNoneSignatureType` is provided as the key.
+
+## Project Status & Versioning
+
+This library is considered production ready. Feedback and feature requests are appreciated. The API should be considered stable. There should be very few backwards-incompatible changes outside of major version updates (and only with good reason).
+
+This project uses [Semantic Versioning 2.0.0](http://semver.org). Accepted pull requests will land on `main`. Periodically, versions will be tagged from `main`. You can find all the releases on [the project releases page](https://github.com/golang-jwt/jwt/releases).
+
+While we try to make it obvious when we make breaking changes, there isn't a great mechanism for pushing announcements out to users. You may want to use this alternative package include: `gopkg.in/golang-jwt/jwt.v3`. It will do the right thing WRT semantic versioning.
+
+**BREAKING CHANGES:***
+* Version 3.0.0 includes _a lot_ of changes from the 2.x line, including a few that break the API. We've tried to break as few things as possible, so there should just be a few type signature changes. A full list of breaking changes is available in `VERSION_HISTORY.md`. See `MIGRATION_GUIDE.md` for more information on updating your code.
+
+## Usage Tips
+
+### Signing vs Encryption
+
+A token is simply a JSON object that is signed by its author. this tells you exactly two things about the data:
+
+* The author of the token was in the possession of the signing secret
+* The data has not been modified since it was signed
+
+It's important to know that JWT does not provide encryption, which means anyone who has access to the token can read its contents. If you need to protect (encrypt) the data, there is a companion spec, `JWE`, that provides this functionality. JWE is currently outside the scope of this library.
+
+### Choosing a Signing Method
+
+There are several signing methods available, and you should probably take the time to learn about the various options before choosing one. The principal design decision is most likely going to be symmetric vs asymmetric.
+
+Symmetric signing methods, such as HSA, use only a single secret. This is probably the simplest signing method to use since any `[]byte` can be used as a valid secret. They are also slightly computationally faster to use, though this rarely is enough to matter. Symmetric signing methods work the best when both producers and consumers of tokens are trusted, or even the same system. Since the same secret is used to both sign and validate tokens, you can't easily distribute the key for validation.
+
+Asymmetric signing methods, such as RSA, use different keys for signing and verifying tokens. This makes it possible to produce tokens with a private key, and allow any consumer to access the public key for verification.
+
+### Signing Methods and Key Types
+
+Each signing method expects a different object type for its signing keys. See the package documentation for details. Here are the most common ones:
+
+* The [HMAC signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodHMAC) (`HS256`,`HS384`,`HS512`) expect `[]byte` values for signing and validation
+* The [RSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodRSA) (`RS256`,`RS384`,`RS512`) expect `*rsa.PrivateKey` for signing and `*rsa.PublicKey` for validation
+* The [ECDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodECDSA) (`ES256`,`ES384`,`ES512`) expect `*ecdsa.PrivateKey` for signing and `*ecdsa.PublicKey` for validation
+
+### JWT and OAuth
+
+It's worth mentioning that OAuth and JWT are not the same thing. A JWT token is simply a signed JSON object. It can be used anywhere such a thing is useful. There is some confusion, though, as JWT is the most common type of bearer token used in OAuth2 authentication.
+
+Without going too far down the rabbit hole, here's a description of the interaction of these technologies:
+
+* OAuth is a protocol for allowing an identity provider to be separate from the service a user is logging in to. For example, whenever you use Facebook to log into a different service (Yelp, Spotify, etc), you are using OAuth.
+* OAuth defines several options for passing around authentication data. One popular method is called a "bearer token". A bearer token is simply a string that _should_ only be held by an authenticated user. Thus, simply presenting this token proves your identity. You can probably derive from here why a JWT might make a good bearer token.
+* Because bearer tokens are used for authentication, it's important they're kept secret. This is why transactions that use bearer tokens typically happen over SSL.
+
+### Troubleshooting
+
+This library uses descriptive error messages whenever possible. If you are not getting the expected result, have a look at the errors. The most common place people get stuck is providing the correct type of key to the parser. See the above section on signing methods and key types.
+
+## More
+
+Documentation can be found [on pkg.go.dev](https://pkg.go.dev/github.com/golang-jwt/jwt).
+
+The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. You'll also find several implementation examples in the documentation.
diff --git a/vendor/github.com/golang-jwt/jwt/VERSION_HISTORY.md b/vendor/github.com/golang-jwt/jwt/VERSION_HISTORY.md
new file mode 100644
index 0000000..637f2ba
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/VERSION_HISTORY.md
@@ -0,0 +1,131 @@
+## `jwt-go` Version History
+
+#### 3.2.2
+
+* Starting from this release, we are adopting the policy to support the most 2 recent versions of Go currently available. By the time of this release, this is Go 1.15 and 1.16 ([#28](https://github.com/golang-jwt/jwt/pull/28)).
+* Fixed a potential issue that could occur when the verification of `exp`, `iat` or `nbf` was not required and contained invalid contents, i.e. non-numeric/date. Thanks for @thaJeztah for making us aware of that and @giorgos-f3 for originally reporting it to the formtech fork ([#40](https://github.com/golang-jwt/jwt/pull/40)).
+* Added support for EdDSA / ED25519 ([#36](https://github.com/golang-jwt/jwt/pull/36)).
+* Optimized allocations ([#33](https://github.com/golang-jwt/jwt/pull/33)).
+
+#### 3.2.1
+
+* **Import Path Change**: See MIGRATION_GUIDE.md for tips on updating your code
+ * Changed the import path from `github.com/dgrijalva/jwt-go` to `github.com/golang-jwt/jwt`
+* Fixed type confusing issue between `string` and `[]string` in `VerifyAudience` ([#12](https://github.com/golang-jwt/jwt/pull/12)). This fixes CVE-2020-26160
+
+#### 3.2.0
+
+* Added method `ParseUnverified` to allow users to split up the tasks of parsing and validation
+* HMAC signing method returns `ErrInvalidKeyType` instead of `ErrInvalidKey` where appropriate
+* Added options to `request.ParseFromRequest`, which allows for an arbitrary list of modifiers to parsing behavior. Initial set include `WithClaims` and `WithParser`. Existing usage of this function will continue to work as before.
+* Deprecated `ParseFromRequestWithClaims` to simplify API in the future.
+
+#### 3.1.0
+
+* Improvements to `jwt` command line tool
+* Added `SkipClaimsValidation` option to `Parser`
+* Documentation updates
+
+#### 3.0.0
+
+* **Compatibility Breaking Changes**: See MIGRATION_GUIDE.md for tips on updating your code
+ * Dropped support for `[]byte` keys when using RSA signing methods. This convenience feature could contribute to security vulnerabilities involving mismatched key types with signing methods.
+ * `ParseFromRequest` has been moved to `request` subpackage and usage has changed
+ * The `Claims` property on `Token` is now type `Claims` instead of `map[string]interface{}`. The default value is type `MapClaims`, which is an alias to `map[string]interface{}`. This makes it possible to use a custom type when decoding claims.
+* Other Additions and Changes
+ * Added `Claims` interface type to allow users to decode the claims into a custom type
+ * Added `ParseWithClaims`, which takes a third argument of type `Claims`. Use this function instead of `Parse` if you have a custom type you'd like to decode into.
+ * Dramatically improved the functionality and flexibility of `ParseFromRequest`, which is now in the `request` subpackage
+ * Added `ParseFromRequestWithClaims` which is the `FromRequest` equivalent of `ParseWithClaims`
+ * Added new interface type `Extractor`, which is used for extracting JWT strings from http requests. Used with `ParseFromRequest` and `ParseFromRequestWithClaims`.
+ * Added several new, more specific, validation errors to error type bitmask
+ * Moved examples from README to executable example files
+ * Signing method registry is now thread safe
+ * Added new property to `ValidationError`, which contains the raw error returned by calls made by parse/verify (such as those returned by keyfunc or json parser)
+
+#### 2.7.0
+
+This will likely be the last backwards compatible release before 3.0.0, excluding essential bug fixes.
+
+* Added new option `-show` to the `jwt` command that will just output the decoded token without verifying
+* Error text for expired tokens includes how long it's been expired
+* Fixed incorrect error returned from `ParseRSAPublicKeyFromPEM`
+* Documentation updates
+
+#### 2.6.0
+
+* Exposed inner error within ValidationError
+* Fixed validation errors when using UseJSONNumber flag
+* Added several unit tests
+
+#### 2.5.0
+
+* Added support for signing method none. You shouldn't use this. The API tries to make this clear.
+* Updated/fixed some documentation
+* Added more helpful error message when trying to parse tokens that begin with `BEARER `
+
+#### 2.4.0
+
+* Added new type, Parser, to allow for configuration of various parsing parameters
+ * You can now specify a list of valid signing methods. Anything outside this set will be rejected.
+ * You can now opt to use the `json.Number` type instead of `float64` when parsing token JSON
+* Added support for [Travis CI](https://travis-ci.org/dgrijalva/jwt-go)
+* Fixed some bugs with ECDSA parsing
+
+#### 2.3.0
+
+* Added support for ECDSA signing methods
+* Added support for RSA PSS signing methods (requires go v1.4)
+
+#### 2.2.0
+
+* Gracefully handle a `nil` `Keyfunc` being passed to `Parse`. Result will now be the parsed token and an error, instead of a panic.
+
+#### 2.1.0
+
+Backwards compatible API change that was missed in 2.0.0.
+
+* The `SignedString` method on `Token` now takes `interface{}` instead of `[]byte`
+
+#### 2.0.0
+
+There were two major reasons for breaking backwards compatibility with this update. The first was a refactor required to expand the width of the RSA and HMAC-SHA signing implementations. There will likely be no required code changes to support this change.
+
+The second update, while unfortunately requiring a small change in integration, is required to open up this library to other signing methods. Not all keys used for all signing methods have a single standard on-disk representation. Requiring `[]byte` as the type for all keys proved too limiting. Additionally, this implementation allows for pre-parsed tokens to be reused, which might matter in an application that parses a high volume of tokens with a small set of keys. Backwards compatibilty has been maintained for passing `[]byte` to the RSA signing methods, but they will also accept `*rsa.PublicKey` and `*rsa.PrivateKey`.
+
+It is likely the only integration change required here will be to change `func(t *jwt.Token) ([]byte, error)` to `func(t *jwt.Token) (interface{}, error)` when calling `Parse`.
+
+* **Compatibility Breaking Changes**
+ * `SigningMethodHS256` is now `*SigningMethodHMAC` instead of `type struct`
+ * `SigningMethodRS256` is now `*SigningMethodRSA` instead of `type struct`
+ * `KeyFunc` now returns `interface{}` instead of `[]byte`
+ * `SigningMethod.Sign` now takes `interface{}` instead of `[]byte` for the key
+ * `SigningMethod.Verify` now takes `interface{}` instead of `[]byte` for the key
+* Renamed type `SigningMethodHS256` to `SigningMethodHMAC`. Specific sizes are now just instances of this type.
+ * Added public package global `SigningMethodHS256`
+ * Added public package global `SigningMethodHS384`
+ * Added public package global `SigningMethodHS512`
+* Renamed type `SigningMethodRS256` to `SigningMethodRSA`. Specific sizes are now just instances of this type.
+ * Added public package global `SigningMethodRS256`
+ * Added public package global `SigningMethodRS384`
+ * Added public package global `SigningMethodRS512`
+* Moved sample private key for HMAC tests from an inline value to a file on disk. Value is unchanged.
+* Refactored the RSA implementation to be easier to read
+* Exposed helper methods `ParseRSAPrivateKeyFromPEM` and `ParseRSAPublicKeyFromPEM`
+
+#### 1.0.2
+
+* Fixed bug in parsing public keys from certificates
+* Added more tests around the parsing of keys for RS256
+* Code refactoring in RS256 implementation. No functional changes
+
+#### 1.0.1
+
+* Fixed panic if RS256 signing method was passed an invalid key
+
+#### 1.0.0
+
+* First versioned release
+* API stabilized
+* Supports creating, signing, parsing, and validating JWT tokens
+* Supports RS256 and HS256 signing methods
diff --git a/vendor/github.com/golang-jwt/jwt/claims.go b/vendor/github.com/golang-jwt/jwt/claims.go
new file mode 100644
index 0000000..f1dba3c
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/claims.go
@@ -0,0 +1,146 @@
+package jwt
+
+import (
+ "crypto/subtle"
+ "fmt"
+ "time"
+)
+
+// For a type to be a Claims object, it must just have a Valid method that determines
+// if the token is invalid for any supported reason
+type Claims interface {
+ Valid() error
+}
+
+// Structured version of Claims Section, as referenced at
+// https://tools.ietf.org/html/rfc7519#section-4.1
+// See examples for how to use this with your own claim types
+type StandardClaims struct {
+ Audience string `json:"aud,omitempty"`
+ ExpiresAt int64 `json:"exp,omitempty"`
+ Id string `json:"jti,omitempty"`
+ IssuedAt int64 `json:"iat,omitempty"`
+ Issuer string `json:"iss,omitempty"`
+ NotBefore int64 `json:"nbf,omitempty"`
+ Subject string `json:"sub,omitempty"`
+}
+
+// Validates time based claims "exp, iat, nbf".
+// There is no accounting for clock skew.
+// As well, if any of the above claims are not in the token, it will still
+// be considered a valid claim.
+func (c StandardClaims) Valid() error {
+ vErr := new(ValidationError)
+ now := TimeFunc().Unix()
+
+ // The claims below are optional, by default, so if they are set to the
+ // default value in Go, let's not fail the verification for them.
+ if !c.VerifyExpiresAt(now, false) {
+ delta := time.Unix(now, 0).Sub(time.Unix(c.ExpiresAt, 0))
+ vErr.Inner = fmt.Errorf("token is expired by %v", delta)
+ vErr.Errors |= ValidationErrorExpired
+ }
+
+ if !c.VerifyIssuedAt(now, false) {
+ vErr.Inner = fmt.Errorf("Token used before issued")
+ vErr.Errors |= ValidationErrorIssuedAt
+ }
+
+ if !c.VerifyNotBefore(now, false) {
+ vErr.Inner = fmt.Errorf("token is not valid yet")
+ vErr.Errors |= ValidationErrorNotValidYet
+ }
+
+ if vErr.valid() {
+ return nil
+ }
+
+ return vErr
+}
+
+// Compares the aud claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (c *StandardClaims) VerifyAudience(cmp string, req bool) bool {
+ return verifyAud([]string{c.Audience}, cmp, req)
+}
+
+// Compares the exp claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (c *StandardClaims) VerifyExpiresAt(cmp int64, req bool) bool {
+ return verifyExp(c.ExpiresAt, cmp, req)
+}
+
+// Compares the iat claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (c *StandardClaims) VerifyIssuedAt(cmp int64, req bool) bool {
+ return verifyIat(c.IssuedAt, cmp, req)
+}
+
+// Compares the iss claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (c *StandardClaims) VerifyIssuer(cmp string, req bool) bool {
+ return verifyIss(c.Issuer, cmp, req)
+}
+
+// Compares the nbf claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (c *StandardClaims) VerifyNotBefore(cmp int64, req bool) bool {
+ return verifyNbf(c.NotBefore, cmp, req)
+}
+
+// ----- helpers
+
+func verifyAud(aud []string, cmp string, required bool) bool {
+ if len(aud) == 0 {
+ return !required
+ }
+ // use a var here to keep constant time compare when looping over a number of claims
+ result := false
+
+ var stringClaims string
+ for _, a := range aud {
+ if subtle.ConstantTimeCompare([]byte(a), []byte(cmp)) != 0 {
+ result = true
+ }
+ stringClaims = stringClaims + a
+ }
+
+ // case where "" is sent in one or many aud claims
+ if len(stringClaims) == 0 {
+ return !required
+ }
+
+ return result
+}
+
+func verifyExp(exp int64, now int64, required bool) bool {
+ if exp == 0 {
+ return !required
+ }
+ return now <= exp
+}
+
+func verifyIat(iat int64, now int64, required bool) bool {
+ if iat == 0 {
+ return !required
+ }
+ return now >= iat
+}
+
+func verifyIss(iss string, cmp string, required bool) bool {
+ if iss == "" {
+ return !required
+ }
+ if subtle.ConstantTimeCompare([]byte(iss), []byte(cmp)) != 0 {
+ return true
+ } else {
+ return false
+ }
+}
+
+func verifyNbf(nbf int64, now int64, required bool) bool {
+ if nbf == 0 {
+ return !required
+ }
+ return now >= nbf
+}
diff --git a/vendor/github.com/golang-jwt/jwt/doc.go b/vendor/github.com/golang-jwt/jwt/doc.go
new file mode 100644
index 0000000..a86dc1a
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/doc.go
@@ -0,0 +1,4 @@
+// Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html
+//
+// See README.md for more info.
+package jwt
diff --git a/vendor/github.com/golang-jwt/jwt/ecdsa.go b/vendor/github.com/golang-jwt/jwt/ecdsa.go
new file mode 100644
index 0000000..15e2343
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/ecdsa.go
@@ -0,0 +1,142 @@
+package jwt
+
+import (
+ "crypto"
+ "crypto/ecdsa"
+ "crypto/rand"
+ "errors"
+ "math/big"
+)
+
+var (
+ // Sadly this is missing from crypto/ecdsa compared to crypto/rsa
+ ErrECDSAVerification = errors.New("crypto/ecdsa: verification error")
+)
+
+// Implements the ECDSA family of signing methods signing methods
+// Expects *ecdsa.PrivateKey for signing and *ecdsa.PublicKey for verification
+type SigningMethodECDSA struct {
+ Name string
+ Hash crypto.Hash
+ KeySize int
+ CurveBits int
+}
+
+// Specific instances for EC256 and company
+var (
+ SigningMethodES256 *SigningMethodECDSA
+ SigningMethodES384 *SigningMethodECDSA
+ SigningMethodES512 *SigningMethodECDSA
+)
+
+func init() {
+ // ES256
+ SigningMethodES256 = &SigningMethodECDSA{"ES256", crypto.SHA256, 32, 256}
+ RegisterSigningMethod(SigningMethodES256.Alg(), func() SigningMethod {
+ return SigningMethodES256
+ })
+
+ // ES384
+ SigningMethodES384 = &SigningMethodECDSA{"ES384", crypto.SHA384, 48, 384}
+ RegisterSigningMethod(SigningMethodES384.Alg(), func() SigningMethod {
+ return SigningMethodES384
+ })
+
+ // ES512
+ SigningMethodES512 = &SigningMethodECDSA{"ES512", crypto.SHA512, 66, 521}
+ RegisterSigningMethod(SigningMethodES512.Alg(), func() SigningMethod {
+ return SigningMethodES512
+ })
+}
+
+func (m *SigningMethodECDSA) Alg() string {
+ return m.Name
+}
+
+// Implements the Verify method from SigningMethod
+// For this verify method, key must be an ecdsa.PublicKey struct
+func (m *SigningMethodECDSA) Verify(signingString, signature string, key interface{}) error {
+ var err error
+
+ // Decode the signature
+ var sig []byte
+ if sig, err = DecodeSegment(signature); err != nil {
+ return err
+ }
+
+ // Get the key
+ var ecdsaKey *ecdsa.PublicKey
+ switch k := key.(type) {
+ case *ecdsa.PublicKey:
+ ecdsaKey = k
+ default:
+ return ErrInvalidKeyType
+ }
+
+ if len(sig) != 2*m.KeySize {
+ return ErrECDSAVerification
+ }
+
+ r := big.NewInt(0).SetBytes(sig[:m.KeySize])
+ s := big.NewInt(0).SetBytes(sig[m.KeySize:])
+
+ // Create hasher
+ if !m.Hash.Available() {
+ return ErrHashUnavailable
+ }
+ hasher := m.Hash.New()
+ hasher.Write([]byte(signingString))
+
+ // Verify the signature
+ if verifystatus := ecdsa.Verify(ecdsaKey, hasher.Sum(nil), r, s); verifystatus {
+ return nil
+ }
+
+ return ErrECDSAVerification
+}
+
+// Implements the Sign method from SigningMethod
+// For this signing method, key must be an ecdsa.PrivateKey struct
+func (m *SigningMethodECDSA) Sign(signingString string, key interface{}) (string, error) {
+ // Get the key
+ var ecdsaKey *ecdsa.PrivateKey
+ switch k := key.(type) {
+ case *ecdsa.PrivateKey:
+ ecdsaKey = k
+ default:
+ return "", ErrInvalidKeyType
+ }
+
+ // Create the hasher
+ if !m.Hash.Available() {
+ return "", ErrHashUnavailable
+ }
+
+ hasher := m.Hash.New()
+ hasher.Write([]byte(signingString))
+
+ // Sign the string and return r, s
+ if r, s, err := ecdsa.Sign(rand.Reader, ecdsaKey, hasher.Sum(nil)); err == nil {
+ curveBits := ecdsaKey.Curve.Params().BitSize
+
+ if m.CurveBits != curveBits {
+ return "", ErrInvalidKey
+ }
+
+ keyBytes := curveBits / 8
+ if curveBits%8 > 0 {
+ keyBytes += 1
+ }
+
+ // We serialize the outputs (r and s) into big-endian byte arrays
+ // padded with zeros on the left to make sure the sizes work out.
+ // Output must be 2*keyBytes long.
+ out := make([]byte, 2*keyBytes)
+ r.FillBytes(out[0:keyBytes]) // r is assigned to the first half of output.
+ s.FillBytes(out[keyBytes:]) // s is assigned to the second half of output.
+
+ return EncodeSegment(out), nil
+ } else {
+ return "", err
+ }
+}
diff --git a/vendor/github.com/golang-jwt/jwt/ecdsa_utils.go b/vendor/github.com/golang-jwt/jwt/ecdsa_utils.go
new file mode 100644
index 0000000..db9f4be
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/ecdsa_utils.go
@@ -0,0 +1,69 @@
+package jwt
+
+import (
+ "crypto/ecdsa"
+ "crypto/x509"
+ "encoding/pem"
+ "errors"
+)
+
+var (
+ ErrNotECPublicKey = errors.New("Key is not a valid ECDSA public key")
+ ErrNotECPrivateKey = errors.New("Key is not a valid ECDSA private key")
+)
+
+// Parse PEM encoded Elliptic Curve Private Key Structure
+func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) {
+ var err error
+
+ // Parse PEM block
+ var block *pem.Block
+ if block, _ = pem.Decode(key); block == nil {
+ return nil, ErrKeyMustBePEMEncoded
+ }
+
+ // Parse the key
+ var parsedKey interface{}
+ if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil {
+ if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
+ return nil, err
+ }
+ }
+
+ var pkey *ecdsa.PrivateKey
+ var ok bool
+ if pkey, ok = parsedKey.(*ecdsa.PrivateKey); !ok {
+ return nil, ErrNotECPrivateKey
+ }
+
+ return pkey, nil
+}
+
+// Parse PEM encoded PKCS1 or PKCS8 public key
+func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error) {
+ var err error
+
+ // Parse PEM block
+ var block *pem.Block
+ if block, _ = pem.Decode(key); block == nil {
+ return nil, ErrKeyMustBePEMEncoded
+ }
+
+ // Parse the key
+ var parsedKey interface{}
+ if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
+ if cert, err := x509.ParseCertificate(block.Bytes); err == nil {
+ parsedKey = cert.PublicKey
+ } else {
+ return nil, err
+ }
+ }
+
+ var pkey *ecdsa.PublicKey
+ var ok bool
+ if pkey, ok = parsedKey.(*ecdsa.PublicKey); !ok {
+ return nil, ErrNotECPublicKey
+ }
+
+ return pkey, nil
+}
diff --git a/vendor/github.com/golang-jwt/jwt/ed25519.go b/vendor/github.com/golang-jwt/jwt/ed25519.go
new file mode 100644
index 0000000..a2f8ddb
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/ed25519.go
@@ -0,0 +1,81 @@
+package jwt
+
+import (
+ "errors"
+
+ "crypto/ed25519"
+)
+
+var (
+ ErrEd25519Verification = errors.New("ed25519: verification error")
+)
+
+// Implements the EdDSA family
+// Expects ed25519.PrivateKey for signing and ed25519.PublicKey for verification
+type SigningMethodEd25519 struct{}
+
+// Specific instance for EdDSA
+var (
+ SigningMethodEdDSA *SigningMethodEd25519
+)
+
+func init() {
+ SigningMethodEdDSA = &SigningMethodEd25519{}
+ RegisterSigningMethod(SigningMethodEdDSA.Alg(), func() SigningMethod {
+ return SigningMethodEdDSA
+ })
+}
+
+func (m *SigningMethodEd25519) Alg() string {
+ return "EdDSA"
+}
+
+// Implements the Verify method from SigningMethod
+// For this verify method, key must be an ed25519.PublicKey
+func (m *SigningMethodEd25519) Verify(signingString, signature string, key interface{}) error {
+ var err error
+ var ed25519Key ed25519.PublicKey
+ var ok bool
+
+ if ed25519Key, ok = key.(ed25519.PublicKey); !ok {
+ return ErrInvalidKeyType
+ }
+
+ if len(ed25519Key) != ed25519.PublicKeySize {
+ return ErrInvalidKey
+ }
+
+ // Decode the signature
+ var sig []byte
+ if sig, err = DecodeSegment(signature); err != nil {
+ return err
+ }
+
+ // Verify the signature
+ if !ed25519.Verify(ed25519Key, []byte(signingString), sig) {
+ return ErrEd25519Verification
+ }
+
+ return nil
+}
+
+// Implements the Sign method from SigningMethod
+// For this signing method, key must be an ed25519.PrivateKey
+func (m *SigningMethodEd25519) Sign(signingString string, key interface{}) (string, error) {
+ var ed25519Key ed25519.PrivateKey
+ var ok bool
+
+ if ed25519Key, ok = key.(ed25519.PrivateKey); !ok {
+ return "", ErrInvalidKeyType
+ }
+
+ // ed25519.Sign panics if private key not equal to ed25519.PrivateKeySize
+ // this allows to avoid recover usage
+ if len(ed25519Key) != ed25519.PrivateKeySize {
+ return "", ErrInvalidKey
+ }
+
+ // Sign the string and return the encoded result
+ sig := ed25519.Sign(ed25519Key, []byte(signingString))
+ return EncodeSegment(sig), nil
+}
diff --git a/vendor/github.com/golang-jwt/jwt/ed25519_utils.go b/vendor/github.com/golang-jwt/jwt/ed25519_utils.go
new file mode 100644
index 0000000..c635727
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/ed25519_utils.go
@@ -0,0 +1,64 @@
+package jwt
+
+import (
+ "crypto"
+ "crypto/ed25519"
+ "crypto/x509"
+ "encoding/pem"
+ "errors"
+)
+
+var (
+ ErrNotEdPrivateKey = errors.New("Key is not a valid Ed25519 private key")
+ ErrNotEdPublicKey = errors.New("Key is not a valid Ed25519 public key")
+)
+
+// Parse PEM-encoded Edwards curve private key
+func ParseEdPrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error) {
+ var err error
+
+ // Parse PEM block
+ var block *pem.Block
+ if block, _ = pem.Decode(key); block == nil {
+ return nil, ErrKeyMustBePEMEncoded
+ }
+
+ // Parse the key
+ var parsedKey interface{}
+ if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
+ return nil, err
+ }
+
+ var pkey ed25519.PrivateKey
+ var ok bool
+ if pkey, ok = parsedKey.(ed25519.PrivateKey); !ok {
+ return nil, ErrNotEdPrivateKey
+ }
+
+ return pkey, nil
+}
+
+// Parse PEM-encoded Edwards curve public key
+func ParseEdPublicKeyFromPEM(key []byte) (crypto.PublicKey, error) {
+ var err error
+
+ // Parse PEM block
+ var block *pem.Block
+ if block, _ = pem.Decode(key); block == nil {
+ return nil, ErrKeyMustBePEMEncoded
+ }
+
+ // Parse the key
+ var parsedKey interface{}
+ if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
+ return nil, err
+ }
+
+ var pkey ed25519.PublicKey
+ var ok bool
+ if pkey, ok = parsedKey.(ed25519.PublicKey); !ok {
+ return nil, ErrNotEdPublicKey
+ }
+
+ return pkey, nil
+}
diff --git a/vendor/github.com/golang-jwt/jwt/errors.go b/vendor/github.com/golang-jwt/jwt/errors.go
new file mode 100644
index 0000000..1c93024
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/errors.go
@@ -0,0 +1,59 @@
+package jwt
+
+import (
+ "errors"
+)
+
+// Error constants
+var (
+ ErrInvalidKey = errors.New("key is invalid")
+ ErrInvalidKeyType = errors.New("key is of invalid type")
+ ErrHashUnavailable = errors.New("the requested hash function is unavailable")
+)
+
+// The errors that might occur when parsing and validating a token
+const (
+ ValidationErrorMalformed uint32 = 1 << iota // Token is malformed
+ ValidationErrorUnverifiable // Token could not be verified because of signing problems
+ ValidationErrorSignatureInvalid // Signature validation failed
+
+ // Standard Claim validation errors
+ ValidationErrorAudience // AUD validation failed
+ ValidationErrorExpired // EXP validation failed
+ ValidationErrorIssuedAt // IAT validation failed
+ ValidationErrorIssuer // ISS validation failed
+ ValidationErrorNotValidYet // NBF validation failed
+ ValidationErrorId // JTI validation failed
+ ValidationErrorClaimsInvalid // Generic claims validation error
+)
+
+// Helper for constructing a ValidationError with a string error message
+func NewValidationError(errorText string, errorFlags uint32) *ValidationError {
+ return &ValidationError{
+ text: errorText,
+ Errors: errorFlags,
+ }
+}
+
+// The error from Parse if token is not valid
+type ValidationError struct {
+ Inner error // stores the error returned by external dependencies, i.e.: KeyFunc
+ Errors uint32 // bitfield. see ValidationError... constants
+ text string // errors that do not have a valid error just have text
+}
+
+// Validation error is an error type
+func (e ValidationError) Error() string {
+ if e.Inner != nil {
+ return e.Inner.Error()
+ } else if e.text != "" {
+ return e.text
+ } else {
+ return "token is invalid"
+ }
+}
+
+// No errors
+func (e *ValidationError) valid() bool {
+ return e.Errors == 0
+}
diff --git a/vendor/github.com/golang-jwt/jwt/hmac.go b/vendor/github.com/golang-jwt/jwt/hmac.go
new file mode 100644
index 0000000..addbe5d
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/hmac.go
@@ -0,0 +1,95 @@
+package jwt
+
+import (
+ "crypto"
+ "crypto/hmac"
+ "errors"
+)
+
+// Implements the HMAC-SHA family of signing methods signing methods
+// Expects key type of []byte for both signing and validation
+type SigningMethodHMAC struct {
+ Name string
+ Hash crypto.Hash
+}
+
+// Specific instances for HS256 and company
+var (
+ SigningMethodHS256 *SigningMethodHMAC
+ SigningMethodHS384 *SigningMethodHMAC
+ SigningMethodHS512 *SigningMethodHMAC
+ ErrSignatureInvalid = errors.New("signature is invalid")
+)
+
+func init() {
+ // HS256
+ SigningMethodHS256 = &SigningMethodHMAC{"HS256", crypto.SHA256}
+ RegisterSigningMethod(SigningMethodHS256.Alg(), func() SigningMethod {
+ return SigningMethodHS256
+ })
+
+ // HS384
+ SigningMethodHS384 = &SigningMethodHMAC{"HS384", crypto.SHA384}
+ RegisterSigningMethod(SigningMethodHS384.Alg(), func() SigningMethod {
+ return SigningMethodHS384
+ })
+
+ // HS512
+ SigningMethodHS512 = &SigningMethodHMAC{"HS512", crypto.SHA512}
+ RegisterSigningMethod(SigningMethodHS512.Alg(), func() SigningMethod {
+ return SigningMethodHS512
+ })
+}
+
+func (m *SigningMethodHMAC) Alg() string {
+ return m.Name
+}
+
+// Verify the signature of HSXXX tokens. Returns nil if the signature is valid.
+func (m *SigningMethodHMAC) Verify(signingString, signature string, key interface{}) error {
+ // Verify the key is the right type
+ keyBytes, ok := key.([]byte)
+ if !ok {
+ return ErrInvalidKeyType
+ }
+
+ // Decode signature, for comparison
+ sig, err := DecodeSegment(signature)
+ if err != nil {
+ return err
+ }
+
+ // Can we use the specified hashing method?
+ if !m.Hash.Available() {
+ return ErrHashUnavailable
+ }
+
+ // This signing method is symmetric, so we validate the signature
+ // by reproducing the signature from the signing string and key, then
+ // comparing that against the provided signature.
+ hasher := hmac.New(m.Hash.New, keyBytes)
+ hasher.Write([]byte(signingString))
+ if !hmac.Equal(sig, hasher.Sum(nil)) {
+ return ErrSignatureInvalid
+ }
+
+ // No validation errors. Signature is good.
+ return nil
+}
+
+// Implements the Sign method from SigningMethod for this signing method.
+// Key must be []byte
+func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) (string, error) {
+ if keyBytes, ok := key.([]byte); ok {
+ if !m.Hash.Available() {
+ return "", ErrHashUnavailable
+ }
+
+ hasher := hmac.New(m.Hash.New, keyBytes)
+ hasher.Write([]byte(signingString))
+
+ return EncodeSegment(hasher.Sum(nil)), nil
+ }
+
+ return "", ErrInvalidKeyType
+}
diff --git a/vendor/github.com/golang-jwt/jwt/map_claims.go b/vendor/github.com/golang-jwt/jwt/map_claims.go
new file mode 100644
index 0000000..72c79f9
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/map_claims.go
@@ -0,0 +1,120 @@
+package jwt
+
+import (
+ "encoding/json"
+ "errors"
+ // "fmt"
+)
+
+// Claims type that uses the map[string]interface{} for JSON decoding
+// This is the default claims type if you don't supply one
+type MapClaims map[string]interface{}
+
+// VerifyAudience Compares the aud claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (m MapClaims) VerifyAudience(cmp string, req bool) bool {
+ var aud []string
+ switch v := m["aud"].(type) {
+ case string:
+ aud = append(aud, v)
+ case []string:
+ aud = v
+ case []interface{}:
+ for _, a := range v {
+ vs, ok := a.(string)
+ if !ok {
+ return false
+ }
+ aud = append(aud, vs)
+ }
+ }
+ return verifyAud(aud, cmp, req)
+}
+
+// Compares the exp claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool {
+ exp, ok := m["exp"]
+ if !ok {
+ return !req
+ }
+ switch expType := exp.(type) {
+ case float64:
+ return verifyExp(int64(expType), cmp, req)
+ case json.Number:
+ v, _ := expType.Int64()
+ return verifyExp(v, cmp, req)
+ }
+ return false
+}
+
+// Compares the iat claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (m MapClaims) VerifyIssuedAt(cmp int64, req bool) bool {
+ iat, ok := m["iat"]
+ if !ok {
+ return !req
+ }
+ switch iatType := iat.(type) {
+ case float64:
+ return verifyIat(int64(iatType), cmp, req)
+ case json.Number:
+ v, _ := iatType.Int64()
+ return verifyIat(v, cmp, req)
+ }
+ return false
+}
+
+// Compares the iss claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (m MapClaims) VerifyIssuer(cmp string, req bool) bool {
+ iss, _ := m["iss"].(string)
+ return verifyIss(iss, cmp, req)
+}
+
+// Compares the nbf claim against cmp.
+// If required is false, this method will return true if the value matches or is unset
+func (m MapClaims) VerifyNotBefore(cmp int64, req bool) bool {
+ nbf, ok := m["nbf"]
+ if !ok {
+ return !req
+ }
+ switch nbfType := nbf.(type) {
+ case float64:
+ return verifyNbf(int64(nbfType), cmp, req)
+ case json.Number:
+ v, _ := nbfType.Int64()
+ return verifyNbf(v, cmp, req)
+ }
+ return false
+}
+
+// Validates time based claims "exp, iat, nbf".
+// There is no accounting for clock skew.
+// As well, if any of the above claims are not in the token, it will still
+// be considered a valid claim.
+func (m MapClaims) Valid() error {
+ vErr := new(ValidationError)
+ now := TimeFunc().Unix()
+
+ if !m.VerifyExpiresAt(now, false) {
+ vErr.Inner = errors.New("Token is expired")
+ vErr.Errors |= ValidationErrorExpired
+ }
+
+ if !m.VerifyIssuedAt(now, false) {
+ vErr.Inner = errors.New("Token used before issued")
+ vErr.Errors |= ValidationErrorIssuedAt
+ }
+
+ if !m.VerifyNotBefore(now, false) {
+ vErr.Inner = errors.New("Token is not valid yet")
+ vErr.Errors |= ValidationErrorNotValidYet
+ }
+
+ if vErr.valid() {
+ return nil
+ }
+
+ return vErr
+}
diff --git a/vendor/github.com/golang-jwt/jwt/none.go b/vendor/github.com/golang-jwt/jwt/none.go
new file mode 100644
index 0000000..f04d189
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/none.go
@@ -0,0 +1,52 @@
+package jwt
+
+// Implements the none signing method. This is required by the spec
+// but you probably should never use it.
+var SigningMethodNone *signingMethodNone
+
+const UnsafeAllowNoneSignatureType unsafeNoneMagicConstant = "none signing method allowed"
+
+var NoneSignatureTypeDisallowedError error
+
+type signingMethodNone struct{}
+type unsafeNoneMagicConstant string
+
+func init() {
+ SigningMethodNone = &signingMethodNone{}
+ NoneSignatureTypeDisallowedError = NewValidationError("'none' signature type is not allowed", ValidationErrorSignatureInvalid)
+
+ RegisterSigningMethod(SigningMethodNone.Alg(), func() SigningMethod {
+ return SigningMethodNone
+ })
+}
+
+func (m *signingMethodNone) Alg() string {
+ return "none"
+}
+
+// Only allow 'none' alg type if UnsafeAllowNoneSignatureType is specified as the key
+func (m *signingMethodNone) Verify(signingString, signature string, key interface{}) (err error) {
+ // Key must be UnsafeAllowNoneSignatureType to prevent accidentally
+ // accepting 'none' signing method
+ if _, ok := key.(unsafeNoneMagicConstant); !ok {
+ return NoneSignatureTypeDisallowedError
+ }
+ // If signing method is none, signature must be an empty string
+ if signature != "" {
+ return NewValidationError(
+ "'none' signing method with non-empty signature",
+ ValidationErrorSignatureInvalid,
+ )
+ }
+
+ // Accept 'none' signing method.
+ return nil
+}
+
+// Only allow 'none' signing if UnsafeAllowNoneSignatureType is specified as the key
+func (m *signingMethodNone) Sign(signingString string, key interface{}) (string, error) {
+ if _, ok := key.(unsafeNoneMagicConstant); ok {
+ return "", nil
+ }
+ return "", NoneSignatureTypeDisallowedError
+}
diff --git a/vendor/github.com/golang-jwt/jwt/parser.go b/vendor/github.com/golang-jwt/jwt/parser.go
new file mode 100644
index 0000000..d6901d9
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/parser.go
@@ -0,0 +1,148 @@
+package jwt
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "strings"
+)
+
+type Parser struct {
+ ValidMethods []string // If populated, only these methods will be considered valid
+ UseJSONNumber bool // Use JSON Number format in JSON decoder
+ SkipClaimsValidation bool // Skip claims validation during token parsing
+}
+
+// Parse, validate, and return a token.
+// keyFunc will receive the parsed token and should return the key for validating.
+// If everything is kosher, err will be nil
+func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
+ return p.ParseWithClaims(tokenString, MapClaims{}, keyFunc)
+}
+
+func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) {
+ token, parts, err := p.ParseUnverified(tokenString, claims)
+ if err != nil {
+ return token, err
+ }
+
+ // Verify signing method is in the required set
+ if p.ValidMethods != nil {
+ var signingMethodValid = false
+ var alg = token.Method.Alg()
+ for _, m := range p.ValidMethods {
+ if m == alg {
+ signingMethodValid = true
+ break
+ }
+ }
+ if !signingMethodValid {
+ // signing method is not in the listed set
+ return token, NewValidationError(fmt.Sprintf("signing method %v is invalid", alg), ValidationErrorSignatureInvalid)
+ }
+ }
+
+ // Lookup key
+ var key interface{}
+ if keyFunc == nil {
+ // keyFunc was not provided. short circuiting validation
+ return token, NewValidationError("no Keyfunc was provided.", ValidationErrorUnverifiable)
+ }
+ if key, err = keyFunc(token); err != nil {
+ // keyFunc returned an error
+ if ve, ok := err.(*ValidationError); ok {
+ return token, ve
+ }
+ return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable}
+ }
+
+ vErr := &ValidationError{}
+
+ // Validate Claims
+ if !p.SkipClaimsValidation {
+ if err := token.Claims.Valid(); err != nil {
+
+ // If the Claims Valid returned an error, check if it is a validation error,
+ // If it was another error type, create a ValidationError with a generic ClaimsInvalid flag set
+ if e, ok := err.(*ValidationError); !ok {
+ vErr = &ValidationError{Inner: err, Errors: ValidationErrorClaimsInvalid}
+ } else {
+ vErr = e
+ }
+ }
+ }
+
+ // Perform validation
+ token.Signature = parts[2]
+ if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
+ vErr.Inner = err
+ vErr.Errors |= ValidationErrorSignatureInvalid
+ }
+
+ if vErr.valid() {
+ token.Valid = true
+ return token, nil
+ }
+
+ return token, vErr
+}
+
+// WARNING: Don't use this method unless you know what you're doing
+//
+// This method parses the token but doesn't validate the signature. It's only
+// ever useful in cases where you know the signature is valid (because it has
+// been checked previously in the stack) and you want to extract values from
+// it.
+func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) {
+ parts = strings.Split(tokenString, ".")
+ if len(parts) != 3 {
+ return nil, parts, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed)
+ }
+
+ token = &Token{Raw: tokenString}
+
+ // parse Header
+ var headerBytes []byte
+ if headerBytes, err = DecodeSegment(parts[0]); err != nil {
+ if strings.HasPrefix(strings.ToLower(tokenString), "bearer ") {
+ return token, parts, NewValidationError("tokenstring should not contain 'bearer '", ValidationErrorMalformed)
+ }
+ return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed}
+ }
+ if err = json.Unmarshal(headerBytes, &token.Header); err != nil {
+ return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed}
+ }
+
+ // parse Claims
+ var claimBytes []byte
+ token.Claims = claims
+
+ if claimBytes, err = DecodeSegment(parts[1]); err != nil {
+ return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed}
+ }
+ dec := json.NewDecoder(bytes.NewBuffer(claimBytes))
+ if p.UseJSONNumber {
+ dec.UseNumber()
+ }
+ // JSON Decode. Special case for map type to avoid weird pointer behavior
+ if c, ok := token.Claims.(MapClaims); ok {
+ err = dec.Decode(&c)
+ } else {
+ err = dec.Decode(&claims)
+ }
+ // Handle decode error
+ if err != nil {
+ return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed}
+ }
+
+ // Lookup signature method
+ if method, ok := token.Header["alg"].(string); ok {
+ if token.Method = GetSigningMethod(method); token.Method == nil {
+ return token, parts, NewValidationError("signing method (alg) is unavailable.", ValidationErrorUnverifiable)
+ }
+ } else {
+ return token, parts, NewValidationError("signing method (alg) is unspecified.", ValidationErrorUnverifiable)
+ }
+
+ return token, parts, nil
+}
diff --git a/vendor/github.com/golang-jwt/jwt/rsa.go b/vendor/github.com/golang-jwt/jwt/rsa.go
new file mode 100644
index 0000000..e4caf1c
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/rsa.go
@@ -0,0 +1,101 @@
+package jwt
+
+import (
+ "crypto"
+ "crypto/rand"
+ "crypto/rsa"
+)
+
+// Implements the RSA family of signing methods signing methods
+// Expects *rsa.PrivateKey for signing and *rsa.PublicKey for validation
+type SigningMethodRSA struct {
+ Name string
+ Hash crypto.Hash
+}
+
+// Specific instances for RS256 and company
+var (
+ SigningMethodRS256 *SigningMethodRSA
+ SigningMethodRS384 *SigningMethodRSA
+ SigningMethodRS512 *SigningMethodRSA
+)
+
+func init() {
+ // RS256
+ SigningMethodRS256 = &SigningMethodRSA{"RS256", crypto.SHA256}
+ RegisterSigningMethod(SigningMethodRS256.Alg(), func() SigningMethod {
+ return SigningMethodRS256
+ })
+
+ // RS384
+ SigningMethodRS384 = &SigningMethodRSA{"RS384", crypto.SHA384}
+ RegisterSigningMethod(SigningMethodRS384.Alg(), func() SigningMethod {
+ return SigningMethodRS384
+ })
+
+ // RS512
+ SigningMethodRS512 = &SigningMethodRSA{"RS512", crypto.SHA512}
+ RegisterSigningMethod(SigningMethodRS512.Alg(), func() SigningMethod {
+ return SigningMethodRS512
+ })
+}
+
+func (m *SigningMethodRSA) Alg() string {
+ return m.Name
+}
+
+// Implements the Verify method from SigningMethod
+// For this signing method, must be an *rsa.PublicKey structure.
+func (m *SigningMethodRSA) Verify(signingString, signature string, key interface{}) error {
+ var err error
+
+ // Decode the signature
+ var sig []byte
+ if sig, err = DecodeSegment(signature); err != nil {
+ return err
+ }
+
+ var rsaKey *rsa.PublicKey
+ var ok bool
+
+ if rsaKey, ok = key.(*rsa.PublicKey); !ok {
+ return ErrInvalidKeyType
+ }
+
+ // Create hasher
+ if !m.Hash.Available() {
+ return ErrHashUnavailable
+ }
+ hasher := m.Hash.New()
+ hasher.Write([]byte(signingString))
+
+ // Verify the signature
+ return rsa.VerifyPKCS1v15(rsaKey, m.Hash, hasher.Sum(nil), sig)
+}
+
+// Implements the Sign method from SigningMethod
+// For this signing method, must be an *rsa.PrivateKey structure.
+func (m *SigningMethodRSA) Sign(signingString string, key interface{}) (string, error) {
+ var rsaKey *rsa.PrivateKey
+ var ok bool
+
+ // Validate type of key
+ if rsaKey, ok = key.(*rsa.PrivateKey); !ok {
+ return "", ErrInvalidKey
+ }
+
+ // Create the hasher
+ if !m.Hash.Available() {
+ return "", ErrHashUnavailable
+ }
+
+ hasher := m.Hash.New()
+ hasher.Write([]byte(signingString))
+
+ // Sign the string and return the encoded bytes
+ if sigBytes, err := rsa.SignPKCS1v15(rand.Reader, rsaKey, m.Hash, hasher.Sum(nil)); err == nil {
+ return EncodeSegment(sigBytes), nil
+ } else {
+ return "", err
+ }
+}
diff --git a/vendor/github.com/golang-jwt/jwt/rsa_pss.go b/vendor/github.com/golang-jwt/jwt/rsa_pss.go
new file mode 100644
index 0000000..c014708
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/rsa_pss.go
@@ -0,0 +1,142 @@
+// +build go1.4
+
+package jwt
+
+import (
+ "crypto"
+ "crypto/rand"
+ "crypto/rsa"
+)
+
+// Implements the RSAPSS family of signing methods signing methods
+type SigningMethodRSAPSS struct {
+ *SigningMethodRSA
+ Options *rsa.PSSOptions
+ // VerifyOptions is optional. If set overrides Options for rsa.VerifyPPS.
+ // Used to accept tokens signed with rsa.PSSSaltLengthAuto, what doesn't follow
+ // https://tools.ietf.org/html/rfc7518#section-3.5 but was used previously.
+ // See https://github.com/dgrijalva/jwt-go/issues/285#issuecomment-437451244 for details.
+ VerifyOptions *rsa.PSSOptions
+}
+
+// Specific instances for RS/PS and company.
+var (
+ SigningMethodPS256 *SigningMethodRSAPSS
+ SigningMethodPS384 *SigningMethodRSAPSS
+ SigningMethodPS512 *SigningMethodRSAPSS
+)
+
+func init() {
+ // PS256
+ SigningMethodPS256 = &SigningMethodRSAPSS{
+ SigningMethodRSA: &SigningMethodRSA{
+ Name: "PS256",
+ Hash: crypto.SHA256,
+ },
+ Options: &rsa.PSSOptions{
+ SaltLength: rsa.PSSSaltLengthEqualsHash,
+ },
+ VerifyOptions: &rsa.PSSOptions{
+ SaltLength: rsa.PSSSaltLengthAuto,
+ },
+ }
+ RegisterSigningMethod(SigningMethodPS256.Alg(), func() SigningMethod {
+ return SigningMethodPS256
+ })
+
+ // PS384
+ SigningMethodPS384 = &SigningMethodRSAPSS{
+ SigningMethodRSA: &SigningMethodRSA{
+ Name: "PS384",
+ Hash: crypto.SHA384,
+ },
+ Options: &rsa.PSSOptions{
+ SaltLength: rsa.PSSSaltLengthEqualsHash,
+ },
+ VerifyOptions: &rsa.PSSOptions{
+ SaltLength: rsa.PSSSaltLengthAuto,
+ },
+ }
+ RegisterSigningMethod(SigningMethodPS384.Alg(), func() SigningMethod {
+ return SigningMethodPS384
+ })
+
+ // PS512
+ SigningMethodPS512 = &SigningMethodRSAPSS{
+ SigningMethodRSA: &SigningMethodRSA{
+ Name: "PS512",
+ Hash: crypto.SHA512,
+ },
+ Options: &rsa.PSSOptions{
+ SaltLength: rsa.PSSSaltLengthEqualsHash,
+ },
+ VerifyOptions: &rsa.PSSOptions{
+ SaltLength: rsa.PSSSaltLengthAuto,
+ },
+ }
+ RegisterSigningMethod(SigningMethodPS512.Alg(), func() SigningMethod {
+ return SigningMethodPS512
+ })
+}
+
+// Implements the Verify method from SigningMethod
+// For this verify method, key must be an rsa.PublicKey struct
+func (m *SigningMethodRSAPSS) Verify(signingString, signature string, key interface{}) error {
+ var err error
+
+ // Decode the signature
+ var sig []byte
+ if sig, err = DecodeSegment(signature); err != nil {
+ return err
+ }
+
+ var rsaKey *rsa.PublicKey
+ switch k := key.(type) {
+ case *rsa.PublicKey:
+ rsaKey = k
+ default:
+ return ErrInvalidKey
+ }
+
+ // Create hasher
+ if !m.Hash.Available() {
+ return ErrHashUnavailable
+ }
+ hasher := m.Hash.New()
+ hasher.Write([]byte(signingString))
+
+ opts := m.Options
+ if m.VerifyOptions != nil {
+ opts = m.VerifyOptions
+ }
+
+ return rsa.VerifyPSS(rsaKey, m.Hash, hasher.Sum(nil), sig, opts)
+}
+
+// Implements the Sign method from SigningMethod
+// For this signing method, key must be an rsa.PrivateKey struct
+func (m *SigningMethodRSAPSS) Sign(signingString string, key interface{}) (string, error) {
+ var rsaKey *rsa.PrivateKey
+
+ switch k := key.(type) {
+ case *rsa.PrivateKey:
+ rsaKey = k
+ default:
+ return "", ErrInvalidKeyType
+ }
+
+ // Create the hasher
+ if !m.Hash.Available() {
+ return "", ErrHashUnavailable
+ }
+
+ hasher := m.Hash.New()
+ hasher.Write([]byte(signingString))
+
+ // Sign the string and return the encoded bytes
+ if sigBytes, err := rsa.SignPSS(rand.Reader, rsaKey, m.Hash, hasher.Sum(nil), m.Options); err == nil {
+ return EncodeSegment(sigBytes), nil
+ } else {
+ return "", err
+ }
+}
diff --git a/vendor/github.com/golang-jwt/jwt/rsa_utils.go b/vendor/github.com/golang-jwt/jwt/rsa_utils.go
new file mode 100644
index 0000000..14c78c2
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/rsa_utils.go
@@ -0,0 +1,101 @@
+package jwt
+
+import (
+ "crypto/rsa"
+ "crypto/x509"
+ "encoding/pem"
+ "errors"
+)
+
+var (
+ ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be a PEM encoded PKCS1 or PKCS8 key")
+ ErrNotRSAPrivateKey = errors.New("Key is not a valid RSA private key")
+ ErrNotRSAPublicKey = errors.New("Key is not a valid RSA public key")
+)
+
+// Parse PEM encoded PKCS1 or PKCS8 private key
+func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) {
+ var err error
+
+ // Parse PEM block
+ var block *pem.Block
+ if block, _ = pem.Decode(key); block == nil {
+ return nil, ErrKeyMustBePEMEncoded
+ }
+
+ var parsedKey interface{}
+ if parsedKey, err = x509.ParsePKCS1PrivateKey(block.Bytes); err != nil {
+ if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
+ return nil, err
+ }
+ }
+
+ var pkey *rsa.PrivateKey
+ var ok bool
+ if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok {
+ return nil, ErrNotRSAPrivateKey
+ }
+
+ return pkey, nil
+}
+
+// Parse PEM encoded PKCS1 or PKCS8 private key protected with password
+func ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error) {
+ var err error
+
+ // Parse PEM block
+ var block *pem.Block
+ if block, _ = pem.Decode(key); block == nil {
+ return nil, ErrKeyMustBePEMEncoded
+ }
+
+ var parsedKey interface{}
+
+ var blockDecrypted []byte
+ if blockDecrypted, err = x509.DecryptPEMBlock(block, []byte(password)); err != nil {
+ return nil, err
+ }
+
+ if parsedKey, err = x509.ParsePKCS1PrivateKey(blockDecrypted); err != nil {
+ if parsedKey, err = x509.ParsePKCS8PrivateKey(blockDecrypted); err != nil {
+ return nil, err
+ }
+ }
+
+ var pkey *rsa.PrivateKey
+ var ok bool
+ if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok {
+ return nil, ErrNotRSAPrivateKey
+ }
+
+ return pkey, nil
+}
+
+// Parse PEM encoded PKCS1 or PKCS8 public key
+func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) {
+ var err error
+
+ // Parse PEM block
+ var block *pem.Block
+ if block, _ = pem.Decode(key); block == nil {
+ return nil, ErrKeyMustBePEMEncoded
+ }
+
+ // Parse the key
+ var parsedKey interface{}
+ if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
+ if cert, err := x509.ParseCertificate(block.Bytes); err == nil {
+ parsedKey = cert.PublicKey
+ } else {
+ return nil, err
+ }
+ }
+
+ var pkey *rsa.PublicKey
+ var ok bool
+ if pkey, ok = parsedKey.(*rsa.PublicKey); !ok {
+ return nil, ErrNotRSAPublicKey
+ }
+
+ return pkey, nil
+}
diff --git a/vendor/github.com/golang-jwt/jwt/signing_method.go b/vendor/github.com/golang-jwt/jwt/signing_method.go
new file mode 100644
index 0000000..ed1f212
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/signing_method.go
@@ -0,0 +1,35 @@
+package jwt
+
+import (
+ "sync"
+)
+
+var signingMethods = map[string]func() SigningMethod{}
+var signingMethodLock = new(sync.RWMutex)
+
+// Implement SigningMethod to add new methods for signing or verifying tokens.
+type SigningMethod interface {
+ Verify(signingString, signature string, key interface{}) error // Returns nil if signature is valid
+ Sign(signingString string, key interface{}) (string, error) // Returns encoded signature or error
+ Alg() string // returns the alg identifier for this method (example: 'HS256')
+}
+
+// Register the "alg" name and a factory function for signing method.
+// This is typically done during init() in the method's implementation
+func RegisterSigningMethod(alg string, f func() SigningMethod) {
+ signingMethodLock.Lock()
+ defer signingMethodLock.Unlock()
+
+ signingMethods[alg] = f
+}
+
+// Get a signing method from an "alg" string
+func GetSigningMethod(alg string) (method SigningMethod) {
+ signingMethodLock.RLock()
+ defer signingMethodLock.RUnlock()
+
+ if methodF, ok := signingMethods[alg]; ok {
+ method = methodF()
+ }
+ return
+}
diff --git a/vendor/github.com/golang-jwt/jwt/token.go b/vendor/github.com/golang-jwt/jwt/token.go
new file mode 100644
index 0000000..6b30ced
--- /dev/null
+++ b/vendor/github.com/golang-jwt/jwt/token.go
@@ -0,0 +1,104 @@
+package jwt
+
+import (
+ "encoding/base64"
+ "encoding/json"
+ "strings"
+ "time"
+)
+
+// TimeFunc provides the current time when parsing token to validate "exp" claim (expiration time).
+// You can override it to use another time value. This is useful for testing or if your
+// server uses a different time zone than your tokens.
+var TimeFunc = time.Now
+
+// Parse methods use this callback function to supply
+// the key for verification. The function receives the parsed,
+// but unverified Token. This allows you to use properties in the
+// Header of the token (such as `kid`) to identify which key to use.
+type Keyfunc func(*Token) (interface{}, error)
+
+// A JWT Token. Different fields will be used depending on whether you're
+// creating or parsing/verifying a token.
+type Token struct {
+ Raw string // The raw token. Populated when you Parse a token
+ Method SigningMethod // The signing method used or to be used
+ Header map[string]interface{} // The first segment of the token
+ Claims Claims // The second segment of the token
+ Signature string // The third segment of the token. Populated when you Parse a token
+ Valid bool // Is the token valid? Populated when you Parse/Verify a token
+}
+
+// Create a new Token. Takes a signing method
+func New(method SigningMethod) *Token {
+ return NewWithClaims(method, MapClaims{})
+}
+
+func NewWithClaims(method SigningMethod, claims Claims) *Token {
+ return &Token{
+ Header: map[string]interface{}{
+ "typ": "JWT",
+ "alg": method.Alg(),
+ },
+ Claims: claims,
+ Method: method,
+ }
+}
+
+// Get the complete, signed token
+func (t *Token) SignedString(key interface{}) (string, error) {
+ var sig, sstr string
+ var err error
+ if sstr, err = t.SigningString(); err != nil {
+ return "", err
+ }
+ if sig, err = t.Method.Sign(sstr, key); err != nil {
+ return "", err
+ }
+ return strings.Join([]string{sstr, sig}, "."), nil
+}
+
+// Generate the signing string. This is the
+// most expensive part of the whole deal. Unless you
+// need this for something special, just go straight for
+// the SignedString.
+func (t *Token) SigningString() (string, error) {
+ var err error
+ parts := make([]string, 2)
+ for i := range parts {
+ var jsonValue []byte
+ if i == 0 {
+ if jsonValue, err = json.Marshal(t.Header); err != nil {
+ return "", err
+ }
+ } else {
+ if jsonValue, err = json.Marshal(t.Claims); err != nil {
+ return "", err
+ }
+ }
+
+ parts[i] = EncodeSegment(jsonValue)
+ }
+ return strings.Join(parts, "."), nil
+}
+
+// Parse, validate, and return a token.
+// keyFunc will receive the parsed token and should return the key for validating.
+// If everything is kosher, err will be nil
+func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
+ return new(Parser).Parse(tokenString, keyFunc)
+}
+
+func ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) {
+ return new(Parser).ParseWithClaims(tokenString, claims, keyFunc)
+}
+
+// Encode JWT specific base64url encoding with padding stripped
+func EncodeSegment(seg []byte) string {
+ return base64.RawURLEncoding.EncodeToString(seg)
+}
+
+// Decode JWT specific base64url encoding with padding stripped
+func DecodeSegment(seg string) ([]byte, error) {
+ return base64.RawURLEncoding.DecodeString(seg)
+}
diff --git a/vendor/github.com/golang/snappy/README b/vendor/github.com/golang/snappy/README
index fd191f7..cea1287 100644
--- a/vendor/github.com/golang/snappy/README
+++ b/vendor/github.com/golang/snappy/README
@@ -1,13 +1,8 @@
The Snappy compression format in the Go programming language.
-To use as a library:
+To download and install from source:
$ go get github.com/golang/snappy
-To use as a binary:
-$ go install github.com/golang/snappy/cmd/snappytool@latest
-$ cat decoded | ~/go/bin/snappytool -e > encoded
-$ cat encoded | ~/go/bin/snappytool -d > decoded
-
Unless otherwise noted, the Snappy-Go source files are distributed
under the BSD-style license found in the LICENSE file.
diff --git a/vendor/github.com/golang/snappy/encode_arm64.s b/vendor/github.com/golang/snappy/encode_arm64.s
index f0c876a..f8d54ad 100644
--- a/vendor/github.com/golang/snappy/encode_arm64.s
+++ b/vendor/github.com/golang/snappy/encode_arm64.s
@@ -27,7 +27,7 @@
// The unusual register allocation of local variables, such as R10 for the
// source pointer, matches the allocation used at the call site in encodeBlock,
// which makes it easier to manually inline this function.
-TEXT ·emitLiteral(SB), NOSPLIT, $40-56
+TEXT ·emitLiteral(SB), NOSPLIT, $32-56
MOVD dst_base+0(FP), R8
MOVD lit_base+24(FP), R10
MOVD lit_len+32(FP), R3
@@ -261,7 +261,7 @@ extendMatchEnd:
// "var table [maxTableSize]uint16" takes up 32768 bytes of stack space. An
// extra 64 bytes, to call other functions, and an extra 64 bytes, to spill
// local variables (registers) during calls gives 32768 + 64 + 64 = 32896.
-TEXT ·encodeBlock(SB), 0, $32904-56
+TEXT ·encodeBlock(SB), 0, $32896-56
MOVD dst_base+0(FP), R8
MOVD src_base+24(FP), R7
MOVD src_len+32(FP), R14
diff --git a/vendor/github.com/json-iterator/go/README.md b/vendor/github.com/json-iterator/go/README.md
index c589add..52b111d 100644
--- a/vendor/github.com/json-iterator/go/README.md
+++ b/vendor/github.com/json-iterator/go/README.md
@@ -8,6 +8,8 @@
A high-performance 100% compatible drop-in replacement of "encoding/json"
+You can also use thrift like JSON using [thrift-iterator](https://github.com/thrift-iterator/go)
+
# Benchmark

diff --git a/vendor/github.com/labstack/echo/v4/.travis.yml b/vendor/github.com/labstack/echo/v4/.travis.yml
new file mode 100644
index 0000000..67d45ad
--- /dev/null
+++ b/vendor/github.com/labstack/echo/v4/.travis.yml
@@ -0,0 +1,21 @@
+arch:
+ - amd64
+ - ppc64le
+
+language: go
+go:
+ - 1.14.x
+ - 1.15.x
+ - tip
+env:
+ - GO111MODULE=on
+install:
+ - go get -v golang.org/x/lint/golint
+script:
+ - golint -set_exit_status ./...
+ - go test -race -coverprofile=coverage.txt -covermode=atomic ./...
+after_success:
+ - bash <(curl -s https://codecov.io/bash)
+matrix:
+ allow_failures:
+ - go: tip
diff --git a/vendor/github.com/labstack/echo/v4/CHANGELOG.md b/vendor/github.com/labstack/echo/v4/CHANGELOG.md
index 967fac2..02eb36f 100644
--- a/vendor/github.com/labstack/echo/v4/CHANGELOG.md
+++ b/vendor/github.com/labstack/echo/v4/CHANGELOG.md
@@ -1,389 +1,5 @@
# Changelog
-## v4.13.4 - 2025-05-22
-
-**Enhancements**
-
-* chore: fix some typos in comment by @zhuhaicity in https://github.com/labstack/echo/pull/2735
-* CI: test with Go 1.24 by @aldas in https://github.com/labstack/echo/pull/2748
-* Add support for TLS WebSocket proxy by @t-ibayashi-safie in https://github.com/labstack/echo/pull/2762
-
-**Security**
-
-* Update dependencies for [GO-2025-3487](https://pkg.go.dev/vuln/GO-2025-3487), [GO-2025-3503](https://pkg.go.dev/vuln/GO-2025-3503) and [GO-2025-3595](https://pkg.go.dev/vuln/GO-2025-3595) in https://github.com/labstack/echo/pull/2780
-
-
-## v4.13.3 - 2024-12-19
-
-**Security**
-
-* Update golang.org/x/net dependency [GO-2024-3333](https://pkg.go.dev/vuln/GO-2024-3333) in https://github.com/labstack/echo/pull/2722
-
-
-## v4.13.2 - 2024-12-12
-
-**Security**
-
-* Update dependencies (dependabot reports [GO-2024-3321](https://pkg.go.dev/vuln/GO-2024-3321)) in https://github.com/labstack/echo/pull/2721
-
-
-## v4.13.1 - 2024-12-11
-
-**Fixes**
-
-* Fix BindBody ignoring `Transfer-Encoding: chunked` requests by @178inaba in https://github.com/labstack/echo/pull/2717
-
-
-
-## v4.13.0 - 2024-12-04
-
-**BREAKING CHANGE** JWT Middleware Removed from Core use [labstack/echo-jwt](https://github.com/labstack/echo-jwt) instead
-
-The JWT middleware has been **removed from Echo core** due to another security vulnerability, [CVE-2024-51744](https://nvd.nist.gov/vuln/detail/CVE-2024-51744). For more details, refer to issue [#2699](https://github.com/labstack/echo/issues/2699). A drop-in replacement is available in the [labstack/echo-jwt](https://github.com/labstack/echo-jwt) repository.
-
-**Important**: Direct assignments like `token := c.Get("user").(*jwt.Token)` will now cause a panic due to an invalid cast. Update your code accordingly. Replace the current imports from `"github.com/golang-jwt/jwt"` in your handlers to the new middleware version using `"github.com/golang-jwt/jwt/v5"`.
-
-
-Background:
-
-The version of `golang-jwt/jwt` (v3.2.2) previously used in Echo core has been in an unmaintained state for some time. This is not the first vulnerability affecting this library; earlier issues were addressed in [PR #1946](https://github.com/labstack/echo/pull/1946).
-JWT middleware was marked as deprecated in Echo core as of [v4.10.0](https://github.com/labstack/echo/releases/tag/v4.10.0) on 2022-12-27. If you did not notice that, consider leveraging tools like [Staticcheck](https://staticcheck.dev/) to catch such deprecations earlier in you dev/CI flow. For bonus points - check out [gosec](https://github.com/securego/gosec).
-
-We sincerely apologize for any inconvenience caused by this change. While we strive to maintain backward compatibility within Echo core, recurring security issues with third-party dependencies have forced this decision.
-
-**Enhancements**
-
-* remove jwt middleware by @stevenwhitehead in https://github.com/labstack/echo/pull/2701
-* optimization: struct alignment by @behnambm in https://github.com/labstack/echo/pull/2636
-* bind: Maintain backwards compatibility for map[string]interface{} binding by @thesaltree in https://github.com/labstack/echo/pull/2656
-* Add Go 1.23 to CI by @aldas in https://github.com/labstack/echo/pull/2675
-* improve `MultipartForm` test by @martinyonatann in https://github.com/labstack/echo/pull/2682
-* `bind` : add support of multipart multi files by @martinyonatann in https://github.com/labstack/echo/pull/2684
-* Add TemplateRenderer struct to ease creating renderers for `html/template` and `text/template` packages. by @aldas in https://github.com/labstack/echo/pull/2690
-* Refactor TestBasicAuth to utilize table-driven test format by @ErikOlson in https://github.com/labstack/echo/pull/2688
-* Remove broken header by @aldas in https://github.com/labstack/echo/pull/2705
-* fix(bind body): content-length can be -1 by @phamvinhdat in https://github.com/labstack/echo/pull/2710
-* CORS middleware should compile allowOrigin regexp at creation by @aldas in https://github.com/labstack/echo/pull/2709
-* Shorten Github issue template and add test example by @aldas in https://github.com/labstack/echo/pull/2711
-
-
-## v4.12.0 - 2024-04-15
-
-**Security**
-
-* Update golang.org/x/net dep because of [GO-2024-2687](https://pkg.go.dev/vuln/GO-2024-2687) by @aldas in https://github.com/labstack/echo/pull/2625
-
-
-**Enhancements**
-
-* binder: make binding to Map work better with string destinations by @aldas in https://github.com/labstack/echo/pull/2554
-* README.md: add Encore as sponsor by @marcuskohlberg in https://github.com/labstack/echo/pull/2579
-* Reorder paragraphs in README.md by @aldas in https://github.com/labstack/echo/pull/2581
-* CI: upgrade actions/checkout to v4 by @aldas in https://github.com/labstack/echo/pull/2584
-* Remove default charset from 'application/json' Content-Type header by @doortts in https://github.com/labstack/echo/pull/2568
-* CI: Use Go 1.22 by @aldas in https://github.com/labstack/echo/pull/2588
-* binder: allow binding to a nil map by @georgmu in https://github.com/labstack/echo/pull/2574
-* Add Skipper Unit Test In BasicBasicAuthConfig and Add More Detail Explanation regarding BasicAuthValidator by @RyoKusnadi in https://github.com/labstack/echo/pull/2461
-* fix some typos by @teslaedison in https://github.com/labstack/echo/pull/2603
-* fix: some typos by @pomadev in https://github.com/labstack/echo/pull/2596
-* Allow ResponseWriters to unwrap writers when flushing/hijacking by @aldas in https://github.com/labstack/echo/pull/2595
-* Add SPDX licence comments to files. by @aldas in https://github.com/labstack/echo/pull/2604
-* Upgrade deps by @aldas in https://github.com/labstack/echo/pull/2605
-* Change type definition blocks to single declarations. This helps copy… by @aldas in https://github.com/labstack/echo/pull/2606
-* Fix Real IP logic by @cl-bvl in https://github.com/labstack/echo/pull/2550
-* Default binder can use `UnmarshalParams(params []string) error` inter… by @aldas in https://github.com/labstack/echo/pull/2607
-* Default binder can bind pointer to slice as struct field. For example `*[]string` by @aldas in https://github.com/labstack/echo/pull/2608
-* Remove maxparam dependence from Context by @aldas in https://github.com/labstack/echo/pull/2611
-* When route is registered with empty path it is normalized to `/`. by @aldas in https://github.com/labstack/echo/pull/2616
-* proxy middleware should use httputil.ReverseProxy for SSE requests by @aldas in https://github.com/labstack/echo/pull/2624
-
-
-## v4.11.4 - 2023-12-20
-
-**Security**
-
-* Upgrade golang.org/x/crypto to v0.17.0 to fix vulnerability [issue](https://pkg.go.dev/vuln/GO-2023-2402) [#2562](https://github.com/labstack/echo/pull/2562)
-
-**Enhancements**
-
-* Update deps and mark Go version to 1.18 as this is what golang.org/x/* use [#2563](https://github.com/labstack/echo/pull/2563)
-* Request logger: add example for Slog https://pkg.go.dev/log/slog [#2543](https://github.com/labstack/echo/pull/2543)
-
-
-## v4.11.3 - 2023-11-07
-
-**Security**
-
-* 'c.Attachment' and 'c.Inline' should escape filename in 'Content-Disposition' header to avoid 'Reflect File Download' vulnerability. [#2541](https://github.com/labstack/echo/pull/2541)
-
-**Enhancements**
-
-* Tests: refactor context tests to be separate functions [#2540](https://github.com/labstack/echo/pull/2540)
-* Proxy middleware: reuse echo request context [#2537](https://github.com/labstack/echo/pull/2537)
-* Mark unmarshallable yaml struct tags as ignored [#2536](https://github.com/labstack/echo/pull/2536)
-
-
-## v4.11.2 - 2023-10-11
-
-**Security**
-
-* Bump golang.org/x/net to prevent CVE-2023-39325 / CVE-2023-44487 HTTP/2 Rapid Reset Attack [#2527](https://github.com/labstack/echo/pull/2527)
-* fix(sec): randomString bias introduced by #2490 [#2492](https://github.com/labstack/echo/pull/2492)
-* CSRF/RequestID mw: switch math/random usage to crypto/random [#2490](https://github.com/labstack/echo/pull/2490)
-
-**Enhancements**
-
-* Delete unused context in body_limit.go [#2483](https://github.com/labstack/echo/pull/2483)
-* Use Go 1.21 in CI [#2505](https://github.com/labstack/echo/pull/2505)
-* Fix some typos [#2511](https://github.com/labstack/echo/pull/2511)
-* Allow CORS middleware to send Access-Control-Max-Age: 0 [#2518](https://github.com/labstack/echo/pull/2518)
-* Bump dependancies [#2522](https://github.com/labstack/echo/pull/2522)
-
-## v4.11.1 - 2023-07-16
-
-**Fixes**
-
-* Fix `Gzip` middleware not sending response code for no content responses (404, 301/302 redirects etc) [#2481](https://github.com/labstack/echo/pull/2481)
-
-
-## v4.11.0 - 2023-07-14
-
-
-**Fixes**
-
-* Fixes the proxy middleware concurrency issue of calling the Next() proxy target on Round Robin Balancer [#2409](https://github.com/labstack/echo/pull/2409)
-* Fix `group.RouteNotFound` not working when group has attached middlewares [#2411](https://github.com/labstack/echo/pull/2411)
-* Fix global error handler return error message when message is an error [#2456](https://github.com/labstack/echo/pull/2456)
-* Do not use global timeNow variables [#2477](https://github.com/labstack/echo/pull/2477)
-
-
-**Enhancements**
-
-* Added a optional config variable to disable centralized error handler in recovery middleware [#2410](https://github.com/labstack/echo/pull/2410)
-* refactor: use `strings.ReplaceAll` directly [#2424](https://github.com/labstack/echo/pull/2424)
-* Add support for Go1.20 `http.rwUnwrapper` to Response struct [#2425](https://github.com/labstack/echo/pull/2425)
-* Check whether is nil before invoking centralized error handling [#2429](https://github.com/labstack/echo/pull/2429)
-* Proper colon support in `echo.Reverse` method [#2416](https://github.com/labstack/echo/pull/2416)
-* Fix misuses of a vs an in documentation comments [#2436](https://github.com/labstack/echo/pull/2436)
-* Add link to slog.Handler library for Echo logging into README.md [#2444](https://github.com/labstack/echo/pull/2444)
-* In proxy middleware Support retries of failed proxy requests [#2414](https://github.com/labstack/echo/pull/2414)
-* gofmt fixes to comments [#2452](https://github.com/labstack/echo/pull/2452)
-* gzip response only if it exceeds a minimal length [#2267](https://github.com/labstack/echo/pull/2267)
-* Upgrade packages [#2475](https://github.com/labstack/echo/pull/2475)
-
-
-## v4.10.2 - 2023-02-22
-
-**Security**
-
-* `filepath.Clean` behaviour has changed in Go 1.20 - adapt to it [#2406](https://github.com/labstack/echo/pull/2406)
-* Add `middleware.CORSConfig.UnsafeWildcardOriginWithAllowCredentials` to make UNSAFE usages of wildcard origin + allow cretentials less likely [#2405](https://github.com/labstack/echo/pull/2405)
-
-**Enhancements**
-
-* Add more HTTP error values [#2277](https://github.com/labstack/echo/pull/2277)
-
-
-## v4.10.1 - 2023-02-19
-
-**Security**
-
-* Upgrade deps due to the latest golang.org/x/net vulnerability [#2402](https://github.com/labstack/echo/pull/2402)
-
-
-**Enhancements**
-
-* Add new JWT repository to the README [#2377](https://github.com/labstack/echo/pull/2377)
-* Return an empty string for ctx.path if there is no registered path [#2385](https://github.com/labstack/echo/pull/2385)
-* Add context timeout middleware [#2380](https://github.com/labstack/echo/pull/2380)
-* Update link to jaegertracing [#2394](https://github.com/labstack/echo/pull/2394)
-
-
-## v4.10.0 - 2022-12-27
-
-**Security**
-
-* We are deprecating JWT middleware in this repository. Please use https://github.com/labstack/echo-jwt instead.
-
- JWT middleware is moved to separate repository to allow us to bump/upgrade version of JWT implementation (`github.com/golang-jwt/jwt`) we are using
-which we can not do in Echo core because this would break backwards compatibility guarantees we try to maintain.
-
-* This minor version bumps minimum Go version to 1.17 (from 1.16) due `golang.org/x/` packages we depend on. There are
- several vulnerabilities fixed in these libraries.
-
- Echo still tries to support last 4 Go versions but there are occasions we can not guarantee this promise.
-
-
-**Enhancements**
-
-* Bump x/text to 0.3.8 [#2305](https://github.com/labstack/echo/pull/2305)
-* Bump dependencies and add notes about Go releases we support [#2336](https://github.com/labstack/echo/pull/2336)
-* Add helper interface for ProxyBalancer interface [#2316](https://github.com/labstack/echo/pull/2316)
-* Expose `middleware.CreateExtractors` function so we can use it from echo-contrib repository [#2338](https://github.com/labstack/echo/pull/2338)
-* Refactor func(Context) error to HandlerFunc [#2315](https://github.com/labstack/echo/pull/2315)
-* Improve function comments [#2329](https://github.com/labstack/echo/pull/2329)
-* Add new method HTTPError.WithInternal [#2340](https://github.com/labstack/echo/pull/2340)
-* Replace io/ioutil package usages [#2342](https://github.com/labstack/echo/pull/2342)
-* Add staticcheck to CI flow [#2343](https://github.com/labstack/echo/pull/2343)
-* Replace relative path determination from proprietary to std [#2345](https://github.com/labstack/echo/pull/2345)
-* Remove square brackets from ipv6 addresses in XFF (X-Forwarded-For header) [#2182](https://github.com/labstack/echo/pull/2182)
-* Add testcases for some BodyLimit middleware configuration options [#2350](https://github.com/labstack/echo/pull/2350)
-* Additional configuration options for RequestLogger and Logger middleware [#2341](https://github.com/labstack/echo/pull/2341)
-* Add route to request log [#2162](https://github.com/labstack/echo/pull/2162)
-* GitHub Workflows security hardening [#2358](https://github.com/labstack/echo/pull/2358)
-* Add govulncheck to CI and bump dependencies [#2362](https://github.com/labstack/echo/pull/2362)
-* Fix rate limiter docs [#2366](https://github.com/labstack/echo/pull/2366)
-* Refactor how `e.Routes()` work and introduce `e.OnAddRouteHandler` callback [#2337](https://github.com/labstack/echo/pull/2337)
-
-
-## v4.9.1 - 2022-10-12
-
-**Fixes**
-
-* Fix logger panicing (when template is set to empty) by bumping dependency version [#2295](https://github.com/labstack/echo/issues/2295)
-
-**Enhancements**
-
-* Improve CORS documentation [#2272](https://github.com/labstack/echo/pull/2272)
-* Update readme about supported Go versions [#2291](https://github.com/labstack/echo/pull/2291)
-* Tests: improve error handling on closing body [#2254](https://github.com/labstack/echo/pull/2254)
-* Tests: refactor some of the assertions in tests [#2275](https://github.com/labstack/echo/pull/2275)
-* Tests: refactor assertions [#2301](https://github.com/labstack/echo/pull/2301)
-
-## v4.9.0 - 2022-09-04
-
-**Security**
-
-* Fix open redirect vulnerability in handlers serving static directories (e.Static, e.StaticFs, echo.StaticDirectoryHandler) [#2260](https://github.com/labstack/echo/pull/2260)
-
-**Enhancements**
-
-* Allow configuring ErrorHandler in CSRF middleware [#2257](https://github.com/labstack/echo/pull/2257)
-* Replace HTTP method constants in tests with stdlib constants [#2247](https://github.com/labstack/echo/pull/2247)
-
-
-## v4.8.0 - 2022-08-10
-
-**Most notable things**
-
-You can now add any arbitrary HTTP method type as a route [#2237](https://github.com/labstack/echo/pull/2237)
-```go
-e.Add("COPY", "/*", func(c echo.Context) error
- return c.String(http.StatusOK, "OK COPY")
-})
-```
-
-You can add custom 404 handler for specific paths [#2217](https://github.com/labstack/echo/pull/2217)
-```go
-e.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })
-
-g := e.Group("/images")
-g.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })
-```
-
-**Enhancements**
-
-* Add new value binding methods (UnixTimeMilli,TextUnmarshaler,JSONUnmarshaler) to Valuebinder [#2127](https://github.com/labstack/echo/pull/2127)
-* Refactor: body_limit middleware unit test [#2145](https://github.com/labstack/echo/pull/2145)
-* Refactor: Timeout mw: rework how test waits for timeout. [#2187](https://github.com/labstack/echo/pull/2187)
-* BasicAuth middleware returns 500 InternalServerError on invalid base64 strings but should return 400 [#2191](https://github.com/labstack/echo/pull/2191)
-* Refactor: duplicated findStaticChild process at findChildWithLabel [#2176](https://github.com/labstack/echo/pull/2176)
-* Allow different param names in different methods with same path scheme [#2209](https://github.com/labstack/echo/pull/2209)
-* Add support for registering handlers for different 404 routes [#2217](https://github.com/labstack/echo/pull/2217)
-* Middlewares should use errors.As() instead of type assertion on HTTPError [#2227](https://github.com/labstack/echo/pull/2227)
-* Allow arbitrary HTTP method types to be added as routes [#2237](https://github.com/labstack/echo/pull/2237)
-
-## v4.7.2 - 2022-03-16
-
-**Fixes**
-
-* Fix nil pointer exception when calling Start again after address binding error [#2131](https://github.com/labstack/echo/pull/2131)
-* Fix CSRF middleware not being able to extract token from multipart/form-data form [#2136](https://github.com/labstack/echo/pull/2136)
-* Fix Timeout middleware write race [#2126](https://github.com/labstack/echo/pull/2126)
-
-**Enhancements**
-
-* Recover middleware should not log panic for aborted handler [#2134](https://github.com/labstack/echo/pull/2134)
-
-
-## v4.7.1 - 2022-03-13
-
-**Fixes**
-
-* Fix `e.Static`, `.File()`, `c.Attachment()` being picky with paths starting with `./`, `../` and `/` after 4.7.0 introduced echo.Filesystem support (Go1.16+) [#2123](https://github.com/labstack/echo/pull/2123)
-
-**Enhancements**
-
-* Remove some unused code [#2116](https://github.com/labstack/echo/pull/2116)
-
-
-## v4.7.0 - 2022-03-01
-
-**Enhancements**
-
-* Add JWT, KeyAuth, CSRF multivalue extractors [#2060](https://github.com/labstack/echo/pull/2060)
-* Add LogErrorFunc to recover middleware [#2072](https://github.com/labstack/echo/pull/2072)
-* Add support for HEAD method query params binding [#2027](https://github.com/labstack/echo/pull/2027)
-* Improve filesystem support with echo.FileFS, echo.StaticFS, group.FileFS, group.StaticFS [#2064](https://github.com/labstack/echo/pull/2064)
-
-**Fixes**
-
-* Fix X-Real-IP bug, improve tests [#2007](https://github.com/labstack/echo/pull/2007)
-* Minor syntax fixes [#1994](https://github.com/labstack/echo/pull/1994), [#2102](https://github.com/labstack/echo/pull/2102), [#2102](https://github.com/labstack/echo/pull/2102)
-
-**General**
-
-* Add cache-control and connection headers [#2103](https://github.com/labstack/echo/pull/2103)
-* Add Retry-After header constant [#2078](https://github.com/labstack/echo/pull/2078)
-* Upgrade `go` directive in `go.mod` to 1.17 [#2049](https://github.com/labstack/echo/pull/2049)
-* Add Pagoda [#2077](https://github.com/labstack/echo/pull/2077) and Souin [#2069](https://github.com/labstack/echo/pull/2069) to 3rd-party middlewares in README
-
-## v4.6.3 - 2022-01-10
-
-**Fixes**
-
-* Fixed Echo version number in greeting message which was not incremented to `4.6.2` [#2066](https://github.com/labstack/echo/issues/2066)
-
-
-## v4.6.2 - 2022-01-08
-
-**Fixes**
-
-* Fixed route containing escaped colon should be matchable but is not matched to request path [#2047](https://github.com/labstack/echo/pull/2047)
-* Fixed a problem that returned wrong content-encoding when the gzip compressed content was empty. [#1921](https://github.com/labstack/echo/pull/1921)
-* Update (test) dependencies [#2021](https://github.com/labstack/echo/pull/2021)
-
-
-**Enhancements**
-
-* Add support for configurable target header for the request_id middleware [#2040](https://github.com/labstack/echo/pull/2040)
-* Change decompress middleware to use stream decompression instead of buffering [#2018](https://github.com/labstack/echo/pull/2018)
-* Documentation updates
-
-
-## v4.6.1 - 2021-09-26
-
-**Enhancements**
-
-* Add start time to request logger middleware values [#1991](https://github.com/labstack/echo/pull/1991)
-
-## v4.6.0 - 2021-09-20
-
-Introduced a new [request logger](https://github.com/labstack/echo/blob/master/middleware/request_logger.go) middleware
-to help with cases when you want to use some other logging library in your application.
-
-**Fixes**
-
-* fix timeout middleware warning: superfluous response.WriteHeader [#1905](https://github.com/labstack/echo/issues/1905)
-
-**Enhancements**
-
-* Add Cookie to KeyAuth middleware's KeyLookup [#1929](https://github.com/labstack/echo/pull/1929)
-* JWT middleware should ignore case of auth scheme in request header [#1951](https://github.com/labstack/echo/pull/1951)
-* Refactor default error handler to return first if response is already committed [#1956](https://github.com/labstack/echo/pull/1956)
-* Added request logger middleware which helps to use custom logger library for logging requests. [#1980](https://github.com/labstack/echo/pull/1980)
-* Allow escaping of colon in route path so Google Cloud API "custom methods" could be implemented [#1988](https://github.com/labstack/echo/pull/1988)
-
## v4.5.0 - 2021-08-01
**Important notes**
diff --git a/vendor/github.com/labstack/echo/v4/Makefile b/vendor/github.com/labstack/echo/v4/Makefile
index 7f4a220..48061f7 100644
--- a/vendor/github.com/labstack/echo/v4/Makefile
+++ b/vendor/github.com/labstack/echo/v4/Makefile
@@ -9,11 +9,9 @@ tag:
check: lint vet race ## Check project
init:
- @go install golang.org/x/lint/golint@latest
- @go install honnef.co/go/tools/cmd/staticcheck@latest
+ @go get -u golang.org/x/lint/golint
lint: ## Lint the files
- @staticcheck ${PKG_LIST}
@golint -set_exit_status ${PKG_LIST}
vet: ## Vet the files
@@ -31,6 +29,6 @@ benchmark: ## Run benchmarks
help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
-goversion ?= "1.21"
-test_version: ## Run tests inside Docker with given version (defaults to 1.21 oldest supported). Example: make test_version goversion=1.21
+goversion ?= "1.15"
+test_version: ## Run tests inside Docker with given version (defaults to 1.15 oldest supported). Example: make test_version goversion=1.15
@docker run --rm -it -v $(shell pwd):/project golang:$(goversion) /bin/sh -c "cd /project && make init check"
diff --git a/vendor/github.com/labstack/echo/v4/README.md b/vendor/github.com/labstack/echo/v4/README.md
index 5381898..4dec531 100644
--- a/vendor/github.com/labstack/echo/v4/README.md
+++ b/vendor/github.com/labstack/echo/v4/README.md
@@ -1,24 +1,30 @@
+
+
[](https://sourcegraph.com/github.com/labstack/echo?badge)
[](https://pkg.go.dev/github.com/labstack/echo/v4)
[](https://goreportcard.com/report/github.com/labstack/echo)
-[](https://github.com/labstack/echo/actions)
+[](https://travis-ci.org/labstack/echo)
[](https://codecov.io/gh/labstack/echo)
+[](https://gitter.im/labstack/echo)
[](https://github.com/labstack/echo/discussions)
[](https://twitter.com/labstack)
[](https://raw.githubusercontent.com/labstack/echo/master/LICENSE)
-## Echo
+## Supported Go versions
-High performance, extensible, minimalist Go web framework.
+As of version 4.0.0, Echo is available as a [Go module](https://github.com/golang/go/wiki/Modules).
+Therefore a Go version capable of understanding /vN suffixed imports is required:
-* [Official website](https://echo.labstack.com)
-* [Quick start](https://echo.labstack.com/docs/quick-start)
-* [Middlewares](https://echo.labstack.com/docs/category/middleware)
+- 1.9.7+
+- 1.10.3+
+- 1.14+
-Help and questions: [Github Discussions](https://github.com/labstack/echo/discussions)
+Any of these versions will allow you to import Echo as `github.com/labstack/echo/v4` which is the recommended
+way of using Echo going forward.
+For older versions, please use the latest v3 tag.
-### Feature Overview
+## Feature Overview
- Optimized HTTP router which smartly prioritize routes
- Build robust and scalable RESTful APIs
@@ -34,18 +40,6 @@ Help and questions: [Github Discussions](https://github.com/labstack/echo/discus
- Automatic TLS via Let’s Encrypt
- HTTP/2 support
-## Sponsors
-
-
-
-
-Click [here](https://github.com/sponsors/labstack) for more information on sponsorship.
-
## Benchmarks
Date: 2020/11/11
@@ -65,7 +59,6 @@ The benchmarks above were run on an Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
// go get github.com/labstack/echo/{version}
go get github.com/labstack/echo/v4
```
-Latest version of Echo supports last four Go major [releases](https://go.dev/doc/devel/release) and might work with older versions.
### Example
@@ -73,10 +66,9 @@ Latest version of Echo supports last four Go major [releases](https://go.dev/doc
package main
import (
+ "net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
- "log/slog"
- "net/http"
)
func main() {
@@ -91,9 +83,7 @@ func main() {
e.GET("/", hello)
// Start server
- if err := e.Start(":8080"); err != nil && !errors.Is(err, http.ErrServerClosed) {
- slog.Error("failed to start server", "error", err)
- }
+ e.Logger.Fatal(e.Start(":1323"))
}
// Handler
@@ -102,32 +92,10 @@ func hello(c echo.Context) error {
}
```
-# Official middleware repositories
+## Help
-Following list of middleware is maintained by Echo team.
-
-| Repository | Description |
-|------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| [github.com/labstack/echo-jwt](https://github.com/labstack/echo-jwt) | [JWT](https://github.com/golang-jwt/jwt) middleware |
-| [github.com/labstack/echo-contrib](https://github.com/labstack/echo-contrib) | [casbin](https://github.com/casbin/casbin), [gorilla/sessions](https://github.com/gorilla/sessions), [jaegertracing](https://github.com/uber/jaeger-client-go), [prometheus](https://github.com/prometheus/client_golang/), [pprof](https://pkg.go.dev/net/http/pprof), [zipkin](https://github.com/openzipkin/zipkin-go) middlewares |
-
-# Third-party middleware repositories
-
-Be careful when adding 3rd party middleware. Echo teams does not have time or manpower to guarantee safety and quality
-of middlewares in this list.
-
-| Repository | Description |
-|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| [deepmap/oapi-codegen](https://github.com/deepmap/oapi-codegen) | Automatically generate RESTful API documentation with [OpenAPI](https://swagger.io/specification/) Client and Server Code Generator |
-| [github.com/swaggo/echo-swagger](https://github.com/swaggo/echo-swagger) | Automatically generate RESTful API documentation with [Swagger](https://swagger.io/) 2.0. |
-| [github.com/ziflex/lecho](https://github.com/ziflex/lecho) | [Zerolog](https://github.com/rs/zerolog) logging library wrapper for Echo logger interface. |
-| [github.com/brpaz/echozap](https://github.com/brpaz/echozap) | Uber´s [Zap](https://github.com/uber-go/zap) logging library wrapper for Echo logger interface. |
-| [github.com/samber/slog-echo](https://github.com/samber/slog-echo) | Go [slog](https://pkg.go.dev/golang.org/x/exp/slog) logging library wrapper for Echo logger interface. |
-| [github.com/darkweak/souin/plugins/echo](https://github.com/darkweak/souin/tree/master/plugins/echo) | HTTP cache system based on [Souin](https://github.com/darkweak/souin) to automatically get your endpoints cached. It supports some distributed and non-distributed storage systems depending your needs. |
-| [github.com/mikestefanello/pagoda](https://github.com/mikestefanello/pagoda) | Rapid, easy full-stack web development starter kit built with Echo. |
-| [github.com/go-woo/protoc-gen-echo](https://github.com/go-woo/protoc-gen-echo) | ProtoBuf generate Echo server side code |
-
-Please send a PR to add your own library here.
+- [Forum](https://github.com/labstack/echo/discussions)
+- [Chat](https://gitter.im/labstack/echo)
## Contribute
@@ -146,11 +114,8 @@ Please send a PR to add your own library here.
## Credits
-- [Vishal Rana](https://github.com/vishr) (Author)
-- [Nitin Rana](https://github.com/nr17) (Consultant)
-- [Roland Lammel](https://github.com/lammel) (Maintainer)
-- [Martti T.](https://github.com/aldas) (Maintainer)
-- [Pablo Andres Fuente](https://github.com/pafuent) (Maintainer)
+- [Vishal Rana](https://github.com/vishr) - Author
+- [Nitin Rana](https://github.com/nr17) - Consultant
- [Contributors](https://github.com/labstack/echo/graphs/contributors)
## License
diff --git a/vendor/github.com/labstack/echo/v4/bind.go b/vendor/github.com/labstack/echo/v4/bind.go
index 5940e15..fdf0524 100644
--- a/vendor/github.com/labstack/echo/v4/bind.go
+++ b/vendor/github.com/labstack/echo/v4/bind.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package echo
import (
@@ -8,35 +5,29 @@ import (
"encoding/xml"
"errors"
"fmt"
- "mime/multipart"
"net/http"
"reflect"
"strconv"
"strings"
)
-// Binder is the interface that wraps the Bind method.
-type Binder interface {
- Bind(i interface{}, c Context) error
-}
+type (
+ // Binder is the interface that wraps the Bind method.
+ Binder interface {
+ Bind(i interface{}, c Context) error
+ }
-// DefaultBinder is the default implementation of the Binder interface.
-type DefaultBinder struct{}
+ // DefaultBinder is the default implementation of the Binder interface.
+ DefaultBinder struct{}
-// BindUnmarshaler is the interface used to wrap the UnmarshalParam method.
-// Types that don't implement this, but do implement encoding.TextUnmarshaler
-// will use that interface instead.
-type BindUnmarshaler interface {
- // UnmarshalParam decodes and assigns a value from an form or query param.
- UnmarshalParam(param string) error
-}
-
-// bindMultipleUnmarshaler is used by binder to unmarshal multiple values from request at once to
-// type implementing this interface. For example request could have multiple query fields `?a=1&a=2&b=test` in that case
-// for `a` following slice `["1", "2"] will be passed to unmarshaller.
-type bindMultipleUnmarshaler interface {
- UnmarshalParams(params []string) error
-}
+ // BindUnmarshaler is the interface used to wrap the UnmarshalParam method.
+ // Types that don't implement this, but do implement encoding.TextUnmarshaler
+ // will use that interface instead.
+ BindUnmarshaler interface {
+ // UnmarshalParam decodes and assigns a value from an form or query param.
+ UnmarshalParam(param string) error
+ }
+)
// BindPathParams binds path params to bindable object
func (b *DefaultBinder) BindPathParams(c Context, i interface{}) error {
@@ -46,7 +37,7 @@ func (b *DefaultBinder) BindPathParams(c Context, i interface{}) error {
for i, name := range names {
params[name] = []string{values[i]}
}
- if err := b.bindData(i, params, "param", nil); err != nil {
+ if err := b.bindData(i, params, "param"); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
return nil
@@ -54,7 +45,7 @@ func (b *DefaultBinder) BindPathParams(c Context, i interface{}) error {
// BindQueryParams binds query params to bindable object
func (b *DefaultBinder) BindQueryParams(c Context, i interface{}) error {
- if err := b.bindData(i, c.QueryParams(), "query", nil); err != nil {
+ if err := b.bindData(i, c.QueryParams(), "query"); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
return nil
@@ -71,12 +62,9 @@ func (b *DefaultBinder) BindBody(c Context, i interface{}) (err error) {
return
}
- // mediatype is found like `mime.ParseMediaType()` does it
- base, _, _ := strings.Cut(req.Header.Get(HeaderContentType), ";")
- mediatype := strings.TrimSpace(base)
-
- switch mediatype {
- case MIMEApplicationJSON:
+ ctype := req.Header.Get(HeaderContentType)
+ switch {
+ case strings.HasPrefix(ctype, MIMEApplicationJSON):
if err = c.Echo().JSONSerializer.Deserialize(c, i); err != nil {
switch err.(type) {
case *HTTPError:
@@ -85,7 +73,7 @@ func (b *DefaultBinder) BindBody(c Context, i interface{}) (err error) {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
}
- case MIMEApplicationXML, MIMETextXML:
+ case strings.HasPrefix(ctype, MIMEApplicationXML), strings.HasPrefix(ctype, MIMETextXML):
if err = xml.NewDecoder(req.Body).Decode(i); err != nil {
if ute, ok := err.(*xml.UnsupportedTypeError); ok {
return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unsupported type error: type=%v, error=%v", ute.Type, ute.Error())).SetInternal(err)
@@ -94,20 +82,12 @@ func (b *DefaultBinder) BindBody(c Context, i interface{}) (err error) {
}
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
- case MIMEApplicationForm:
+ case strings.HasPrefix(ctype, MIMEApplicationForm), strings.HasPrefix(ctype, MIMEMultipartForm):
params, err := c.FormParams()
if err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
- if err = b.bindData(i, params, "form", nil); err != nil {
- return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
- }
- case MIMEMultipartForm:
- params, err := c.MultipartForm()
- if err != nil {
- return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
- }
- if err = b.bindData(i, params.Value, "form", params.File); err != nil {
+ if err = b.bindData(i, params, "form"); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
default:
@@ -118,7 +98,7 @@ func (b *DefaultBinder) BindBody(c Context, i interface{}) (err error) {
// BindHeaders binds HTTP headers to a bindable object
func (b *DefaultBinder) BindHeaders(c Context, i interface{}) error {
- if err := b.bindData(i, c.Request().Header, "header", nil); err != nil {
+ if err := b.bindData(i, c.Request().Header, "header"); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
return nil
@@ -131,11 +111,11 @@ func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
if err := b.BindPathParams(c, i); err != nil {
return err
}
- // Only bind query parameters for GET/DELETE/HEAD to avoid unexpected behavior with destination struct binding from body.
- // For example a request URL `&id=1&lang=en` with body `{"id":100,"lang":"de"}` would lead to precedence issues.
- // The HTTP method check restores pre-v4.1.11 behavior to avoid these problems (see issue #1670)
- method := c.Request().Method
- if method == http.MethodGet || method == http.MethodDelete || method == http.MethodHead {
+ // Issue #1670 - Query params are binded only for GET/DELETE and NOT for usual request with body (POST/PUT/PATCH)
+ // Reasoning here is that parameters in query and bind destination struct could have UNEXPECTED matches and results due that.
+ // i.e. is `&id=1&lang=en` from URL same as `{"id":100,"lang":"de"}` request body and which one should have priority when binding.
+ // This HTTP method check restores pre v4.1.11 behavior and avoids different problems when query is mixed with body
+ if c.Request().Method == http.MethodGet || c.Request().Method == http.MethodDelete {
if err = b.BindQueryParams(c, i); err != nil {
return err
}
@@ -144,41 +124,17 @@ func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
}
// bindData will bind data ONLY fields in destination struct that have EXPLICIT tag
-func (b *DefaultBinder) bindData(destination interface{}, data map[string][]string, tag string, dataFiles map[string][]*multipart.FileHeader) error {
- if destination == nil || (len(data) == 0 && len(dataFiles) == 0) {
+func (b *DefaultBinder) bindData(destination interface{}, data map[string][]string, tag string) error {
+ if destination == nil || len(data) == 0 {
return nil
}
- hasFiles := len(dataFiles) > 0
typ := reflect.TypeOf(destination).Elem()
val := reflect.ValueOf(destination).Elem()
- // Support binding to limited Map destinations:
- // - map[string][]string,
- // - map[string]string <-- (binds first value from data slice)
- // - map[string]interface{}
- // You are better off binding to struct but there are user who want this map feature. Source of data for these cases are:
- // params,query,header,form as these sources produce string values, most of the time slice of strings, actually.
- if typ.Kind() == reflect.Map && typ.Key().Kind() == reflect.String {
- k := typ.Elem().Kind()
- isElemInterface := k == reflect.Interface
- isElemString := k == reflect.String
- isElemSliceOfStrings := k == reflect.Slice && typ.Elem().Elem().Kind() == reflect.String
- if !(isElemSliceOfStrings || isElemString || isElemInterface) {
- return nil
- }
- if val.IsNil() {
- val.Set(reflect.MakeMap(typ))
- }
+ // Map
+ if typ.Kind() == reflect.Map {
for k, v := range data {
- if isElemString {
- val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v[0]))
- } else if isElemInterface {
- // To maintain backward compatibility, we always bind to the first string value
- // and not the slice of strings when dealing with map[string]interface{}{}
- val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v[0]))
- } else {
- val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v))
- }
+ val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v[0]))
}
return nil
}
@@ -192,7 +148,7 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
return errors.New("binding element must be a struct")
}
- for i := 0; i < typ.NumField(); i++ { // iterate over all destination fields
+ for i := 0; i < typ.NumField(); i++ {
typeField := typ.Field(i)
structField := val.Field(i)
if typeField.Anonymous {
@@ -205,16 +161,16 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
}
structFieldKind := structField.Kind()
inputFieldName := typeField.Tag.Get(tag)
- if typeField.Anonymous && structFieldKind == reflect.Struct && inputFieldName != "" {
+ if typeField.Anonymous && structField.Kind() == reflect.Struct && inputFieldName != "" {
// if anonymous struct with query/param/form tags, report an error
return errors.New("query/param/form tags are not allowed with anonymous struct field")
}
if inputFieldName == "" {
- // If tag is nil, we inspect if the field is a not BindUnmarshaler struct and try to bind data into it (might contain fields with tags).
- // structs that implement BindUnmarshaler are bound only when they have explicit tag
+ // If tag is nil, we inspect if the field is a not BindUnmarshaler struct and try to bind data into it (might contains fields with tags).
+ // structs that implement BindUnmarshaler are binded only when they have explicit tag
if _, ok := structField.Addr().Interface().(BindUnmarshaler); !ok && structFieldKind == reflect.Struct {
- if err := b.bindData(structField.Addr().Interface(), data, tag, dataFiles); err != nil {
+ if err := b.bindData(structField.Addr().Interface(), data, tag); err != nil {
return err
}
}
@@ -222,20 +178,10 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
continue
}
- if hasFiles {
- if ok, err := isFieldMultipartFile(structField.Type()); err != nil {
- return err
- } else if ok {
- if ok := setMultipartFileHeaderTypes(structField, inputFieldName, dataFiles); ok {
- continue
- }
- }
- }
-
inputValue, exists := data[inputFieldName]
if !exists {
- // Go json.Unmarshal supports case-insensitive binding. However the
- // url params are bound case-sensitive which is inconsistent. To
+ // Go json.Unmarshal supports case insensitive binding. However the
+ // url params are bound case sensitive which is inconsistent. To
// fix this we must check all of the map values in a
// case-insensitive search.
for k, v := range data {
@@ -251,46 +197,27 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
continue
}
- // NOTE: algorithm here is not particularly sophisticated. It probably does not work with absurd types like `**[]*int`
- // but it is smart enough to handle niche cases like `*int`,`*[]string`,`[]*int` .
-
- // try unmarshalling first, in case we're dealing with an alias to an array type
- if ok, err := unmarshalInputsToField(typeField.Type.Kind(), inputValue, structField); ok {
+ // Call this first, in case we're dealing with an alias to an array type
+ if ok, err := unmarshalField(typeField.Type.Kind(), inputValue[0], structField); ok {
if err != nil {
return err
}
continue
}
- if ok, err := unmarshalInputToField(typeField.Type.Kind(), inputValue[0], structField); ok {
- if err != nil {
- return err
- }
- continue
- }
-
- // we could be dealing with pointer to slice `*[]string` so dereference it. There are weird OpenAPI generators
- // that could create struct fields like that.
- if structFieldKind == reflect.Pointer {
- structFieldKind = structField.Elem().Kind()
- structField = structField.Elem()
- }
-
- if structFieldKind == reflect.Slice {
+ numElems := len(inputValue)
+ if structFieldKind == reflect.Slice && numElems > 0 {
sliceOf := structField.Type().Elem().Kind()
- numElems := len(inputValue)
slice := reflect.MakeSlice(structField.Type(), numElems, numElems)
for j := 0; j < numElems; j++ {
if err := setWithProperType(sliceOf, inputValue[j], slice.Index(j)); err != nil {
return err
}
}
- structField.Set(slice)
- continue
- }
-
- if err := setWithProperType(structFieldKind, inputValue[0], structField); err != nil {
+ val.Field(i).Set(slice)
+ } else if err := setWithProperType(typeField.Type.Kind(), inputValue[0], structField); err != nil {
return err
+
}
}
return nil
@@ -298,7 +225,7 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
func setWithProperType(valueKind reflect.Kind, val string, structField reflect.Value) error {
// But also call it here, in case we're dealing with an array of BindUnmarshalers
- if ok, err := unmarshalInputToField(valueKind, val, structField); ok {
+ if ok, err := unmarshalField(valueKind, val, structField); ok {
return err
}
@@ -339,41 +266,35 @@ func setWithProperType(valueKind reflect.Kind, val string, structField reflect.V
return nil
}
-func unmarshalInputsToField(valueKind reflect.Kind, values []string, field reflect.Value) (bool, error) {
- if valueKind == reflect.Ptr {
- if field.IsNil() {
- field.Set(reflect.New(field.Type().Elem()))
- }
- field = field.Elem()
+func unmarshalField(valueKind reflect.Kind, val string, field reflect.Value) (bool, error) {
+ switch valueKind {
+ case reflect.Ptr:
+ return unmarshalFieldPtr(val, field)
+ default:
+ return unmarshalFieldNonPtr(val, field)
}
-
- fieldIValue := field.Addr().Interface()
- unmarshaler, ok := fieldIValue.(bindMultipleUnmarshaler)
- if !ok {
- return false, nil
- }
- return true, unmarshaler.UnmarshalParams(values)
}
-func unmarshalInputToField(valueKind reflect.Kind, val string, field reflect.Value) (bool, error) {
- if valueKind == reflect.Ptr {
- if field.IsNil() {
- field.Set(reflect.New(field.Type().Elem()))
- }
- field = field.Elem()
- }
-
+func unmarshalFieldNonPtr(value string, field reflect.Value) (bool, error) {
fieldIValue := field.Addr().Interface()
- switch unmarshaler := fieldIValue.(type) {
- case BindUnmarshaler:
- return true, unmarshaler.UnmarshalParam(val)
- case encoding.TextUnmarshaler:
- return true, unmarshaler.UnmarshalText([]byte(val))
+ if unmarshaler, ok := fieldIValue.(BindUnmarshaler); ok {
+ return true, unmarshaler.UnmarshalParam(value)
+ }
+ if unmarshaler, ok := fieldIValue.(encoding.TextUnmarshaler); ok {
+ return true, unmarshaler.UnmarshalText([]byte(value))
}
return false, nil
}
+func unmarshalFieldPtr(value string, field reflect.Value) (bool, error) {
+ if field.IsNil() {
+ // Initialize the pointer to a nil value
+ field.Set(reflect.New(field.Type().Elem()))
+ }
+ return unmarshalFieldNonPtr(value, field.Elem())
+}
+
func setIntField(value string, bitSize int, field reflect.Value) error {
if value == "" {
value = "0"
@@ -417,50 +338,3 @@ func setFloatField(value string, bitSize int, field reflect.Value) error {
}
return err
}
-
-var (
- // NOT supported by bind as you can NOT check easily empty struct being actual file or not
- multipartFileHeaderType = reflect.TypeOf(multipart.FileHeader{})
- // supported by bind as you can check by nil value if file existed or not
- multipartFileHeaderPointerType = reflect.TypeOf(&multipart.FileHeader{})
- multipartFileHeaderSliceType = reflect.TypeOf([]multipart.FileHeader(nil))
- multipartFileHeaderPointerSliceType = reflect.TypeOf([]*multipart.FileHeader(nil))
-)
-
-func isFieldMultipartFile(field reflect.Type) (bool, error) {
- switch field {
- case multipartFileHeaderPointerType,
- multipartFileHeaderSliceType,
- multipartFileHeaderPointerSliceType:
- return true, nil
- case multipartFileHeaderType:
- return true, errors.New("binding to multipart.FileHeader struct is not supported, use pointer to struct")
- default:
- return false, nil
- }
-}
-
-func setMultipartFileHeaderTypes(structField reflect.Value, inputFieldName string, files map[string][]*multipart.FileHeader) bool {
- fileHeaders := files[inputFieldName]
- if len(fileHeaders) == 0 {
- return false
- }
-
- result := true
- switch structField.Type() {
- case multipartFileHeaderPointerSliceType:
- structField.Set(reflect.ValueOf(fileHeaders))
- case multipartFileHeaderSliceType:
- headers := make([]multipart.FileHeader, len(fileHeaders))
- for i, fileHeader := range fileHeaders {
- headers[i] = *fileHeader
- }
- structField.Set(reflect.ValueOf(headers))
- case multipartFileHeaderPointerType:
- structField.Set(reflect.ValueOf(fileHeaders[0]))
- default:
- result = false
- }
-
- return result
-}
diff --git a/vendor/github.com/labstack/echo/v4/binder.go b/vendor/github.com/labstack/echo/v4/binder.go
index da15ae8..0900ce8 100644
--- a/vendor/github.com/labstack/echo/v4/binder.go
+++ b/vendor/github.com/labstack/echo/v4/binder.go
@@ -1,11 +1,6 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package echo
import (
- "encoding"
- "encoding/json"
"fmt"
"net/http"
"strconv"
@@ -57,11 +52,8 @@ import (
* time
* duration
* BindUnmarshaler() interface
- * TextUnmarshaler() interface
- * JSONUnmarshaler() interface
* UnixTime() - converts unix time (integer) to time.Time
- * UnixTimeMilli() - converts unix time with millisecond precision (integer) to time.Time
- * UnixTimeNano() - converts unix time with nanosecond precision (integer) to time.Time
+ * UnixTimeNano() - converts unix time with nano second precision (integer) to time.Time
* CustomFunc() - callback function for your custom conversion logic. Signature `func(values []string) []error`
*/
@@ -69,9 +61,9 @@ import (
type BindingError struct {
// Field is the field name where value binding failed
Field string `json:"field"`
- *HTTPError
// Values of parameter that failed to bind.
Values []string `json:"-"`
+ *HTTPError
}
// NewBindingError creates new instance of binding error
@@ -94,15 +86,16 @@ func (be *BindingError) Error() string {
// ValueBinder provides utility methods for binding query or path parameter to various Go built-in types
type ValueBinder struct {
+ // failFast is flag for binding methods to return without attempting to bind when previous binding already failed
+ failFast bool
+ errors []error
+
// ValueFunc is used to get single parameter (first) value from request
ValueFunc func(sourceParam string) string
// ValuesFunc is used to get all values for parameter from request. i.e. `/api/search?ids=1&ids=2`
ValuesFunc func(sourceParam string) []string
// ErrorFunc is used to create errors. Allows you to use your own error type, that for example marshals to your specific json response
ErrorFunc func(sourceParam string, values []string, message interface{}, internalError error) error
- errors []error
- // failFast is flag for binding methods to return without attempting to bind when previous binding already failed
- failFast bool
}
// QueryParamsBinder creates query parameter value binder
@@ -211,7 +204,7 @@ func (b *ValueBinder) CustomFunc(sourceParam string, customFunc func(values []st
return b.customFunc(sourceParam, customFunc, false)
}
-// MustCustomFunc requires parameter values to exist to bind with Func. Returns error when value does not exist.
+// MustCustomFunc requires parameter values to exist to be bind with Func. Returns error when value does not exist.
func (b *ValueBinder) MustCustomFunc(sourceParam string, customFunc func(values []string) []error) *ValueBinder {
return b.customFunc(sourceParam, customFunc, true)
}
@@ -248,7 +241,7 @@ func (b *ValueBinder) String(sourceParam string, dest *string) *ValueBinder {
return b
}
-// MustString requires parameter value to exist to bind to string variable. Returns error when value does not exist
+// MustString requires parameter value to exist to be bind to string variable. Returns error when value does not exist
func (b *ValueBinder) MustString(sourceParam string, dest *string) *ValueBinder {
if b.failFast && b.errors != nil {
return b
@@ -277,7 +270,7 @@ func (b *ValueBinder) Strings(sourceParam string, dest *[]string) *ValueBinder {
return b
}
-// MustStrings requires parameter values to exist to bind to slice of string variables. Returns error when value does not exist
+// MustStrings requires parameter values to exist to be bind to slice of string variables. Returns error when value does not exist
func (b *ValueBinder) MustStrings(sourceParam string, dest *[]string) *ValueBinder {
if b.failFast && b.errors != nil {
return b
@@ -309,7 +302,7 @@ func (b *ValueBinder) BindUnmarshaler(sourceParam string, dest BindUnmarshaler)
return b
}
-// MustBindUnmarshaler requires parameter value to exist to bind to destination implementing BindUnmarshaler interface.
+// MustBindUnmarshaler requires parameter value to exist to be bind to destination implementing BindUnmarshaler interface.
// Returns error when value does not exist
func (b *ValueBinder) MustBindUnmarshaler(sourceParam string, dest BindUnmarshaler) *ValueBinder {
if b.failFast && b.errors != nil {
@@ -328,85 +321,13 @@ func (b *ValueBinder) MustBindUnmarshaler(sourceParam string, dest BindUnmarshal
return b
}
-// JSONUnmarshaler binds parameter to destination implementing json.Unmarshaler interface
-func (b *ValueBinder) JSONUnmarshaler(sourceParam string, dest json.Unmarshaler) *ValueBinder {
- if b.failFast && b.errors != nil {
- return b
- }
-
- tmp := b.ValueFunc(sourceParam)
- if tmp == "" {
- return b
- }
-
- if err := dest.UnmarshalJSON([]byte(tmp)); err != nil {
- b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to json.Unmarshaler interface", err))
- }
- return b
-}
-
-// MustJSONUnmarshaler requires parameter value to exist to bind to destination implementing json.Unmarshaler interface.
-// Returns error when value does not exist
-func (b *ValueBinder) MustJSONUnmarshaler(sourceParam string, dest json.Unmarshaler) *ValueBinder {
- if b.failFast && b.errors != nil {
- return b
- }
-
- tmp := b.ValueFunc(sourceParam)
- if tmp == "" {
- b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "required field value is empty", nil))
- return b
- }
-
- if err := dest.UnmarshalJSON([]byte(tmp)); err != nil {
- b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to json.Unmarshaler interface", err))
- }
- return b
-}
-
-// TextUnmarshaler binds parameter to destination implementing encoding.TextUnmarshaler interface
-func (b *ValueBinder) TextUnmarshaler(sourceParam string, dest encoding.TextUnmarshaler) *ValueBinder {
- if b.failFast && b.errors != nil {
- return b
- }
-
- tmp := b.ValueFunc(sourceParam)
- if tmp == "" {
- return b
- }
-
- if err := dest.UnmarshalText([]byte(tmp)); err != nil {
- b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to encoding.TextUnmarshaler interface", err))
- }
- return b
-}
-
-// MustTextUnmarshaler requires parameter value to exist to bind to destination implementing encoding.TextUnmarshaler interface.
-// Returns error when value does not exist
-func (b *ValueBinder) MustTextUnmarshaler(sourceParam string, dest encoding.TextUnmarshaler) *ValueBinder {
- if b.failFast && b.errors != nil {
- return b
- }
-
- tmp := b.ValueFunc(sourceParam)
- if tmp == "" {
- b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "required field value is empty", nil))
- return b
- }
-
- if err := dest.UnmarshalText([]byte(tmp)); err != nil {
- b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to encoding.TextUnmarshaler interface", err))
- }
- return b
-}
-
// BindWithDelimiter binds parameter to destination by suitable conversion function.
// Delimiter is used before conversion to split parameter value to separate values
func (b *ValueBinder) BindWithDelimiter(sourceParam string, dest interface{}, delimiter string) *ValueBinder {
return b.bindWithDelimiter(sourceParam, dest, delimiter, false)
}
-// MustBindWithDelimiter requires parameter value to exist to bind destination by suitable conversion function.
+// MustBindWithDelimiter requires parameter value to exist to be bind destination by suitable conversion function.
// Delimiter is used before conversion to split parameter value to separate values
func (b *ValueBinder) MustBindWithDelimiter(sourceParam string, dest interface{}, delimiter string) *ValueBinder {
return b.bindWithDelimiter(sourceParam, dest, delimiter, true)
@@ -455,7 +376,7 @@ func (b *ValueBinder) Int64(sourceParam string, dest *int64) *ValueBinder {
return b.intValue(sourceParam, dest, 64, false)
}
-// MustInt64 requires parameter value to exist to bind to int64 variable. Returns error when value does not exist
+// MustInt64 requires parameter value to exist to be bind to int64 variable. Returns error when value does not exist
func (b *ValueBinder) MustInt64(sourceParam string, dest *int64) *ValueBinder {
return b.intValue(sourceParam, dest, 64, true)
}
@@ -465,7 +386,7 @@ func (b *ValueBinder) Int32(sourceParam string, dest *int32) *ValueBinder {
return b.intValue(sourceParam, dest, 32, false)
}
-// MustInt32 requires parameter value to exist to bind to int32 variable. Returns error when value does not exist
+// MustInt32 requires parameter value to exist to be bind to int32 variable. Returns error when value does not exist
func (b *ValueBinder) MustInt32(sourceParam string, dest *int32) *ValueBinder {
return b.intValue(sourceParam, dest, 32, true)
}
@@ -475,7 +396,7 @@ func (b *ValueBinder) Int16(sourceParam string, dest *int16) *ValueBinder {
return b.intValue(sourceParam, dest, 16, false)
}
-// MustInt16 requires parameter value to exist to bind to int16 variable. Returns error when value does not exist
+// MustInt16 requires parameter value to exist to be bind to int16 variable. Returns error when value does not exist
func (b *ValueBinder) MustInt16(sourceParam string, dest *int16) *ValueBinder {
return b.intValue(sourceParam, dest, 16, true)
}
@@ -485,7 +406,7 @@ func (b *ValueBinder) Int8(sourceParam string, dest *int8) *ValueBinder {
return b.intValue(sourceParam, dest, 8, false)
}
-// MustInt8 requires parameter value to exist to bind to int8 variable. Returns error when value does not exist
+// MustInt8 requires parameter value to exist to be bind to int8 variable. Returns error when value does not exist
func (b *ValueBinder) MustInt8(sourceParam string, dest *int8) *ValueBinder {
return b.intValue(sourceParam, dest, 8, true)
}
@@ -495,7 +416,7 @@ func (b *ValueBinder) Int(sourceParam string, dest *int) *ValueBinder {
return b.intValue(sourceParam, dest, 0, false)
}
-// MustInt requires parameter value to exist to bind to int variable. Returns error when value does not exist
+// MustInt requires parameter value to exist to be bind to int variable. Returns error when value does not exist
func (b *ValueBinder) MustInt(sourceParam string, dest *int) *ValueBinder {
return b.intValue(sourceParam, dest, 0, true)
}
@@ -623,7 +544,7 @@ func (b *ValueBinder) Int64s(sourceParam string, dest *[]int64) *ValueBinder {
return b.intsValue(sourceParam, dest, false)
}
-// MustInt64s requires parameter value to exist to bind to int64 slice variable. Returns error when value does not exist
+// MustInt64s requires parameter value to exist to be bind to int64 slice variable. Returns error when value does not exist
func (b *ValueBinder) MustInt64s(sourceParam string, dest *[]int64) *ValueBinder {
return b.intsValue(sourceParam, dest, true)
}
@@ -633,7 +554,7 @@ func (b *ValueBinder) Int32s(sourceParam string, dest *[]int32) *ValueBinder {
return b.intsValue(sourceParam, dest, false)
}
-// MustInt32s requires parameter value to exist to bind to int32 slice variable. Returns error when value does not exist
+// MustInt32s requires parameter value to exist to be bind to int32 slice variable. Returns error when value does not exist
func (b *ValueBinder) MustInt32s(sourceParam string, dest *[]int32) *ValueBinder {
return b.intsValue(sourceParam, dest, true)
}
@@ -643,7 +564,7 @@ func (b *ValueBinder) Int16s(sourceParam string, dest *[]int16) *ValueBinder {
return b.intsValue(sourceParam, dest, false)
}
-// MustInt16s requires parameter value to exist to bind to int16 slice variable. Returns error when value does not exist
+// MustInt16s requires parameter value to exist to be bind to int16 slice variable. Returns error when value does not exist
func (b *ValueBinder) MustInt16s(sourceParam string, dest *[]int16) *ValueBinder {
return b.intsValue(sourceParam, dest, true)
}
@@ -653,7 +574,7 @@ func (b *ValueBinder) Int8s(sourceParam string, dest *[]int8) *ValueBinder {
return b.intsValue(sourceParam, dest, false)
}
-// MustInt8s requires parameter value to exist to bind to int8 slice variable. Returns error when value does not exist
+// MustInt8s requires parameter value to exist to be bind to int8 slice variable. Returns error when value does not exist
func (b *ValueBinder) MustInt8s(sourceParam string, dest *[]int8) *ValueBinder {
return b.intsValue(sourceParam, dest, true)
}
@@ -663,7 +584,7 @@ func (b *ValueBinder) Ints(sourceParam string, dest *[]int) *ValueBinder {
return b.intsValue(sourceParam, dest, false)
}
-// MustInts requires parameter value to exist to bind to int slice variable. Returns error when value does not exist
+// MustInts requires parameter value to exist to be bind to int slice variable. Returns error when value does not exist
func (b *ValueBinder) MustInts(sourceParam string, dest *[]int) *ValueBinder {
return b.intsValue(sourceParam, dest, true)
}
@@ -673,7 +594,7 @@ func (b *ValueBinder) Uint64(sourceParam string, dest *uint64) *ValueBinder {
return b.uintValue(sourceParam, dest, 64, false)
}
-// MustUint64 requires parameter value to exist to bind to uint64 variable. Returns error when value does not exist
+// MustUint64 requires parameter value to exist to be bind to uint64 variable. Returns error when value does not exist
func (b *ValueBinder) MustUint64(sourceParam string, dest *uint64) *ValueBinder {
return b.uintValue(sourceParam, dest, 64, true)
}
@@ -683,7 +604,7 @@ func (b *ValueBinder) Uint32(sourceParam string, dest *uint32) *ValueBinder {
return b.uintValue(sourceParam, dest, 32, false)
}
-// MustUint32 requires parameter value to exist to bind to uint32 variable. Returns error when value does not exist
+// MustUint32 requires parameter value to exist to be bind to uint32 variable. Returns error when value does not exist
func (b *ValueBinder) MustUint32(sourceParam string, dest *uint32) *ValueBinder {
return b.uintValue(sourceParam, dest, 32, true)
}
@@ -693,7 +614,7 @@ func (b *ValueBinder) Uint16(sourceParam string, dest *uint16) *ValueBinder {
return b.uintValue(sourceParam, dest, 16, false)
}
-// MustUint16 requires parameter value to exist to bind to uint16 variable. Returns error when value does not exist
+// MustUint16 requires parameter value to exist to be bind to uint16 variable. Returns error when value does not exist
func (b *ValueBinder) MustUint16(sourceParam string, dest *uint16) *ValueBinder {
return b.uintValue(sourceParam, dest, 16, true)
}
@@ -703,7 +624,7 @@ func (b *ValueBinder) Uint8(sourceParam string, dest *uint8) *ValueBinder {
return b.uintValue(sourceParam, dest, 8, false)
}
-// MustUint8 requires parameter value to exist to bind to uint8 variable. Returns error when value does not exist
+// MustUint8 requires parameter value to exist to be bind to uint8 variable. Returns error when value does not exist
func (b *ValueBinder) MustUint8(sourceParam string, dest *uint8) *ValueBinder {
return b.uintValue(sourceParam, dest, 8, true)
}
@@ -713,7 +634,7 @@ func (b *ValueBinder) Byte(sourceParam string, dest *byte) *ValueBinder {
return b.uintValue(sourceParam, dest, 8, false)
}
-// MustByte requires parameter value to exist to bind to byte variable. Returns error when value does not exist
+// MustByte requires parameter value to exist to be bind to byte variable. Returns error when value does not exist
func (b *ValueBinder) MustByte(sourceParam string, dest *byte) *ValueBinder {
return b.uintValue(sourceParam, dest, 8, true)
}
@@ -723,7 +644,7 @@ func (b *ValueBinder) Uint(sourceParam string, dest *uint) *ValueBinder {
return b.uintValue(sourceParam, dest, 0, false)
}
-// MustUint requires parameter value to exist to bind to uint variable. Returns error when value does not exist
+// MustUint requires parameter value to exist to be bind to uint variable. Returns error when value does not exist
func (b *ValueBinder) MustUint(sourceParam string, dest *uint) *ValueBinder {
return b.uintValue(sourceParam, dest, 0, true)
}
@@ -851,7 +772,7 @@ func (b *ValueBinder) Uint64s(sourceParam string, dest *[]uint64) *ValueBinder {
return b.uintsValue(sourceParam, dest, false)
}
-// MustUint64s requires parameter value to exist to bind to uint64 slice variable. Returns error when value does not exist
+// MustUint64s requires parameter value to exist to be bind to uint64 slice variable. Returns error when value does not exist
func (b *ValueBinder) MustUint64s(sourceParam string, dest *[]uint64) *ValueBinder {
return b.uintsValue(sourceParam, dest, true)
}
@@ -861,7 +782,7 @@ func (b *ValueBinder) Uint32s(sourceParam string, dest *[]uint32) *ValueBinder {
return b.uintsValue(sourceParam, dest, false)
}
-// MustUint32s requires parameter value to exist to bind to uint32 slice variable. Returns error when value does not exist
+// MustUint32s requires parameter value to exist to be bind to uint32 slice variable. Returns error when value does not exist
func (b *ValueBinder) MustUint32s(sourceParam string, dest *[]uint32) *ValueBinder {
return b.uintsValue(sourceParam, dest, true)
}
@@ -871,7 +792,7 @@ func (b *ValueBinder) Uint16s(sourceParam string, dest *[]uint16) *ValueBinder {
return b.uintsValue(sourceParam, dest, false)
}
-// MustUint16s requires parameter value to exist to bind to uint16 slice variable. Returns error when value does not exist
+// MustUint16s requires parameter value to exist to be bind to uint16 slice variable. Returns error when value does not exist
func (b *ValueBinder) MustUint16s(sourceParam string, dest *[]uint16) *ValueBinder {
return b.uintsValue(sourceParam, dest, true)
}
@@ -881,7 +802,7 @@ func (b *ValueBinder) Uint8s(sourceParam string, dest *[]uint8) *ValueBinder {
return b.uintsValue(sourceParam, dest, false)
}
-// MustUint8s requires parameter value to exist to bind to uint8 slice variable. Returns error when value does not exist
+// MustUint8s requires parameter value to exist to be bind to uint8 slice variable. Returns error when value does not exist
func (b *ValueBinder) MustUint8s(sourceParam string, dest *[]uint8) *ValueBinder {
return b.uintsValue(sourceParam, dest, true)
}
@@ -891,7 +812,7 @@ func (b *ValueBinder) Uints(sourceParam string, dest *[]uint) *ValueBinder {
return b.uintsValue(sourceParam, dest, false)
}
-// MustUints requires parameter value to exist to bind to uint slice variable. Returns error when value does not exist
+// MustUints requires parameter value to exist to be bind to uint slice variable. Returns error when value does not exist
func (b *ValueBinder) MustUints(sourceParam string, dest *[]uint) *ValueBinder {
return b.uintsValue(sourceParam, dest, true)
}
@@ -901,7 +822,7 @@ func (b *ValueBinder) Bool(sourceParam string, dest *bool) *ValueBinder {
return b.boolValue(sourceParam, dest, false)
}
-// MustBool requires parameter value to exist to bind to bool variable. Returns error when value does not exist
+// MustBool requires parameter value to exist to be bind to bool variable. Returns error when value does not exist
func (b *ValueBinder) MustBool(sourceParam string, dest *bool) *ValueBinder {
return b.boolValue(sourceParam, dest, true)
}
@@ -966,7 +887,7 @@ func (b *ValueBinder) Bools(sourceParam string, dest *[]bool) *ValueBinder {
return b.boolsValue(sourceParam, dest, false)
}
-// MustBools requires parameter values to exist to bind to slice of bool variables. Returns error when values does not exist
+// MustBools requires parameter values to exist to be bind to slice of bool variables. Returns error when values does not exist
func (b *ValueBinder) MustBools(sourceParam string, dest *[]bool) *ValueBinder {
return b.boolsValue(sourceParam, dest, true)
}
@@ -976,7 +897,7 @@ func (b *ValueBinder) Float64(sourceParam string, dest *float64) *ValueBinder {
return b.floatValue(sourceParam, dest, 64, false)
}
-// MustFloat64 requires parameter value to exist to bind to float64 variable. Returns error when value does not exist
+// MustFloat64 requires parameter value to exist to be bind to float64 variable. Returns error when value does not exist
func (b *ValueBinder) MustFloat64(sourceParam string, dest *float64) *ValueBinder {
return b.floatValue(sourceParam, dest, 64, true)
}
@@ -986,7 +907,7 @@ func (b *ValueBinder) Float32(sourceParam string, dest *float32) *ValueBinder {
return b.floatValue(sourceParam, dest, 32, false)
}
-// MustFloat32 requires parameter value to exist to bind to float32 variable. Returns error when value does not exist
+// MustFloat32 requires parameter value to exist to be bind to float32 variable. Returns error when value does not exist
func (b *ValueBinder) MustFloat32(sourceParam string, dest *float32) *ValueBinder {
return b.floatValue(sourceParam, dest, 32, true)
}
@@ -1071,7 +992,7 @@ func (b *ValueBinder) Float64s(sourceParam string, dest *[]float64) *ValueBinder
return b.floatsValue(sourceParam, dest, false)
}
-// MustFloat64s requires parameter values to exist to bind to slice of float64 variables. Returns error when values does not exist
+// MustFloat64s requires parameter values to exist to be bind to slice of float64 variables. Returns error when values does not exist
func (b *ValueBinder) MustFloat64s(sourceParam string, dest *[]float64) *ValueBinder {
return b.floatsValue(sourceParam, dest, true)
}
@@ -1081,7 +1002,7 @@ func (b *ValueBinder) Float32s(sourceParam string, dest *[]float32) *ValueBinder
return b.floatsValue(sourceParam, dest, false)
}
-// MustFloat32s requires parameter values to exist to bind to slice of float32 variables. Returns error when values does not exist
+// MustFloat32s requires parameter values to exist to be bind to slice of float32 variables. Returns error when values does not exist
func (b *ValueBinder) MustFloat32s(sourceParam string, dest *[]float32) *ValueBinder {
return b.floatsValue(sourceParam, dest, true)
}
@@ -1091,7 +1012,7 @@ func (b *ValueBinder) Time(sourceParam string, dest *time.Time, layout string) *
return b.time(sourceParam, dest, layout, false)
}
-// MustTime requires parameter value to exist to bind to time.Time variable. Returns error when value does not exist
+// MustTime requires parameter value to exist to be bind to time.Time variable. Returns error when value does not exist
func (b *ValueBinder) MustTime(sourceParam string, dest *time.Time, layout string) *ValueBinder {
return b.time(sourceParam, dest, layout, true)
}
@@ -1122,7 +1043,7 @@ func (b *ValueBinder) Times(sourceParam string, dest *[]time.Time, layout string
return b.times(sourceParam, dest, layout, false)
}
-// MustTimes requires parameter values to exist to bind to slice of time.Time variables. Returns error when values does not exist
+// MustTimes requires parameter values to exist to be bind to slice of time.Time variables. Returns error when values does not exist
func (b *ValueBinder) MustTimes(sourceParam string, dest *[]time.Time, layout string) *ValueBinder {
return b.times(sourceParam, dest, layout, true)
}
@@ -1163,7 +1084,7 @@ func (b *ValueBinder) Duration(sourceParam string, dest *time.Duration) *ValueBi
return b.duration(sourceParam, dest, false)
}
-// MustDuration requires parameter value to exist to bind to time.Duration variable. Returns error when value does not exist
+// MustDuration requires parameter value to exist to be bind to time.Duration variable. Returns error when value does not exist
func (b *ValueBinder) MustDuration(sourceParam string, dest *time.Duration) *ValueBinder {
return b.duration(sourceParam, dest, true)
}
@@ -1194,7 +1115,7 @@ func (b *ValueBinder) Durations(sourceParam string, dest *[]time.Duration) *Valu
return b.durationsValue(sourceParam, dest, false)
}
-// MustDurations requires parameter values to exist to bind to slice of time.Duration variables. Returns error when values does not exist
+// MustDurations requires parameter values to exist to be bind to slice of time.Duration variables. Returns error when values does not exist
func (b *ValueBinder) MustDurations(sourceParam string, dest *[]time.Duration) *ValueBinder {
return b.durationsValue(sourceParam, dest, true)
}
@@ -1238,57 +1159,36 @@ func (b *ValueBinder) durations(sourceParam string, values []string, dest *[]tim
// Example: 1609180603 bind to 2020-12-28T18:36:43.000000000+00:00
//
// Note:
-// - time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
+// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
func (b *ValueBinder) UnixTime(sourceParam string, dest *time.Time) *ValueBinder {
- return b.unixTime(sourceParam, dest, false, time.Second)
+ return b.unixTime(sourceParam, dest, false, false)
}
-// MustUnixTime requires parameter value to exist to bind to time.Duration variable (in local time corresponding
+// MustUnixTime requires parameter value to exist to be bind to time.Duration variable (in local Time corresponding
// to the given Unix time). Returns error when value does not exist.
//
// Example: 1609180603 bind to 2020-12-28T18:36:43.000000000+00:00
//
// Note:
-// - time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
+// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
func (b *ValueBinder) MustUnixTime(sourceParam string, dest *time.Time) *ValueBinder {
- return b.unixTime(sourceParam, dest, true, time.Second)
+ return b.unixTime(sourceParam, dest, true, false)
}
-// UnixTimeMilli binds parameter to time.Time variable (in local time corresponding to the given Unix time in millisecond precision).
-//
-// Example: 1647184410140 bind to 2022-03-13T15:13:30.140000000+00:00
-//
-// Note:
-// - time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
-func (b *ValueBinder) UnixTimeMilli(sourceParam string, dest *time.Time) *ValueBinder {
- return b.unixTime(sourceParam, dest, false, time.Millisecond)
-}
-
-// MustUnixTimeMilli requires parameter value to exist to bind to time.Duration variable (in local time corresponding
-// to the given Unix time in millisecond precision). Returns error when value does not exist.
-//
-// Example: 1647184410140 bind to 2022-03-13T15:13:30.140000000+00:00
-//
-// Note:
-// - time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
-func (b *ValueBinder) MustUnixTimeMilli(sourceParam string, dest *time.Time) *ValueBinder {
- return b.unixTime(sourceParam, dest, true, time.Millisecond)
-}
-
-// UnixTimeNano binds parameter to time.Time variable (in local time corresponding to the given Unix time in nanosecond precision).
+// UnixTimeNano binds parameter to time.Time variable (in local Time corresponding to the given Unix time in nano second precision).
//
// Example: 1609180603123456789 binds to 2020-12-28T18:36:43.123456789+00:00
// Example: 1000000000 binds to 1970-01-01T00:00:01.000000000+00:00
// Example: 999999999 binds to 1970-01-01T00:00:00.999999999+00:00
//
// Note:
-// - time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
-// - Javascript's Number type only has about 53 bits of precision (Number.MAX_SAFE_INTEGER = 9007199254740991). Compare it to 1609180603123456789 in example.
+// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
+// * Javascript's Number type only has about 53 bits of precision (Number.MAX_SAFE_INTEGER = 9007199254740991). Compare it to 1609180603123456789 in example.
func (b *ValueBinder) UnixTimeNano(sourceParam string, dest *time.Time) *ValueBinder {
- return b.unixTime(sourceParam, dest, false, time.Nanosecond)
+ return b.unixTime(sourceParam, dest, false, true)
}
-// MustUnixTimeNano requires parameter value to exist to bind to time.Duration variable (in local Time corresponding
+// MustUnixTimeNano requires parameter value to exist to be bind to time.Duration variable (in local Time corresponding
// to the given Unix time value in nano second precision). Returns error when value does not exist.
//
// Example: 1609180603123456789 binds to 2020-12-28T18:36:43.123456789+00:00
@@ -1296,13 +1196,13 @@ func (b *ValueBinder) UnixTimeNano(sourceParam string, dest *time.Time) *ValueBi
// Example: 999999999 binds to 1970-01-01T00:00:00.999999999+00:00
//
// Note:
-// - time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
-// - Javascript's Number type only has about 53 bits of precision (Number.MAX_SAFE_INTEGER = 9007199254740991). Compare it to 1609180603123456789 in example.
+// * time.Time{} (param is empty) and time.Unix(0,0) (param = "0") are not equal
+// * Javascript's Number type only has about 53 bits of precision (Number.MAX_SAFE_INTEGER = 9007199254740991). Compare it to 1609180603123456789 in example.
func (b *ValueBinder) MustUnixTimeNano(sourceParam string, dest *time.Time) *ValueBinder {
- return b.unixTime(sourceParam, dest, true, time.Nanosecond)
+ return b.unixTime(sourceParam, dest, true, true)
}
-func (b *ValueBinder) unixTime(sourceParam string, dest *time.Time, valueMustExist bool, precision time.Duration) *ValueBinder {
+func (b *ValueBinder) unixTime(sourceParam string, dest *time.Time, valueMustExist bool, isNano bool) *ValueBinder {
if b.failFast && b.errors != nil {
return b
}
@@ -1321,13 +1221,10 @@ func (b *ValueBinder) unixTime(sourceParam string, dest *time.Time, valueMustExi
return b
}
- switch precision {
- case time.Second:
- *dest = time.Unix(n, 0)
- case time.Millisecond:
- *dest = time.UnixMilli(n)
- case time.Nanosecond:
+ if isNano {
*dest = time.Unix(0, n)
+ } else {
+ *dest = time.Unix(n, 0)
}
return b
}
diff --git a/vendor/github.com/labstack/echo/v4/context.go b/vendor/github.com/labstack/echo/v4/context.go
index f5dd5a6..91ab6e4 100644
--- a/vendor/github.com/labstack/echo/v4/context.go
+++ b/vendor/github.com/labstack/echo/v4/context.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package echo
import (
@@ -12,226 +9,205 @@ import (
"net"
"net/http"
"net/url"
+ "os"
+ "path/filepath"
"strings"
"sync"
)
-// Context represents the context of the current HTTP request. It holds request and
-// response objects, path, path parameters, data and registered handler.
-type Context interface {
- // Request returns `*http.Request`.
- Request() *http.Request
+type (
+ // Context represents the context of the current HTTP request. It holds request and
+ // response objects, path, path parameters, data and registered handler.
+ Context interface {
+ // Request returns `*http.Request`.
+ Request() *http.Request
- // SetRequest sets `*http.Request`.
- SetRequest(r *http.Request)
+ // SetRequest sets `*http.Request`.
+ SetRequest(r *http.Request)
- // SetResponse sets `*Response`.
- SetResponse(r *Response)
+ // SetResponse sets `*Response`.
+ SetResponse(r *Response)
- // Response returns `*Response`.
- Response() *Response
+ // Response returns `*Response`.
+ Response() *Response
- // IsTLS returns true if HTTP connection is TLS otherwise false.
- IsTLS() bool
+ // IsTLS returns true if HTTP connection is TLS otherwise false.
+ IsTLS() bool
- // IsWebSocket returns true if HTTP connection is WebSocket otherwise false.
- IsWebSocket() bool
+ // IsWebSocket returns true if HTTP connection is WebSocket otherwise false.
+ IsWebSocket() bool
- // Scheme returns the HTTP protocol scheme, `http` or `https`.
- Scheme() string
+ // Scheme returns the HTTP protocol scheme, `http` or `https`.
+ Scheme() string
- // RealIP returns the client's network address based on `X-Forwarded-For`
- // or `X-Real-IP` request header.
- // The behavior can be configured using `Echo#IPExtractor`.
- RealIP() string
+ // RealIP returns the client's network address based on `X-Forwarded-For`
+ // or `X-Real-IP` request header.
+ // The behavior can be configured using `Echo#IPExtractor`.
+ RealIP() string
- // Path returns the registered path for the handler.
- Path() string
+ // Path returns the registered path for the handler.
+ Path() string
- // SetPath sets the registered path for the handler.
- SetPath(p string)
+ // SetPath sets the registered path for the handler.
+ SetPath(p string)
- // Param returns path parameter by name.
- Param(name string) string
+ // Param returns path parameter by name.
+ Param(name string) string
- // ParamNames returns path parameter names.
- ParamNames() []string
+ // ParamNames returns path parameter names.
+ ParamNames() []string
- // SetParamNames sets path parameter names.
- SetParamNames(names ...string)
+ // SetParamNames sets path parameter names.
+ SetParamNames(names ...string)
- // ParamValues returns path parameter values.
- ParamValues() []string
+ // ParamValues returns path parameter values.
+ ParamValues() []string
- // SetParamValues sets path parameter values.
- SetParamValues(values ...string)
+ // SetParamValues sets path parameter values.
+ SetParamValues(values ...string)
- // QueryParam returns the query param for the provided name.
- QueryParam(name string) string
+ // QueryParam returns the query param for the provided name.
+ QueryParam(name string) string
- // QueryParams returns the query parameters as `url.Values`.
- QueryParams() url.Values
+ // QueryParams returns the query parameters as `url.Values`.
+ QueryParams() url.Values
- // QueryString returns the URL query string.
- QueryString() string
+ // QueryString returns the URL query string.
+ QueryString() string
- // FormValue returns the form field value for the provided name.
- FormValue(name string) string
+ // FormValue returns the form field value for the provided name.
+ FormValue(name string) string
- // FormParams returns the form parameters as `url.Values`.
- FormParams() (url.Values, error)
+ // FormParams returns the form parameters as `url.Values`.
+ FormParams() (url.Values, error)
- // FormFile returns the multipart form file for the provided name.
- FormFile(name string) (*multipart.FileHeader, error)
+ // FormFile returns the multipart form file for the provided name.
+ FormFile(name string) (*multipart.FileHeader, error)
- // MultipartForm returns the multipart form.
- MultipartForm() (*multipart.Form, error)
+ // MultipartForm returns the multipart form.
+ MultipartForm() (*multipart.Form, error)
- // Cookie returns the named cookie provided in the request.
- Cookie(name string) (*http.Cookie, error)
+ // Cookie returns the named cookie provided in the request.
+ Cookie(name string) (*http.Cookie, error)
- // SetCookie adds a `Set-Cookie` header in HTTP response.
- SetCookie(cookie *http.Cookie)
+ // SetCookie adds a `Set-Cookie` header in HTTP response.
+ SetCookie(cookie *http.Cookie)
- // Cookies returns the HTTP cookies sent with the request.
- Cookies() []*http.Cookie
+ // Cookies returns the HTTP cookies sent with the request.
+ Cookies() []*http.Cookie
- // Get retrieves data from the context.
- Get(key string) interface{}
+ // Get retrieves data from the context.
+ Get(key string) interface{}
- // Set saves data in the context.
- Set(key string, val interface{})
+ // Set saves data in the context.
+ Set(key string, val interface{})
- // Bind binds path params, query params and the request body into provided type `i`. The default binder
- // binds body based on Content-Type header.
- Bind(i interface{}) error
+ // Bind binds the request body into provided type `i`. The default binder
+ // does it based on Content-Type header.
+ Bind(i interface{}) error
- // Validate validates provided `i`. It is usually called after `Context#Bind()`.
- // Validator must be registered using `Echo#Validator`.
- Validate(i interface{}) error
+ // Validate validates provided `i`. It is usually called after `Context#Bind()`.
+ // Validator must be registered using `Echo#Validator`.
+ Validate(i interface{}) error
- // Render renders a template with data and sends a text/html response with status
- // code. Renderer must be registered using `Echo.Renderer`.
- Render(code int, name string, data interface{}) error
+ // Render renders a template with data and sends a text/html response with status
+ // code. Renderer must be registered using `Echo.Renderer`.
+ Render(code int, name string, data interface{}) error
- // HTML sends an HTTP response with status code.
- HTML(code int, html string) error
+ // HTML sends an HTTP response with status code.
+ HTML(code int, html string) error
- // HTMLBlob sends an HTTP blob response with status code.
- HTMLBlob(code int, b []byte) error
+ // HTMLBlob sends an HTTP blob response with status code.
+ HTMLBlob(code int, b []byte) error
- // String sends a string response with status code.
- String(code int, s string) error
+ // String sends a string response with status code.
+ String(code int, s string) error
- // JSON sends a JSON response with status code.
- JSON(code int, i interface{}) error
+ // JSON sends a JSON response with status code.
+ JSON(code int, i interface{}) error
- // JSONPretty sends a pretty-print JSON with status code.
- JSONPretty(code int, i interface{}, indent string) error
+ // JSONPretty sends a pretty-print JSON with status code.
+ JSONPretty(code int, i interface{}, indent string) error
- // JSONBlob sends a JSON blob response with status code.
- JSONBlob(code int, b []byte) error
+ // JSONBlob sends a JSON blob response with status code.
+ JSONBlob(code int, b []byte) error
- // JSONP sends a JSONP response with status code. It uses `callback` to construct
- // the JSONP payload.
- JSONP(code int, callback string, i interface{}) error
+ // JSONP sends a JSONP response with status code. It uses `callback` to construct
+ // the JSONP payload.
+ JSONP(code int, callback string, i interface{}) error
- // JSONPBlob sends a JSONP blob response with status code. It uses `callback`
- // to construct the JSONP payload.
- JSONPBlob(code int, callback string, b []byte) error
+ // JSONPBlob sends a JSONP blob response with status code. It uses `callback`
+ // to construct the JSONP payload.
+ JSONPBlob(code int, callback string, b []byte) error
- // XML sends an XML response with status code.
- XML(code int, i interface{}) error
+ // XML sends an XML response with status code.
+ XML(code int, i interface{}) error
- // XMLPretty sends a pretty-print XML with status code.
- XMLPretty(code int, i interface{}, indent string) error
+ // XMLPretty sends a pretty-print XML with status code.
+ XMLPretty(code int, i interface{}, indent string) error
- // XMLBlob sends an XML blob response with status code.
- XMLBlob(code int, b []byte) error
+ // XMLBlob sends an XML blob response with status code.
+ XMLBlob(code int, b []byte) error
- // Blob sends a blob response with status code and content type.
- Blob(code int, contentType string, b []byte) error
+ // Blob sends a blob response with status code and content type.
+ Blob(code int, contentType string, b []byte) error
- // Stream sends a streaming response with status code and content type.
- Stream(code int, contentType string, r io.Reader) error
+ // Stream sends a streaming response with status code and content type.
+ Stream(code int, contentType string, r io.Reader) error
- // File sends a response with the content of the file.
- File(file string) error
+ // File sends a response with the content of the file.
+ File(file string) error
- // Attachment sends a response as attachment, prompting client to save the
- // file.
- Attachment(file string, name string) error
+ // Attachment sends a response as attachment, prompting client to save the
+ // file.
+ Attachment(file string, name string) error
- // Inline sends a response as inline, opening the file in the browser.
- Inline(file string, name string) error
+ // Inline sends a response as inline, opening the file in the browser.
+ Inline(file string, name string) error
- // NoContent sends a response with no body and a status code.
- NoContent(code int) error
+ // NoContent sends a response with no body and a status code.
+ NoContent(code int) error
- // Redirect redirects the request to a provided URL with status code.
- Redirect(code int, url string) error
+ // Redirect redirects the request to a provided URL with status code.
+ Redirect(code int, url string) error
- // Error invokes the registered global HTTP error handler. Generally used by middleware.
- // A side-effect of calling global error handler is that now Response has been committed (sent to the client) and
- // middlewares up in chain can not change Response status code or Response body anymore.
- //
- // Avoid using this method in handlers as no middleware will be able to effectively handle errors after that.
- Error(err error)
+ // Error invokes the registered HTTP error handler. Generally used by middleware.
+ Error(err error)
- // Handler returns the matched handler by router.
- Handler() HandlerFunc
+ // Handler returns the matched handler by router.
+ Handler() HandlerFunc
- // SetHandler sets the matched handler by router.
- SetHandler(h HandlerFunc)
+ // SetHandler sets the matched handler by router.
+ SetHandler(h HandlerFunc)
- // Logger returns the `Logger` instance.
- Logger() Logger
+ // Logger returns the `Logger` instance.
+ Logger() Logger
- // SetLogger Set the logger
- SetLogger(l Logger)
+ // Set the logger
+ SetLogger(l Logger)
- // Echo returns the `Echo` instance.
- Echo() *Echo
+ // Echo returns the `Echo` instance.
+ Echo() *Echo
- // Reset resets the context after request completes. It must be called along
- // with `Echo#AcquireContext()` and `Echo#ReleaseContext()`.
- // See `Echo#ServeHTTP()`
- Reset(r *http.Request, w http.ResponseWriter)
-}
+ // Reset resets the context after request completes. It must be called along
+ // with `Echo#AcquireContext()` and `Echo#ReleaseContext()`.
+ // See `Echo#ServeHTTP()`
+ Reset(r *http.Request, w http.ResponseWriter)
+ }
-type context struct {
- logger Logger
- request *http.Request
- response *Response
- query url.Values
- echo *Echo
-
- store Map
- lock sync.RWMutex
-
- // following fields are set by Router
- handler HandlerFunc
-
- // path is route path that Router matched. It is empty string where there is no route match.
- // Route registered with RouteNotFound is considered as a match and path therefore is not empty.
- path string
-
- // Usually echo.Echo is sizing pvalues but there could be user created middlewares that decide to
- // overwrite parameter by calling SetParamNames + SetParamValues.
- // When echo.Echo allocated that slice it length/capacity is tied to echo.Echo.maxParam value.
- //
- // It is important that pvalues size is always equal or bigger to pnames length.
- pvalues []string
-
- // pnames length is tied to param count for the matched route
- pnames []string
-}
-
-const (
- // ContextKeyHeaderAllow is set by Router for getting value for `Allow` header in later stages of handler call chain.
- // Allow header is mandatory for status 405 (method not found) and useful for OPTIONS method requests.
- // It is added to context only when Router does not find matching method handler for request.
- ContextKeyHeaderAllow = "echo_header_allow"
+ context struct {
+ request *http.Request
+ response *Response
+ path string
+ pnames []string
+ pvalues []string
+ query url.Values
+ handler HandlerFunc
+ store Map
+ echo *Echo
+ logger Logger
+ lock sync.RWMutex
+ }
)
const (
@@ -301,16 +277,11 @@ func (c *context) RealIP() string {
if ip := c.request.Header.Get(HeaderXForwardedFor); ip != "" {
i := strings.IndexAny(ip, ",")
if i > 0 {
- xffip := strings.TrimSpace(ip[:i])
- xffip = strings.TrimPrefix(xffip, "[")
- xffip = strings.TrimSuffix(xffip, "]")
- return xffip
+ return strings.TrimSpace(ip[:i])
}
return ip
}
if ip := c.request.Header.Get(HeaderXRealIP); ip != "" {
- ip = strings.TrimPrefix(ip, "[")
- ip = strings.TrimSuffix(ip, "]")
return ip
}
ra, _, _ := net.SplitHostPort(c.request.RemoteAddr)
@@ -344,9 +315,13 @@ func (c *context) SetParamNames(names ...string) {
c.pnames = names
l := len(names)
+ if *c.echo.maxParam < l {
+ *c.echo.maxParam = l
+ }
+
if len(c.pvalues) < l {
// Keeping the old pvalues just for backward compatibility, but it sounds that doesn't make sense to keep them,
- // probably those values will be overridden in a Context#SetParamValues
+ // probably those values will be overriden in a Context#SetParamValues
newPvalues := make([]string, l)
copy(newPvalues, c.pvalues)
c.pvalues = newPvalues
@@ -358,11 +333,11 @@ func (c *context) ParamValues() []string {
}
func (c *context) SetParamValues(values ...string) {
- // NOTE: Don't just set c.pvalues = values, because it has to have length c.echo.maxParam (or bigger) at all times
+ // NOTE: Don't just set c.pvalues = values, because it has to have length c.echo.maxParam at all times
// It will brake the Router#Find code
limit := len(values)
- if limit > len(c.pvalues) {
- c.pvalues = make([]string, limit)
+ if limit > *c.echo.maxParam {
+ limit = *c.echo.maxParam
}
for i := 0; i < limit; i++ {
c.pvalues[i] = values[i]
@@ -500,7 +475,7 @@ func (c *context) jsonPBlob(code int, callback string, i interface{}) (err error
}
func (c *context) json(code int, i interface{}, indent string) error {
- c.writeContentType(MIMEApplicationJSON)
+ c.writeContentType(MIMEApplicationJSONCharsetUTF8)
c.response.Status = code
return c.echo.JSONSerializer.Serialize(c, i, indent)
}
@@ -518,7 +493,7 @@ func (c *context) JSONPretty(code int, i interface{}, indent string) (err error)
}
func (c *context) JSONBlob(code int, b []byte) (err error) {
- return c.Blob(code, MIMEApplicationJSON, b)
+ return c.Blob(code, MIMEApplicationJSONCharsetUTF8, b)
}
func (c *context) JSONP(code int, callback string, i interface{}) (err error) {
@@ -587,6 +562,29 @@ func (c *context) Stream(code int, contentType string, r io.Reader) (err error)
return
}
+func (c *context) File(file string) (err error) {
+ f, err := os.Open(file)
+ if err != nil {
+ return NotFoundHandler(c)
+ }
+ defer f.Close()
+
+ fi, _ := f.Stat()
+ if fi.IsDir() {
+ file = filepath.Join(file, indexPage)
+ f, err = os.Open(file)
+ if err != nil {
+ return NotFoundHandler(c)
+ }
+ defer f.Close()
+ if fi, err = f.Stat(); err != nil {
+ return
+ }
+ }
+ http.ServeContent(c.Response(), c.Request(), fi.Name(), fi.ModTime(), f)
+ return
+}
+
func (c *context) Attachment(file, name string) error {
return c.contentDisposition(file, name, "attachment")
}
@@ -595,10 +593,8 @@ func (c *context) Inline(file, name string) error {
return c.contentDisposition(file, name, "inline")
}
-var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"")
-
func (c *context) contentDisposition(file, name, dispositionType string) error {
- c.response.Header().Set(HeaderContentDisposition, fmt.Sprintf(`%s; filename="%s"`, dispositionType, quoteEscaper.Replace(name)))
+ c.response.Header().Set(HeaderContentDisposition, fmt.Sprintf("%s; filename=%q", dispositionType, name))
return c.File(file)
}
@@ -653,8 +649,8 @@ func (c *context) Reset(r *http.Request, w http.ResponseWriter) {
c.path = ""
c.pnames = nil
c.logger = nil
- // NOTE: Don't reset because it has to have length c.echo.maxParam (or bigger) at all times
- for i := 0; i < len(c.pvalues); i++ {
+ // NOTE: Don't reset because it has to have length c.echo.maxParam at all times
+ for i := 0; i < *c.echo.maxParam; i++ {
c.pvalues[i] = ""
}
}
diff --git a/vendor/github.com/labstack/echo/v4/context_fs.go b/vendor/github.com/labstack/echo/v4/context_fs.go
deleted file mode 100644
index 1c25baf..0000000
--- a/vendor/github.com/labstack/echo/v4/context_fs.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
-package echo
-
-import (
- "errors"
- "io"
- "io/fs"
- "net/http"
- "path/filepath"
-)
-
-func (c *context) File(file string) error {
- return fsFile(c, file, c.echo.Filesystem)
-}
-
-// FileFS serves file from given file system.
-//
-// When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary
-// prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths
-// including `assets/images` as their prefix.
-func (c *context) FileFS(file string, filesystem fs.FS) error {
- return fsFile(c, file, filesystem)
-}
-
-func fsFile(c Context, file string, filesystem fs.FS) error {
- f, err := filesystem.Open(file)
- if err != nil {
- return ErrNotFound
- }
- defer f.Close()
-
- fi, _ := f.Stat()
- if fi.IsDir() {
- file = filepath.ToSlash(filepath.Join(file, indexPage)) // ToSlash is necessary for Windows. fs.Open and os.Open are different in that aspect.
- f, err = filesystem.Open(file)
- if err != nil {
- return ErrNotFound
- }
- defer f.Close()
- if fi, err = f.Stat(); err != nil {
- return err
- }
- }
- ff, ok := f.(io.ReadSeeker)
- if !ok {
- return errors.New("file does not implement io.ReadSeeker")
- }
- http.ServeContent(c.Response(), c.Request(), fi.Name(), fi.ModTime(), ff)
- return nil
-}
diff --git a/vendor/github.com/labstack/echo/v4/echo.go b/vendor/github.com/labstack/echo/v4/echo.go
index ea6ba16..246a622 100644
--- a/vendor/github.com/labstack/echo/v4/echo.go
+++ b/vendor/github.com/labstack/echo/v4/echo.go
@@ -1,54 +1,55 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
/*
Package echo implements high performance, minimalist Go web framework.
Example:
- package main
+ package main
- import (
- "net/http"
+ import (
+ "net/http"
- "github.com/labstack/echo/v4"
- "github.com/labstack/echo/v4/middleware"
- )
+ "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v4/middleware"
+ )
- // Handler
- func hello(c echo.Context) error {
- return c.String(http.StatusOK, "Hello, World!")
- }
+ // Handler
+ func hello(c echo.Context) error {
+ return c.String(http.StatusOK, "Hello, World!")
+ }
- func main() {
- // Echo instance
- e := echo.New()
+ func main() {
+ // Echo instance
+ e := echo.New()
- // Middleware
- e.Use(middleware.Logger())
- e.Use(middleware.Recover())
+ // Middleware
+ e.Use(middleware.Logger())
+ e.Use(middleware.Recover())
- // Routes
- e.GET("/", hello)
+ // Routes
+ e.GET("/", hello)
- // Start server
- e.Logger.Fatal(e.Start(":1323"))
- }
+ // Start server
+ e.Logger.Fatal(e.Start(":1323"))
+ }
Learn more at https://echo.labstack.com
*/
package echo
import (
+ "bytes"
stdContext "context"
"crypto/tls"
- "encoding/json"
"errors"
"fmt"
+ "io"
+ "io/ioutil"
stdLog "log"
"net"
"net/http"
+ "net/url"
"os"
+ "path/filepath"
"reflect"
"runtime"
"sync"
@@ -62,90 +63,86 @@ import (
"golang.org/x/net/http2/h2c"
)
-// Echo is the top-level framework instance.
-//
-// Goroutine safety: Do not mutate Echo instance fields after server has started. Accessing these
-// fields from handlers/middlewares and changing field values at the same time leads to data-races.
-// Adding new routes after the server has been started is also not safe!
-type Echo struct {
- filesystem
- common
- // startupMutex is mutex to lock Echo instance access during server configuration and startup. Useful for to get
- // listener address info (on which interface/port was listener bound) without having data races.
- startupMutex sync.RWMutex
- colorer *color.Color
+type (
+ // Echo is the top-level framework instance.
+ Echo struct {
+ common
+ // startupMutex is mutex to lock Echo instance access during server configuration and startup. Useful for to get
+ // listener address info (on which interface/port was listener binded) without having data races.
+ startupMutex sync.RWMutex
+ StdLogger *stdLog.Logger
+ colorer *color.Color
+ premiddleware []MiddlewareFunc
+ middleware []MiddlewareFunc
+ maxParam *int
+ router *Router
+ routers map[string]*Router
+ notFoundHandler HandlerFunc
+ pool sync.Pool
+ Server *http.Server
+ TLSServer *http.Server
+ Listener net.Listener
+ TLSListener net.Listener
+ AutoTLSManager autocert.Manager
+ DisableHTTP2 bool
+ Debug bool
+ HideBanner bool
+ HidePort bool
+ HTTPErrorHandler HTTPErrorHandler
+ Binder Binder
+ JSONSerializer JSONSerializer
+ Validator Validator
+ Renderer Renderer
+ Logger Logger
+ IPExtractor IPExtractor
+ ListenerNetwork string
+ }
- // premiddleware are middlewares that are run before routing is done. In case a pre-middleware returns
- // an error the router is not executed and the request will end up in the global error handler.
- premiddleware []MiddlewareFunc
- middleware []MiddlewareFunc
- maxParam *int
- router *Router
- routers map[string]*Router
- pool sync.Pool
+ // Route contains a handler and information for matching against requests.
+ Route struct {
+ Method string `json:"method"`
+ Path string `json:"path"`
+ Name string `json:"name"`
+ }
- StdLogger *stdLog.Logger
- Server *http.Server
- TLSServer *http.Server
- Listener net.Listener
- TLSListener net.Listener
- AutoTLSManager autocert.Manager
- HTTPErrorHandler HTTPErrorHandler
- Binder Binder
- JSONSerializer JSONSerializer
- Validator Validator
- Renderer Renderer
- Logger Logger
- IPExtractor IPExtractor
- ListenerNetwork string
+ // HTTPError represents an error that occurred while handling a request.
+ HTTPError struct {
+ Code int `json:"-"`
+ Message interface{} `json:"message"`
+ Internal error `json:"-"` // Stores the error returned by an external dependency
+ }
- // OnAddRouteHandler is called when Echo adds new route to specific host router.
- OnAddRouteHandler func(host string, route Route, handler HandlerFunc, middleware []MiddlewareFunc)
- DisableHTTP2 bool
- Debug bool
- HideBanner bool
- HidePort bool
-}
+ // MiddlewareFunc defines a function to process middleware.
+ MiddlewareFunc func(HandlerFunc) HandlerFunc
-// Route contains a handler and information for matching against requests.
-type Route struct {
- Method string `json:"method"`
- Path string `json:"path"`
- Name string `json:"name"`
-}
+ // HandlerFunc defines a function to serve HTTP requests.
+ HandlerFunc func(Context) error
-// HTTPError represents an error that occurred while handling a request.
-type HTTPError struct {
- Internal error `json:"-"` // Stores the error returned by an external dependency
- Message interface{} `json:"message"`
- Code int `json:"-"`
-}
+ // HTTPErrorHandler is a centralized HTTP error handler.
+ HTTPErrorHandler func(error, Context)
-// MiddlewareFunc defines a function to process middleware.
-type MiddlewareFunc func(next HandlerFunc) HandlerFunc
+ // Validator is the interface that wraps the Validate function.
+ Validator interface {
+ Validate(i interface{}) error
+ }
-// HandlerFunc defines a function to serve HTTP requests.
-type HandlerFunc func(c Context) error
+ // JSONSerializer is the interface that encodes and decodes JSON to and from interfaces.
+ JSONSerializer interface {
+ Serialize(c Context, i interface{}, indent string) error
+ Deserialize(c Context, i interface{}) error
+ }
-// HTTPErrorHandler is a centralized HTTP error handler.
-type HTTPErrorHandler func(err error, c Context)
+ // Renderer is the interface that wraps the Render function.
+ Renderer interface {
+ Render(io.Writer, string, interface{}, Context) error
+ }
-// Validator is the interface that wraps the Validate function.
-type Validator interface {
- Validate(i interface{}) error
-}
+ // Map defines a generic map of type `map[string]interface{}`.
+ Map map[string]interface{}
-// JSONSerializer is the interface that encodes and decodes JSON to and from interfaces.
-type JSONSerializer interface {
- Serialize(c Context, i interface{}, indent string) error
- Deserialize(c Context, i interface{}) error
-}
-
-// Map defines a generic map of type `map[string]interface{}`.
-type Map map[string]interface{}
-
-// Common struct for Echo & Group.
-type common struct{}
+ // Common struct for Echo & Group.
+ common struct{}
+)
// HTTP methods
// NOTE: Deprecated, please use the stdlib constants directly instead.
@@ -164,12 +161,7 @@ const (
// MIME types
const (
- // MIMEApplicationJSON JavaScript Object Notation (JSON) https://www.rfc-editor.org/rfc/rfc8259
- MIMEApplicationJSON = "application/json"
- // Deprecated: Please use MIMEApplicationJSON instead. JSON should be encoded using UTF-8 by default.
- // No "charset" parameter is defined for this registration.
- // Adding one really has no effect on compliant recipients.
- // See RFC 8259, section 8.1. https://datatracker.ietf.org/doc/html/rfc8259#section-8.1
+ MIMEApplicationJSON = "application/json"
MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8
MIMEApplicationJavaScript = "application/javascript"
MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8
@@ -194,18 +186,12 @@ const (
PROPFIND = "PROPFIND"
// REPORT Method can be used to get information about a resource, see rfc 3253
REPORT = "REPORT"
- // RouteNotFound is special method type for routes handling "route not found" (404) cases
- RouteNotFound = "echo_route_not_found"
)
// Headers
const (
- HeaderAccept = "Accept"
- HeaderAcceptEncoding = "Accept-Encoding"
- // HeaderAllow is the name of the "Allow" header field used to list the set of methods
- // advertised as supported by the target resource. Returning an Allow header is mandatory
- // for status 405 (method not found) and useful for the OPTIONS method in responses.
- // See RFC 7231: https://datatracker.ietf.org/doc/html/rfc7231#section-7.4.1
+ HeaderAccept = "Accept"
+ HeaderAcceptEncoding = "Accept-Encoding"
HeaderAllow = "Allow"
HeaderAuthorization = "Authorization"
HeaderContentDisposition = "Content-Disposition"
@@ -217,7 +203,6 @@ const (
HeaderIfModifiedSince = "If-Modified-Since"
HeaderLastModified = "Last-Modified"
HeaderLocation = "Location"
- HeaderRetryAfter = "Retry-After"
HeaderUpgrade = "Upgrade"
HeaderVary = "Vary"
HeaderWWWAuthenticate = "WWW-Authenticate"
@@ -227,14 +212,11 @@ const (
HeaderXForwardedSsl = "X-Forwarded-Ssl"
HeaderXUrlScheme = "X-Url-Scheme"
HeaderXHTTPMethodOverride = "X-HTTP-Method-Override"
- HeaderXRealIP = "X-Real-Ip"
- HeaderXRequestID = "X-Request-Id"
- HeaderXCorrelationID = "X-Correlation-Id"
+ HeaderXRealIP = "X-Real-IP"
+ HeaderXRequestID = "X-Request-ID"
HeaderXRequestedWith = "X-Requested-With"
HeaderServer = "Server"
HeaderOrigin = "Origin"
- HeaderCacheControl = "Cache-Control"
- HeaderConnection = "Connection"
// Access control
HeaderAccessControlRequestMethod = "Access-Control-Request-Method"
@@ -259,7 +241,7 @@ const (
const (
// Version of Echo
- Version = "4.13.4"
+ Version = "4.5.0"
website = "https://echo.labstack.com"
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
banner = `
@@ -274,95 +256,60 @@ ____________________________________O/_______
`
)
-var methods = [...]string{
- http.MethodConnect,
- http.MethodDelete,
- http.MethodGet,
- http.MethodHead,
- http.MethodOptions,
- http.MethodPatch,
- http.MethodPost,
- PROPFIND,
- http.MethodPut,
- http.MethodTrace,
- REPORT,
-}
+var (
+ methods = [...]string{
+ http.MethodConnect,
+ http.MethodDelete,
+ http.MethodGet,
+ http.MethodHead,
+ http.MethodOptions,
+ http.MethodPatch,
+ http.MethodPost,
+ PROPFIND,
+ http.MethodPut,
+ http.MethodTrace,
+ REPORT,
+ }
+)
// Errors
var (
- ErrBadRequest = NewHTTPError(http.StatusBadRequest) // HTTP 400 Bad Request
- ErrUnauthorized = NewHTTPError(http.StatusUnauthorized) // HTTP 401 Unauthorized
- ErrPaymentRequired = NewHTTPError(http.StatusPaymentRequired) // HTTP 402 Payment Required
- ErrForbidden = NewHTTPError(http.StatusForbidden) // HTTP 403 Forbidden
- ErrNotFound = NewHTTPError(http.StatusNotFound) // HTTP 404 Not Found
- ErrMethodNotAllowed = NewHTTPError(http.StatusMethodNotAllowed) // HTTP 405 Method Not Allowed
- ErrNotAcceptable = NewHTTPError(http.StatusNotAcceptable) // HTTP 406 Not Acceptable
- ErrProxyAuthRequired = NewHTTPError(http.StatusProxyAuthRequired) // HTTP 407 Proxy AuthRequired
- ErrRequestTimeout = NewHTTPError(http.StatusRequestTimeout) // HTTP 408 Request Timeout
- ErrConflict = NewHTTPError(http.StatusConflict) // HTTP 409 Conflict
- ErrGone = NewHTTPError(http.StatusGone) // HTTP 410 Gone
- ErrLengthRequired = NewHTTPError(http.StatusLengthRequired) // HTTP 411 Length Required
- ErrPreconditionFailed = NewHTTPError(http.StatusPreconditionFailed) // HTTP 412 Precondition Failed
- ErrStatusRequestEntityTooLarge = NewHTTPError(http.StatusRequestEntityTooLarge) // HTTP 413 Payload Too Large
- ErrRequestURITooLong = NewHTTPError(http.StatusRequestURITooLong) // HTTP 414 URI Too Long
- ErrUnsupportedMediaType = NewHTTPError(http.StatusUnsupportedMediaType) // HTTP 415 Unsupported Media Type
- ErrRequestedRangeNotSatisfiable = NewHTTPError(http.StatusRequestedRangeNotSatisfiable) // HTTP 416 Range Not Satisfiable
- ErrExpectationFailed = NewHTTPError(http.StatusExpectationFailed) // HTTP 417 Expectation Failed
- ErrTeapot = NewHTTPError(http.StatusTeapot) // HTTP 418 I'm a teapot
- ErrMisdirectedRequest = NewHTTPError(http.StatusMisdirectedRequest) // HTTP 421 Misdirected Request
- ErrUnprocessableEntity = NewHTTPError(http.StatusUnprocessableEntity) // HTTP 422 Unprocessable Entity
- ErrLocked = NewHTTPError(http.StatusLocked) // HTTP 423 Locked
- ErrFailedDependency = NewHTTPError(http.StatusFailedDependency) // HTTP 424 Failed Dependency
- ErrTooEarly = NewHTTPError(http.StatusTooEarly) // HTTP 425 Too Early
- ErrUpgradeRequired = NewHTTPError(http.StatusUpgradeRequired) // HTTP 426 Upgrade Required
- ErrPreconditionRequired = NewHTTPError(http.StatusPreconditionRequired) // HTTP 428 Precondition Required
- ErrTooManyRequests = NewHTTPError(http.StatusTooManyRequests) // HTTP 429 Too Many Requests
- ErrRequestHeaderFieldsTooLarge = NewHTTPError(http.StatusRequestHeaderFieldsTooLarge) // HTTP 431 Request Header Fields Too Large
- ErrUnavailableForLegalReasons = NewHTTPError(http.StatusUnavailableForLegalReasons) // HTTP 451 Unavailable For Legal Reasons
- ErrInternalServerError = NewHTTPError(http.StatusInternalServerError) // HTTP 500 Internal Server Error
- ErrNotImplemented = NewHTTPError(http.StatusNotImplemented) // HTTP 501 Not Implemented
- ErrBadGateway = NewHTTPError(http.StatusBadGateway) // HTTP 502 Bad Gateway
- ErrServiceUnavailable = NewHTTPError(http.StatusServiceUnavailable) // HTTP 503 Service Unavailable
- ErrGatewayTimeout = NewHTTPError(http.StatusGatewayTimeout) // HTTP 504 Gateway Timeout
- ErrHTTPVersionNotSupported = NewHTTPError(http.StatusHTTPVersionNotSupported) // HTTP 505 HTTP Version Not Supported
- ErrVariantAlsoNegotiates = NewHTTPError(http.StatusVariantAlsoNegotiates) // HTTP 506 Variant Also Negotiates
- ErrInsufficientStorage = NewHTTPError(http.StatusInsufficientStorage) // HTTP 507 Insufficient Storage
- ErrLoopDetected = NewHTTPError(http.StatusLoopDetected) // HTTP 508 Loop Detected
- ErrNotExtended = NewHTTPError(http.StatusNotExtended) // HTTP 510 Not Extended
- ErrNetworkAuthenticationRequired = NewHTTPError(http.StatusNetworkAuthenticationRequired) // HTTP 511 Network Authentication Required
-
- ErrValidatorNotRegistered = errors.New("validator not registered")
- ErrRendererNotRegistered = errors.New("renderer not registered")
- ErrInvalidRedirectCode = errors.New("invalid redirect status code")
- ErrCookieNotFound = errors.New("cookie not found")
- ErrInvalidCertOrKeyType = errors.New("invalid cert or key type, must be string or []byte")
- ErrInvalidListenerNetwork = errors.New("invalid listener network")
+ ErrUnsupportedMediaType = NewHTTPError(http.StatusUnsupportedMediaType)
+ ErrNotFound = NewHTTPError(http.StatusNotFound)
+ ErrUnauthorized = NewHTTPError(http.StatusUnauthorized)
+ ErrForbidden = NewHTTPError(http.StatusForbidden)
+ ErrMethodNotAllowed = NewHTTPError(http.StatusMethodNotAllowed)
+ ErrStatusRequestEntityTooLarge = NewHTTPError(http.StatusRequestEntityTooLarge)
+ ErrTooManyRequests = NewHTTPError(http.StatusTooManyRequests)
+ ErrBadRequest = NewHTTPError(http.StatusBadRequest)
+ ErrBadGateway = NewHTTPError(http.StatusBadGateway)
+ ErrInternalServerError = NewHTTPError(http.StatusInternalServerError)
+ ErrRequestTimeout = NewHTTPError(http.StatusRequestTimeout)
+ ErrServiceUnavailable = NewHTTPError(http.StatusServiceUnavailable)
+ ErrValidatorNotRegistered = errors.New("validator not registered")
+ ErrRendererNotRegistered = errors.New("renderer not registered")
+ ErrInvalidRedirectCode = errors.New("invalid redirect status code")
+ ErrCookieNotFound = errors.New("cookie not found")
+ ErrInvalidCertOrKeyType = errors.New("invalid cert or key type, must be string or []byte")
+ ErrInvalidListenerNetwork = errors.New("invalid listener network")
)
-// NotFoundHandler is the handler that router uses in case there was no matching route found. Returns an error that results
-// HTTP 404 status code.
-var NotFoundHandler = func(c Context) error {
- return ErrNotFound
-}
-
-// MethodNotAllowedHandler is the handler thar router uses in case there was no matching route found but there was
-// another matching routes for that requested URL. Returns an error that results HTTP 405 Method Not Allowed status code.
-var MethodNotAllowedHandler = func(c Context) error {
- // See RFC 7231 section 7.4.1: An origin server MUST generate an Allow field in a 405 (Method Not Allowed)
- // response and MAY do so in any other response. For disabled resources an empty Allow header may be returned
- routerAllowMethods, ok := c.Get(ContextKeyHeaderAllow).(string)
- if ok && routerAllowMethods != "" {
- c.Response().Header().Set(HeaderAllow, routerAllowMethods)
+// Error handlers
+var (
+ NotFoundHandler = func(c Context) error {
+ return ErrNotFound
}
- return ErrMethodNotAllowed
-}
+
+ MethodNotAllowedHandler = func(c Context) error {
+ return ErrMethodNotAllowed
+ }
+)
// New creates an instance of Echo.
func New() (e *Echo) {
e = &Echo{
- filesystem: createFilesystem(),
- Server: new(http.Server),
- TLSServer: new(http.Server),
+ Server: new(http.Server),
+ TLSServer: new(http.Server),
AutoTLSManager: autocert.Manager{
Prompt: autocert.AcceptTOS,
},
@@ -410,17 +357,7 @@ func (e *Echo) Routers() map[string]*Router {
// DefaultHTTPErrorHandler is the default HTTP error handler. It sends a JSON response
// with status code.
-//
-// NOTE: In case errors happens in middleware call-chain that is returning from handler (which did not return an error).
-// When handler has already sent response (ala c.JSON()) and there is error in middleware that is returning from
-// handler. Then the error that global error handler received will be ignored because we have already "committed" the
-// response and status code header has been sent to the client.
func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
-
- if c.Response().Committed {
- return
- }
-
he, ok := err.(*HTTPError)
if ok {
if he.Internal != nil {
@@ -438,28 +375,24 @@ func (e *Echo) DefaultHTTPErrorHandler(err error, c Context) {
// Issue #1426
code := he.Code
message := he.Message
-
- switch m := he.Message.(type) {
- case string:
+ if m, ok := he.Message.(string); ok {
if e.Debug {
message = Map{"message": m, "error": err.Error()}
} else {
message = Map{"message": m}
}
- case json.Marshaler:
- // do nothing - this type knows how to format itself to JSON
- case error:
- message = Map{"message": m.Error()}
}
// Send response
- if c.Request().Method == http.MethodHead { // Issue #608
- err = c.NoContent(he.Code)
- } else {
- err = c.JSON(code, message)
- }
- if err != nil {
- e.Logger.Error(err)
+ if !c.Response().Committed {
+ if c.Request().Method == http.MethodHead { // Issue #608
+ err = c.NoContent(he.Code)
+ } else {
+ err = c.JSON(code, message)
+ }
+ if err != nil {
+ e.Logger.Error(err)
+ }
}
}
@@ -527,21 +460,8 @@ func (e *Echo) TRACE(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
return e.Add(http.MethodTrace, path, h, m...)
}
-// RouteNotFound registers a special-case route which is executed when no other route is found (i.e. HTTP 404 cases)
-// for current request URL.
-// Path supports static and named/any parameters just like other http method is defined. Generally path is ended with
-// wildcard/match-any character (`/*`, `/download/*` etc).
-//
-// Example: `e.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })`
-func (e *Echo) RouteNotFound(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return e.Add(RouteNotFound, path, h, m...)
-}
-
-// Any registers a new route for all HTTP methods (supported by Echo) and path with matching handler
+// Any registers a new route for all HTTP methods and path with matching handler
// in the router with optional route-level middleware.
-//
-// Note: this method only adds specific set of supported HTTP methods as handler and is not true
-// "catch-any-arbitrary-method" way of matching requests.
func (e *Echo) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) []*Route {
routes := make([]*Route, len(methods))
for i, m := range methods {
@@ -560,6 +480,50 @@ func (e *Echo) Match(methods []string, path string, handler HandlerFunc, middlew
return routes
}
+// Static registers a new route with path prefix to serve static files from the
+// provided root directory.
+func (e *Echo) Static(prefix, root string) *Route {
+ if root == "" {
+ root = "." // For security we want to restrict to CWD.
+ }
+ return e.static(prefix, root, e.GET)
+}
+
+func (common) static(prefix, root string, get func(string, HandlerFunc, ...MiddlewareFunc) *Route) *Route {
+ h := func(c Context) error {
+ p, err := url.PathUnescape(c.Param("*"))
+ if err != nil {
+ return err
+ }
+
+ name := filepath.Join(root, filepath.Clean("/"+p)) // "/"+ for security
+ fi, err := os.Stat(name)
+ if err != nil {
+ // The access path does not exist
+ return NotFoundHandler(c)
+ }
+
+ // If the request is for a directory and does not end with "/"
+ p = c.Request().URL.Path // path must not be empty.
+ if fi.IsDir() && p[len(p)-1] != '/' {
+ // Redirect to ends with "/"
+ return c.Redirect(http.StatusMovedPermanently, p+"/")
+ }
+ return c.File(name)
+ }
+ // Handle added routes based on trailing slash:
+ // /prefix => exact route "/prefix" + any route "/prefix/*"
+ // /prefix/ => only any route "/prefix/*"
+ if prefix != "" {
+ if prefix[len(prefix)-1] == '/' {
+ // Only add any route for intentional trailing slash
+ return get(prefix+"*", h)
+ }
+ get(prefix, h)
+ }
+ return get(prefix+"/*", h)
+}
+
func (common) file(path, file string, get func(string, HandlerFunc, ...MiddlewareFunc) *Route,
m ...MiddlewareFunc) *Route {
return get(path, func(c Context) error {
@@ -572,20 +536,20 @@ func (e *Echo) File(path, file string, m ...MiddlewareFunc) *Route {
return e.file(path, file, e.GET, m...)
}
-func (e *Echo) add(host, method, path string, handler HandlerFunc, middlewares ...MiddlewareFunc) *Route {
- router := e.findRouter(host)
- //FIXME: when handler+middleware are both nil ... make it behave like handler removal
+func (e *Echo) add(host, method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route {
name := handlerName(handler)
- route := router.add(method, path, name, func(c Context) error {
- h := applyMiddleware(handler, middlewares...)
+ router := e.findRouter(host)
+ router.Add(method, path, func(c Context) error {
+ h := applyMiddleware(handler, middleware...)
return h(c)
})
-
- if e.OnAddRouteHandler != nil {
- e.OnAddRouteHandler(host, *route, handler, middlewares)
+ r := &Route{
+ Method: method,
+ Path: path,
+ Name: name,
}
-
- return route
+ e.router.routes[method+path] = r
+ return r
}
// Add registers a new route for an HTTP method and path with matching handler
@@ -609,7 +573,7 @@ func (e *Echo) Group(prefix string, m ...MiddlewareFunc) (g *Group) {
return
}
-// URI generates an URI from handler.
+// URI generates a URI from handler.
func (e *Echo) URI(handler HandlerFunc, params ...interface{}) string {
name := handlerName(handler)
return e.Reverse(name, params...)
@@ -620,15 +584,37 @@ func (e *Echo) URL(h HandlerFunc, params ...interface{}) string {
return e.URI(h, params...)
}
-// Reverse generates a URL from route name and provided parameters.
+// Reverse generates an URL from route name and provided parameters.
func (e *Echo) Reverse(name string, params ...interface{}) string {
- return e.router.Reverse(name, params...)
+ uri := new(bytes.Buffer)
+ ln := len(params)
+ n := 0
+ for _, r := range e.router.routes {
+ if r.Name == name {
+ for i, l := 0, len(r.Path); i < l; i++ {
+ if (r.Path[i] == ':' || r.Path[i] == '*') && n < ln {
+ for ; i < l && r.Path[i] != '/'; i++ {
+ }
+ uri.WriteString(fmt.Sprintf("%v", params[n]))
+ n++
+ }
+ if i < l {
+ uri.WriteByte(r.Path[i])
+ }
+ }
+ break
+ }
+ }
+ return uri.String()
}
-// Routes returns the registered routes for default router.
-// In case when Echo serves multiple hosts/domains use `e.Routers()["domain2.site"].Routes()` to get specific host routes.
+// Routes returns the registered routes.
func (e *Echo) Routes() []*Route {
- return e.router.Routes()
+ routes := make([]*Route, 0, len(e.router.routes))
+ for _, v := range e.router.routes {
+ routes = append(routes, v)
+ }
+ return routes
}
// AcquireContext returns an empty `Context` instance from the pool.
@@ -648,7 +634,7 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Acquire context
c := e.pool.Get().(*context)
c.Reset(r, w)
- var h HandlerFunc
+ h := NotFoundHandler
if e.premiddleware == nil {
e.findRouter(r.Host).Find(r.Method, GetPath(r), c)
@@ -722,7 +708,7 @@ func (e *Echo) StartTLS(address string, certFile, keyFile interface{}) (err erro
func filepathOrContent(fileOrContent interface{}) (content []byte, err error) {
switch v := fileOrContent.(type) {
case string:
- return os.ReadFile(v)
+ return ioutil.ReadFile(v)
case []byte:
return v, nil
default:
@@ -770,7 +756,7 @@ func (e *Echo) StartServer(s *http.Server) (err error) {
return s.Serve(e.Listener)
}
-func (e *Echo) configureServer(s *http.Server) error {
+func (e *Echo) configureServer(s *http.Server) (err error) {
// Setup
e.colorer.SetOutput(e.Logger.Output())
s.ErrorLog = e.StdLogger
@@ -785,11 +771,10 @@ func (e *Echo) configureServer(s *http.Server) error {
if s.TLSConfig == nil {
if e.Listener == nil {
- l, err := newListener(s.Addr, e.ListenerNetwork)
+ e.Listener, err = newListener(s.Addr, e.ListenerNetwork)
if err != nil {
return err
}
- e.Listener = l
}
if !e.HidePort {
e.colorer.Printf("⇨ http server started on %s\n", e.colorer.Green(e.Listener.Addr()))
@@ -830,7 +815,7 @@ func (e *Echo) TLSListenerAddr() net.Addr {
}
// StartH2CServer starts a custom http/2 server with h2c (HTTP/2 Cleartext).
-func (e *Echo) StartH2CServer(address string, h2s *http2.Server) error {
+func (e *Echo) StartH2CServer(address string, h2s *http2.Server) (err error) {
e.startupMutex.Lock()
// Setup
s := e.Server
@@ -847,12 +832,11 @@ func (e *Echo) StartH2CServer(address string, h2s *http2.Server) error {
}
if e.Listener == nil {
- l, err := newListener(s.Addr, e.ListenerNetwork)
+ e.Listener, err = newListener(s.Addr, e.ListenerNetwork)
if err != nil {
e.startupMutex.Unlock()
return err
}
- e.Listener = l
}
if !e.HidePort {
e.colorer.Printf("⇨ http server started on %s\n", e.colorer.Green(e.Listener.Addr()))
@@ -906,15 +890,6 @@ func (he *HTTPError) SetInternal(err error) *HTTPError {
return he
}
-// WithInternal returns clone of HTTPError with err set to HTTPError.Internal field
-func (he *HTTPError) WithInternal(err error) *HTTPError {
- return &HTTPError{
- Code: he.Code,
- Message: he.Message,
- Internal: err,
- }
-}
-
// Unwrap satisfies the Go 1.13 error wrapper interface.
func (he *HTTPError) Unwrap() error {
return he.Internal
@@ -944,8 +919,8 @@ func WrapMiddleware(m func(http.Handler) http.Handler) MiddlewareFunc {
// GetPath returns RawPath, if it's empty returns Path from URL
// Difference between RawPath and Path is:
-// - Path is where request path is stored. Value is stored in decoded form: /%47%6f%2f becomes /Go/.
-// - RawPath is an optional field which only gets set if the default encoding is different from Path.
+// * Path is where request path is stored. Value is stored in decoded form: /%47%6f%2f becomes /Go/.
+// * RawPath is an optional field which only gets set if the default encoding is different from Path.
func GetPath(r *http.Request) string {
path := r.URL.RawPath
if path == "" {
diff --git a/vendor/github.com/labstack/echo/v4/echo_fs.go b/vendor/github.com/labstack/echo/v4/echo_fs.go
deleted file mode 100644
index 0ffc4b0..0000000
--- a/vendor/github.com/labstack/echo/v4/echo_fs.go
+++ /dev/null
@@ -1,162 +0,0 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
-package echo
-
-import (
- "fmt"
- "io/fs"
- "net/http"
- "net/url"
- "os"
- "path/filepath"
- "strings"
-)
-
-type filesystem struct {
- // Filesystem is file system used by Static and File handlers to access files.
- // Defaults to os.DirFS(".")
- //
- // When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary
- // prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths
- // including `assets/images` as their prefix.
- Filesystem fs.FS
-}
-
-func createFilesystem() filesystem {
- return filesystem{
- Filesystem: newDefaultFS(),
- }
-}
-
-// Static registers a new route with path prefix to serve static files from the provided root directory.
-func (e *Echo) Static(pathPrefix, fsRoot string) *Route {
- subFs := MustSubFS(e.Filesystem, fsRoot)
- return e.Add(
- http.MethodGet,
- pathPrefix+"*",
- StaticDirectoryHandler(subFs, false),
- )
-}
-
-// StaticFS registers a new route with path prefix to serve static files from the provided file system.
-//
-// When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary
-// prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths
-// including `assets/images` as their prefix.
-func (e *Echo) StaticFS(pathPrefix string, filesystem fs.FS) *Route {
- return e.Add(
- http.MethodGet,
- pathPrefix+"*",
- StaticDirectoryHandler(filesystem, false),
- )
-}
-
-// StaticDirectoryHandler creates handler function to serve files from provided file system
-// When disablePathUnescaping is set then file name from path is not unescaped and is served as is.
-func StaticDirectoryHandler(fileSystem fs.FS, disablePathUnescaping bool) HandlerFunc {
- return func(c Context) error {
- p := c.Param("*")
- if !disablePathUnescaping { // when router is already unescaping we do not want to do is twice
- tmpPath, err := url.PathUnescape(p)
- if err != nil {
- return fmt.Errorf("failed to unescape path variable: %w", err)
- }
- p = tmpPath
- }
-
- // fs.FS.Open() already assumes that file names are relative to FS root path and considers name with prefix `/` as invalid
- name := filepath.ToSlash(filepath.Clean(strings.TrimPrefix(p, "/")))
- fi, err := fs.Stat(fileSystem, name)
- if err != nil {
- return ErrNotFound
- }
-
- // If the request is for a directory and does not end with "/"
- p = c.Request().URL.Path // path must not be empty.
- if fi.IsDir() && len(p) > 0 && p[len(p)-1] != '/' {
- // Redirect to ends with "/"
- return c.Redirect(http.StatusMovedPermanently, sanitizeURI(p+"/"))
- }
- return fsFile(c, name, fileSystem)
- }
-}
-
-// FileFS registers a new route with path to serve file from the provided file system.
-func (e *Echo) FileFS(path, file string, filesystem fs.FS, m ...MiddlewareFunc) *Route {
- return e.GET(path, StaticFileHandler(file, filesystem), m...)
-}
-
-// StaticFileHandler creates handler function to serve file from provided file system
-func StaticFileHandler(file string, filesystem fs.FS) HandlerFunc {
- return func(c Context) error {
- return fsFile(c, file, filesystem)
- }
-}
-
-// defaultFS exists to preserve pre v4.7.0 behaviour where files were open by `os.Open`.
-// v4.7 introduced `echo.Filesystem` field which is Go1.16+ `fs.Fs` interface.
-// Difference between `os.Open` and `fs.Open` is that FS does not allow opening path that start with `.`, `..` or `/`
-// etc. For example previously you could have `../images` in your application but `fs := os.DirFS("./")` would not
-// allow you to use `fs.Open("../images")` and this would break all old applications that rely on being able to
-// traverse up from current executable run path.
-// NB: private because you really should use fs.FS implementation instances
-type defaultFS struct {
- fs fs.FS
- prefix string
-}
-
-func newDefaultFS() *defaultFS {
- dir, _ := os.Getwd()
- return &defaultFS{
- prefix: dir,
- fs: nil,
- }
-}
-
-func (fs defaultFS) Open(name string) (fs.File, error) {
- if fs.fs == nil {
- return os.Open(name)
- }
- return fs.fs.Open(name)
-}
-
-func subFS(currentFs fs.FS, root string) (fs.FS, error) {
- root = filepath.ToSlash(filepath.Clean(root)) // note: fs.FS operates only with slashes. `ToSlash` is necessary for Windows
- if dFS, ok := currentFs.(*defaultFS); ok {
- // we need to make exception for `defaultFS` instances as it interprets root prefix differently from fs.FS.
- // fs.Fs.Open does not like relative paths ("./", "../") and absolute paths at all but prior echo.Filesystem we
- // were able to use paths like `./myfile.log`, `/etc/hosts` and these would work fine with `os.Open` but not with fs.Fs
- if !filepath.IsAbs(root) {
- root = filepath.Join(dFS.prefix, root)
- }
- return &defaultFS{
- prefix: root,
- fs: os.DirFS(root),
- }, nil
- }
- return fs.Sub(currentFs, root)
-}
-
-// MustSubFS creates sub FS from current filesystem or panic on failure.
-// Panic happens when `fsRoot` contains invalid path according to `fs.ValidPath` rules.
-//
-// MustSubFS is helpful when dealing with `embed.FS` because for example `//go:embed assets/images` embeds files with
-// paths including `assets/images` as their prefix. In that case use `fs := echo.MustSubFS(fs, "rootDirectory") to
-// create sub fs which uses necessary prefix for directory path.
-func MustSubFS(currentFs fs.FS, fsRoot string) fs.FS {
- subFs, err := subFS(currentFs, fsRoot)
- if err != nil {
- panic(fmt.Errorf("can not create sub FS, invalid root given, err: %w", err))
- }
- return subFs
-}
-
-func sanitizeURI(uri string) string {
- // double slash `\\`, `//` or even `\/` is absolute uri for browsers and by redirecting request to that uri
- // we are vulnerable to open redirect attack. so replace all slashes from the beginning with single slash
- if len(uri) > 1 && (uri[0] == '\\' || uri[0] == '/') && (uri[1] == '\\' || uri[1] == '/') {
- uri = "/" + strings.TrimLeft(uri, `/\`)
- }
- return uri
-}
diff --git a/vendor/github.com/labstack/echo/v4/group.go b/vendor/github.com/labstack/echo/v4/group.go
index cb37b12..426bef9 100644
--- a/vendor/github.com/labstack/echo/v4/group.go
+++ b/vendor/github.com/labstack/echo/v4/group.go
@@ -1,22 +1,21 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package echo
import (
"net/http"
)
-// Group is a set of sub-routes for a specified route. It can be used for inner
-// routes that share a common middleware or functionality that should be separate
-// from the parent echo instance while still inheriting from it.
-type Group struct {
- common
- host string
- prefix string
- echo *Echo
- middleware []MiddlewareFunc
-}
+type (
+ // Group is a set of sub-routes for a specified route. It can be used for inner
+ // routes that share a common middleware or functionality that should be separate
+ // from the parent echo instance while still inheriting from it.
+ Group struct {
+ common
+ host string
+ prefix string
+ middleware []MiddlewareFunc
+ echo *Echo
+ }
+)
// Use implements `Echo#Use()` for sub-routes within the Group.
func (g *Group) Use(middleware ...MiddlewareFunc) {
@@ -24,12 +23,10 @@ func (g *Group) Use(middleware ...MiddlewareFunc) {
if len(g.middleware) == 0 {
return
}
- // group level middlewares are different from Echo `Pre` and `Use` middlewares (those are global). Group level middlewares
- // are only executed if they are added to the Router with route.
- // So we register catch all route (404 is a safe way to emulate route match) for this group and now during routing the
- // Router would find route to match our request path and therefore guarantee the middleware(s) will get executed.
- g.RouteNotFound("", NotFoundHandler)
- g.RouteNotFound("/*", NotFoundHandler)
+ // Allow all requests to reach the group as they might get dropped if router
+ // doesn't find a match, making none of the group middleware process.
+ g.Any("", NotFoundHandler)
+ g.Any("/*", NotFoundHandler)
}
// CONNECT implements `Echo#CONNECT()` for sub-routes within the Group.
@@ -105,18 +102,16 @@ func (g *Group) Group(prefix string, middleware ...MiddlewareFunc) (sg *Group) {
return
}
+// Static implements `Echo#Static()` for sub-routes within the Group.
+func (g *Group) Static(prefix, root string) {
+ g.static(prefix, root, g.GET)
+}
+
// File implements `Echo#File()` for sub-routes within the Group.
func (g *Group) File(path, file string) {
g.file(path, file, g.GET)
}
-// RouteNotFound implements `Echo#RouteNotFound()` for sub-routes within the Group.
-//
-// Example: `g.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })`
-func (g *Group) RouteNotFound(path string, h HandlerFunc, m ...MiddlewareFunc) *Route {
- return g.Add(RouteNotFound, path, h, m...)
-}
-
// Add implements `Echo#Add()` for sub-routes within the Group.
func (g *Group) Add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route {
// Combine into a new slice to avoid accidentally passing the same slice for
diff --git a/vendor/github.com/labstack/echo/v4/group_fs.go b/vendor/github.com/labstack/echo/v4/group_fs.go
deleted file mode 100644
index c1b7ec2..0000000
--- a/vendor/github.com/labstack/echo/v4/group_fs.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
-package echo
-
-import (
- "io/fs"
- "net/http"
-)
-
-// Static implements `Echo#Static()` for sub-routes within the Group.
-func (g *Group) Static(pathPrefix, fsRoot string) {
- subFs := MustSubFS(g.echo.Filesystem, fsRoot)
- g.StaticFS(pathPrefix, subFs)
-}
-
-// StaticFS implements `Echo#StaticFS()` for sub-routes within the Group.
-//
-// When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary
-// prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths
-// including `assets/images` as their prefix.
-func (g *Group) StaticFS(pathPrefix string, filesystem fs.FS) {
- g.Add(
- http.MethodGet,
- pathPrefix+"*",
- StaticDirectoryHandler(filesystem, false),
- )
-}
-
-// FileFS implements `Echo#FileFS()` for sub-routes within the Group.
-func (g *Group) FileFS(path, file string, filesystem fs.FS, m ...MiddlewareFunc) *Route {
- return g.GET(path, StaticFileHandler(file, filesystem), m...)
-}
diff --git a/vendor/github.com/labstack/echo/v4/ip.go b/vendor/github.com/labstack/echo/v4/ip.go
index 6ed1d11..39cb421 100644
--- a/vendor/github.com/labstack/echo/v4/ip.go
+++ b/vendor/github.com/labstack/echo/v4/ip.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package echo
import (
@@ -9,135 +6,11 @@ import (
"strings"
)
-/**
-By: https://github.com/tmshn (See: https://github.com/labstack/echo/pull/1478 , https://github.com/labstack/echox/pull/134 )
-Source: https://echo.labstack.com/guide/ip-address/
-
-IP address plays fundamental role in HTTP; it's used for access control, auditing, geo-based access analysis and more.
-Echo provides handy method [`Context#RealIP()`](https://godoc.org/github.com/labstack/echo#Context) for that.
-
-However, it is not trivial to retrieve the _real_ IP address from requests especially when you put L7 proxies before the application.
-In such situation, _real_ IP needs to be relayed on HTTP layer from proxies to your app, but you must not trust HTTP headers unconditionally.
-Otherwise, you might give someone a chance of deceiving you. **A security risk!**
-
-To retrieve IP address reliably/securely, you must let your application be aware of the entire architecture of your infrastructure.
-In Echo, this can be done by configuring `Echo#IPExtractor` appropriately.
-This guides show you why and how.
-
-> Note: if you don't set `Echo#IPExtractor` explicitly, Echo fallback to legacy behavior, which is not a good choice.
-
-Let's start from two questions to know the right direction:
-
-1. Do you put any HTTP (L7) proxy in front of the application?
- - It includes both cloud solutions (such as AWS ALB or GCP HTTP LB) and OSS ones (such as Nginx, Envoy or Istio ingress gateway).
-2. If yes, what HTTP header do your proxies use to pass client IP to the application?
-
-## Case 1. With no proxy
-
-If you put no proxy (e.g.: directory facing to the internet), all you need to (and have to) see is IP address from network layer.
-Any HTTP header is untrustable because the clients have full control what headers to be set.
-
-In this case, use `echo.ExtractIPDirect()`.
-
-```go
-e.IPExtractor = echo.ExtractIPDirect()
-```
-
-## Case 2. With proxies using `X-Forwarded-For` header
-
-[`X-Forwared-For` (XFF)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For) is the popular header
-to relay clients' IP addresses.
-At each hop on the proxies, they append the request IP address at the end of the header.
-
-Following example diagram illustrates this behavior.
-
-```text
-┌──────────┠┌──────────┠┌──────────┠┌──────────â”
-│ "Origin" │───────────>│ Proxy 1 │───────────>│ Proxy 2 │───────────>│ Your app │
-│ (IP: a) │ │ (IP: b) │ │ (IP: c) │ │ │
-└──────────┘ └──────────┘ └──────────┘ └──────────┘
-
-Case 1.
-XFF: "" "a" "a, b"
- ~~~~~~
-Case 2.
-XFF: "x" "x, a" "x, a, b"
- ~~~~~~~~~
- ↑ What your app will see
-```
-
-In this case, use **first _untrustable_ IP reading from right**. Never use first one reading from left, as it is
-configurable by client. Here "trustable" means "you are sure the IP address belongs to your infrastructure".
-In above example, if `b` and `c` are trustable, the IP address of the client is `a` for both cases, never be `x`.
-
-In Echo, use `ExtractIPFromXFFHeader(...TrustOption)`.
-
-```go
-e.IPExtractor = echo.ExtractIPFromXFFHeader()
-```
-
-By default, it trusts internal IP addresses (loopback, link-local unicast, private-use and unique local address
-from [RFC6890](https://tools.ietf.org/html/rfc6890), [RFC4291](https://tools.ietf.org/html/rfc4291) and
-[RFC4193](https://tools.ietf.org/html/rfc4193)).
-To control this behavior, use [`TrustOption`](https://godoc.org/github.com/labstack/echo#TrustOption)s.
-
-E.g.:
-
-```go
-e.IPExtractor = echo.ExtractIPFromXFFHeader(
- TrustLinkLocal(false),
- TrustIPRanges(lbIPRange),
-)
-```
-
-- Ref: https://godoc.org/github.com/labstack/echo#TrustOption
-
-## Case 3. With proxies using `X-Real-IP` header
-
-`X-Real-IP` is another HTTP header to relay clients' IP addresses, but it carries only one address unlike XFF.
-
-If your proxies set this header, use `ExtractIPFromRealIPHeader(...TrustOption)`.
-
-```go
-e.IPExtractor = echo.ExtractIPFromRealIPHeader()
-```
-
-Again, it trusts internal IP addresses by default (loopback, link-local unicast, private-use and unique local address
-from [RFC6890](https://tools.ietf.org/html/rfc6890), [RFC4291](https://tools.ietf.org/html/rfc4291) and
-[RFC4193](https://tools.ietf.org/html/rfc4193)).
-To control this behavior, use [`TrustOption`](https://godoc.org/github.com/labstack/echo#TrustOption)s.
-
-- Ref: https://godoc.org/github.com/labstack/echo#TrustOption
-
-> **Never forget** to configure the outermost proxy (i.e.; at the edge of your infrastructure) **not to pass through incoming headers**.
-> Otherwise there is a chance of fraud, as it is what clients can control.
-
-## About default behavior
-
-In default behavior, Echo sees all of first XFF header, X-Real-IP header and IP from network layer.
-
-As you might already notice, after reading this article, this is not good.
-Sole reason this is default is just backward compatibility.
-
-## Private IP ranges
-
-See: https://en.wikipedia.org/wiki/Private_network
-
-Private IPv4 address ranges (RFC 1918):
-* 10.0.0.0 – 10.255.255.255 (24-bit block)
-* 172.16.0.0 – 172.31.255.255 (20-bit block)
-* 192.168.0.0 – 192.168.255.255 (16-bit block)
-
-Private IPv6 address ranges:
-* fc00::/7 address block = RFC 4193 Unique Local Addresses (ULA)
-
-*/
-
type ipChecker struct {
- trustExtraRanges []*net.IPNet
trustLoopback bool
trustLinkLocal bool
trustPrivateNet bool
+ trustExtraRanges []*net.IPNet
}
// TrustOption is config for which IP address to trust
@@ -179,7 +52,6 @@ func newIPChecker(configs []TrustOption) *ipChecker {
return checker
}
-// Go1.16+ added `ip.IsPrivate()` but until that use this implementation
func isPrivateIPRange(ip net.IP) bool {
if ip4 := ip.To4(); ip4 != nil {
return ip4[0] == 10 ||
@@ -215,12 +87,10 @@ type IPExtractor func(*http.Request) string
// ExtractIPDirect extracts IP address using actual IP address.
// Use this if your server faces to internet directory (i.e.: uses no proxy).
func ExtractIPDirect() IPExtractor {
- return extractIP
-}
-
-func extractIP(req *http.Request) string {
- ra, _, _ := net.SplitHostPort(req.RemoteAddr)
- return ra
+ return func(req *http.Request) string {
+ ra, _, _ := net.SplitHostPort(req.RemoteAddr)
+ return ra
+ }
}
// ExtractIPFromRealIPHeader extracts IP address using x-real-ip header.
@@ -228,20 +98,13 @@ func extractIP(req *http.Request) string {
func ExtractIPFromRealIPHeader(options ...TrustOption) IPExtractor {
checker := newIPChecker(options)
return func(req *http.Request) string {
- directIP := extractIP(req)
+ directIP := ExtractIPDirect()(req)
realIP := req.Header.Get(HeaderXRealIP)
- if realIP == "" {
- return directIP
- }
-
- if checker.trust(net.ParseIP(directIP)) {
- realIP = strings.TrimPrefix(realIP, "[")
- realIP = strings.TrimSuffix(realIP, "]")
- if rIP := net.ParseIP(realIP); rIP != nil {
+ if realIP != "" {
+ if ip := net.ParseIP(directIP); ip != nil && checker.trust(ip) {
return realIP
}
}
-
return directIP
}
}
@@ -252,17 +115,14 @@ func ExtractIPFromRealIPHeader(options ...TrustOption) IPExtractor {
func ExtractIPFromXFFHeader(options ...TrustOption) IPExtractor {
checker := newIPChecker(options)
return func(req *http.Request) string {
- directIP := extractIP(req)
+ directIP := ExtractIPDirect()(req)
xffs := req.Header[HeaderXForwardedFor]
if len(xffs) == 0 {
return directIP
}
ips := append(strings.Split(strings.Join(xffs, ","), ","), directIP)
for i := len(ips) - 1; i >= 0; i-- {
- ips[i] = strings.TrimSpace(ips[i])
- ips[i] = strings.TrimPrefix(ips[i], "[")
- ips[i] = strings.TrimSuffix(ips[i], "]")
- ip := net.ParseIP(ips[i])
+ ip := net.ParseIP(strings.TrimSpace(ips[i]))
if ip == nil {
// Unable to parse IP; cannot trust entire records
return directIP
diff --git a/vendor/github.com/labstack/echo/v4/json.go b/vendor/github.com/labstack/echo/v4/json.go
index 6da0aaf..16b2d05 100644
--- a/vendor/github.com/labstack/echo/v4/json.go
+++ b/vendor/github.com/labstack/echo/v4/json.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package echo
import (
diff --git a/vendor/github.com/labstack/echo/v4/log.go b/vendor/github.com/labstack/echo/v4/log.go
index 0acd9ff..3f8de59 100644
--- a/vendor/github.com/labstack/echo/v4/log.go
+++ b/vendor/github.com/labstack/echo/v4/log.go
@@ -1,41 +1,41 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package echo
import (
- "github.com/labstack/gommon/log"
"io"
+
+ "github.com/labstack/gommon/log"
)
-// Logger defines the logging interface.
-type Logger interface {
- Output() io.Writer
- SetOutput(w io.Writer)
- Prefix() string
- SetPrefix(p string)
- Level() log.Lvl
- SetLevel(v log.Lvl)
- SetHeader(h string)
- Print(i ...interface{})
- Printf(format string, args ...interface{})
- Printj(j log.JSON)
- Debug(i ...interface{})
- Debugf(format string, args ...interface{})
- Debugj(j log.JSON)
- Info(i ...interface{})
- Infof(format string, args ...interface{})
- Infoj(j log.JSON)
- Warn(i ...interface{})
- Warnf(format string, args ...interface{})
- Warnj(j log.JSON)
- Error(i ...interface{})
- Errorf(format string, args ...interface{})
- Errorj(j log.JSON)
- Fatal(i ...interface{})
- Fatalj(j log.JSON)
- Fatalf(format string, args ...interface{})
- Panic(i ...interface{})
- Panicj(j log.JSON)
- Panicf(format string, args ...interface{})
-}
+type (
+ // Logger defines the logging interface.
+ Logger interface {
+ Output() io.Writer
+ SetOutput(w io.Writer)
+ Prefix() string
+ SetPrefix(p string)
+ Level() log.Lvl
+ SetLevel(v log.Lvl)
+ SetHeader(h string)
+ Print(i ...interface{})
+ Printf(format string, args ...interface{})
+ Printj(j log.JSON)
+ Debug(i ...interface{})
+ Debugf(format string, args ...interface{})
+ Debugj(j log.JSON)
+ Info(i ...interface{})
+ Infof(format string, args ...interface{})
+ Infoj(j log.JSON)
+ Warn(i ...interface{})
+ Warnf(format string, args ...interface{})
+ Warnj(j log.JSON)
+ Error(i ...interface{})
+ Errorf(format string, args ...interface{})
+ Errorj(j log.JSON)
+ Fatal(i ...interface{})
+ Fatalj(j log.JSON)
+ Fatalf(format string, args ...interface{})
+ Panic(i ...interface{})
+ Panicj(j log.JSON)
+ Panicf(format string, args ...interface{})
+ }
+)
diff --git a/vendor/github.com/labstack/echo/v4/middleware/basic_auth.go b/vendor/github.com/labstack/echo/v4/middleware/basic_auth.go
index 9285f29..8cf1ed9 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/basic_auth.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/basic_auth.go
@@ -1,46 +1,44 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
"encoding/base64"
- "net/http"
"strconv"
"strings"
"github.com/labstack/echo/v4"
)
-// BasicAuthConfig defines the config for BasicAuth middleware.
-type BasicAuthConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // BasicAuthConfig defines the config for BasicAuth middleware.
+ BasicAuthConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // Validator is a function to validate BasicAuth credentials.
- // Required.
- Validator BasicAuthValidator
+ // Validator is a function to validate BasicAuth credentials.
+ // Required.
+ Validator BasicAuthValidator
- // Realm is a string to define realm attribute of BasicAuth.
- // Default value "Restricted".
- Realm string
-}
+ // Realm is a string to define realm attribute of BasicAuth.
+ // Default value "Restricted".
+ Realm string
+ }
-// BasicAuthValidator defines a function to validate BasicAuth credentials.
-// The function should return a boolean indicating whether the credentials are valid,
-// and an error if any error occurs during the validation process.
-type BasicAuthValidator func(string, string, echo.Context) (bool, error)
+ // BasicAuthValidator defines a function to validate BasicAuth credentials.
+ BasicAuthValidator func(string, string, echo.Context) (bool, error)
+)
const (
basic = "basic"
defaultRealm = "Restricted"
)
-// DefaultBasicAuthConfig is the default BasicAuth middleware config.
-var DefaultBasicAuthConfig = BasicAuthConfig{
- Skipper: DefaultSkipper,
- Realm: defaultRealm,
-}
+var (
+ // DefaultBasicAuthConfig is the default BasicAuth middleware config.
+ DefaultBasicAuthConfig = BasicAuthConfig{
+ Skipper: DefaultSkipper,
+ Realm: defaultRealm,
+ }
+)
// BasicAuth returns an BasicAuth middleware.
//
@@ -76,13 +74,10 @@ func BasicAuthWithConfig(config BasicAuthConfig) echo.MiddlewareFunc {
l := len(basic)
if len(auth) > l+1 && strings.EqualFold(auth[:l], basic) {
- // Invalid base64 shouldn't be treated as error
- // instead should be treated as invalid client input
b, err := base64.StdEncoding.DecodeString(auth[l+1:])
if err != nil {
- return echo.NewHTTPError(http.StatusBadRequest).SetInternal(err)
+ return err
}
-
cred := string(b)
for i := 0; i < len(cred); i++ {
if cred[i] == ':' {
diff --git a/vendor/github.com/labstack/echo/v4/middleware/body_dump.go b/vendor/github.com/labstack/echo/v4/middleware/body_dump.go
index e4119ec..ebd0d0a 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/body_dump.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/body_dump.go
@@ -1,41 +1,42 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
"bufio"
"bytes"
- "errors"
"io"
+ "io/ioutil"
"net"
"net/http"
"github.com/labstack/echo/v4"
)
-// BodyDumpConfig defines the config for BodyDump middleware.
-type BodyDumpConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // BodyDumpConfig defines the config for BodyDump middleware.
+ BodyDumpConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // Handler receives request and response payload.
- // Required.
- Handler BodyDumpHandler
-}
+ // Handler receives request and response payload.
+ // Required.
+ Handler BodyDumpHandler
+ }
-// BodyDumpHandler receives the request and response payload.
-type BodyDumpHandler func(echo.Context, []byte, []byte)
+ // BodyDumpHandler receives the request and response payload.
+ BodyDumpHandler func(echo.Context, []byte, []byte)
-type bodyDumpResponseWriter struct {
- io.Writer
- http.ResponseWriter
-}
+ bodyDumpResponseWriter struct {
+ io.Writer
+ http.ResponseWriter
+ }
+)
-// DefaultBodyDumpConfig is the default BodyDump middleware config.
-var DefaultBodyDumpConfig = BodyDumpConfig{
- Skipper: DefaultSkipper,
-}
+var (
+ // DefaultBodyDumpConfig is the default BodyDump middleware config.
+ DefaultBodyDumpConfig = BodyDumpConfig{
+ Skipper: DefaultSkipper,
+ }
+)
// BodyDump returns a BodyDump middleware.
//
@@ -67,9 +68,9 @@ func BodyDumpWithConfig(config BodyDumpConfig) echo.MiddlewareFunc {
// Request
reqBody := []byte{}
if c.Request().Body != nil { // Read
- reqBody, _ = io.ReadAll(c.Request().Body)
+ reqBody, _ = ioutil.ReadAll(c.Request().Body)
}
- c.Request().Body = io.NopCloser(bytes.NewBuffer(reqBody)) // Reset
+ c.Request().Body = ioutil.NopCloser(bytes.NewBuffer(reqBody)) // Reset
// Response
resBody := new(bytes.Buffer)
@@ -98,16 +99,9 @@ func (w *bodyDumpResponseWriter) Write(b []byte) (int, error) {
}
func (w *bodyDumpResponseWriter) Flush() {
- err := http.NewResponseController(w.ResponseWriter).Flush()
- if err != nil && errors.Is(err, http.ErrNotSupported) {
- panic(errors.New("response writer flushing is not supported"))
- }
+ w.ResponseWriter.(http.Flusher).Flush()
}
func (w *bodyDumpResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
- return http.NewResponseController(w.ResponseWriter).Hijack()
-}
-
-func (w *bodyDumpResponseWriter) Unwrap() http.ResponseWriter {
- return w.ResponseWriter
+ return w.ResponseWriter.(http.Hijacker).Hijack()
}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/body_limit.go b/vendor/github.com/labstack/echo/v4/middleware/body_limit.go
index 7d3c665..b436bd5 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/body_limit.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/body_limit.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
@@ -12,27 +9,32 @@ import (
"github.com/labstack/gommon/bytes"
)
-// BodyLimitConfig defines the config for BodyLimit middleware.
-type BodyLimitConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // BodyLimitConfig defines the config for BodyLimit middleware.
+ BodyLimitConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // Maximum allowed size for a request body, it can be specified
- // as `4x` or `4xB`, where x is one of the multiple from K, M, G, T or P.
- Limit string `yaml:"limit"`
- limit int64
-}
+ // Maximum allowed size for a request body, it can be specified
+ // as `4x` or `4xB`, where x is one of the multiple from K, M, G, T or P.
+ Limit string `yaml:"limit"`
+ limit int64
+ }
-type limitedReader struct {
- BodyLimitConfig
- reader io.ReadCloser
- read int64
-}
+ limitedReader struct {
+ BodyLimitConfig
+ reader io.ReadCloser
+ read int64
+ context echo.Context
+ }
+)
-// DefaultBodyLimitConfig is the default BodyLimit middleware config.
-var DefaultBodyLimitConfig = BodyLimitConfig{
- Skipper: DefaultSkipper,
-}
+var (
+ // DefaultBodyLimitConfig is the default BodyLimit middleware config.
+ DefaultBodyLimitConfig = BodyLimitConfig{
+ Skipper: DefaultSkipper,
+ }
+)
// BodyLimit returns a BodyLimit middleware.
//
@@ -78,7 +80,7 @@ func BodyLimitWithConfig(config BodyLimitConfig) echo.MiddlewareFunc {
// Based on content read
r := pool.Get().(*limitedReader)
- r.Reset(req.Body)
+ r.Reset(req.Body, c)
defer pool.Put(r)
req.Body = r
@@ -100,8 +102,9 @@ func (r *limitedReader) Close() error {
return r.reader.Close()
}
-func (r *limitedReader) Reset(reader io.ReadCloser) {
+func (r *limitedReader) Reset(reader io.ReadCloser, context echo.Context) {
r.reader = reader
+ r.context = context
r.read = 0
}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/compress.go b/vendor/github.com/labstack/echo/v4/middleware/compress.go
index 012b76b..6ae1974 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/compress.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/compress.go
@@ -1,13 +1,10 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
"bufio"
- "bytes"
"compress/gzip"
"io"
+ "io/ioutil"
"net"
"net/http"
"strings"
@@ -16,50 +13,34 @@ import (
"github.com/labstack/echo/v4"
)
-// GzipConfig defines the config for Gzip middleware.
-type GzipConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // GzipConfig defines the config for Gzip middleware.
+ GzipConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // Gzip compression level.
- // Optional. Default value -1.
- Level int `yaml:"level"`
+ // Gzip compression level.
+ // Optional. Default value -1.
+ Level int `yaml:"level"`
+ }
- // Length threshold before gzip compression is applied.
- // Optional. Default value 0.
- //
- // Most of the time you will not need to change the default. Compressing
- // a short response might increase the transmitted data because of the
- // gzip format overhead. Compressing the response will also consume CPU
- // and time on the server and the client (for decompressing). Depending on
- // your use case such a threshold might be useful.
- //
- // See also:
- // https://webmasters.stackexchange.com/questions/31750/what-is-recommended-minimum-object-size-for-gzip-performance-benefits
- MinLength int
-}
-
-type gzipResponseWriter struct {
- io.Writer
- http.ResponseWriter
- wroteHeader bool
- wroteBody bool
- minLength int
- minLengthExceeded bool
- buffer *bytes.Buffer
- code int
-}
+ gzipResponseWriter struct {
+ io.Writer
+ http.ResponseWriter
+ }
+)
const (
gzipScheme = "gzip"
)
-// DefaultGzipConfig is the default Gzip middleware config.
-var DefaultGzipConfig = GzipConfig{
- Skipper: DefaultSkipper,
- Level: -1,
- MinLength: 0,
-}
+var (
+ // DefaultGzipConfig is the default Gzip middleware config.
+ DefaultGzipConfig = GzipConfig{
+ Skipper: DefaultSkipper,
+ Level: -1,
+ }
+)
// Gzip returns a middleware which compresses HTTP response using gzip compression
// scheme.
@@ -77,12 +58,8 @@ func GzipWithConfig(config GzipConfig) echo.MiddlewareFunc {
if config.Level == 0 {
config.Level = DefaultGzipConfig.Level
}
- if config.MinLength < 0 {
- config.MinLength = DefaultGzipConfig.MinLength
- }
pool := gzipCompressPool(config)
- bpool := bufferPool()
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
@@ -93,6 +70,7 @@ func GzipWithConfig(config GzipConfig) echo.MiddlewareFunc {
res := c.Response()
res.Header().Add(echo.HeaderVary, echo.HeaderAcceptEncoding)
if strings.Contains(c.Request().Header.Get(echo.HeaderAcceptEncoding), gzipScheme) {
+ res.Header().Set(echo.HeaderContentEncoding, gzipScheme) // Issue #806
i := pool.Get()
w, ok := i.(*gzip.Writer)
if !ok {
@@ -100,40 +78,21 @@ func GzipWithConfig(config GzipConfig) echo.MiddlewareFunc {
}
rw := res.Writer
w.Reset(rw)
-
- buf := bpool.Get().(*bytes.Buffer)
- buf.Reset()
-
- grw := &gzipResponseWriter{Writer: w, ResponseWriter: rw, minLength: config.MinLength, buffer: buf}
defer func() {
- // There are different reasons for cases when we have not yet written response to the client and now need to do so.
- // a) handler response had only response code and no response body (ala 404 or redirects etc). Response code need to be written now.
- // b) body is shorter than our minimum length threshold and being buffered currently and needs to be written
- if !grw.wroteBody {
+ if res.Size == 0 {
if res.Header().Get(echo.HeaderContentEncoding) == gzipScheme {
res.Header().Del(echo.HeaderContentEncoding)
}
- if grw.wroteHeader {
- rw.WriteHeader(grw.code)
- }
// We have to reset response to it's pristine state when
// nothing is written to body or error is returned.
// See issue #424, #407.
res.Writer = rw
- w.Reset(io.Discard)
- } else if !grw.minLengthExceeded {
- // Write uncompressed response
- res.Writer = rw
- if grw.wroteHeader {
- grw.ResponseWriter.WriteHeader(grw.code)
- }
- grw.buffer.WriteTo(rw)
- w.Reset(io.Discard)
+ w.Reset(ioutil.Discard)
}
w.Close()
- bpool.Put(buf)
pool.Put(w)
}()
+ grw := &gzipResponseWriter{Writer: w, ResponseWriter: rw}
res.Writer = grw
}
return next(c)
@@ -142,63 +101,29 @@ func GzipWithConfig(config GzipConfig) echo.MiddlewareFunc {
}
func (w *gzipResponseWriter) WriteHeader(code int) {
+ if code == http.StatusNoContent { // Issue #489
+ w.ResponseWriter.Header().Del(echo.HeaderContentEncoding)
+ }
w.Header().Del(echo.HeaderContentLength) // Issue #444
-
- w.wroteHeader = true
-
- // Delay writing of the header until we know if we'll actually compress the response
- w.code = code
+ w.ResponseWriter.WriteHeader(code)
}
func (w *gzipResponseWriter) Write(b []byte) (int, error) {
if w.Header().Get(echo.HeaderContentType) == "" {
w.Header().Set(echo.HeaderContentType, http.DetectContentType(b))
}
- w.wroteBody = true
-
- if !w.minLengthExceeded {
- n, err := w.buffer.Write(b)
-
- if w.buffer.Len() >= w.minLength {
- w.minLengthExceeded = true
-
- // The minimum length is exceeded, add Content-Encoding header and write the header
- w.Header().Set(echo.HeaderContentEncoding, gzipScheme) // Issue #806
- if w.wroteHeader {
- w.ResponseWriter.WriteHeader(w.code)
- }
-
- return w.Writer.Write(w.buffer.Bytes())
- }
-
- return n, err
- }
-
return w.Writer.Write(b)
}
func (w *gzipResponseWriter) Flush() {
- if !w.minLengthExceeded {
- // Enforce compression because we will not know how much more data will come
- w.minLengthExceeded = true
- w.Header().Set(echo.HeaderContentEncoding, gzipScheme) // Issue #806
- if w.wroteHeader {
- w.ResponseWriter.WriteHeader(w.code)
- }
-
- w.Writer.Write(w.buffer.Bytes())
- }
-
w.Writer.(*gzip.Writer).Flush()
- _ = http.NewResponseController(w.ResponseWriter).Flush()
-}
-
-func (w *gzipResponseWriter) Unwrap() http.ResponseWriter {
- return w.ResponseWriter
+ if flusher, ok := w.ResponseWriter.(http.Flusher); ok {
+ flusher.Flush()
+ }
}
func (w *gzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
- return http.NewResponseController(w.ResponseWriter).Hijack()
+ return w.ResponseWriter.(http.Hijacker).Hijack()
}
func (w *gzipResponseWriter) Push(target string, opts *http.PushOptions) error {
@@ -211,7 +136,7 @@ func (w *gzipResponseWriter) Push(target string, opts *http.PushOptions) error {
func gzipCompressPool(config GzipConfig) sync.Pool {
return sync.Pool{
New: func() interface{} {
- w, err := gzip.NewWriterLevel(io.Discard, config.Level)
+ w, err := gzip.NewWriterLevel(ioutil.Discard, config.Level)
if err != nil {
return err
}
@@ -219,12 +144,3 @@ func gzipCompressPool(config GzipConfig) sync.Pool {
},
}
}
-
-func bufferPool() sync.Pool {
- return sync.Pool{
- New: func() interface{} {
- b := &bytes.Buffer{}
- return b
- },
- }
-}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/context_timeout.go b/vendor/github.com/labstack/echo/v4/middleware/context_timeout.go
deleted file mode 100644
index e67173f..0000000
--- a/vendor/github.com/labstack/echo/v4/middleware/context_timeout.go
+++ /dev/null
@@ -1,75 +0,0 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
-package middleware
-
-import (
- "context"
- "errors"
- "time"
-
- "github.com/labstack/echo/v4"
-)
-
-// ContextTimeoutConfig defines the config for ContextTimeout middleware.
-type ContextTimeoutConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
-
- // ErrorHandler is a function when error aries in middleware execution.
- ErrorHandler func(err error, c echo.Context) error
-
- // Timeout configures a timeout for the middleware, defaults to 0 for no timeout
- Timeout time.Duration
-}
-
-// ContextTimeout returns a middleware which returns error (503 Service Unavailable error) to client
-// when underlying method returns context.DeadlineExceeded error.
-func ContextTimeout(timeout time.Duration) echo.MiddlewareFunc {
- return ContextTimeoutWithConfig(ContextTimeoutConfig{Timeout: timeout})
-}
-
-// ContextTimeoutWithConfig returns a Timeout middleware with config.
-func ContextTimeoutWithConfig(config ContextTimeoutConfig) echo.MiddlewareFunc {
- mw, err := config.ToMiddleware()
- if err != nil {
- panic(err)
- }
- return mw
-}
-
-// ToMiddleware converts Config to middleware.
-func (config ContextTimeoutConfig) ToMiddleware() (echo.MiddlewareFunc, error) {
- if config.Timeout == 0 {
- return nil, errors.New("timeout must be set")
- }
- if config.Skipper == nil {
- config.Skipper = DefaultSkipper
- }
- if config.ErrorHandler == nil {
- config.ErrorHandler = func(err error, c echo.Context) error {
- if err != nil && errors.Is(err, context.DeadlineExceeded) {
- return echo.ErrServiceUnavailable.WithInternal(err)
- }
- return err
- }
- }
-
- return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
- if config.Skipper(c) {
- return next(c)
- }
-
- timeoutContext, cancel := context.WithTimeout(c.Request().Context(), config.Timeout)
- defer cancel()
-
- c.SetRequest(c.Request().WithContext(timeoutContext))
-
- if err := next(c); err != nil {
- return config.ErrorHandler(err, c)
- }
- return nil
- }
- }, nil
-}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/cors.go b/vendor/github.com/labstack/echo/v4/middleware/cors.go
index a1f4453..d6ef896 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/cors.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/cors.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
@@ -12,127 +9,69 @@ import (
"github.com/labstack/echo/v4"
)
-// CORSConfig defines the config for CORS middleware.
-type CORSConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // CORSConfig defines the config for CORS middleware.
+ CORSConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // AllowOrigins determines the value of the Access-Control-Allow-Origin
- // response header. This header defines a list of origins that may access the
- // resource. The wildcard characters '*' and '?' are supported and are
- // converted to regex fragments '.*' and '.' accordingly.
- //
- // Security: use extreme caution when handling the origin, and carefully
- // validate any logic. Remember that attackers may register hostile domain names.
- // See https://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html
- //
- // Optional. Default value []string{"*"}.
- //
- // See also: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
- AllowOrigins []string `yaml:"allow_origins"`
+ // AllowOrigin defines a list of origins that may access the resource.
+ // Optional. Default value []string{"*"}.
+ AllowOrigins []string `yaml:"allow_origins"`
- // AllowOriginFunc is a custom function to validate the origin. It takes the
- // origin as an argument and returns true if allowed or false otherwise. If
- // an error is returned, it is returned by the handler. If this option is
- // set, AllowOrigins is ignored.
- //
- // Security: use extreme caution when handling the origin, and carefully
- // validate any logic. Remember that attackers may register hostile domain names.
- // See https://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html
- //
- // Optional.
- AllowOriginFunc func(origin string) (bool, error) `yaml:"-"`
+ // AllowOriginFunc is a custom function to validate the origin. It takes the
+ // origin as an argument and returns true if allowed or false otherwise. If
+ // an error is returned, it is returned by the handler. If this option is
+ // set, AllowOrigins is ignored.
+ // Optional.
+ AllowOriginFunc func(origin string) (bool, error) `yaml:"allow_origin_func"`
- // AllowMethods determines the value of the Access-Control-Allow-Methods
- // response header. This header specified the list of methods allowed when
- // accessing the resource. This is used in response to a preflight request.
- //
- // Optional. Default value DefaultCORSConfig.AllowMethods.
- // If `allowMethods` is left empty, this middleware will fill for preflight
- // request `Access-Control-Allow-Methods` header value
- // from `Allow` header that echo.Router set into context.
- //
- // See also: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
- AllowMethods []string `yaml:"allow_methods"`
+ // AllowMethods defines a list methods allowed when accessing the resource.
+ // This is used in response to a preflight request.
+ // Optional. Default value DefaultCORSConfig.AllowMethods.
+ AllowMethods []string `yaml:"allow_methods"`
- // AllowHeaders determines the value of the Access-Control-Allow-Headers
- // response header. This header is used in response to a preflight request to
- // indicate which HTTP headers can be used when making the actual request.
- //
- // Optional. Default value []string{}.
- //
- // See also: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
- AllowHeaders []string `yaml:"allow_headers"`
+ // AllowHeaders defines a list of request headers that can be used when
+ // making the actual request. This is in response to a preflight request.
+ // Optional. Default value []string{}.
+ AllowHeaders []string `yaml:"allow_headers"`
- // AllowCredentials determines the value of the
- // Access-Control-Allow-Credentials response header. This header indicates
- // whether or not the response to the request can be exposed when the
- // credentials mode (Request.credentials) is true. When used as part of a
- // response to a preflight request, this indicates whether or not the actual
- // request can be made using credentials. See also
- // [MDN: Access-Control-Allow-Credentials].
- //
- // Optional. Default value false, in which case the header is not set.
- //
- // Security: avoid using `AllowCredentials = true` with `AllowOrigins = *`.
- // See "Exploiting CORS misconfigurations for Bitcoins and bounties",
- // https://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html
- //
- // See also: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
- AllowCredentials bool `yaml:"allow_credentials"`
+ // AllowCredentials indicates whether or not the response to the request
+ // can be exposed when the credentials flag is true. When used as part of
+ // a response to a preflight request, this indicates whether or not the
+ // actual request can be made using credentials.
+ // Optional. Default value false.
+ AllowCredentials bool `yaml:"allow_credentials"`
- // UnsafeWildcardOriginWithAllowCredentials UNSAFE/INSECURE: allows wildcard '*' origin to be used with AllowCredentials
- // flag. In that case we consider any origin allowed and send it back to the client with `Access-Control-Allow-Origin` header.
- //
- // This is INSECURE and potentially leads to [cross-origin](https://portswigger.net/research/exploiting-cors-misconfigurations-for-bitcoins-and-bounties)
- // attacks. See: https://github.com/labstack/echo/issues/2400 for discussion on the subject.
- //
- // Optional. Default value is false.
- UnsafeWildcardOriginWithAllowCredentials bool `yaml:"unsafe_wildcard_origin_with_allow_credentials"`
+ // ExposeHeaders defines a whitelist headers that clients are allowed to
+ // access.
+ // Optional. Default value []string{}.
+ ExposeHeaders []string `yaml:"expose_headers"`
- // ExposeHeaders determines the value of Access-Control-Expose-Headers, which
- // defines a list of headers that clients are allowed to access.
- //
- // Optional. Default value []string{}, in which case the header is not set.
- //
- // See also: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Header
- ExposeHeaders []string `yaml:"expose_headers"`
+ // MaxAge indicates how long (in seconds) the results of a preflight request
+ // can be cached.
+ // Optional. Default value 0.
+ MaxAge int `yaml:"max_age"`
+ }
+)
- // MaxAge determines the value of the Access-Control-Max-Age response header.
- // This header indicates how long (in seconds) the results of a preflight
- // request can be cached.
- // The header is set only if MaxAge != 0, negative value sends "0" which instructs browsers not to cache that response.
- //
- // Optional. Default value 0 - meaning header is not sent.
- //
- // See also: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
- MaxAge int `yaml:"max_age"`
-}
-
-// DefaultCORSConfig is the default CORS middleware config.
-var DefaultCORSConfig = CORSConfig{
- Skipper: DefaultSkipper,
- AllowOrigins: []string{"*"},
- AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
-}
+var (
+ // DefaultCORSConfig is the default CORS middleware config.
+ DefaultCORSConfig = CORSConfig{
+ Skipper: DefaultSkipper,
+ AllowOrigins: []string{"*"},
+ AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
+ }
+)
// CORS returns a Cross-Origin Resource Sharing (CORS) middleware.
-// See also [MDN: Cross-Origin Resource Sharing (CORS)].
-//
-// Security: Poorly configured CORS can compromise security because it allows
-// relaxation of the browser's Same-Origin policy. See [Exploiting CORS
-// misconfigurations for Bitcoins and bounties] and [Portswigger: Cross-origin
-// resource sharing (CORS)] for more details.
-//
-// [MDN: Cross-Origin Resource Sharing (CORS)]: https://developer.mozilla.org/en/docs/Web/HTTP/Access_control_CORS
-// [Exploiting CORS misconfigurations for Bitcoins and bounties]: https://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html
-// [Portswigger: Cross-origin resource sharing (CORS)]: https://portswigger.net/web-security/cors
+// See: https://developer.mozilla.org/en/docs/Web/HTTP/Access_control_CORS
func CORS() echo.MiddlewareFunc {
return CORSWithConfig(DefaultCORSConfig)
}
// CORSWithConfig returns a CORS middleware with config.
-// See: [CORS].
+// See: `CORS()`.
func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
// Defaults
if config.Skipper == nil {
@@ -141,41 +80,23 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
if len(config.AllowOrigins) == 0 {
config.AllowOrigins = DefaultCORSConfig.AllowOrigins
}
- hasCustomAllowMethods := true
if len(config.AllowMethods) == 0 {
- hasCustomAllowMethods = false
config.AllowMethods = DefaultCORSConfig.AllowMethods
}
- allowOriginPatterns := make([]*regexp.Regexp, 0, len(config.AllowOrigins))
+ allowOriginPatterns := []string{}
for _, origin := range config.AllowOrigins {
- if origin == "*" {
- continue // "*" is handled differently and does not need regexp
- }
pattern := regexp.QuoteMeta(origin)
- pattern = strings.ReplaceAll(pattern, "\\*", ".*")
- pattern = strings.ReplaceAll(pattern, "\\?", ".")
+ pattern = strings.Replace(pattern, "\\*", ".*", -1)
+ pattern = strings.Replace(pattern, "\\?", ".", -1)
pattern = "^" + pattern + "$"
-
- re, err := regexp.Compile(pattern)
- if err != nil {
- // this is to preserve previous behaviour - invalid patterns were just ignored.
- // If we would turn this to panic, users with invalid patterns
- // would have applications crashing in production due unrecovered panic.
- // TODO: this should be turned to error/panic in `v5`
- continue
- }
- allowOriginPatterns = append(allowOriginPatterns, re)
+ allowOriginPatterns = append(allowOriginPatterns, pattern)
}
allowMethods := strings.Join(config.AllowMethods, ",")
allowHeaders := strings.Join(config.AllowHeaders, ",")
exposeHeaders := strings.Join(config.ExposeHeaders, ",")
-
- maxAge := "0"
- if config.MaxAge > 0 {
- maxAge = strconv.Itoa(config.MaxAge)
- }
+ maxAge := strconv.Itoa(config.MaxAge)
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
@@ -188,28 +109,10 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
origin := req.Header.Get(echo.HeaderOrigin)
allowOrigin := ""
+ preflight := req.Method == http.MethodOptions
res.Header().Add(echo.HeaderVary, echo.HeaderOrigin)
- // Preflight request is an OPTIONS request, using three HTTP request headers: Access-Control-Request-Method,
- // Access-Control-Request-Headers, and the Origin header. See: https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
- // For simplicity we just consider method type and later `Origin` header.
- preflight := req.Method == http.MethodOptions
-
- // Although router adds special handler in case of OPTIONS method we avoid calling next for OPTIONS in this middleware
- // as CORS requests do not have cookies / authentication headers by default, so we could get stuck in auth
- // middlewares by calling next(c).
- // But we still want to send `Allow` header as response in case of Non-CORS OPTIONS request as router default
- // handler does.
- routerAllowMethods := ""
- if preflight {
- tmpAllowMethods, ok := c.Get(echo.ContextKeyHeaderAllow).(string)
- if ok && tmpAllowMethods != "" {
- routerAllowMethods = tmpAllowMethods
- c.Response().Header().Set(echo.HeaderAllow, routerAllowMethods)
- }
- }
-
- // No Origin provided. This is (probably) not request from actual browser - proceed executing middleware chain
+ // No Origin provided
if origin == "" {
if !preflight {
return next(c)
@@ -228,7 +131,7 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
} else {
// Check allowed origins
for _, o := range config.AllowOrigins {
- if o == "*" && config.AllowCredentials && config.UnsafeWildcardOriginWithAllowCredentials {
+ if o == "*" && config.AllowCredentials {
allowOrigin = origin
break
}
@@ -242,16 +145,20 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
}
}
- checkPatterns := false
- if allowOrigin == "" {
- // to avoid regex cost by invalid (long) domains (253 is domain name max limit)
- if len(origin) <= (253+3+5) && strings.Contains(origin, "://") {
- checkPatterns = true
- }
- }
- if checkPatterns {
- for _, re := range allowOriginPatterns {
- if match := re.MatchString(origin); match {
+ // Check allowed origin patterns
+ for _, re := range allowOriginPatterns {
+ if allowOrigin == "" {
+ didx := strings.Index(origin, "://")
+ if didx == -1 {
+ continue
+ }
+ domAuth := origin[didx+3:]
+ // to avoid regex cost by invalid long domain
+ if len(domAuth) > 253 {
+ break
+ }
+
+ if match, _ := regexp.MatchString(re, origin); match {
allowOrigin = origin
break
}
@@ -267,13 +174,12 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
return c.NoContent(http.StatusNoContent)
}
- res.Header().Set(echo.HeaderAccessControlAllowOrigin, allowOrigin)
- if config.AllowCredentials {
- res.Header().Set(echo.HeaderAccessControlAllowCredentials, "true")
- }
-
// Simple request
if !preflight {
+ res.Header().Set(echo.HeaderAccessControlAllowOrigin, allowOrigin)
+ if config.AllowCredentials {
+ res.Header().Set(echo.HeaderAccessControlAllowCredentials, "true")
+ }
if exposeHeaders != "" {
res.Header().Set(echo.HeaderAccessControlExposeHeaders, exposeHeaders)
}
@@ -283,13 +189,11 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
// Preflight request
res.Header().Add(echo.HeaderVary, echo.HeaderAccessControlRequestMethod)
res.Header().Add(echo.HeaderVary, echo.HeaderAccessControlRequestHeaders)
-
- if !hasCustomAllowMethods && routerAllowMethods != "" {
- res.Header().Set(echo.HeaderAccessControlAllowMethods, routerAllowMethods)
- } else {
- res.Header().Set(echo.HeaderAccessControlAllowMethods, allowMethods)
+ res.Header().Set(echo.HeaderAccessControlAllowOrigin, allowOrigin)
+ res.Header().Set(echo.HeaderAccessControlAllowMethods, allowMethods)
+ if config.AllowCredentials {
+ res.Header().Set(echo.HeaderAccessControlAllowCredentials, "true")
}
-
if allowHeaders != "" {
res.Header().Set(echo.HeaderAccessControlAllowHeaders, allowHeaders)
} else {
@@ -298,7 +202,7 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
res.Header().Set(echo.HeaderAccessControlAllowHeaders, h)
}
}
- if config.MaxAge != 0 {
+ if config.MaxAge > 0 {
res.Header().Set(echo.HeaderAccessControlMaxAge, maxAge)
}
return c.NoContent(http.StatusNoContent)
diff --git a/vendor/github.com/labstack/echo/v4/middleware/csrf.go b/vendor/github.com/labstack/echo/v4/middleware/csrf.go
index 92f4019..7804997 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/csrf.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/csrf.go
@@ -1,88 +1,85 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
"crypto/subtle"
+ "errors"
"net/http"
+ "strings"
"time"
"github.com/labstack/echo/v4"
+ "github.com/labstack/gommon/random"
)
-// CSRFConfig defines the config for CSRF middleware.
-type CSRFConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // CSRFConfig defines the config for CSRF middleware.
+ CSRFConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // TokenLength is the length of the generated token.
- TokenLength uint8 `yaml:"token_length"`
- // Optional. Default value 32.
+ // TokenLength is the length of the generated token.
+ TokenLength uint8 `yaml:"token_length"`
+ // Optional. Default value 32.
- // TokenLookup is a string in the form of ":" or ":,:" that is used
- // to extract token from the request.
- // Optional. Default value "header:X-CSRF-Token".
- // Possible values:
- // - "header:" or "header::"
- // - "query:"
- // - "form:"
- // Multiple sources example:
- // - "header:X-CSRF-Token,query:csrf"
- TokenLookup string `yaml:"token_lookup"`
+ // TokenLookup is a string in the form of ":" that is used
+ // to extract token from the request.
+ // Optional. Default value "header:X-CSRF-Token".
+ // Possible values:
+ // - "header:"
+ // - "form:"
+ // - "query:"
+ TokenLookup string `yaml:"token_lookup"`
- // Context key to store generated CSRF token into context.
- // Optional. Default value "csrf".
- ContextKey string `yaml:"context_key"`
+ // Context key to store generated CSRF token into context.
+ // Optional. Default value "csrf".
+ ContextKey string `yaml:"context_key"`
- // Name of the CSRF cookie. This cookie will store CSRF token.
- // Optional. Default value "csrf".
- CookieName string `yaml:"cookie_name"`
+ // Name of the CSRF cookie. This cookie will store CSRF token.
+ // Optional. Default value "csrf".
+ CookieName string `yaml:"cookie_name"`
- // Domain of the CSRF cookie.
- // Optional. Default value none.
- CookieDomain string `yaml:"cookie_domain"`
+ // Domain of the CSRF cookie.
+ // Optional. Default value none.
+ CookieDomain string `yaml:"cookie_domain"`
- // Path of the CSRF cookie.
- // Optional. Default value none.
- CookiePath string `yaml:"cookie_path"`
+ // Path of the CSRF cookie.
+ // Optional. Default value none.
+ CookiePath string `yaml:"cookie_path"`
- // Max age (in seconds) of the CSRF cookie.
- // Optional. Default value 86400 (24hr).
- CookieMaxAge int `yaml:"cookie_max_age"`
+ // Max age (in seconds) of the CSRF cookie.
+ // Optional. Default value 86400 (24hr).
+ CookieMaxAge int `yaml:"cookie_max_age"`
- // Indicates if CSRF cookie is secure.
- // Optional. Default value false.
- CookieSecure bool `yaml:"cookie_secure"`
+ // Indicates if CSRF cookie is secure.
+ // Optional. Default value false.
+ CookieSecure bool `yaml:"cookie_secure"`
- // Indicates if CSRF cookie is HTTP only.
- // Optional. Default value false.
- CookieHTTPOnly bool `yaml:"cookie_http_only"`
+ // Indicates if CSRF cookie is HTTP only.
+ // Optional. Default value false.
+ CookieHTTPOnly bool `yaml:"cookie_http_only"`
- // Indicates SameSite mode of the CSRF cookie.
- // Optional. Default value SameSiteDefaultMode.
- CookieSameSite http.SameSite `yaml:"cookie_same_site"`
+ // Indicates SameSite mode of the CSRF cookie.
+ // Optional. Default value SameSiteDefaultMode.
+ CookieSameSite http.SameSite `yaml:"cookie_same_site"`
+ }
- // ErrorHandler defines a function which is executed for returning custom errors.
- ErrorHandler CSRFErrorHandler
-}
+ // csrfTokenExtractor defines a function that takes `echo.Context` and returns
+ // either a token or an error.
+ csrfTokenExtractor func(echo.Context) (string, error)
+)
-// CSRFErrorHandler is a function which is executed for creating custom errors.
-type CSRFErrorHandler func(err error, c echo.Context) error
-
-// ErrCSRFInvalid is returned when CSRF check fails
-var ErrCSRFInvalid = echo.NewHTTPError(http.StatusForbidden, "invalid csrf token")
-
-// DefaultCSRFConfig is the default CSRF middleware config.
-var DefaultCSRFConfig = CSRFConfig{
- Skipper: DefaultSkipper,
- TokenLength: 32,
- TokenLookup: "header:" + echo.HeaderXCSRFToken,
- ContextKey: "csrf",
- CookieName: "_csrf",
- CookieMaxAge: 86400,
- CookieSameSite: http.SameSiteDefaultMode,
-}
+var (
+ // DefaultCSRFConfig is the default CSRF middleware config.
+ DefaultCSRFConfig = CSRFConfig{
+ Skipper: DefaultSkipper,
+ TokenLength: 32,
+ TokenLookup: "header:" + echo.HeaderXCSRFToken,
+ ContextKey: "csrf",
+ CookieName: "_csrf",
+ CookieMaxAge: 86400,
+ CookieSameSite: http.SameSiteDefaultMode,
+ }
+)
// CSRF returns a Cross-Site Request Forgery (CSRF) middleware.
// See: https://en.wikipedia.org/wiki/Cross-site_request_forgery
@@ -101,7 +98,6 @@ func CSRFWithConfig(config CSRFConfig) echo.MiddlewareFunc {
if config.TokenLength == 0 {
config.TokenLength = DefaultCSRFConfig.TokenLength
}
-
if config.TokenLookup == "" {
config.TokenLookup = DefaultCSRFConfig.TokenLookup
}
@@ -118,9 +114,14 @@ func CSRFWithConfig(config CSRFConfig) echo.MiddlewareFunc {
config.CookieSecure = true
}
- extractors, cErr := CreateExtractors(config.TokenLookup)
- if cErr != nil {
- panic(cErr)
+ // Initialize
+ parts := strings.Split(config.TokenLookup, ":")
+ extractor := csrfTokenFromHeader(parts[1])
+ switch parts[0] {
+ case "form":
+ extractor = csrfTokenFromForm(parts[1])
+ case "query":
+ extractor = csrfTokenFromQuery(parts[1])
}
return func(next echo.HandlerFunc) echo.HandlerFunc {
@@ -129,58 +130,28 @@ func CSRFWithConfig(config CSRFConfig) echo.MiddlewareFunc {
return next(c)
}
+ req := c.Request()
+ k, err := c.Cookie(config.CookieName)
token := ""
- if k, err := c.Cookie(config.CookieName); err != nil {
- token = randomString(config.TokenLength)
+
+ // Generate token
+ if err != nil {
+ token = random.String(config.TokenLength)
} else {
- token = k.Value // Reuse token
+ // Reuse token
+ token = k.Value
}
- switch c.Request().Method {
+ switch req.Method {
case http.MethodGet, http.MethodHead, http.MethodOptions, http.MethodTrace:
default:
// Validate token only for requests which are not defined as 'safe' by RFC7231
- var lastExtractorErr error
- var lastTokenErr error
- outer:
- for _, extractor := range extractors {
- clientTokens, err := extractor(c)
- if err != nil {
- lastExtractorErr = err
- continue
- }
-
- for _, clientToken := range clientTokens {
- if validateCSRFToken(token, clientToken) {
- lastTokenErr = nil
- lastExtractorErr = nil
- break outer
- }
- lastTokenErr = ErrCSRFInvalid
- }
+ clientToken, err := extractor(c)
+ if err != nil {
+ return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}
- var finalErr error
- if lastTokenErr != nil {
- finalErr = lastTokenErr
- } else if lastExtractorErr != nil {
- // ugly part to preserve backwards compatible errors. someone could rely on them
- if lastExtractorErr == errQueryExtractorValueMissing {
- lastExtractorErr = echo.NewHTTPError(http.StatusBadRequest, "missing csrf token in the query string")
- } else if lastExtractorErr == errFormExtractorValueMissing {
- lastExtractorErr = echo.NewHTTPError(http.StatusBadRequest, "missing csrf token in the form parameter")
- } else if lastExtractorErr == errHeaderExtractorValueMissing {
- lastExtractorErr = echo.NewHTTPError(http.StatusBadRequest, "missing csrf token in request header")
- } else {
- lastExtractorErr = echo.NewHTTPError(http.StatusBadRequest, lastExtractorErr.Error())
- }
- finalErr = lastExtractorErr
- }
-
- if finalErr != nil {
- if config.ErrorHandler != nil {
- return config.ErrorHandler(finalErr, c)
- }
- return finalErr
+ if !validateCSRFToken(token, clientToken) {
+ return echo.NewHTTPError(http.StatusForbidden, "invalid csrf token")
}
}
@@ -213,6 +184,38 @@ func CSRFWithConfig(config CSRFConfig) echo.MiddlewareFunc {
}
}
+// csrfTokenFromForm returns a `csrfTokenExtractor` that extracts token from the
+// provided request header.
+func csrfTokenFromHeader(header string) csrfTokenExtractor {
+ return func(c echo.Context) (string, error) {
+ return c.Request().Header.Get(header), nil
+ }
+}
+
+// csrfTokenFromForm returns a `csrfTokenExtractor` that extracts token from the
+// provided form parameter.
+func csrfTokenFromForm(param string) csrfTokenExtractor {
+ return func(c echo.Context) (string, error) {
+ token := c.FormValue(param)
+ if token == "" {
+ return "", errors.New("missing csrf token in the form parameter")
+ }
+ return token, nil
+ }
+}
+
+// csrfTokenFromQuery returns a `csrfTokenExtractor` that extracts token from the
+// provided query parameter.
+func csrfTokenFromQuery(param string) csrfTokenExtractor {
+ return func(c echo.Context) (string, error) {
+ token := c.QueryParam(param)
+ if token == "" {
+ return "", errors.New("missing csrf token in the query string")
+ }
+ return token, nil
+ }
+}
+
func validateCSRFToken(token, clientToken string) bool {
return subtle.ConstantTimeCompare([]byte(token), []byte(clientToken)) == 1
}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/decompress.go b/vendor/github.com/labstack/echo/v4/middleware/decompress.go
index 0c56176..c046359 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/decompress.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/decompress.go
@@ -1,27 +1,28 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
+ "bytes"
"compress/gzip"
"io"
+ "io/ioutil"
"net/http"
"sync"
"github.com/labstack/echo/v4"
)
-// DecompressConfig defines the config for Decompress middleware.
-type DecompressConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // DecompressConfig defines the config for Decompress middleware.
+ DecompressConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // GzipDecompressPool defines an interface to provide the sync.Pool used to create/store Gzip readers
- GzipDecompressPool Decompressor
-}
+ // GzipDecompressPool defines an interface to provide the sync.Pool used to create/store Gzip readers
+ GzipDecompressPool Decompressor
+ }
+)
-// GZIPEncoding content-encoding header if set to "gzip", decompress body contents.
+//GZIPEncoding content-encoding header if set to "gzip", decompress body contents.
const GZIPEncoding string = "gzip"
// Decompressor is used to get the sync.Pool used by the middleware to get Gzip readers
@@ -29,26 +30,47 @@ type Decompressor interface {
gzipDecompressPool() sync.Pool
}
-// DefaultDecompressConfig defines the config for decompress middleware
-var DefaultDecompressConfig = DecompressConfig{
- Skipper: DefaultSkipper,
- GzipDecompressPool: &DefaultGzipDecompressPool{},
-}
+var (
+ //DefaultDecompressConfig defines the config for decompress middleware
+ DefaultDecompressConfig = DecompressConfig{
+ Skipper: DefaultSkipper,
+ GzipDecompressPool: &DefaultGzipDecompressPool{},
+ }
+)
// DefaultGzipDecompressPool is the default implementation of Decompressor interface
type DefaultGzipDecompressPool struct {
}
func (d *DefaultGzipDecompressPool) gzipDecompressPool() sync.Pool {
- return sync.Pool{New: func() interface{} { return new(gzip.Reader) }}
+ return sync.Pool{
+ New: func() interface{} {
+ // create with an empty reader (but with GZIP header)
+ w, err := gzip.NewWriterLevel(ioutil.Discard, gzip.BestSpeed)
+ if err != nil {
+ return err
+ }
+
+ b := new(bytes.Buffer)
+ w.Reset(b)
+ w.Flush()
+ w.Close()
+
+ r, err := gzip.NewReader(bytes.NewReader(b.Bytes()))
+ if err != nil {
+ return err
+ }
+ return r
+ },
+ }
}
-// Decompress decompresses request body based if content encoding type is set to "gzip" with default config
+//Decompress decompresses request body based if content encoding type is set to "gzip" with default config
func Decompress() echo.MiddlewareFunc {
return DecompressWithConfig(DefaultDecompressConfig)
}
-// DecompressWithConfig decompresses request body based if content encoding type is set to "gzip" with config
+//DecompressWithConfig decompresses request body based if content encoding type is set to "gzip" with config
func DecompressWithConfig(config DecompressConfig) echo.MiddlewareFunc {
// Defaults
if config.Skipper == nil {
@@ -60,38 +82,38 @@ func DecompressWithConfig(config DecompressConfig) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
pool := config.GzipDecompressPool.gzipDecompressPool()
-
return func(c echo.Context) error {
if config.Skipper(c) {
return next(c)
}
+ switch c.Request().Header.Get(echo.HeaderContentEncoding) {
+ case GZIPEncoding:
+ b := c.Request().Body
- if c.Request().Header.Get(echo.HeaderContentEncoding) != GZIPEncoding {
- return next(c)
- }
-
- i := pool.Get()
- gr, ok := i.(*gzip.Reader)
- if !ok || gr == nil {
- return echo.NewHTTPError(http.StatusInternalServerError, i.(error).Error())
- }
- defer pool.Put(gr)
-
- b := c.Request().Body
- defer b.Close()
-
- if err := gr.Reset(b); err != nil {
- if err == io.EOF { //ignore if body is empty
- return next(c)
+ i := pool.Get()
+ gr, ok := i.(*gzip.Reader)
+ if !ok {
+ return echo.NewHTTPError(http.StatusInternalServerError, i.(error).Error())
}
- return err
+
+ if err := gr.Reset(b); err != nil {
+ pool.Put(gr)
+ if err == io.EOF { //ignore if body is empty
+ return next(c)
+ }
+ return err
+ }
+ var buf bytes.Buffer
+ io.Copy(&buf, gr)
+
+ gr.Close()
+ pool.Put(gr)
+
+ b.Close() // http.Request.Body is closed by the Server, but because we are replacing it, it must be closed here
+
+ r := ioutil.NopCloser(&buf)
+ c.Request().Body = r
}
-
- // only Close gzip reader if it was set to a proper gzip source otherwise it will panic on close.
- defer gr.Close()
-
- c.Request().Body = gr
-
return next(c)
}
}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/extractor.go b/vendor/github.com/labstack/echo/v4/middleware/extractor.go
deleted file mode 100644
index 3f27414..0000000
--- a/vendor/github.com/labstack/echo/v4/middleware/extractor.go
+++ /dev/null
@@ -1,207 +0,0 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
-package middleware
-
-import (
- "errors"
- "fmt"
- "github.com/labstack/echo/v4"
- "net/textproto"
- "strings"
-)
-
-const (
- // extractorLimit is arbitrary number to limit values extractor can return. this limits possible resource exhaustion
- // attack vector
- extractorLimit = 20
-)
-
-var errHeaderExtractorValueMissing = errors.New("missing value in request header")
-var errHeaderExtractorValueInvalid = errors.New("invalid value in request header")
-var errQueryExtractorValueMissing = errors.New("missing value in the query string")
-var errParamExtractorValueMissing = errors.New("missing value in path params")
-var errCookieExtractorValueMissing = errors.New("missing value in cookies")
-var errFormExtractorValueMissing = errors.New("missing value in the form")
-
-// ValuesExtractor defines a function for extracting values (keys/tokens) from the given context.
-type ValuesExtractor func(c echo.Context) ([]string, error)
-
-// CreateExtractors creates ValuesExtractors from given lookups.
-// Lookups is a string in the form of ":" or ":,:" that is used
-// to extract key from the request.
-// Possible values:
-// - "header:" or "header::"
-// `` is argument value to cut/trim prefix of the extracted value. This is useful if header
-// value has static prefix like `Authorization: ` where part that we
-// want to cut is ` ` note the space at the end.
-// In case of basic authentication `Authorization: Basic ` prefix we want to remove is `Basic `.
-// - "query:"
-// - "param:"
-// - "form:"
-// - "cookie:"
-//
-// Multiple sources example:
-// - "header:Authorization,header:X-Api-Key"
-func CreateExtractors(lookups string) ([]ValuesExtractor, error) {
- return createExtractors(lookups, "")
-}
-
-func createExtractors(lookups string, authScheme string) ([]ValuesExtractor, error) {
- if lookups == "" {
- return nil, nil
- }
- sources := strings.Split(lookups, ",")
- var extractors = make([]ValuesExtractor, 0)
- for _, source := range sources {
- parts := strings.Split(source, ":")
- if len(parts) < 2 {
- return nil, fmt.Errorf("extractor source for lookup could not be split into needed parts: %v", source)
- }
-
- switch parts[0] {
- case "query":
- extractors = append(extractors, valuesFromQuery(parts[1]))
- case "param":
- extractors = append(extractors, valuesFromParam(parts[1]))
- case "cookie":
- extractors = append(extractors, valuesFromCookie(parts[1]))
- case "form":
- extractors = append(extractors, valuesFromForm(parts[1]))
- case "header":
- prefix := ""
- if len(parts) > 2 {
- prefix = parts[2]
- } else if authScheme != "" && parts[1] == echo.HeaderAuthorization {
- // backwards compatibility for JWT and KeyAuth:
- // * we only apply this fix to Authorization as header we use and uses prefixes like "Bearer " etc
- // * previously header extractor assumed that auth-scheme/prefix had a space as suffix we need to retain that
- // behaviour for default values and Authorization header.
- prefix = authScheme
- if !strings.HasSuffix(prefix, " ") {
- prefix += " "
- }
- }
- extractors = append(extractors, valuesFromHeader(parts[1], prefix))
- }
- }
- return extractors, nil
-}
-
-// valuesFromHeader returns a functions that extracts values from the request header.
-// valuePrefix is parameter to remove first part (prefix) of the extracted value. This is useful if header value has static
-// prefix like `Authorization: ` where part that we want to remove is ` `
-// note the space at the end. In case of basic authentication `Authorization: Basic ` prefix we want to remove
-// is `Basic `. In case of JWT tokens `Authorization: Bearer ` prefix is `Bearer `.
-// If prefix is left empty the whole value is returned.
-func valuesFromHeader(header string, valuePrefix string) ValuesExtractor {
- prefixLen := len(valuePrefix)
- // standard library parses http.Request header keys in canonical form but we may provide something else so fix this
- header = textproto.CanonicalMIMEHeaderKey(header)
- return func(c echo.Context) ([]string, error) {
- values := c.Request().Header.Values(header)
- if len(values) == 0 {
- return nil, errHeaderExtractorValueMissing
- }
-
- result := make([]string, 0)
- for i, value := range values {
- if prefixLen == 0 {
- result = append(result, value)
- if i >= extractorLimit-1 {
- break
- }
- continue
- }
- if len(value) > prefixLen && strings.EqualFold(value[:prefixLen], valuePrefix) {
- result = append(result, value[prefixLen:])
- if i >= extractorLimit-1 {
- break
- }
- }
- }
-
- if len(result) == 0 {
- if prefixLen > 0 {
- return nil, errHeaderExtractorValueInvalid
- }
- return nil, errHeaderExtractorValueMissing
- }
- return result, nil
- }
-}
-
-// valuesFromQuery returns a function that extracts values from the query string.
-func valuesFromQuery(param string) ValuesExtractor {
- return func(c echo.Context) ([]string, error) {
- result := c.QueryParams()[param]
- if len(result) == 0 {
- return nil, errQueryExtractorValueMissing
- } else if len(result) > extractorLimit-1 {
- result = result[:extractorLimit]
- }
- return result, nil
- }
-}
-
-// valuesFromParam returns a function that extracts values from the url param string.
-func valuesFromParam(param string) ValuesExtractor {
- return func(c echo.Context) ([]string, error) {
- result := make([]string, 0)
- paramVales := c.ParamValues()
- for i, p := range c.ParamNames() {
- if param == p {
- result = append(result, paramVales[i])
- if i >= extractorLimit-1 {
- break
- }
- }
- }
- if len(result) == 0 {
- return nil, errParamExtractorValueMissing
- }
- return result, nil
- }
-}
-
-// valuesFromCookie returns a function that extracts values from the named cookie.
-func valuesFromCookie(name string) ValuesExtractor {
- return func(c echo.Context) ([]string, error) {
- cookies := c.Cookies()
- if len(cookies) == 0 {
- return nil, errCookieExtractorValueMissing
- }
-
- result := make([]string, 0)
- for i, cookie := range cookies {
- if name == cookie.Name {
- result = append(result, cookie.Value)
- if i >= extractorLimit-1 {
- break
- }
- }
- }
- if len(result) == 0 {
- return nil, errCookieExtractorValueMissing
- }
- return result, nil
- }
-}
-
-// valuesFromForm returns a function that extracts values from the form field.
-func valuesFromForm(name string) ValuesExtractor {
- return func(c echo.Context) ([]string, error) {
- if c.Request().Form == nil {
- _ = c.Request().ParseMultipartForm(32 << 20) // same what `c.Request().FormValue(name)` does
- }
- values := c.Request().Form[name]
- if len(values) == 0 {
- return nil, errFormExtractorValueMissing
- }
- if len(values) > extractorLimit-1 {
- values = values[:extractorLimit]
- }
- result := append([]string{}, values...)
- return result, nil
- }
-}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/jwt.go b/vendor/github.com/labstack/echo/v4/middleware/jwt.go
new file mode 100644
index 0000000..c2e7c06
--- /dev/null
+++ b/vendor/github.com/labstack/echo/v4/middleware/jwt.go
@@ -0,0 +1,347 @@
+// +build go1.15
+
+package middleware
+
+import (
+ "errors"
+ "fmt"
+ "net/http"
+ "reflect"
+ "strings"
+
+ "github.com/golang-jwt/jwt"
+ "github.com/labstack/echo/v4"
+)
+
+type (
+ // JWTConfig defines the config for JWT middleware.
+ JWTConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
+
+ // BeforeFunc defines a function which is executed just before the middleware.
+ BeforeFunc BeforeFunc
+
+ // SuccessHandler defines a function which is executed for a valid token.
+ SuccessHandler JWTSuccessHandler
+
+ // ErrorHandler defines a function which is executed for an invalid token.
+ // It may be used to define a custom JWT error.
+ ErrorHandler JWTErrorHandler
+
+ // ErrorHandlerWithContext is almost identical to ErrorHandler, but it's passed the current context.
+ ErrorHandlerWithContext JWTErrorHandlerWithContext
+
+ // Signing key to validate token.
+ // This is one of the three options to provide a token validation key.
+ // The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
+ // Required if neither user-defined KeyFunc nor SigningKeys is provided.
+ SigningKey interface{}
+
+ // Map of signing keys to validate token with kid field usage.
+ // This is one of the three options to provide a token validation key.
+ // The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
+ // Required if neither user-defined KeyFunc nor SigningKey is provided.
+ SigningKeys map[string]interface{}
+
+ // Signing method used to check the token's signing algorithm.
+ // Optional. Default value HS256.
+ SigningMethod string
+
+ // Context key to store user information from the token into context.
+ // Optional. Default value "user".
+ ContextKey string
+
+ // Claims are extendable claims data defining token content. Used by default ParseTokenFunc implementation.
+ // Not used if custom ParseTokenFunc is set.
+ // Optional. Default value jwt.MapClaims
+ Claims jwt.Claims
+
+ // TokenLookup is a string in the form of ":" or ":,:" that is used
+ // to extract token from the request.
+ // Optional. Default value "header:Authorization".
+ // Possible values:
+ // - "header:"
+ // - "query:"
+ // - "param:"
+ // - "cookie:"
+ // - "form:"
+ // Multiply sources example:
+ // - "header: Authorization,cookie: myowncookie"
+
+ TokenLookup string
+
+ // AuthScheme to be used in the Authorization header.
+ // Optional. Default value "Bearer".
+ AuthScheme string
+
+ // KeyFunc defines a user-defined function that supplies the public key for a token validation.
+ // The function shall take care of verifying the signing algorithm and selecting the proper key.
+ // A user-defined KeyFunc can be useful if tokens are issued by an external party.
+ // Used by default ParseTokenFunc implementation.
+ //
+ // When a user-defined KeyFunc is provided, SigningKey, SigningKeys, and SigningMethod are ignored.
+ // This is one of the three options to provide a token validation key.
+ // The order of precedence is a user-defined KeyFunc, SigningKeys and SigningKey.
+ // Required if neither SigningKeys nor SigningKey is provided.
+ // Not used if custom ParseTokenFunc is set.
+ // Default to an internal implementation verifying the signing algorithm and selecting the proper key.
+ KeyFunc jwt.Keyfunc
+
+ // ParseTokenFunc defines a user-defined function that parses token from given auth. Returns an error when token
+ // parsing fails or parsed token is invalid.
+ // Defaults to implementation using `github.com/golang-jwt/jwt` as JWT implementation library
+ ParseTokenFunc func(auth string, c echo.Context) (interface{}, error)
+ }
+
+ // JWTSuccessHandler defines a function which is executed for a valid token.
+ JWTSuccessHandler func(echo.Context)
+
+ // JWTErrorHandler defines a function which is executed for an invalid token.
+ JWTErrorHandler func(error) error
+
+ // JWTErrorHandlerWithContext is almost identical to JWTErrorHandler, but it's passed the current context.
+ JWTErrorHandlerWithContext func(error, echo.Context) error
+
+ jwtExtractor func(echo.Context) (string, error)
+)
+
+// Algorithms
+const (
+ AlgorithmHS256 = "HS256"
+)
+
+// Errors
+var (
+ ErrJWTMissing = echo.NewHTTPError(http.StatusBadRequest, "missing or malformed jwt")
+ ErrJWTInvalid = echo.NewHTTPError(http.StatusUnauthorized, "invalid or expired jwt")
+)
+
+var (
+ // DefaultJWTConfig is the default JWT auth middleware config.
+ DefaultJWTConfig = JWTConfig{
+ Skipper: DefaultSkipper,
+ SigningMethod: AlgorithmHS256,
+ ContextKey: "user",
+ TokenLookup: "header:" + echo.HeaderAuthorization,
+ AuthScheme: "Bearer",
+ Claims: jwt.MapClaims{},
+ KeyFunc: nil,
+ }
+)
+
+// JWT returns a JSON Web Token (JWT) auth middleware.
+//
+// For valid token, it sets the user in context and calls next handler.
+// For invalid token, it returns "401 - Unauthorized" error.
+// For missing token, it returns "400 - Bad Request" error.
+//
+// See: https://jwt.io/introduction
+// See `JWTConfig.TokenLookup`
+func JWT(key interface{}) echo.MiddlewareFunc {
+ c := DefaultJWTConfig
+ c.SigningKey = key
+ return JWTWithConfig(c)
+}
+
+// JWTWithConfig returns a JWT auth middleware with config.
+// See: `JWT()`.
+func JWTWithConfig(config JWTConfig) echo.MiddlewareFunc {
+ // Defaults
+ if config.Skipper == nil {
+ config.Skipper = DefaultJWTConfig.Skipper
+ }
+ if config.SigningKey == nil && len(config.SigningKeys) == 0 && config.KeyFunc == nil && config.ParseTokenFunc == nil {
+ panic("echo: jwt middleware requires signing key")
+ }
+ if config.SigningMethod == "" {
+ config.SigningMethod = DefaultJWTConfig.SigningMethod
+ }
+ if config.ContextKey == "" {
+ config.ContextKey = DefaultJWTConfig.ContextKey
+ }
+ if config.Claims == nil {
+ config.Claims = DefaultJWTConfig.Claims
+ }
+ if config.TokenLookup == "" {
+ config.TokenLookup = DefaultJWTConfig.TokenLookup
+ }
+ if config.AuthScheme == "" {
+ config.AuthScheme = DefaultJWTConfig.AuthScheme
+ }
+ if config.KeyFunc == nil {
+ config.KeyFunc = config.defaultKeyFunc
+ }
+ if config.ParseTokenFunc == nil {
+ config.ParseTokenFunc = config.defaultParseToken
+ }
+
+ // Initialize
+ // Split sources
+ sources := strings.Split(config.TokenLookup, ",")
+ var extractors []jwtExtractor
+ for _, source := range sources {
+ parts := strings.Split(source, ":")
+
+ switch parts[0] {
+ case "query":
+ extractors = append(extractors, jwtFromQuery(parts[1]))
+ case "param":
+ extractors = append(extractors, jwtFromParam(parts[1]))
+ case "cookie":
+ extractors = append(extractors, jwtFromCookie(parts[1]))
+ case "form":
+ extractors = append(extractors, jwtFromForm(parts[1]))
+ case "header":
+ extractors = append(extractors, jwtFromHeader(parts[1], config.AuthScheme))
+ }
+ }
+
+ return func(next echo.HandlerFunc) echo.HandlerFunc {
+ return func(c echo.Context) error {
+ if config.Skipper(c) {
+ return next(c)
+ }
+
+ if config.BeforeFunc != nil {
+ config.BeforeFunc(c)
+ }
+ var auth string
+ var err error
+ for _, extractor := range extractors {
+ // Extract token from extractor, if it's not fail break the loop and
+ // set auth
+ auth, err = extractor(c)
+ if err == nil {
+ break
+ }
+ }
+ // If none of extractor has a token, handle error
+ if err != nil {
+ if config.ErrorHandler != nil {
+ return config.ErrorHandler(err)
+ }
+
+ if config.ErrorHandlerWithContext != nil {
+ return config.ErrorHandlerWithContext(err, c)
+ }
+ return err
+ }
+
+ token, err := config.ParseTokenFunc(auth, c)
+ if err == nil {
+ // Store user information from token into context.
+ c.Set(config.ContextKey, token)
+ if config.SuccessHandler != nil {
+ config.SuccessHandler(c)
+ }
+ return next(c)
+ }
+ if config.ErrorHandler != nil {
+ return config.ErrorHandler(err)
+ }
+ if config.ErrorHandlerWithContext != nil {
+ return config.ErrorHandlerWithContext(err, c)
+ }
+ return &echo.HTTPError{
+ Code: ErrJWTInvalid.Code,
+ Message: ErrJWTInvalid.Message,
+ Internal: err,
+ }
+ }
+ }
+}
+
+func (config *JWTConfig) defaultParseToken(auth string, c echo.Context) (interface{}, error) {
+ token := new(jwt.Token)
+ var err error
+ // Issue #647, #656
+ if _, ok := config.Claims.(jwt.MapClaims); ok {
+ token, err = jwt.Parse(auth, config.KeyFunc)
+ } else {
+ t := reflect.ValueOf(config.Claims).Type().Elem()
+ claims := reflect.New(t).Interface().(jwt.Claims)
+ token, err = jwt.ParseWithClaims(auth, claims, config.KeyFunc)
+ }
+ if err != nil {
+ return nil, err
+ }
+ if !token.Valid {
+ return nil, errors.New("invalid token")
+ }
+ return token, nil
+}
+
+// defaultKeyFunc returns a signing key of the given token.
+func (config *JWTConfig) defaultKeyFunc(t *jwt.Token) (interface{}, error) {
+ // Check the signing method
+ if t.Method.Alg() != config.SigningMethod {
+ return nil, fmt.Errorf("unexpected jwt signing method=%v", t.Header["alg"])
+ }
+ if len(config.SigningKeys) > 0 {
+ if kid, ok := t.Header["kid"].(string); ok {
+ if key, ok := config.SigningKeys[kid]; ok {
+ return key, nil
+ }
+ }
+ return nil, fmt.Errorf("unexpected jwt key id=%v", t.Header["kid"])
+ }
+
+ return config.SigningKey, nil
+}
+
+// jwtFromHeader returns a `jwtExtractor` that extracts token from the request header.
+func jwtFromHeader(header string, authScheme string) jwtExtractor {
+ return func(c echo.Context) (string, error) {
+ auth := c.Request().Header.Get(header)
+ l := len(authScheme)
+ if len(auth) > l+1 && auth[:l] == authScheme {
+ return auth[l+1:], nil
+ }
+ return "", ErrJWTMissing
+ }
+}
+
+// jwtFromQuery returns a `jwtExtractor` that extracts token from the query string.
+func jwtFromQuery(param string) jwtExtractor {
+ return func(c echo.Context) (string, error) {
+ token := c.QueryParam(param)
+ if token == "" {
+ return "", ErrJWTMissing
+ }
+ return token, nil
+ }
+}
+
+// jwtFromParam returns a `jwtExtractor` that extracts token from the url param string.
+func jwtFromParam(param string) jwtExtractor {
+ return func(c echo.Context) (string, error) {
+ token := c.Param(param)
+ if token == "" {
+ return "", ErrJWTMissing
+ }
+ return token, nil
+ }
+}
+
+// jwtFromCookie returns a `jwtExtractor` that extracts token from the named cookie.
+func jwtFromCookie(name string) jwtExtractor {
+ return func(c echo.Context) (string, error) {
+ cookie, err := c.Cookie(name)
+ if err != nil {
+ return "", ErrJWTMissing
+ }
+ return cookie.Value, nil
+ }
+}
+
+// jwtFromForm returns a `jwtExtractor` that extracts token from the form field.
+func jwtFromForm(name string) jwtExtractor {
+ return func(c echo.Context) (string, error) {
+ field := c.FormValue(name)
+ if field == "" {
+ return "", ErrJWTMissing
+ }
+ return field, nil
+ }
+}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/key_auth.go b/vendor/github.com/labstack/echo/v4/middleware/key_auth.go
index 79bee20..fd169aa 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/key_auth.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/key_auth.go
@@ -1,82 +1,58 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
"errors"
- "github.com/labstack/echo/v4"
"net/http"
+ "strings"
+
+ "github.com/labstack/echo/v4"
)
-// KeyAuthConfig defines the config for KeyAuth middleware.
-type KeyAuthConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // KeyAuthConfig defines the config for KeyAuth middleware.
+ KeyAuthConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // KeyLookup is a string in the form of ":" or ":,:" that is used
- // to extract key from the request.
- // Optional. Default value "header:Authorization".
- // Possible values:
- // - "header:" or "header::"
- // `` is argument value to cut/trim prefix of the extracted value. This is useful if header
- // value has static prefix like `Authorization: ` where part that we
- // want to cut is ` ` note the space at the end.
- // In case of basic authentication `Authorization: Basic ` prefix we want to remove is `Basic `.
- // - "query:"
- // - "form:"
- // - "cookie:"
- // Multiple sources example:
- // - "header:Authorization,header:X-Api-Key"
- KeyLookup string
+ // KeyLookup is a string in the form of ":" that is used
+ // to extract key from the request.
+ // Optional. Default value "header:Authorization".
+ // Possible values:
+ // - "header:"
+ // - "query:"
+ // - "form:"
+ KeyLookup string `yaml:"key_lookup"`
- // AuthScheme to be used in the Authorization header.
- // Optional. Default value "Bearer".
- AuthScheme string
+ // AuthScheme to be used in the Authorization header.
+ // Optional. Default value "Bearer".
+ AuthScheme string
- // Validator is a function to validate key.
- // Required.
- Validator KeyAuthValidator
+ // Validator is a function to validate key.
+ // Required.
+ Validator KeyAuthValidator
- // ErrorHandler defines a function which is executed for an invalid key.
- // It may be used to define a custom error.
- ErrorHandler KeyAuthErrorHandler
+ // ErrorHandler defines a function which is executed for an invalid key.
+ // It may be used to define a custom error.
+ ErrorHandler KeyAuthErrorHandler
+ }
- // ContinueOnIgnoredError allows the next middleware/handler to be called when ErrorHandler decides to
- // ignore the error (by returning `nil`).
- // This is useful when parts of your site/api allow public access and some authorized routes provide extra functionality.
- // In that case you can use ErrorHandler to set a default public key auth value in the request context
- // and continue. Some logic down the remaining execution chain needs to check that (public) key auth value then.
- ContinueOnIgnoredError bool
-}
+ // KeyAuthValidator defines a function to validate KeyAuth credentials.
+ KeyAuthValidator func(string, echo.Context) (bool, error)
-// KeyAuthValidator defines a function to validate KeyAuth credentials.
-type KeyAuthValidator func(auth string, c echo.Context) (bool, error)
+ keyExtractor func(echo.Context) (string, error)
-// KeyAuthErrorHandler defines a function which is executed for an invalid key.
-type KeyAuthErrorHandler func(err error, c echo.Context) error
+ // KeyAuthErrorHandler defines a function which is executed for an invalid key.
+ KeyAuthErrorHandler func(error, echo.Context) error
+)
-// ErrKeyAuthMissing is error type when KeyAuth middleware is unable to extract value from lookups
-type ErrKeyAuthMissing struct {
- Err error
-}
-
-// DefaultKeyAuthConfig is the default KeyAuth middleware config.
-var DefaultKeyAuthConfig = KeyAuthConfig{
- Skipper: DefaultSkipper,
- KeyLookup: "header:" + echo.HeaderAuthorization,
- AuthScheme: "Bearer",
-}
-
-// Error returns errors text
-func (e *ErrKeyAuthMissing) Error() string {
- return e.Err.Error()
-}
-
-// Unwrap unwraps error
-func (e *ErrKeyAuthMissing) Unwrap() error {
- return e.Err
-}
+var (
+ // DefaultKeyAuthConfig is the default KeyAuth middleware config.
+ DefaultKeyAuthConfig = KeyAuthConfig{
+ Skipper: DefaultSkipper,
+ KeyLookup: "header:" + echo.HeaderAuthorization,
+ AuthScheme: "Bearer",
+ }
+)
// KeyAuth returns an KeyAuth middleware.
//
@@ -107,9 +83,14 @@ func KeyAuthWithConfig(config KeyAuthConfig) echo.MiddlewareFunc {
panic("echo: key-auth middleware requires a validator function")
}
- extractors, cErr := createExtractors(config.KeyLookup, config.AuthScheme)
- if cErr != nil {
- panic(cErr)
+ // Initialize
+ parts := strings.Split(config.KeyLookup, ":")
+ extractor := keyFromHeader(parts[1], config.AuthScheme)
+ switch parts[0] {
+ case "query":
+ extractor = keyFromQuery(parts[1])
+ case "form":
+ extractor = keyFromForm(parts[1])
}
return func(next echo.HandlerFunc) echo.HandlerFunc {
@@ -118,62 +99,68 @@ func KeyAuthWithConfig(config KeyAuthConfig) echo.MiddlewareFunc {
return next(c)
}
- var lastExtractorErr error
- var lastValidatorErr error
- for _, extractor := range extractors {
- keys, err := extractor(c)
- if err != nil {
- lastExtractorErr = err
- continue
- }
- for _, key := range keys {
- valid, err := config.Validator(key, c)
- if err != nil {
- lastValidatorErr = err
- continue
- }
- if valid {
- return next(c)
- }
- lastValidatorErr = errors.New("invalid key")
+ // Extract and verify key
+ key, err := extractor(c)
+ if err != nil {
+ if config.ErrorHandler != nil {
+ return config.ErrorHandler(err, c)
}
+ return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}
-
- // we are here only when we did not successfully extract and validate any of keys
- err := lastValidatorErr
- if err == nil { // prioritize validator errors over extracting errors
- // ugly part to preserve backwards compatible errors. someone could rely on them
- if lastExtractorErr == errQueryExtractorValueMissing {
- err = errors.New("missing key in the query string")
- } else if lastExtractorErr == errCookieExtractorValueMissing {
- err = errors.New("missing key in cookies")
- } else if lastExtractorErr == errFormExtractorValueMissing {
- err = errors.New("missing key in the form")
- } else if lastExtractorErr == errHeaderExtractorValueMissing {
- err = errors.New("missing key in request header")
- } else if lastExtractorErr == errHeaderExtractorValueInvalid {
- err = errors.New("invalid key in the request header")
- } else {
- err = lastExtractorErr
+ valid, err := config.Validator(key, c)
+ if err != nil {
+ if config.ErrorHandler != nil {
+ return config.ErrorHandler(err, c)
}
- err = &ErrKeyAuthMissing{Err: err}
- }
-
- if config.ErrorHandler != nil {
- tmpErr := config.ErrorHandler(err, c)
- if config.ContinueOnIgnoredError && tmpErr == nil {
- return next(c)
- }
- return tmpErr
- }
- if lastValidatorErr != nil { // prioritize validator errors over extracting errors
return &echo.HTTPError{
Code: http.StatusUnauthorized,
- Message: "Unauthorized",
- Internal: lastValidatorErr,
+ Message: "invalid key",
+ Internal: err,
}
+ } else if valid {
+ return next(c)
}
- return echo.NewHTTPError(http.StatusBadRequest, err.Error())
+ return echo.ErrUnauthorized
}
}
}
+
+// keyFromHeader returns a `keyExtractor` that extracts key from the request header.
+func keyFromHeader(header string, authScheme string) keyExtractor {
+ return func(c echo.Context) (string, error) {
+ auth := c.Request().Header.Get(header)
+ if auth == "" {
+ return "", errors.New("missing key in request header")
+ }
+ if header == echo.HeaderAuthorization {
+ l := len(authScheme)
+ if len(auth) > l+1 && auth[:l] == authScheme {
+ return auth[l+1:], nil
+ }
+ return "", errors.New("invalid key in the request header")
+ }
+ return auth, nil
+ }
+}
+
+// keyFromQuery returns a `keyExtractor` that extracts key from the query string.
+func keyFromQuery(param string) keyExtractor {
+ return func(c echo.Context) (string, error) {
+ key := c.QueryParam(param)
+ if key == "" {
+ return "", errors.New("missing key in the query string")
+ }
+ return key, nil
+ }
+}
+
+// keyFromForm returns a `keyExtractor` that extracts key from the form.
+func keyFromForm(param string) keyExtractor {
+ return func(c echo.Context) (string, error) {
+ key := c.FormValue(param)
+ if key == "" {
+ return "", errors.New("missing key in the form")
+ }
+ return key, nil
+ }
+}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/logger.go b/vendor/github.com/labstack/echo/v4/middleware/logger.go
index 910fce8..9baac47 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/logger.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/logger.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
@@ -17,73 +14,68 @@ import (
"github.com/valyala/fasttemplate"
)
-// LoggerConfig defines the config for Logger middleware.
-type LoggerConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // LoggerConfig defines the config for Logger middleware.
+ LoggerConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // Tags to construct the logger format.
- //
- // - time_unix
- // - time_unix_milli
- // - time_unix_micro
- // - time_unix_nano
- // - time_rfc3339
- // - time_rfc3339_nano
- // - time_custom
- // - id (Request ID)
- // - remote_ip
- // - uri
- // - host
- // - method
- // - path
- // - route
- // - protocol
- // - referer
- // - user_agent
- // - status
- // - error
- // - latency (In nanoseconds)
- // - latency_human (Human readable)
- // - bytes_in (Bytes received)
- // - bytes_out (Bytes sent)
- // - header:
- // - query:
- // - form:
- // - custom (see CustomTagFunc field)
- //
- // Example "${remote_ip} ${status}"
- //
- // Optional. Default value DefaultLoggerConfig.Format.
- Format string `yaml:"format"`
+ // Tags to construct the logger format.
+ //
+ // - time_unix
+ // - time_unix_nano
+ // - time_rfc3339
+ // - time_rfc3339_nano
+ // - time_custom
+ // - id (Request ID)
+ // - remote_ip
+ // - uri
+ // - host
+ // - method
+ // - path
+ // - protocol
+ // - referer
+ // - user_agent
+ // - status
+ // - error
+ // - latency (In nanoseconds)
+ // - latency_human (Human readable)
+ // - bytes_in (Bytes received)
+ // - bytes_out (Bytes sent)
+ // - header:
+ // - query:
+ // - form:
+ //
+ // Example "${remote_ip} ${status}"
+ //
+ // Optional. Default value DefaultLoggerConfig.Format.
+ Format string `yaml:"format"`
- // Optional. Default value DefaultLoggerConfig.CustomTimeFormat.
- CustomTimeFormat string `yaml:"custom_time_format"`
+ // Optional. Default value DefaultLoggerConfig.CustomTimeFormat.
+ CustomTimeFormat string `yaml:"custom_time_format"`
- // CustomTagFunc is function called for `${custom}` tag to output user implemented text by writing it to buf.
- // Make sure that outputted text creates valid JSON string with other logged tags.
- // Optional.
- CustomTagFunc func(c echo.Context, buf *bytes.Buffer) (int, error)
+ // Output is a writer where logs in JSON format are written.
+ // Optional. Default value os.Stdout.
+ Output io.Writer
- // Output is a writer where logs in JSON format are written.
- // Optional. Default value os.Stdout.
- Output io.Writer
+ template *fasttemplate.Template
+ colorer *color.Color
+ pool *sync.Pool
+ }
+)
- template *fasttemplate.Template
- colorer *color.Color
- pool *sync.Pool
-}
-
-// DefaultLoggerConfig is the default Logger middleware config.
-var DefaultLoggerConfig = LoggerConfig{
- Skipper: DefaultSkipper,
- Format: `{"time":"${time_rfc3339_nano}","id":"${id}","remote_ip":"${remote_ip}",` +
- `"host":"${host}","method":"${method}","uri":"${uri}","user_agent":"${user_agent}",` +
- `"status":${status},"error":"${error}","latency":${latency},"latency_human":"${latency_human}"` +
- `,"bytes_in":${bytes_in},"bytes_out":${bytes_out}}` + "\n",
- CustomTimeFormat: "2006-01-02 15:04:05.00000",
- colorer: color.New(),
-}
+var (
+ // DefaultLoggerConfig is the default Logger middleware config.
+ DefaultLoggerConfig = LoggerConfig{
+ Skipper: DefaultSkipper,
+ Format: `{"time":"${time_rfc3339_nano}","id":"${id}","remote_ip":"${remote_ip}",` +
+ `"host":"${host}","method":"${method}","uri":"${uri}","user_agent":"${user_agent}",` +
+ `"status":${status},"error":"${error}","latency":${latency},"latency_human":"${latency_human}"` +
+ `,"bytes_in":${bytes_in},"bytes_out":${bytes_out}}` + "\n",
+ CustomTimeFormat: "2006-01-02 15:04:05.00000",
+ colorer: color.New(),
+ }
+)
// Logger returns a middleware that logs HTTP requests.
func Logger() echo.MiddlewareFunc {
@@ -132,19 +124,8 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
if _, err = config.template.ExecuteFunc(buf, func(w io.Writer, tag string) (int, error) {
switch tag {
- case "custom":
- if config.CustomTagFunc == nil {
- return 0, nil
- }
- return config.CustomTagFunc(c, buf)
case "time_unix":
return buf.WriteString(strconv.FormatInt(time.Now().Unix(), 10))
- case "time_unix_milli":
- // go 1.17 or later, it supports time#UnixMilli()
- return buf.WriteString(strconv.FormatInt(time.Now().UnixNano()/1000000, 10))
- case "time_unix_micro":
- // go 1.17 or later, it supports time#UnixMicro()
- return buf.WriteString(strconv.FormatInt(time.Now().UnixNano()/1000, 10))
case "time_unix_nano":
return buf.WriteString(strconv.FormatInt(time.Now().UnixNano(), 10))
case "time_rfc3339":
@@ -173,8 +154,6 @@ func LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc {
p = "/"
}
return buf.WriteString(p)
- case "route":
- return buf.WriteString(c.Path())
case "protocol":
return buf.WriteString(req.Proto)
case "referer":
diff --git a/vendor/github.com/labstack/echo/v4/middleware/method_override.go b/vendor/github.com/labstack/echo/v4/middleware/method_override.go
index 3991e10..92b14d2 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/method_override.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/method_override.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
@@ -9,24 +6,28 @@ import (
"github.com/labstack/echo/v4"
)
-// MethodOverrideConfig defines the config for MethodOverride middleware.
-type MethodOverrideConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // MethodOverrideConfig defines the config for MethodOverride middleware.
+ MethodOverrideConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // Getter is a function that gets overridden method from the request.
- // Optional. Default values MethodFromHeader(echo.HeaderXHTTPMethodOverride).
- Getter MethodOverrideGetter
-}
+ // Getter is a function that gets overridden method from the request.
+ // Optional. Default values MethodFromHeader(echo.HeaderXHTTPMethodOverride).
+ Getter MethodOverrideGetter
+ }
-// MethodOverrideGetter is a function that gets overridden method from the request
-type MethodOverrideGetter func(echo.Context) string
+ // MethodOverrideGetter is a function that gets overridden method from the request
+ MethodOverrideGetter func(echo.Context) string
+)
-// DefaultMethodOverrideConfig is the default MethodOverride middleware config.
-var DefaultMethodOverrideConfig = MethodOverrideConfig{
- Skipper: DefaultSkipper,
- Getter: MethodFromHeader(echo.HeaderXHTTPMethodOverride),
-}
+var (
+ // DefaultMethodOverrideConfig is the default MethodOverride middleware config.
+ DefaultMethodOverrideConfig = MethodOverrideConfig{
+ Skipper: DefaultSkipper,
+ Getter: MethodFromHeader(echo.HeaderXHTTPMethodOverride),
+ }
+)
// MethodOverride returns a MethodOverride middleware.
// MethodOverride middleware checks for the overridden method from the request and
diff --git a/vendor/github.com/labstack/echo/v4/middleware/middleware.go b/vendor/github.com/labstack/echo/v4/middleware/middleware.go
index 6f33cc5..a7ad73a 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/middleware.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/middleware.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
@@ -12,12 +9,14 @@ import (
"github.com/labstack/echo/v4"
)
-// Skipper defines a function to skip middleware. Returning true skips processing
-// the middleware.
-type Skipper func(c echo.Context) bool
+type (
+ // Skipper defines a function to skip middleware. Returning true skips processing
+ // the middleware.
+ Skipper func(echo.Context) bool
-// BeforeFunc defines a function which is executed just before the middleware.
-type BeforeFunc func(c echo.Context)
+ // BeforeFunc defines a function which is executed just before the middleware.
+ BeforeFunc func(echo.Context)
+)
func captureTokens(pattern *regexp.Regexp, input string) *strings.Replacer {
groups := pattern.FindAllStringSubmatch(input, -1)
@@ -39,9 +38,9 @@ func rewriteRulesRegex(rewrite map[string]string) map[*regexp.Regexp]string {
rulesRegex := map[*regexp.Regexp]string{}
for k, v := range rewrite {
k = regexp.QuoteMeta(k)
- k = strings.ReplaceAll(k, `\*`, "(.*?)")
+ k = strings.Replace(k, `\*`, "(.*?)", -1)
if strings.HasPrefix(k, `\^`) {
- k = strings.ReplaceAll(k, `\^`, "^")
+ k = strings.Replace(k, `\^`, "^", -1)
}
k = k + "$"
rulesRegex[regexp.MustCompile(k)] = v
@@ -54,7 +53,7 @@ func rewriteURL(rewriteRegex map[*regexp.Regexp]string, req *http.Request) error
return nil
}
- // Depending on how HTTP request is sent RequestURI could contain Scheme://Host/path or be just /path.
+ // Depending how HTTP request is sent RequestURI could contain Scheme://Host/path or be just /path.
// We only want to use path part for rewriting and therefore trim prefix if it exists
rawURI := req.RequestURI
if rawURI != "" && rawURI[0] != '/' {
diff --git a/vendor/github.com/labstack/echo/v4/middleware/proxy.go b/vendor/github.com/labstack/echo/v4/middleware/proxy.go
index 2744bc4..6cfd673 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/proxy.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/proxy.go
@@ -1,11 +1,7 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
"context"
- "crypto/tls"
"fmt"
"io"
"math/rand"
@@ -16,6 +12,7 @@ import (
"regexp"
"strings"
"sync"
+ "sync/atomic"
"time"
"github.com/labstack/echo/v4"
@@ -23,146 +20,104 @@ import (
// TODO: Handle TLS proxy
-// ProxyConfig defines the config for Proxy middleware.
-type ProxyConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // ProxyConfig defines the config for Proxy middleware.
+ ProxyConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // Balancer defines a load balancing technique.
- // Required.
- Balancer ProxyBalancer
+ // Balancer defines a load balancing technique.
+ // Required.
+ Balancer ProxyBalancer
- // RetryCount defines the number of times a failed proxied request should be retried
- // using the next available ProxyTarget. Defaults to 0, meaning requests are never retried.
- RetryCount int
+ // Rewrite defines URL path rewrite rules. The values captured in asterisk can be
+ // retrieved by index e.g. $1, $2 and so on.
+ // Examples:
+ // "/old": "/new",
+ // "/api/*": "/$1",
+ // "/js/*": "/public/javascripts/$1",
+ // "/users/*/orders/*": "/user/$1/order/$2",
+ Rewrite map[string]string
- // RetryFilter defines a function used to determine if a failed request to a
- // ProxyTarget should be retried. The RetryFilter will only be called when the number
- // of previous retries is less than RetryCount. If the function returns true, the
- // request will be retried. The provided error indicates the reason for the request
- // failure. When the ProxyTarget is unavailable, the error will be an instance of
- // echo.HTTPError with a Code of http.StatusBadGateway. In all other cases, the error
- // will indicate an internal error in the Proxy middleware. When a RetryFilter is not
- // specified, all requests that fail with http.StatusBadGateway will be retried. A custom
- // RetryFilter can be provided to only retry specific requests. Note that RetryFilter is
- // only called when the request to the target fails, or an internal error in the Proxy
- // middleware has occurred. Successful requests that return a non-200 response code cannot
- // be retried.
- RetryFilter func(c echo.Context, e error) bool
+ // RegexRewrite defines rewrite rules using regexp.Rexexp with captures
+ // Every capture group in the values can be retrieved by index e.g. $1, $2 and so on.
+ // Example:
+ // "^/old/[0.9]+/": "/new",
+ // "^/api/.+?/(.*)": "/v2/$1",
+ RegexRewrite map[*regexp.Regexp]string
- // ErrorHandler defines a function which can be used to return custom errors from
- // the Proxy middleware. ErrorHandler is only invoked when there has been
- // either an internal error in the Proxy middleware or the ProxyTarget is
- // unavailable. Due to the way requests are proxied, ErrorHandler is not invoked
- // when a ProxyTarget returns a non-200 response. In these cases, the response
- // is already written so errors cannot be modified. ErrorHandler is only
- // invoked after all retry attempts have been exhausted.
- ErrorHandler func(c echo.Context, err error) error
+ // Context key to store selected ProxyTarget into context.
+ // Optional. Default value "target".
+ ContextKey string
- // Rewrite defines URL path rewrite rules. The values captured in asterisk can be
- // retrieved by index e.g. $1, $2 and so on.
- // Examples:
- // "/old": "/new",
- // "/api/*": "/$1",
- // "/js/*": "/public/javascripts/$1",
- // "/users/*/orders/*": "/user/$1/order/$2",
- Rewrite map[string]string
+ // To customize the transport to remote.
+ // Examples: If custom TLS certificates are required.
+ Transport http.RoundTripper
- // RegexRewrite defines rewrite rules using regexp.Rexexp with captures
- // Every capture group in the values can be retrieved by index e.g. $1, $2 and so on.
- // Example:
- // "^/old/[0.9]+/": "/new",
- // "^/api/.+?/(.*)": "/v2/$1",
- RegexRewrite map[*regexp.Regexp]string
-
- // Context key to store selected ProxyTarget into context.
- // Optional. Default value "target".
- ContextKey string
-
- // To customize the transport to remote.
- // Examples: If custom TLS certificates are required.
- Transport http.RoundTripper
-
- // ModifyResponse defines function to modify response from ProxyTarget.
- ModifyResponse func(*http.Response) error
-}
-
-// ProxyTarget defines the upstream target.
-type ProxyTarget struct {
- Name string
- URL *url.URL
- Meta echo.Map
-}
-
-// ProxyBalancer defines an interface to implement a load balancing technique.
-type ProxyBalancer interface {
- AddTarget(*ProxyTarget) bool
- RemoveTarget(string) bool
- Next(echo.Context) *ProxyTarget
-}
-
-// TargetProvider defines an interface that gives the opportunity for balancer
-// to return custom errors when selecting target.
-type TargetProvider interface {
- NextTarget(echo.Context) (*ProxyTarget, error)
-}
-
-type commonBalancer struct {
- targets []*ProxyTarget
- mutex sync.Mutex
-}
-
-// RandomBalancer implements a random load balancing technique.
-type randomBalancer struct {
- commonBalancer
- random *rand.Rand
-}
-
-// RoundRobinBalancer implements a round-robin load balancing technique.
-type roundRobinBalancer struct {
- commonBalancer
- // tracking the index on `targets` slice for the next `*ProxyTarget` to be used
- i int
-}
-
-// DefaultProxyConfig is the default Proxy middleware config.
-var DefaultProxyConfig = ProxyConfig{
- Skipper: DefaultSkipper,
- ContextKey: "target",
-}
-
-func proxyRaw(t *ProxyTarget, c echo.Context, config ProxyConfig) http.Handler {
- var dialFunc func(ctx context.Context, network, addr string) (net.Conn, error)
- if transport, ok := config.Transport.(*http.Transport); ok {
- if transport.TLSClientConfig != nil {
- d := tls.Dialer{
- Config: transport.TLSClientConfig,
- }
- dialFunc = d.DialContext
- }
- }
- if dialFunc == nil {
- var d net.Dialer
- dialFunc = d.DialContext
+ // ModifyResponse defines function to modify response from ProxyTarget.
+ ModifyResponse func(*http.Response) error
}
+ // ProxyTarget defines the upstream target.
+ ProxyTarget struct {
+ Name string
+ URL *url.URL
+ Meta echo.Map
+ }
+
+ // ProxyBalancer defines an interface to implement a load balancing technique.
+ ProxyBalancer interface {
+ AddTarget(*ProxyTarget) bool
+ RemoveTarget(string) bool
+ Next(echo.Context) *ProxyTarget
+ }
+
+ commonBalancer struct {
+ targets []*ProxyTarget
+ mutex sync.RWMutex
+ }
+
+ // RandomBalancer implements a random load balancing technique.
+ randomBalancer struct {
+ *commonBalancer
+ random *rand.Rand
+ }
+
+ // RoundRobinBalancer implements a round-robin load balancing technique.
+ roundRobinBalancer struct {
+ *commonBalancer
+ i uint32
+ }
+)
+
+var (
+ // DefaultProxyConfig is the default Proxy middleware config.
+ DefaultProxyConfig = ProxyConfig{
+ Skipper: DefaultSkipper,
+ ContextKey: "target",
+ }
+)
+
+func proxyRaw(t *ProxyTarget, c echo.Context) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
in, _, err := c.Response().Hijack()
if err != nil {
- c.Set("_error", fmt.Errorf("proxy raw, hijack error=%w, url=%s", err, t.URL))
+ c.Set("_error", fmt.Sprintf("proxy raw, hijack error=%v, url=%s", t.URL, err))
return
}
defer in.Close()
- out, err := dialFunc(c.Request().Context(), "tcp", t.URL.Host)
+
+ out, err := net.Dial("tcp", t.URL.Host)
if err != nil {
- c.Set("_error", echo.NewHTTPError(http.StatusBadGateway, fmt.Sprintf("proxy raw, dial error=%v, url=%s", err, t.URL)))
+ c.Set("_error", echo.NewHTTPError(http.StatusBadGateway, fmt.Sprintf("proxy raw, dial error=%v, url=%s", t.URL, err)))
return
}
+ defer out.Close()
// Write header
err = r.Write(out)
if err != nil {
- c.Set("_error", echo.NewHTTPError(http.StatusBadGateway, fmt.Sprintf("proxy raw, request header copy error=%v, url=%s", err, t.URL)))
+ c.Set("_error", echo.NewHTTPError(http.StatusBadGateway, fmt.Sprintf("proxy raw, request header copy error=%v, url=%s", t.URL, err)))
return
}
@@ -176,44 +131,39 @@ func proxyRaw(t *ProxyTarget, c echo.Context, config ProxyConfig) http.Handler {
go cp(in, out)
err = <-errCh
if err != nil && err != io.EOF {
- c.Set("_error", fmt.Errorf("proxy raw, copy body error=%w, url=%s", err, t.URL))
+ c.Set("_error", fmt.Errorf("proxy raw, copy body error=%v, url=%s", t.URL, err))
}
})
}
// NewRandomBalancer returns a random proxy balancer.
func NewRandomBalancer(targets []*ProxyTarget) ProxyBalancer {
- b := randomBalancer{}
+ b := &randomBalancer{commonBalancer: new(commonBalancer)}
b.targets = targets
- b.random = rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
- return &b
+ return b
}
// NewRoundRobinBalancer returns a round-robin proxy balancer.
func NewRoundRobinBalancer(targets []*ProxyTarget) ProxyBalancer {
- b := roundRobinBalancer{}
+ b := &roundRobinBalancer{commonBalancer: new(commonBalancer)}
b.targets = targets
- return &b
+ return b
}
-// AddTarget adds an upstream target to the list and returns `true`.
-//
-// However, if a target with the same name already exists then the operation is aborted returning `false`.
+// AddTarget adds an upstream target to the list.
func (b *commonBalancer) AddTarget(target *ProxyTarget) bool {
- b.mutex.Lock()
- defer b.mutex.Unlock()
for _, t := range b.targets {
if t.Name == target.Name {
return false
}
}
+ b.mutex.Lock()
+ defer b.mutex.Unlock()
b.targets = append(b.targets, target)
return true
}
-// RemoveTarget removes an upstream target from the list by name.
-//
-// Returns `true` on success, `false` if no target with the name is found.
+// RemoveTarget removes an upstream target from the list.
func (b *commonBalancer) RemoveTarget(name string) bool {
b.mutex.Lock()
defer b.mutex.Unlock()
@@ -227,58 +177,21 @@ func (b *commonBalancer) RemoveTarget(name string) bool {
}
// Next randomly returns an upstream target.
-//
-// Note: `nil` is returned in case upstream target list is empty.
func (b *randomBalancer) Next(c echo.Context) *ProxyTarget {
- b.mutex.Lock()
- defer b.mutex.Unlock()
- if len(b.targets) == 0 {
- return nil
- } else if len(b.targets) == 1 {
- return b.targets[0]
+ if b.random == nil {
+ b.random = rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
}
+ b.mutex.RLock()
+ defer b.mutex.RUnlock()
return b.targets[b.random.Intn(len(b.targets))]
}
-// Next returns an upstream target using round-robin technique. In the case
-// where a previously failed request is being retried, the round-robin
-// balancer will attempt to use the next target relative to the original
-// request. If the list of targets held by the balancer is modified while a
-// failed request is being retried, it is possible that the balancer will
-// return the original failed target.
-//
-// Note: `nil` is returned in case upstream target list is empty.
+// Next returns an upstream target using round-robin technique.
func (b *roundRobinBalancer) Next(c echo.Context) *ProxyTarget {
- b.mutex.Lock()
- defer b.mutex.Unlock()
- if len(b.targets) == 0 {
- return nil
- } else if len(b.targets) == 1 {
- return b.targets[0]
- }
-
- var i int
- const lastIdxKey = "_round_robin_last_index"
- // This request is a retry, start from the index of the previous
- // target to ensure we don't attempt to retry the request with
- // the same failed target
- if c.Get(lastIdxKey) != nil {
- i = c.Get(lastIdxKey).(int)
- i++
- if i >= len(b.targets) {
- i = 0
- }
- } else {
- // This is a first time request, use the global index
- if b.i >= len(b.targets) {
- b.i = 0
- }
- i = b.i
- b.i++
- }
-
- c.Set(lastIdxKey, i)
- return b.targets[i]
+ b.i = b.i % uint32(len(b.targets))
+ t := b.targets[b.i]
+ atomic.AddUint32(&b.i, 1)
+ return t
}
// Proxy returns a Proxy middleware.
@@ -293,26 +206,14 @@ func Proxy(balancer ProxyBalancer) echo.MiddlewareFunc {
// ProxyWithConfig returns a Proxy middleware with config.
// See: `Proxy()`
func ProxyWithConfig(config ProxyConfig) echo.MiddlewareFunc {
- if config.Balancer == nil {
- panic("echo: proxy middleware requires balancer")
- }
// Defaults
if config.Skipper == nil {
config.Skipper = DefaultProxyConfig.Skipper
}
- if config.RetryFilter == nil {
- config.RetryFilter = func(c echo.Context, e error) bool {
- if httpErr, ok := e.(*echo.HTTPError); ok {
- return httpErr.Code == http.StatusBadGateway
- }
- return false
- }
- }
- if config.ErrorHandler == nil {
- config.ErrorHandler = func(c echo.Context, err error) error {
- return err
- }
+ if config.Balancer == nil {
+ panic("echo: proxy middleware requires balancer")
}
+
if config.Rewrite != nil {
if config.RegexRewrite == nil {
config.RegexRewrite = make(map[*regexp.Regexp]string)
@@ -322,18 +223,19 @@ func ProxyWithConfig(config ProxyConfig) echo.MiddlewareFunc {
}
}
- provider, isTargetProvider := config.Balancer.(TargetProvider)
-
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c echo.Context) (err error) {
if config.Skipper(c) {
return next(c)
}
req := c.Request()
res := c.Response()
+ tgt := config.Balancer.Next(c)
+ c.Set(config.ContextKey, tgt)
+
if err := rewriteURL(config.RegexRewrite, req); err != nil {
- return config.ErrorHandler(c, err)
+ return err
}
// Fix header
@@ -349,52 +251,19 @@ func ProxyWithConfig(config ProxyConfig) echo.MiddlewareFunc {
req.Header.Set(echo.HeaderXForwardedFor, c.RealIP())
}
- retries := config.RetryCount
- for {
- var tgt *ProxyTarget
- var err error
- if isTargetProvider {
- tgt, err = provider.NextTarget(c)
- if err != nil {
- return config.ErrorHandler(c, err)
- }
- } else {
- tgt = config.Balancer.Next(c)
- }
-
- c.Set(config.ContextKey, tgt)
-
- //If retrying a failed request, clear any previous errors from
- //context here so that balancers have the option to check for
- //errors that occurred using previous target
- if retries < config.RetryCount {
- c.Set("_error", nil)
- }
-
- // This is needed for ProxyConfig.ModifyResponse and/or ProxyConfig.Transport to be able to process the Request
- // that Balancer may have replaced with c.SetRequest.
- req = c.Request()
-
- // Proxy
- switch {
- case c.IsWebSocket():
- proxyRaw(tgt, c, config).ServeHTTP(res, req)
- default: // even SSE requests
- proxyHTTP(tgt, c, config).ServeHTTP(res, req)
- }
-
- err, hasError := c.Get("_error").(error)
- if !hasError {
- return nil
- }
-
- retry := retries > 0 && config.RetryFilter(c, err)
- if !retry {
- return config.ErrorHandler(c, err)
- }
-
- retries--
+ // Proxy
+ switch {
+ case c.IsWebSocket():
+ proxyRaw(tgt, c).ServeHTTP(res, req)
+ case req.Header.Get(echo.HeaderAccept) == "text/event-stream":
+ default:
+ proxyHTTP(tgt, c, config).ServeHTTP(res, req)
}
+ if e, ok := c.Get("_error").(error); ok {
+ err = e
+ }
+
+ return
}
}
}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/rate_limiter.go b/vendor/github.com/labstack/echo/v4/middleware/rate_limiter.go
index 70b89b0..0291eb4 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/rate_limiter.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/rate_limiter.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
@@ -12,34 +9,39 @@ import (
"golang.org/x/time/rate"
)
-// RateLimiterStore is the interface to be implemented by custom stores.
-type RateLimiterStore interface {
- // Stores for the rate limiter have to implement the Allow method
- Allow(identifier string) (bool, error)
-}
+type (
+ // RateLimiterStore is the interface to be implemented by custom stores.
+ RateLimiterStore interface {
+ // Stores for the rate limiter have to implement the Allow method
+ Allow(identifier string) (bool, error)
+ }
+)
-// RateLimiterConfig defines the configuration for the rate limiter
-type RateLimiterConfig struct {
- Skipper Skipper
- BeforeFunc BeforeFunc
- // IdentifierExtractor uses echo.Context to extract the identifier for a visitor
- IdentifierExtractor Extractor
- // Store defines a store for the rate limiter
- Store RateLimiterStore
- // ErrorHandler provides a handler to be called when IdentifierExtractor returns an error
- ErrorHandler func(context echo.Context, err error) error
- // DenyHandler provides a handler to be called when RateLimiter denies access
- DenyHandler func(context echo.Context, identifier string, err error) error
-}
+type (
+ // RateLimiterConfig defines the configuration for the rate limiter
+ RateLimiterConfig struct {
+ Skipper Skipper
+ BeforeFunc BeforeFunc
+ // IdentifierExtractor uses echo.Context to extract the identifier for a visitor
+ IdentifierExtractor Extractor
+ // Store defines a store for the rate limiter
+ Store RateLimiterStore
+ // ErrorHandler provides a handler to be called when IdentifierExtractor returns an error
+ ErrorHandler func(context echo.Context, err error) error
+ // DenyHandler provides a handler to be called when RateLimiter denies access
+ DenyHandler func(context echo.Context, identifier string, err error) error
+ }
+ // Extractor is used to extract data from echo.Context
+ Extractor func(context echo.Context) (string, error)
+)
-// Extractor is used to extract data from echo.Context
-type Extractor func(context echo.Context) (string, error)
-
-// ErrRateLimitExceeded denotes an error raised when rate limit is exceeded
-var ErrRateLimitExceeded = echo.NewHTTPError(http.StatusTooManyRequests, "rate limit exceeded")
-
-// ErrExtractorError denotes an error raised when extractor function is unsuccessful
-var ErrExtractorError = echo.NewHTTPError(http.StatusForbidden, "error while extracting identifier")
+// errors
+var (
+ // ErrRateLimitExceeded denotes an error raised when rate limit is exceeded
+ ErrRateLimitExceeded = echo.NewHTTPError(http.StatusTooManyRequests, "rate limit exceeded")
+ // ErrExtractorError denotes an error raised when extractor function is unsuccessful
+ ErrExtractorError = echo.NewHTTPError(http.StatusForbidden, "error while extracting identifier")
+)
// DefaultRateLimiterConfig defines default values for RateLimiterConfig
var DefaultRateLimiterConfig = RateLimiterConfig{
@@ -148,37 +150,32 @@ func RateLimiterWithConfig(config RateLimiterConfig) echo.MiddlewareFunc {
}
}
-// RateLimiterMemoryStore is the built-in store implementation for RateLimiter
-type RateLimiterMemoryStore struct {
- visitors map[string]*Visitor
- mutex sync.Mutex
- rate rate.Limit // for more info check out Limiter docs - https://pkg.go.dev/golang.org/x/time/rate#Limit.
-
- burst int
- expiresIn time.Duration
- lastCleanup time.Time
-
- timeNow func() time.Time
-}
-
-// Visitor signifies a unique user's limiter details
-type Visitor struct {
- *rate.Limiter
- lastSeen time.Time
-}
+type (
+ // RateLimiterMemoryStore is the built-in store implementation for RateLimiter
+ RateLimiterMemoryStore struct {
+ visitors map[string]*Visitor
+ mutex sync.Mutex
+ rate rate.Limit
+ burst int
+ expiresIn time.Duration
+ lastCleanup time.Time
+ }
+ // Visitor signifies a unique user's limiter details
+ Visitor struct {
+ *rate.Limiter
+ lastSeen time.Time
+ }
+)
/*
NewRateLimiterMemoryStore returns an instance of RateLimiterMemoryStore with
-the provided rate (as req/s).
-for more info check out Limiter docs - https://pkg.go.dev/golang.org/x/time/rate#Limit.
-
+the provided rate (as req/s). The provided rate less than 1 will be treated as zero.
Burst and ExpiresIn will be set to default values.
-Note that if the provided rate is a float number and Burst is zero, Burst will be treated as the rounded down value of the rate.
-
Example (with 20 requests/sec):
limiterStore := middleware.NewRateLimiterMemoryStore(20)
+
*/
func NewRateLimiterMemoryStore(rate rate.Limit) (store *RateLimiterMemoryStore) {
return NewRateLimiterMemoryStoreWithConfig(RateLimiterMemoryStoreConfig{
@@ -188,10 +185,10 @@ func NewRateLimiterMemoryStore(rate rate.Limit) (store *RateLimiterMemoryStore)
/*
NewRateLimiterMemoryStoreWithConfig returns an instance of RateLimiterMemoryStore
-with the provided configuration. Rate must be provided. Burst will be set to the rounded down value of
+with the provided configuration. Rate must be provided. Burst will be set to the value of
the configured rate if not provided or set to 0.
-The built-in memory store is usually capable for modest loads. For higher loads other
+The build-in memory store is usually capable for modest loads. For higher loads other
store implementations should be considered.
Characteristics:
@@ -202,7 +199,7 @@ Characteristics:
Example:
limiterStore := middleware.NewRateLimiterMemoryStoreWithConfig(
- middleware.RateLimiterMemoryStoreConfig{Rate: 50, Burst: 200, ExpiresIn: 5 * time.Minute},
+ middleware.RateLimiterMemoryStoreConfig{Rate: 50, Burst: 200, ExpiresIn: 5 * time.Minutes},
)
*/
func NewRateLimiterMemoryStoreWithConfig(config RateLimiterMemoryStoreConfig) (store *RateLimiterMemoryStore) {
@@ -218,15 +215,14 @@ func NewRateLimiterMemoryStoreWithConfig(config RateLimiterMemoryStoreConfig) (s
store.burst = int(config.Rate)
}
store.visitors = make(map[string]*Visitor)
- store.timeNow = time.Now
- store.lastCleanup = store.timeNow()
+ store.lastCleanup = now()
return
}
// RateLimiterMemoryStoreConfig represents configuration for RateLimiterMemoryStore
type RateLimiterMemoryStoreConfig struct {
- Rate rate.Limit // Rate of requests allowed to pass as req/s. For more info check out Limiter docs - https://pkg.go.dev/golang.org/x/time/rate#Limit.
- Burst int // Burst is maximum number of requests to pass at the same moment. It additionally allows a number of requests to pass when rate limit is reached.
+ Rate rate.Limit // Rate of requests allowed to pass as req/s
+ Burst int // Burst additionally allows a number of requests to pass when rate limit is reached
ExpiresIn time.Duration // ExpiresIn is the duration after that a rate limiter is cleaned up
}
@@ -244,13 +240,12 @@ func (store *RateLimiterMemoryStore) Allow(identifier string) (bool, error) {
limiter.Limiter = rate.NewLimiter(store.rate, store.burst)
store.visitors[identifier] = limiter
}
- now := store.timeNow()
- limiter.lastSeen = now
- if now.Sub(store.lastCleanup) > store.expiresIn {
+ limiter.lastSeen = now()
+ if now().Sub(store.lastCleanup) > store.expiresIn {
store.cleanupStaleVisitors()
}
store.mutex.Unlock()
- return limiter.AllowN(store.timeNow(), 1), nil
+ return limiter.AllowN(now(), 1), nil
}
/*
@@ -259,9 +254,14 @@ of users who haven't visited again after the configured expiry time has elapsed
*/
func (store *RateLimiterMemoryStore) cleanupStaleVisitors() {
for id, visitor := range store.visitors {
- if store.timeNow().Sub(visitor.lastSeen) > store.expiresIn {
+ if now().Sub(visitor.lastSeen) > store.expiresIn {
delete(store.visitors, id)
}
}
- store.lastCleanup = store.timeNow()
+ store.lastCleanup = now()
}
+
+/*
+actual time method which is mocked in test file
+*/
+var now = time.Now
diff --git a/vendor/github.com/labstack/echo/v4/middleware/recover.go b/vendor/github.com/labstack/echo/v4/middleware/recover.go
index e6a5940..0dbe740 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/recover.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/recover.go
@@ -1,63 +1,48 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
"fmt"
- "net/http"
"runtime"
"github.com/labstack/echo/v4"
"github.com/labstack/gommon/log"
)
-// LogErrorFunc defines a function for custom logging in the middleware.
-type LogErrorFunc func(c echo.Context, err error, stack []byte) error
+type (
+ // RecoverConfig defines the config for Recover middleware.
+ RecoverConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
-// RecoverConfig defines the config for Recover middleware.
-type RecoverConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+ // Size of the stack to be printed.
+ // Optional. Default value 4KB.
+ StackSize int `yaml:"stack_size"`
- // Size of the stack to be printed.
- // Optional. Default value 4KB.
- StackSize int `yaml:"stack_size"`
+ // DisableStackAll disables formatting stack traces of all other goroutines
+ // into buffer after the trace for the current goroutine.
+ // Optional. Default value false.
+ DisableStackAll bool `yaml:"disable_stack_all"`
- // DisableStackAll disables formatting stack traces of all other goroutines
- // into buffer after the trace for the current goroutine.
- // Optional. Default value false.
- DisableStackAll bool `yaml:"disable_stack_all"`
+ // DisablePrintStack disables printing stack trace.
+ // Optional. Default value as false.
+ DisablePrintStack bool `yaml:"disable_print_stack"`
- // DisablePrintStack disables printing stack trace.
- // Optional. Default value as false.
- DisablePrintStack bool `yaml:"disable_print_stack"`
+ // LogLevel is log level to printing stack trace.
+ // Optional. Default value 0 (Print).
+ LogLevel log.Lvl
+ }
+)
- // LogLevel is log level to printing stack trace.
- // Optional. Default value 0 (Print).
- LogLevel log.Lvl
-
- // LogErrorFunc defines a function for custom logging in the middleware.
- // If it's set you don't need to provide LogLevel for config.
- // If this function returns nil, the centralized HTTPErrorHandler will not be called.
- LogErrorFunc LogErrorFunc
-
- // DisableErrorHandler disables the call to centralized HTTPErrorHandler.
- // The recovered error is then passed back to upstream middleware, instead of swallowing the error.
- // Optional. Default value false.
- DisableErrorHandler bool `yaml:"disable_error_handler"`
-}
-
-// DefaultRecoverConfig is the default Recover middleware config.
-var DefaultRecoverConfig = RecoverConfig{
- Skipper: DefaultSkipper,
- StackSize: 4 << 10, // 4 KB
- DisableStackAll: false,
- DisablePrintStack: false,
- LogLevel: 0,
- LogErrorFunc: nil,
- DisableErrorHandler: false,
-}
+var (
+ // DefaultRecoverConfig is the default Recover middleware config.
+ DefaultRecoverConfig = RecoverConfig{
+ Skipper: DefaultSkipper,
+ StackSize: 4 << 10, // 4 KB
+ DisableStackAll: false,
+ DisablePrintStack: false,
+ LogLevel: 0,
+ }
+)
// Recover returns a middleware which recovers from panics anywhere in the chain
// and handles the control to the centralized HTTPErrorHandler.
@@ -77,32 +62,20 @@ func RecoverWithConfig(config RecoverConfig) echo.MiddlewareFunc {
}
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) (returnErr error) {
+ return func(c echo.Context) error {
if config.Skipper(c) {
return next(c)
}
defer func() {
if r := recover(); r != nil {
- if r == http.ErrAbortHandler {
- panic(r)
- }
err, ok := r.(error)
if !ok {
err = fmt.Errorf("%v", r)
}
- var stack []byte
- var length int
-
+ stack := make([]byte, config.StackSize)
+ length := runtime.Stack(stack, !config.DisableStackAll)
if !config.DisablePrintStack {
- stack = make([]byte, config.StackSize)
- length = runtime.Stack(stack, !config.DisableStackAll)
- stack = stack[:length]
- }
-
- if config.LogErrorFunc != nil {
- err = config.LogErrorFunc(c, err, stack)
- } else if !config.DisablePrintStack {
msg := fmt.Sprintf("[PANIC RECOVER] %v %s\n", err, stack[:length])
switch config.LogLevel {
case log.DEBUG:
@@ -119,12 +92,7 @@ func RecoverWithConfig(config RecoverConfig) echo.MiddlewareFunc {
c.Logger().Print(msg)
}
}
-
- if err != nil && !config.DisableErrorHandler {
- c.Error(err)
- } else {
- returnErr = err
- }
+ c.Error(err)
}
}()
return next(c)
diff --git a/vendor/github.com/labstack/echo/v4/middleware/redirect.go b/vendor/github.com/labstack/echo/v4/middleware/redirect.go
index b772ac1..13877db 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/redirect.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/redirect.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
diff --git a/vendor/github.com/labstack/echo/v4/middleware/request_id.go b/vendor/github.com/labstack/echo/v4/middleware/request_id.go
index 14bd4fd..b0baeeb 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/request_id.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/request_id.go
@@ -1,34 +1,32 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
"github.com/labstack/echo/v4"
+ "github.com/labstack/gommon/random"
)
-// RequestIDConfig defines the config for RequestID middleware.
-type RequestIDConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // RequestIDConfig defines the config for RequestID middleware.
+ RequestIDConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // Generator defines a function to generate an ID.
- // Optional. Defaults to generator for random string of length 32.
- Generator func() string
+ // Generator defines a function to generate an ID.
+ // Optional. Default value random.String(32).
+ Generator func() string
- // RequestIDHandler defines a function which is executed for a request id.
- RequestIDHandler func(echo.Context, string)
+ // RequestIDHandler defines a function which is executed for a request id.
+ RequestIDHandler func(echo.Context, string)
+ }
+)
- // TargetHeader defines what header to look for to populate the id
- TargetHeader string
-}
-
-// DefaultRequestIDConfig is the default RequestID middleware config.
-var DefaultRequestIDConfig = RequestIDConfig{
- Skipper: DefaultSkipper,
- Generator: generator,
- TargetHeader: echo.HeaderXRequestID,
-}
+var (
+ // DefaultRequestIDConfig is the default RequestID middleware config.
+ DefaultRequestIDConfig = RequestIDConfig{
+ Skipper: DefaultSkipper,
+ Generator: generator,
+ }
+)
// RequestID returns a X-Request-ID middleware.
func RequestID() echo.MiddlewareFunc {
@@ -44,9 +42,6 @@ func RequestIDWithConfig(config RequestIDConfig) echo.MiddlewareFunc {
if config.Generator == nil {
config.Generator = generator
}
- if config.TargetHeader == "" {
- config.TargetHeader = echo.HeaderXRequestID
- }
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
@@ -56,11 +51,11 @@ func RequestIDWithConfig(config RequestIDConfig) echo.MiddlewareFunc {
req := c.Request()
res := c.Response()
- rid := req.Header.Get(config.TargetHeader)
+ rid := req.Header.Get(echo.HeaderXRequestID)
if rid == "" {
rid = config.Generator()
}
- res.Header().Set(config.TargetHeader, rid)
+ res.Header().Set(echo.HeaderXRequestID, rid)
if config.RequestIDHandler != nil {
config.RequestIDHandler(c, rid)
}
@@ -71,5 +66,5 @@ func RequestIDWithConfig(config RequestIDConfig) echo.MiddlewareFunc {
}
func generator() string {
- return randomString(32)
+ return random.String(32)
}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/request_logger.go b/vendor/github.com/labstack/echo/v4/middleware/request_logger.go
deleted file mode 100644
index 7c18200..0000000
--- a/vendor/github.com/labstack/echo/v4/middleware/request_logger.go
+++ /dev/null
@@ -1,391 +0,0 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
-package middleware
-
-import (
- "errors"
- "net/http"
- "time"
-
- "github.com/labstack/echo/v4"
-)
-
-// Example for `slog` https://pkg.go.dev/log/slog
-// logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
-// e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
-// LogStatus: true,
-// LogURI: true,
-// LogError: true,
-// HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
-// LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
-// if v.Error == nil {
-// logger.LogAttrs(context.Background(), slog.LevelInfo, "REQUEST",
-// slog.String("uri", v.URI),
-// slog.Int("status", v.Status),
-// )
-// } else {
-// logger.LogAttrs(context.Background(), slog.LevelError, "REQUEST_ERROR",
-// slog.String("uri", v.URI),
-// slog.Int("status", v.Status),
-// slog.String("err", v.Error.Error()),
-// )
-// }
-// return nil
-// },
-// }))
-//
-// Example for `fmt.Printf`
-// e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
-// LogStatus: true,
-// LogURI: true,
-// LogError: true,
-// HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
-// LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
-// if v.Error == nil {
-// fmt.Printf("REQUEST: uri: %v, status: %v\n", v.URI, v.Status)
-// } else {
-// fmt.Printf("REQUEST_ERROR: uri: %v, status: %v, err: %v\n", v.URI, v.Status, v.Error)
-// }
-// return nil
-// },
-// }))
-//
-// Example for Zerolog (https://github.com/rs/zerolog)
-// logger := zerolog.New(os.Stdout)
-// e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
-// LogURI: true,
-// LogStatus: true,
-// LogError: true,
-// HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
-// LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
-// if v.Error == nil {
-// logger.Info().
-// Str("URI", v.URI).
-// Int("status", v.Status).
-// Msg("request")
-// } else {
-// logger.Error().
-// Err(v.Error).
-// Str("URI", v.URI).
-// Int("status", v.Status).
-// Msg("request error")
-// }
-// return nil
-// },
-// }))
-//
-// Example for Zap (https://github.com/uber-go/zap)
-// logger, _ := zap.NewProduction()
-// e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
-// LogURI: true,
-// LogStatus: true,
-// LogError: true,
-// HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
-// LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
-// if v.Error == nil {
-// logger.Info("request",
-// zap.String("URI", v.URI),
-// zap.Int("status", v.Status),
-// )
-// } else {
-// logger.Error("request error",
-// zap.String("URI", v.URI),
-// zap.Int("status", v.Status),
-// zap.Error(v.Error),
-// )
-// }
-// return nil
-// },
-// }))
-//
-// Example for Logrus (https://github.com/sirupsen/logrus)
-// log := logrus.New()
-// e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
-// LogURI: true,
-// LogStatus: true,
-// LogError: true,
-// HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
-// LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
-// if v.Error == nil {
-// log.WithFields(logrus.Fields{
-// "URI": v.URI,
-// "status": v.Status,
-// }).Info("request")
-// } else {
-// log.WithFields(logrus.Fields{
-// "URI": v.URI,
-// "status": v.Status,
-// "error": v.Error,
-// }).Error("request error")
-// }
-// return nil
-// },
-// }))
-
-// RequestLoggerConfig is configuration for Request Logger middleware.
-type RequestLoggerConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
-
- // BeforeNextFunc defines a function that is called before next middleware or handler is called in chain.
- BeforeNextFunc func(c echo.Context)
- // LogValuesFunc defines a function that is called with values extracted by logger from request/response.
- // Mandatory.
- LogValuesFunc func(c echo.Context, v RequestLoggerValues) error
-
- // HandleError instructs logger to call global error handler when next middleware/handler returns an error.
- // This is useful when you have custom error handler that can decide to use different status codes.
- //
- // A side-effect of calling global error handler is that now Response has been committed and sent to the client
- // and middlewares up in chain can not change Response status code or response body.
- HandleError bool
-
- // LogLatency instructs logger to record duration it took to execute rest of the handler chain (next(c) call).
- LogLatency bool
- // LogProtocol instructs logger to extract request protocol (i.e. `HTTP/1.1` or `HTTP/2`)
- LogProtocol bool
- // LogRemoteIP instructs logger to extract request remote IP. See `echo.Context.RealIP()` for implementation details.
- LogRemoteIP bool
- // LogHost instructs logger to extract request host value (i.e. `example.com`)
- LogHost bool
- // LogMethod instructs logger to extract request method value (i.e. `GET` etc)
- LogMethod bool
- // LogURI instructs logger to extract request URI (i.e. `/list?lang=en&page=1`)
- LogURI bool
- // LogURIPath instructs logger to extract request URI path part (i.e. `/list`)
- LogURIPath bool
- // LogRoutePath instructs logger to extract route path part to which request was matched to (i.e. `/user/:id`)
- LogRoutePath bool
- // LogRequestID instructs logger to extract request ID from request `X-Request-ID` header or response if request did not have value.
- LogRequestID bool
- // LogReferer instructs logger to extract request referer values.
- LogReferer bool
- // LogUserAgent instructs logger to extract request user agent values.
- LogUserAgent bool
- // LogStatus instructs logger to extract response status code. If handler chain returns an echo.HTTPError,
- // the status code is extracted from the echo.HTTPError returned
- LogStatus bool
- // LogError instructs logger to extract error returned from executed handler chain.
- LogError bool
- // LogContentLength instructs logger to extract content length header value. Note: this value could be different from
- // actual request body size as it could be spoofed etc.
- LogContentLength bool
- // LogResponseSize instructs logger to extract response content length value. Note: when used with Gzip middleware
- // this value may not be always correct.
- LogResponseSize bool
- // LogHeaders instructs logger to extract given list of headers from request. Note: request can contain more than
- // one header with same value so slice of values is been logger for each given header.
- //
- // Note: header values are converted to canonical form with http.CanonicalHeaderKey as this how request parser converts header
- // names to. For example, the canonical key for "accept-encoding" is "Accept-Encoding".
- LogHeaders []string
- // LogQueryParams instructs logger to extract given list of query parameters from request URI. Note: request can
- // contain more than one query parameter with same name so slice of values is been logger for each given query param name.
- LogQueryParams []string
- // LogFormValues instructs logger to extract given list of form values from request body+URI. Note: request can
- // contain more than one form value with same name so slice of values is been logger for each given form value name.
- LogFormValues []string
-
- timeNow func() time.Time
-}
-
-// RequestLoggerValues contains extracted values from logger.
-type RequestLoggerValues struct {
- // StartTime is time recorded before next middleware/handler is executed.
- StartTime time.Time
- // Latency is duration it took to execute rest of the handler chain (next(c) call).
- Latency time.Duration
- // Protocol is request protocol (i.e. `HTTP/1.1` or `HTTP/2`)
- Protocol string
- // RemoteIP is request remote IP. See `echo.Context.RealIP()` for implementation details.
- RemoteIP string
- // Host is request host value (i.e. `example.com`)
- Host string
- // Method is request method value (i.e. `GET` etc)
- Method string
- // URI is request URI (i.e. `/list?lang=en&page=1`)
- URI string
- // URIPath is request URI path part (i.e. `/list`)
- URIPath string
- // RoutePath is route path part to which request was matched to (i.e. `/user/:id`)
- RoutePath string
- // RequestID is request ID from request `X-Request-ID` header or response if request did not have value.
- RequestID string
- // Referer is request referer values.
- Referer string
- // UserAgent is request user agent values.
- UserAgent string
- // Status is response status code. Then handler returns an echo.HTTPError then code from there.
- Status int
- // Error is error returned from executed handler chain.
- Error error
- // ContentLength is content length header value. Note: this value could be different from actual request body size
- // as it could be spoofed etc.
- ContentLength string
- // ResponseSize is response content length value. Note: when used with Gzip middleware this value may not be always correct.
- ResponseSize int64
- // Headers are list of headers from request. Note: request can contain more than one header with same value so slice
- // of values is been logger for each given header.
- // Note: header values are converted to canonical form with http.CanonicalHeaderKey as this how request parser converts header
- // names to. For example, the canonical key for "accept-encoding" is "Accept-Encoding".
- Headers map[string][]string
- // QueryParams are list of query parameters from request URI. Note: request can contain more than one query parameter
- // with same name so slice of values is been logger for each given query param name.
- QueryParams map[string][]string
- // FormValues are list of form values from request body+URI. Note: request can contain more than one form value with
- // same name so slice of values is been logger for each given form value name.
- FormValues map[string][]string
-}
-
-// RequestLoggerWithConfig returns a RequestLogger middleware with config.
-func RequestLoggerWithConfig(config RequestLoggerConfig) echo.MiddlewareFunc {
- mw, err := config.ToMiddleware()
- if err != nil {
- panic(err)
- }
- return mw
-}
-
-// ToMiddleware converts RequestLoggerConfig into middleware or returns an error for invalid configuration.
-func (config RequestLoggerConfig) ToMiddleware() (echo.MiddlewareFunc, error) {
- if config.Skipper == nil {
- config.Skipper = DefaultSkipper
- }
- now := time.Now
- if config.timeNow != nil {
- now = config.timeNow
- }
-
- if config.LogValuesFunc == nil {
- return nil, errors.New("missing LogValuesFunc callback function for request logger middleware")
- }
-
- logHeaders := len(config.LogHeaders) > 0
- headers := append([]string(nil), config.LogHeaders...)
- for i, v := range headers {
- headers[i] = http.CanonicalHeaderKey(v)
- }
-
- logQueryParams := len(config.LogQueryParams) > 0
- logFormValues := len(config.LogFormValues) > 0
-
- return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
- if config.Skipper(c) {
- return next(c)
- }
-
- req := c.Request()
- res := c.Response()
- start := now()
-
- if config.BeforeNextFunc != nil {
- config.BeforeNextFunc(c)
- }
- err := next(c)
- if err != nil && config.HandleError {
- c.Error(err)
- }
-
- v := RequestLoggerValues{
- StartTime: start,
- }
- if config.LogLatency {
- v.Latency = now().Sub(start)
- }
- if config.LogProtocol {
- v.Protocol = req.Proto
- }
- if config.LogRemoteIP {
- v.RemoteIP = c.RealIP()
- }
- if config.LogHost {
- v.Host = req.Host
- }
- if config.LogMethod {
- v.Method = req.Method
- }
- if config.LogURI {
- v.URI = req.RequestURI
- }
- if config.LogURIPath {
- p := req.URL.Path
- if p == "" {
- p = "/"
- }
- v.URIPath = p
- }
- if config.LogRoutePath {
- v.RoutePath = c.Path()
- }
- if config.LogRequestID {
- id := req.Header.Get(echo.HeaderXRequestID)
- if id == "" {
- id = res.Header().Get(echo.HeaderXRequestID)
- }
- v.RequestID = id
- }
- if config.LogReferer {
- v.Referer = req.Referer()
- }
- if config.LogUserAgent {
- v.UserAgent = req.UserAgent()
- }
- if config.LogStatus {
- v.Status = res.Status
- if err != nil && !config.HandleError {
- // this block should not be executed in case of HandleError=true as the global error handler will decide
- // the status code. In that case status code could be different from what err contains.
- var httpErr *echo.HTTPError
- if errors.As(err, &httpErr) {
- v.Status = httpErr.Code
- }
- }
- }
- if config.LogError && err != nil {
- v.Error = err
- }
- if config.LogContentLength {
- v.ContentLength = req.Header.Get(echo.HeaderContentLength)
- }
- if config.LogResponseSize {
- v.ResponseSize = res.Size
- }
- if logHeaders {
- v.Headers = map[string][]string{}
- for _, header := range headers {
- if values, ok := req.Header[header]; ok {
- v.Headers[header] = values
- }
- }
- }
- if logQueryParams {
- queryParams := c.QueryParams()
- v.QueryParams = map[string][]string{}
- for _, param := range config.LogQueryParams {
- if values, ok := queryParams[param]; ok {
- v.QueryParams[param] = values
- }
- }
- }
- if logFormValues {
- v.FormValues = map[string][]string{}
- for _, formValue := range config.LogFormValues {
- if values, ok := req.Form[formValue]; ok {
- v.FormValues[formValue] = values
- }
- }
- }
-
- if errOnLog := config.LogValuesFunc(c, v); errOnLog != nil {
- return errOnLog
- }
-
- // in case of HandleError=true we are returning the error that we already have handled with global error handler
- // this is deliberate as this error could be useful for upstream middlewares and default global error handler
- // will ignore that error when it bubbles up in middleware chain.
- return err
- }
- }, nil
-}
diff --git a/vendor/github.com/labstack/echo/v4/middleware/rewrite.go b/vendor/github.com/labstack/echo/v4/middleware/rewrite.go
index 4c19cc1..e5b0a6b 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/rewrite.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/rewrite.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
@@ -9,33 +6,37 @@ import (
"github.com/labstack/echo/v4"
)
-// RewriteConfig defines the config for Rewrite middleware.
-type RewriteConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // RewriteConfig defines the config for Rewrite middleware.
+ RewriteConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // Rules defines the URL path rewrite rules. The values captured in asterisk can be
- // retrieved by index e.g. $1, $2 and so on.
- // Example:
- // "/old": "/new",
- // "/api/*": "/$1",
- // "/js/*": "/public/javascripts/$1",
- // "/users/*/orders/*": "/user/$1/order/$2",
- // Required.
- Rules map[string]string `yaml:"rules"`
+ // Rules defines the URL path rewrite rules. The values captured in asterisk can be
+ // retrieved by index e.g. $1, $2 and so on.
+ // Example:
+ // "/old": "/new",
+ // "/api/*": "/$1",
+ // "/js/*": "/public/javascripts/$1",
+ // "/users/*/orders/*": "/user/$1/order/$2",
+ // Required.
+ Rules map[string]string `yaml:"rules"`
- // RegexRules defines the URL path rewrite rules using regexp.Rexexp with captures
- // Every capture group in the values can be retrieved by index e.g. $1, $2 and so on.
- // Example:
- // "^/old/[0.9]+/": "/new",
- // "^/api/.+?/(.*)": "/v2/$1",
- RegexRules map[*regexp.Regexp]string `yaml:"-"`
-}
+ // RegexRules defines the URL path rewrite rules using regexp.Rexexp with captures
+ // Every capture group in the values can be retrieved by index e.g. $1, $2 and so on.
+ // Example:
+ // "^/old/[0.9]+/": "/new",
+ // "^/api/.+?/(.*)": "/v2/$1",
+ RegexRules map[*regexp.Regexp]string `yaml:"regex_rules"`
+ }
+)
-// DefaultRewriteConfig is the default Rewrite middleware config.
-var DefaultRewriteConfig = RewriteConfig{
- Skipper: DefaultSkipper,
-}
+var (
+ // DefaultRewriteConfig is the default Rewrite middleware config.
+ DefaultRewriteConfig = RewriteConfig{
+ Skipper: DefaultSkipper,
+ }
+)
// Rewrite returns a Rewrite middleware.
//
diff --git a/vendor/github.com/labstack/echo/v4/middleware/secure.go b/vendor/github.com/labstack/echo/v4/middleware/secure.go
index c904abf..6c40517 100644
--- a/vendor/github.com/labstack/echo/v4/middleware/secure.go
+++ b/vendor/github.com/labstack/echo/v4/middleware/secure.go
@@ -1,6 +1,3 @@
-// SPDX-License-Identifier: MIT
-// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
-
package middleware
import (
@@ -9,80 +6,84 @@ import (
"github.com/labstack/echo/v4"
)
-// SecureConfig defines the config for Secure middleware.
-type SecureConfig struct {
- // Skipper defines a function to skip middleware.
- Skipper Skipper
+type (
+ // SecureConfig defines the config for Secure middleware.
+ SecureConfig struct {
+ // Skipper defines a function to skip middleware.
+ Skipper Skipper
- // XSSProtection provides protection against cross-site scripting attack (XSS)
- // by setting the `X-XSS-Protection` header.
- // Optional. Default value "1; mode=block".
- XSSProtection string `yaml:"xss_protection"`
+ // XSSProtection provides protection against cross-site scripting attack (XSS)
+ // by setting the `X-XSS-Protection` header.
+ // Optional. Default value "1; mode=block".
+ XSSProtection string `yaml:"xss_protection"`
- // ContentTypeNosniff provides protection against overriding Content-Type
- // header by setting the `X-Content-Type-Options` header.
- // Optional. Default value "nosniff".
- ContentTypeNosniff string `yaml:"content_type_nosniff"`
+ // ContentTypeNosniff provides protection against overriding Content-Type
+ // header by setting the `X-Content-Type-Options` header.
+ // Optional. Default value "nosniff".
+ ContentTypeNosniff string `yaml:"content_type_nosniff"`
- // XFrameOptions can be used to indicate whether or not a browser should
- // be allowed to render a page in a ,