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/.github/actions/builder/action.yml b/.github/actions/builder/action.yml
deleted file mode 100644
index 28c0642..0000000
--- a/.github/actions/builder/action.yml
+++ /dev/null
@@ -1,16 +0,0 @@
----
-name: "builder"
-description: "builder"
-inputs:
- steps:
- description: "commands"
- require: true
- default: ""
-outputs: {}
-
-runs:
- using: "docker"
- image: "docker://golang:1.25"
- args:
- - ${{ inputs.steps }}
- entrypoint: /bin/sh -c
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
index 2221169..0000000
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,39 +0,0 @@
----
-name: build & test
-
-'on':
- push:
- branches:
- - '*'
-
-jobs:
- build:
- runs-on:
- - linux
- - amd64
- outputs:
- upload_url: ${{ steps.create_release.outputs.upload_url }}
- container:
- image: ghcr.io/catthehacker/ubuntu:act-24.04
- steps:
- - name: Checkout
- uses: actions/checkout@v6
- with:
- lfs: true
- - name: Cache
- id: pki-cache
- uses: actions/cache@v4
- with:
- path: go-build
- key: pki-${{ hashFiles('**/go.mod','**/go.sum') }}
- - name: Build
- uses: ./.github/actions/builder
- with:
- steps: |
- go generate cmd/pki/*.go
- go build -mod=vendor -o pki -v cmd/pki/*.go
- env:
- GOOS: linux
- GOARCH: amd64
- GOCACHE: ${{ forgejo.workspace }}/go-build
- VERSION: ${{ forgejo.ref_name }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
deleted file mode 100644
index f4a3caf..0000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,90 +0,0 @@
----
-name: build & release
-
-'on':
- push:
- tags:
- - '*'
- pull_request:
- branches:
- - master
-
-jobs:
- build:
- runs-on:
- - linux
- - ${{ matrix.arch }}
- strategy:
- matrix:
- os:
- - linux
- arch:
- - amd64
- - arm64
- - arm
- outputs:
- upload_url: ${{ steps.create_release.outputs.upload_url }}
- container:
- image: ghcr.io/catthehacker/ubuntu:act-24.04
- steps:
- - name: Checkout
- uses: actions/checkout@v6
- with:
- lfs: true
- - name: Cache
- id: pki-cache
- uses: actions/cache@v4
- with:
- path: go-build
- key: pki-${{ matrix.arch }}-${{ hashFiles('**/go.mod','**/go.sum') }}
- - name: Build pki
- uses: ./.github/actions/builder
- with:
- steps: |
- mkdir $GOARCH artifacts
- go generate cmd/pki/*.go
- go build -mod=vendor -o $GOARCH/pki -v cmd/pki/*.go
- env:
- GOOS: linux
- GOARCH: ${{ matrix.arch }}
- GOCACHE: ${{ forgejo.workspace }}/go-build
- VERSION: ${{ forgejo.ref_name }}
- - name: Create release archive
- if: startsWith(forgejo.ref, 'refs/tags/')
- run: |
- cd ${{ matrix.arch }}
- tar -czvf ../artifacts/pki-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz pki
- - name: Upload artifacts
- uses: actions/upload-artifact@v3
- if: startsWith(forgejo.ref, 'refs/tags/')
- with:
- name: pki-artifacts
- path: "artifacts/*"
- release:
- runs-on:
- - linux
- needs: [build]
- container:
- image: ghcr.io/catthehacker/ubuntu:act-24.04
- outputs:
- upload_url: ${{ steps.create_release.outputs.upload_url }}
- if: startsWith(forgejo.ref, 'refs/tags/')
- steps:
- - name: Download artifacts
- uses: actions/download-artifact@v3
- with:
- name: pki-artifacts
- path: artifacts
- - name: Create checksum files
- run: |
- cd artifacts
- sha256sum *.tar.gz > sha256sum.txt
- sha512sum *.tar.gz > sha512sum.txt
- - name: Create Release
- if: startsWith(forgejo.ref, 'refs/tags/')
- id: create_release
- uses: actions/forgejo-release@v2.7.3
- with:
- direction: upload
- release-dir: artifacts/
- title: "pki ${{ forgejo.ref_name }}"
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 611e21e..a4f6277 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,5 @@
# pki
-
-[](https://git.paulbsd.com/paulbsd/pki/actions)
+[](https://drone.paulbsd.com/paulbsd/pki)
## Summary
@@ -11,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
@@ -41,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 20f61f1..7eb1e93 100644
--- a/go.mod
+++ b/go.mod
@@ -1,43 +1,41 @@
module git.paulbsd.com/paulbsd/pki
-go 1.25
+go 1.17
require (
- github.com/go-acme/lego/v4 v4.29.0
- github.com/golang/snappy v1.0.0 // indirect
- github.com/labstack/echo/v4 v4.14.0
- github.com/lib/pq v1.10.9
- github.com/miekg/dns v1.1.69 // 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.46.0 // indirect
- golang.org/x/net v0.48.0 // indirect
- golang.org/x/sys v0.39.0 // indirect
- golang.org/x/text v0.32.0 // indirect
- golang.org/x/time v0.14.0 // indirect
- gopkg.in/ini.v1 v1.67.0
- xorm.io/builder v0.3.13 // indirect
- xorm.io/xorm v1.3.11
+ 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/cenkalti/backoff/v5 v5.0.3 // indirect
- github.com/go-jose/go-jose/v4 v4.1.3 // 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.13-0.20220915233716-71ac16282d12 // 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.31.0 // indirect
- golang.org/x/oauth2 v0.34.0 // indirect
- golang.org/x/sync v0.19.0 // indirect
- golang.org/x/tools v0.40.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 c614252..54d1601 100644
--- a/go.sum
+++ b/go.sum
@@ -1,49 +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/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
-github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
+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/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
+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-acme/lego/v4 v4.29.0 h1:vKMEtvoKb0gOO9rWO9zMBwE4CgI5A5CWDsK4QEeBqzo=
-github.com/go-acme/lego/v4 v4.29.0/go.mod h1:rnYyDj1NdDd9y1dHkVuUS97j7bfe9I61+oY9odKaHM8=
-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-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs=
-github.com/go-jose/go-jose/v4 v4.1.3/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
-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=
@@ -54,63 +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/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 h1:9Nu54bhS/H/Kgo2/7xNSUuC5G28VR8ljfrLKU2G4IjU=
-github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12/go.mod h1:TBzl5BIHNXfS9+C35ZyJaklL7mLDbgUkcgXzSLa8Tk0=
+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/echo/v4 v4.14.0 h1:+tiMrDLxwv6u0oKtD03mv+V1vXXB3wCqPHJqPuIe+7M=
-github.com/labstack/echo/v4 v4.14.0/go.mod h1:xmw1clThob0BSVRX1CRQkGQ/vjwcpOMjQZSZa9fKA/c=
-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/miekg/dns v1.1.68/go.mod h1:fujopn7TB3Pu3JM69XaawiU0wqjpL9/8xGop5UrTPps=
-github.com/miekg/dns v1.1.69 h1:Kb7Y/1Jo+SG+a2GtfoFUfDkG//csdRPwRLkCsxDG9Sc=
-github.com/miekg/dns v1.1.69/go.mod h1:7OyjD9nEba5OkqQ/hB4fy3PIoxafSZJtducccIelz3g=
+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=
@@ -121,199 +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.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+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.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
-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.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
-golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
-golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
+golang.org/x/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/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
-golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
-golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=
-golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=
+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/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
-golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
-golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
-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/oauth2 v0.33.0 h1:4Q+qn+E5z8gPRJfmRy7C2gGG3T4jIprK6aSYgTXGRpo=
-golang.org/x/oauth2 v0.33.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
-golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
-golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
+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.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
-golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
-golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
+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.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
-golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
-golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
+golang.org/x/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/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
-golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
-golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
-golang.org/x/time v0.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/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
-golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
+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/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
-golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
-golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
-golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
+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.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-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/libc v1.55.3 h1:AzcW1mhlPNrRtjS5sS+eW2ISCgSOLLNyFzRh/V3Qj/U=
-modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
-modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
-modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
-modernc.org/memory v1.4.0 h1:crykUfNSnMAXaOJnnxcSzbUGMqkLWjklJKkBK2nwZwk=
-modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
-modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
-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/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
-modernc.org/token v1.0.1 h1:A3qvTqOwexpfZZeyI0FeGPDlSWX5pjZu9hF4lU+EKWg=
-modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
-modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
-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=
-xorm.io/xorm v1.3.11 h1:i4tlVUASogb0ZZFJHA7dZqoRU2pUpUsutnNdaOlFyMI=
-xorm.io/xorm v1.3.11/go.mod h1:cs0ePc8O4a0jD78cNvD+0VFwhqotTvLQZv372QsDw7Q=
+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/v5/.gitignore b/vendor/github.com/cenkalti/backoff/v4/.gitignore
similarity index 100%
rename from vendor/github.com/cenkalti/backoff/v5/.gitignore
rename to vendor/github.com/cenkalti/backoff/v4/.gitignore
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/v5/LICENSE b/vendor/github.com/cenkalti/backoff/v4/LICENSE
similarity index 100%
rename from vendor/github.com/cenkalti/backoff/v5/LICENSE
rename to vendor/github.com/cenkalti/backoff/v4/LICENSE
diff --git a/vendor/github.com/cenkalti/backoff/v5/README.md b/vendor/github.com/cenkalti/backoff/v4/README.md
similarity index 58%
rename from vendor/github.com/cenkalti/backoff/v5/README.md
rename to vendor/github.com/cenkalti/backoff/v4/README.md
index 4611b1d..16abdfc 100644
--- a/vendor/github.com/cenkalti/backoff/v5/README.md
+++ b/vendor/github.com/cenkalti/backoff/v4/README.md
@@ -1,4 +1,4 @@
-# Exponential Backoff [![GoDoc][godoc image]][godoc]
+# 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].
@@ -9,11 +9,9 @@ The retries exponentially increase and stop increasing when a certain threshold
## Usage
-Import path is `github.com/cenkalti/backoff/v5`. Please note the version part at the end.
+Import path is `github.com/cenkalti/backoff/v4`. Please note the version part at the end.
-For most cases, use `Retry` function. See [example_test.go][example] for an example.
-
-If you have specific needs, copy `Retry` function (from [retry.go][retry-src]) into your code and modify it as needed.
+Use https://pkg.go.dev/github.com/cenkalti/backoff/v4 to view the documentation.
## Contributing
@@ -21,11 +19,14 @@ If you have specific needs, copy `Retry` function (from [retry.go][retry-src]) i
* Please don't send a PR without opening an issue and discussing it first.
* If proposed change is not a common use case, I will probably not accept it.
-[godoc]: https://pkg.go.dev/github.com/cenkalti/backoff/v5
+[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
[google-http-java-client]: https://github.com/google/google-http-java-client/blob/da1aa993e90285ec18579f1553339b00e19b3ab5/google-http-client/src/main/java/com/google/api/client/util/ExponentialBackOff.java
[exponential backoff wiki]: http://en.wikipedia.org/wiki/Exponential_backoff
-[retry-src]: https://github.com/cenkalti/backoff/blob/v5/retry.go
-[example]: https://github.com/cenkalti/backoff/blob/v5/example_test.go
+[advanced example]: https://pkg.go.dev/github.com/cenkalti/backoff/v4?tab=doc#pkg-examples
diff --git a/vendor/github.com/cenkalti/backoff/v5/backoff.go b/vendor/github.com/cenkalti/backoff/v4/backoff.go
similarity index 87%
rename from vendor/github.com/cenkalti/backoff/v5/backoff.go
rename to vendor/github.com/cenkalti/backoff/v4/backoff.go
index dd2b24c..3676ee4 100644
--- a/vendor/github.com/cenkalti/backoff/v5/backoff.go
+++ b/vendor/github.com/cenkalti/backoff/v4/backoff.go
@@ -15,16 +15,16 @@ import "time"
// BackOff is a backoff policy for retrying an operation.
type BackOff interface {
// NextBackOff returns the duration to wait before retrying the operation,
- // backoff.Stop to indicate that no more retries should be made.
+ // or backoff. Stop to indicate that no more retries should be made.
//
// Example usage:
//
- // duration := backoff.NextBackOff()
- // if duration == backoff.Stop {
- // // Do not retry operation.
- // } else {
- // // Sleep for duration and retry operation.
- // }
+ // duration := backoff.NextBackOff();
+ // if (duration == backoff.Stop) {
+ // // Do not retry operation.
+ // } else {
+ // // Sleep for duration and retry operation.
+ // }
//
NextBackOff() time.Duration
diff --git a/vendor/github.com/cenkalti/backoff/v4/context.go b/vendor/github.com/cenkalti/backoff/v4/context.go
new file mode 100644
index 0000000..4848233
--- /dev/null
+++ b/vendor/github.com/cenkalti/backoff/v4/context.go
@@ -0,0 +1,62 @@
+package backoff
+
+import (
+ "context"
+ "time"
+)
+
+// BackOffContext is a backoff policy that stops retrying after the context
+// is canceled.
+type BackOffContext interface { // nolint: golint
+ BackOff
+ Context() context.Context
+}
+
+type backOffContext struct {
+ BackOff
+ ctx context.Context
+}
+
+// WithContext returns a BackOffContext with context ctx
+//
+// ctx must not be nil
+func WithContext(b BackOff, ctx context.Context) BackOffContext { // nolint: golint
+ if ctx == nil {
+ panic("nil context")
+ }
+
+ if b, ok := b.(*backOffContext); ok {
+ return &backOffContext{
+ BackOff: b.BackOff,
+ ctx: ctx,
+ }
+ }
+
+ return &backOffContext{
+ BackOff: b,
+ ctx: ctx,
+ }
+}
+
+func getContext(b BackOff) context.Context {
+ if cb, ok := b.(BackOffContext); ok {
+ return cb.Context()
+ }
+ if tb, ok := b.(*backOffTries); ok {
+ return getContext(tb.delegate)
+ }
+ return context.Background()
+}
+
+func (b *backOffContext) Context() context.Context {
+ return b.ctx
+}
+
+func (b *backOffContext) NextBackOff() time.Duration {
+ select {
+ case <-b.ctx.Done():
+ return Stop
+ default:
+ return b.BackOff.NextBackOff()
+ }
+}
diff --git a/vendor/github.com/cenkalti/backoff/v5/exponential.go b/vendor/github.com/cenkalti/backoff/v4/exponential.go
similarity index 54%
rename from vendor/github.com/cenkalti/backoff/v5/exponential.go
rename to vendor/github.com/cenkalti/backoff/v4/exponential.go
index 79d425e..3d34532 100644
--- a/vendor/github.com/cenkalti/backoff/v5/exponential.go
+++ b/vendor/github.com/cenkalti/backoff/v4/exponential.go
@@ -1,7 +1,7 @@
package backoff
import (
- "math/rand/v2"
+ "math/rand"
"time"
)
@@ -11,36 +11,43 @@ period for each retry attempt using a randomization function that grows exponent
NextBackOff() is calculated using the following formula:
- randomized interval =
- RetryInterval * (random value in range [1 - RandomizationFactor, 1 + RandomizationFactor])
+ randomized interval =
+ RetryInterval * (random value in range [1 - RandomizationFactor, 1 + RandomizationFactor])
In other words NextBackOff() will range between the randomization factor
percentage below and above the retry interval.
For example, given the following parameters:
- RetryInterval = 2
- RandomizationFactor = 0.5
- Multiplier = 2
+ RetryInterval = 2
+ RandomizationFactor = 0.5
+ Multiplier = 2
the actual backoff period used in the next retry attempt will range between 1 and 3 seconds,
multiplied by the exponential, that is, between 2 and 6 seconds.
Note: MaxInterval caps the RetryInterval and not the randomized interval.
-Example: Given the following default arguments, for 9 tries the sequence will be:
+If the time elapsed since an ExponentialBackOff instance is created goes past the
+MaxElapsedTime, then the method NextBackOff() starts returning backoff.Stop.
- Request # RetryInterval (seconds) Randomized Interval (seconds)
+The elapsed time can be reset by calling Reset().
- 1 0.5 [0.25, 0.75]
- 2 0.75 [0.375, 1.125]
- 3 1.125 [0.562, 1.687]
- 4 1.687 [0.8435, 2.53]
- 5 2.53 [1.265, 3.795]
- 6 3.795 [1.897, 5.692]
- 7 5.692 [2.846, 8.538]
- 8 8.538 [4.269, 12.807]
- 9 12.807 [6.403, 19.210]
+Example: Given the following default arguments, for 10 tries the sequence will be,
+and assuming we go over the MaxElapsedTime on the 10th try:
+
+ Request # RetryInterval (seconds) Randomized Interval (seconds)
+
+ 1 0.5 [0.25, 0.75]
+ 2 0.75 [0.375, 1.125]
+ 3 1.125 [0.562, 1.687]
+ 4 1.687 [0.8435, 2.53]
+ 5 2.53 [1.265, 3.795]
+ 6 3.795 [1.897, 5.692]
+ 7 5.692 [2.846, 8.538]
+ 8 8.538 [4.269, 12.807]
+ 9 12.807 [6.403, 19.210]
+ 10 19.210 backoff.Stop
Note: Implementation is not thread-safe.
*/
@@ -49,8 +56,19 @@ type ExponentialBackOff struct {
RandomizationFactor float64
Multiplier float64
MaxInterval time.Duration
+ // After MaxElapsedTime the ExponentialBackOff returns Stop.
+ // It never stops if MaxElapsedTime == 0.
+ MaxElapsedTime time.Duration
+ Stop time.Duration
+ Clock Clock
currentInterval time.Duration
+ startTime time.Time
+}
+
+// Clock is an interface that returns current time for BackOff.
+type Clock interface {
+ Now() time.Time
}
// Default values for ExponentialBackOff.
@@ -59,37 +77,63 @@ const (
DefaultRandomizationFactor = 0.5
DefaultMultiplier = 1.5
DefaultMaxInterval = 60 * time.Second
+ DefaultMaxElapsedTime = 15 * time.Minute
)
// NewExponentialBackOff creates an instance of ExponentialBackOff using default values.
func NewExponentialBackOff() *ExponentialBackOff {
- return &ExponentialBackOff{
+ b := &ExponentialBackOff{
InitialInterval: DefaultInitialInterval,
RandomizationFactor: DefaultRandomizationFactor,
Multiplier: DefaultMultiplier,
MaxInterval: DefaultMaxInterval,
+ MaxElapsedTime: DefaultMaxElapsedTime,
+ Stop: Stop,
+ Clock: SystemClock,
}
+ b.Reset()
+ return b
}
+type systemClock struct{}
+
+func (t systemClock) Now() time.Time {
+ return time.Now()
+}
+
+// SystemClock implements Clock interface that uses time.Now().
+var SystemClock = systemClock{}
+
// Reset the interval back to the initial retry interval and restarts the timer.
// Reset must be called before using b.
func (b *ExponentialBackOff) Reset() {
b.currentInterval = b.InitialInterval
+ b.startTime = b.Clock.Now()
}
// NextBackOff calculates the next backoff interval using the formula:
-//
-// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
+// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
func (b *ExponentialBackOff) NextBackOff() time.Duration {
- if b.currentInterval == 0 {
- b.currentInterval = b.InitialInterval
- }
-
+ // Make sure we have not gone over the maximum elapsed time.
+ elapsed := b.GetElapsedTime()
next := getRandomValueFromInterval(b.RandomizationFactor, rand.Float64(), b.currentInterval)
b.incrementCurrentInterval()
+ if b.MaxElapsedTime != 0 && elapsed+next > b.MaxElapsedTime {
+ return b.Stop
+ }
return next
}
+// GetElapsedTime returns the elapsed time since an ExponentialBackOff instance
+// is created and is reset when Reset() is called.
+//
+// The elapsed time is computed using time.Now().UnixNano(). It is
+// safe to call even while the backoff policy is used by a running
+// ticker.
+func (b *ExponentialBackOff) GetElapsedTime() time.Duration {
+ return b.Clock.Now().Sub(b.startTime)
+}
+
// Increments the current interval by multiplying it with the multiplier.
func (b *ExponentialBackOff) incrementCurrentInterval() {
// Check for overflow, if overflow is detected set the current interval to the max interval.
@@ -101,12 +145,8 @@ func (b *ExponentialBackOff) incrementCurrentInterval() {
}
// Returns a random value from the following interval:
-//
-// [currentInterval - randomizationFactor * currentInterval, currentInterval + randomizationFactor * currentInterval].
+// [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
new file mode 100644
index 0000000..1ce2507
--- /dev/null
+++ b/vendor/github.com/cenkalti/backoff/v4/retry.go
@@ -0,0 +1,112 @@
+package backoff
+
+import (
+ "errors"
+ "time"
+)
+
+// 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
+
+// Notify is a notify-on-error function. It receives an operation error and
+// backoff delay if the operation failed (with an error).
+//
+// NOTE that if the backoff policy stated to stop retrying,
+// the notify function isn't called.
+type Notify func(error, time.Duration)
+
+// Retry the operation o until it does not return error or BackOff stops.
+// o is guaranteed to be run at least once.
+//
+// If o returns a *PermanentError, the operation is not retried, and the
+// wrapped error is returned.
+//
+// Retry sleeps the goroutine for the duration returned by BackOff after a
+// failed operation returns.
+func Retry(o Operation, b BackOff) error {
+ return RetryNotify(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)
+}
+
+// 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 {
+ var err error
+ var next time.Duration
+ if t == nil {
+ t = &defaultTimer{}
+ }
+
+ defer func() {
+ t.Stop()
+ }()
+
+ ctx := getContext(b)
+
+ b.Reset()
+ for {
+ if err = operation(); err == nil {
+ return nil
+ }
+
+ var permanent *PermanentError
+ if errors.As(err, &permanent) {
+ return permanent.Err
+ }
+
+ if next = b.NextBackOff(); next == Stop {
+ if cerr := ctx.Err(); cerr != nil {
+ return cerr
+ }
+
+ return err
+ }
+
+ if notify != nil {
+ notify(err, next)
+ }
+
+ t.Start(next)
+
+ select {
+ case <-ctx.Done():
+ return ctx.Err()
+ case <-t.C():
+ }
+ }
+}
+
+// PermanentError signals that the operation should not be retried.
+type PermanentError struct {
+ Err error
+}
+
+func (e *PermanentError) Error() string {
+ return e.Err.Error()
+}
+
+func (e *PermanentError) Unwrap() error {
+ return e.Err
+}
+
+func (e *PermanentError) Is(target error) bool {
+ _, ok := target.(*PermanentError)
+ return ok
+}
+
+// Permanent wraps the given err in a *PermanentError.
+func Permanent(err error) error {
+ if err == nil {
+ return nil
+ }
+ return &PermanentError{
+ Err: err,
+ }
+}
diff --git a/vendor/github.com/cenkalti/backoff/v5/ticker.go b/vendor/github.com/cenkalti/backoff/v4/ticker.go
similarity index 80%
rename from vendor/github.com/cenkalti/backoff/v5/ticker.go
rename to vendor/github.com/cenkalti/backoff/v4/ticker.go
index f0d4b2a..df9d68b 100644
--- a/vendor/github.com/cenkalti/backoff/v5/ticker.go
+++ b/vendor/github.com/cenkalti/backoff/v4/ticker.go
@@ -1,6 +1,7 @@
package backoff
import (
+ "context"
"sync"
"time"
)
@@ -13,7 +14,8 @@ type Ticker struct {
C <-chan time.Time
c chan time.Time
b BackOff
- timer timer
+ ctx context.Context
+ timer Timer
stop chan struct{}
stopOnce sync.Once
}
@@ -25,12 +27,22 @@ type Ticker struct {
// provided backoff policy (notably calling NextBackOff or Reset)
// while the ticker is running.
func NewTicker(b BackOff) *Ticker {
+ return NewTickerWithTimer(b, &defaultTimer{})
+}
+
+// NewTickerWithTimer returns a new Ticker with a custom timer.
+// A default timer that uses system timer is used when nil is passed.
+func NewTickerWithTimer(b BackOff, timer Timer) *Ticker {
+ if timer == nil {
+ timer = &defaultTimer{}
+ }
c := make(chan time.Time)
t := &Ticker{
C: c,
c: c,
b: b,
- timer: &defaultTimer{},
+ ctx: getContext(b),
+ timer: timer,
stop: make(chan struct{}),
}
t.b.Reset()
@@ -61,6 +73,8 @@ func (t *Ticker) run() {
case <-t.stop:
t.c = nil // Prevent future ticks from being sent to the channel.
return
+ case <-t.ctx.Done():
+ return
}
}
}
diff --git a/vendor/github.com/cenkalti/backoff/v5/timer.go b/vendor/github.com/cenkalti/backoff/v4/timer.go
similarity index 96%
rename from vendor/github.com/cenkalti/backoff/v5/timer.go
rename to vendor/github.com/cenkalti/backoff/v4/timer.go
index a895309..8120d02 100644
--- a/vendor/github.com/cenkalti/backoff/v5/timer.go
+++ b/vendor/github.com/cenkalti/backoff/v4/timer.go
@@ -2,7 +2,7 @@ package backoff
import "time"
-type timer interface {
+type Timer interface {
Start(duration time.Duration)
Stop()
C() <-chan time.Time
diff --git a/vendor/github.com/cenkalti/backoff/v4/tries.go b/vendor/github.com/cenkalti/backoff/v4/tries.go
new file mode 100644
index 0000000..28d58ca
--- /dev/null
+++ b/vendor/github.com/cenkalti/backoff/v4/tries.go
@@ -0,0 +1,38 @@
+package backoff
+
+import "time"
+
+/*
+WithMaxRetries creates a wrapper around another BackOff, which will
+return Stop if NextBackOff() has been called too many times since
+the last time Reset() was called
+
+Note: Implementation is not thread-safe.
+*/
+func WithMaxRetries(b BackOff, max uint64) BackOff {
+ return &backOffTries{delegate: b, maxTries: max}
+}
+
+type backOffTries struct {
+ delegate BackOff
+ maxTries uint64
+ numTries uint64
+}
+
+func (b *backOffTries) NextBackOff() time.Duration {
+ if b.maxTries == 0 {
+ return Stop
+ }
+ if b.maxTries > 0 {
+ if b.maxTries <= b.numTries {
+ return Stop
+ }
+ b.numTries++
+ }
+ return b.delegate.NextBackOff()
+}
+
+func (b *backOffTries) Reset() {
+ b.numTries = 0
+ b.delegate.Reset()
+}
diff --git a/vendor/github.com/cenkalti/backoff/v5/CHANGELOG.md b/vendor/github.com/cenkalti/backoff/v5/CHANGELOG.md
deleted file mode 100644
index 658c374..0000000
--- a/vendor/github.com/cenkalti/backoff/v5/CHANGELOG.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# Changelog
-
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [5.0.0] - 2024-12-19
-
-### Added
-
-- RetryAfterError can be returned from an operation to indicate how long to wait before the next retry.
-
-### Changed
-
-- Retry function now accepts additional options for specifying max number of tries and max elapsed time.
-- Retry function now accepts a context.Context.
-- Operation function signature changed to return result (any type) and error.
-
-### Removed
-
-- RetryNotify* and RetryWithData functions. Only single Retry function remains.
-- Optional arguments from ExponentialBackoff constructor.
-- Clock and Timer interfaces.
-
-### Fixed
-
-- The original error is returned from Retry if there's a PermanentError. (#144)
-- The Retry function respects the wrapped PermanentError. (#140)
diff --git a/vendor/github.com/cenkalti/backoff/v5/error.go b/vendor/github.com/cenkalti/backoff/v5/error.go
deleted file mode 100644
index beb2b38..0000000
--- a/vendor/github.com/cenkalti/backoff/v5/error.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package backoff
-
-import (
- "fmt"
- "time"
-)
-
-// PermanentError signals that the operation should not be retried.
-type PermanentError struct {
- Err error
-}
-
-// Permanent wraps the given err in a *PermanentError.
-func Permanent(err error) error {
- if err == nil {
- return nil
- }
- return &PermanentError{
- Err: err,
- }
-}
-
-// Error returns a string representation of the Permanent error.
-func (e *PermanentError) Error() string {
- return e.Err.Error()
-}
-
-// Unwrap returns the wrapped error.
-func (e *PermanentError) Unwrap() error {
- return e.Err
-}
-
-// RetryAfterError signals that the operation should be retried after the given duration.
-type RetryAfterError struct {
- Duration time.Duration
-}
-
-// RetryAfter returns a RetryAfter error that specifies how long to wait before retrying.
-func RetryAfter(seconds int) error {
- return &RetryAfterError{Duration: time.Duration(seconds) * time.Second}
-}
-
-// Error returns a string representation of the RetryAfter error.
-func (e *RetryAfterError) Error() string {
- return fmt.Sprintf("retry after %s", e.Duration)
-}
diff --git a/vendor/github.com/cenkalti/backoff/v5/retry.go b/vendor/github.com/cenkalti/backoff/v5/retry.go
deleted file mode 100644
index 32a7f98..0000000
--- a/vendor/github.com/cenkalti/backoff/v5/retry.go
+++ /dev/null
@@ -1,139 +0,0 @@
-package backoff
-
-import (
- "context"
- "errors"
- "time"
-)
-
-// DefaultMaxElapsedTime sets a default limit for the total retry duration.
-const DefaultMaxElapsedTime = 15 * time.Minute
-
-// Operation is a function that attempts an operation and may be retried.
-type Operation[T any] func() (T, error)
-
-// Notify is a function called on operation error with the error and backoff duration.
-type Notify func(error, time.Duration)
-
-// retryOptions holds configuration settings for the retry mechanism.
-type retryOptions struct {
- BackOff BackOff // Strategy for calculating backoff periods.
- Timer timer // Timer to manage retry delays.
- Notify Notify // Optional function to notify on each retry error.
- MaxTries uint // Maximum number of retry attempts.
- MaxElapsedTime time.Duration // Maximum total time for all retries.
-}
-
-type RetryOption func(*retryOptions)
-
-// WithBackOff configures a custom backoff strategy.
-func WithBackOff(b BackOff) RetryOption {
- return func(args *retryOptions) {
- args.BackOff = b
- }
-}
-
-// withTimer sets a custom timer for managing delays between retries.
-func withTimer(t timer) RetryOption {
- return func(args *retryOptions) {
- args.Timer = t
- }
-}
-
-// WithNotify sets a notification function to handle retry errors.
-func WithNotify(n Notify) RetryOption {
- return func(args *retryOptions) {
- args.Notify = n
- }
-}
-
-// WithMaxTries limits the number of all attempts.
-func WithMaxTries(n uint) RetryOption {
- return func(args *retryOptions) {
- args.MaxTries = n
- }
-}
-
-// WithMaxElapsedTime limits the total duration for retry attempts.
-func WithMaxElapsedTime(d time.Duration) RetryOption {
- return func(args *retryOptions) {
- args.MaxElapsedTime = d
- }
-}
-
-// Retry attempts the operation until success, a permanent error, or backoff completion.
-// It ensures the operation is executed at least once.
-//
-// Returns the operation result or error if retries are exhausted or context is cancelled.
-func Retry[T any](ctx context.Context, operation Operation[T], opts ...RetryOption) (T, error) {
- // Initialize default retry options.
- args := &retryOptions{
- BackOff: NewExponentialBackOff(),
- Timer: &defaultTimer{},
- MaxElapsedTime: DefaultMaxElapsedTime,
- }
-
- // Apply user-provided options to the default settings.
- for _, opt := range opts {
- opt(args)
- }
-
- defer args.Timer.Stop()
-
- startedAt := time.Now()
- args.BackOff.Reset()
- for numTries := uint(1); ; numTries++ {
- // Execute the operation.
- res, err := operation()
- if err == nil {
- return res, nil
- }
-
- // Stop retrying if maximum tries exceeded.
- if args.MaxTries > 0 && numTries >= args.MaxTries {
- return res, err
- }
-
- // Handle permanent errors without retrying.
- var permanent *PermanentError
- if errors.As(err, &permanent) {
- return res, permanent.Unwrap()
- }
-
- // Stop retrying if context is cancelled.
- if cerr := context.Cause(ctx); cerr != nil {
- return res, cerr
- }
-
- // Calculate next backoff duration.
- next := args.BackOff.NextBackOff()
- if next == Stop {
- return res, err
- }
-
- // Reset backoff if RetryAfterError is encountered.
- var retryAfter *RetryAfterError
- if errors.As(err, &retryAfter) {
- next = retryAfter.Duration
- args.BackOff.Reset()
- }
-
- // Stop retrying if maximum elapsed time exceeded.
- if args.MaxElapsedTime > 0 && time.Since(startedAt)+next > args.MaxElapsedTime {
- return res, err
- }
-
- // Notify on error if a notifier function is provided.
- if args.Notify != nil {
- args.Notify(err, next)
- }
-
- // Wait for the next backoff period or context cancellation.
- args.Timer.Start(next)
- select {
- case <-args.Timer.C():
- case <-ctx.Done():
- return res, context.Cause(ctx)
- }
- }
-}
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 62e5ef9..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
@@ -13,11 +13,10 @@ type AccountService service
// New Creates a new account.
func (a *AccountService) New(req acme.Account) (acme.ExtendedAccount, error) {
var account acme.Account
-
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)
}
@@ -30,9 +29,9 @@ func (a *AccountService) New(req acme.Account) (acme.ExtendedAccount, error) {
// NewEAB Creates a new account with an External Account Binding.
func (a *AccountService) NewEAB(accMsg acme.Account, kid, hmacEncoded string) (acme.ExtendedAccount, error) {
- hmac, err := decodeEABHmac(hmacEncoded)
+ hmac, err := base64.RawURLEncoding.DecodeString(hmacEncoded)
if err != nil {
- return acme.ExtendedAccount{}, err
+ return acme.ExtendedAccount{}, fmt.Errorf("acme: could not decode hmac key: %w", err)
}
eabJWS, err := a.core.signEABContent(a.core.GetDirectory().NewAccountURL, kid, hmac)
@@ -52,12 +51,10 @@ func (a *AccountService) Get(accountURL string) (acme.Account, error) {
}
var account acme.Account
-
_, err := a.core.postAsGet(accountURL, &account)
if err != nil {
return acme.Account{}, err
}
-
return account, nil
}
@@ -68,7 +65,6 @@ func (a *AccountService) Update(accountURL string, req acme.Account) (acme.Accou
}
var account acme.Account
-
_, err := a.core.post(accountURL, req, &account)
if err != nil {
return acme.Account{}, err
@@ -85,20 +81,5 @@ func (a *AccountService) Deactivate(accountURL string) error {
req := acme.Account{Status: acme.StatusDeactivated}
_, err := a.core.post(accountURL, req, nil)
-
return err
}
-
-func decodeEABHmac(hmacEncoded string) ([]byte, error) {
- hmac, errRaw := base64.RawURLEncoding.DecodeString(hmacEncoded)
- if errRaw == nil {
- return hmac, nil
- }
-
- hmac, err := base64.URLEncoding.DecodeString(hmacEncoded)
- if err == nil {
- return hmac, nil
- }
-
- return nil, fmt.Errorf("acme: could not decode hmac key: %w", errors.Join(errRaw, err))
-}
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 da1c94d..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
@@ -10,7 +10,7 @@ import (
"net/http"
"time"
- "github.com/cenkalti/backoff/v5"
+ "github.com/cenkalti/backoff/v4"
"github.com/go-acme/lego/v4/acme"
"github.com/go-acme/lego/v4/acme/api/internal/nonces"
"github.com/go-acme/lego/v4/acme/api/internal/secure"
@@ -61,7 +61,7 @@ func New(httpClient *http.Client, userAgent, caDirURL, kid string, privateKey cr
// post performs an HTTP POST request and parses the response body as JSON,
// into the provided respBody object.
-func (a *Core) post(uri string, reqBody, response any) (*http.Response, error) {
+func (a *Core) post(uri string, reqBody, response interface{}) (*http.Response, error) {
content, err := json.Marshal(reqBody)
if err != nil {
return nil, errors.New("failed to marshal message")
@@ -71,51 +71,57 @@ func (a *Core) post(uri string, reqBody, response any) (*http.Response, error) {
}
// postAsGet performs an HTTP POST ("POST-as-GET") request.
-// https://www.rfc-editor.org/rfc/rfc8555.html#section-6.3
-func (a *Core) postAsGet(uri string, response any) (*http.Response, error) {
+// 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)
}
-func (a *Core) retrievablePost(uri string, content []byte, response any) (*http.Response, error) {
- ctx := context.Background()
-
+func (a *Core) retrievablePost(uri string, content []byte, response interface{}) (*http.Response, error) {
// during tests, allow to support ~90% of bad nonce with a minimum of attempts.
bo := backoff.NewExponentialBackOff()
bo.InitialInterval = 200 * time.Millisecond
bo.MaxInterval = 5 * time.Second
+ bo.MaxElapsedTime = 20 * time.Second
- operation := func() (*http.Response, error) {
- resp, err := a.signedPost(uri, content, response)
+ ctx, cancel := context.WithCancel(context.Background())
+
+ var resp *http.Response
+ operation := func() error {
+ var err error
+ resp, err = a.signedPost(uri, content, response)
if err != nil {
// Retry if the nonce was invalidated
var e *acme.NonceError
if errors.As(err, &e) {
- return resp, err
+ return err
}
- return resp, backoff.Permanent(err)
+ cancel()
+ return err
}
- return resp, nil
+ return nil
}
notify := func(err error, duration time.Duration) {
log.Infof("retry due to: %v", err)
}
- return backoff.Retry(ctx, operation,
- backoff.WithBackOff(bo),
- backoff.WithMaxElapsedTime(20*time.Second),
- backoff.WithNotify(notify))
+ err := backoff.RetryNotify(operation, backoff.WithContext(bo, ctx), notify)
+ if err != nil {
+ return resp, err
+ }
+
+ return resp, nil
}
-func (a *Core) signedPost(uri string, content []byte, response any) (*http.Response, error) {
+func (a *Core) signedPost(uri string, content []byte, response interface{}) (*http.Response, error) {
signedContent, err := a.jws.SignContent(uri, content)
if err != nil {
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)
@@ -155,7 +161,6 @@ func getDirectory(do *sender.Doer, caDirURL string) (acme.Directory, error) {
if dir.NewAccountURL == "" {
return dir, errors.New("directory missing new registration URL")
}
-
if dir.NewOrderURL == "" {
return dir, errors.New("directory missing new order URL")
}
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/authorization.go b/vendor/github.com/go-acme/lego/v4/acme/api/authorization.go
index 4195bd1..a9972aa 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/authorization.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/authorization.go
@@ -15,12 +15,10 @@ func (c *AuthorizationService) Get(authzURL string) (acme.Authorization, error)
}
var authz acme.Authorization
-
_, err := c.core.postAsGet(authzURL, &authz)
if err != nil {
return acme.Authorization{}, err
}
-
return authz, nil
}
@@ -31,8 +29,6 @@ func (c *AuthorizationService) Deactivate(authzURL string) error {
}
var disabledAuth acme.Authorization
-
_, err := c.core.post(authzURL, acme.Authorization{Status: acme.StatusDeactivated}, &disabledAuth)
-
return err
}
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 b422967..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,13 +1,15 @@
package api
import (
- "bytes"
+ "crypto/x509"
"encoding/pem"
"errors"
- "io"
+ "io/ioutil"
"net/http"
"github.com/go-acme/lego/v4/acme"
+ "github.com/go-acme/lego/v4/certcrypto"
+ "github.com/go-acme/lego/v4/log"
)
// maxBodySize is the maximum size of body that we will read.
@@ -37,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 {
@@ -69,27 +71,62 @@ 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
}
- cert := c.getCertificateChain(data, bundle)
+ cert := c.getCertificateChain(data, resp.Header, bundle, certURL)
return cert, resp.Header, err
}
// getCertificateChain Returns the certificate and the issuer certificate.
-func (c *CertificateService) getCertificateChain(cert []byte, bundle bool) *acme.RawCertificate {
+func (c *CertificateService) getCertificateChain(cert []byte, headers http.Header, bundle bool, certURL string) *acme.RawCertificate {
// Get issuerCert from bundled response from Let's Encrypt
// See https://community.letsencrypt.org/t/acme-v2-no-up-link-in-response/64962
_, issuer := pem.Decode(cert)
+ if issuer != nil {
+ return &acme.RawCertificate{Cert: cert, Issuer: issuer}
+ }
- // 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)
+ // The issuer certificate link may be supplied via an "up" link
+ // in the response headers of a new certificate.
+ // See https://tools.ietf.org/html/rfc8555#section-7.4.2
+ up := getLink(headers, "up")
+
+ issuer, err := c.getIssuerFromLink(up)
+ if err != nil {
+ // If we fail to acquire the issuer cert, return the issued certificate - do not fail.
+ log.Warnf("acme: Could not bundle issuer certificate [%s]: %v", certURL, err)
+ } else if len(issuer) > 0 {
+ // If bundle is true, we want to return a certificate bundle.
+ // To do this, we append the issuer cert to the issued cert.
+ if bundle {
+ cert = append(cert, issuer...)
+ }
}
return &acme.RawCertificate{Cert: cert, Issuer: issuer}
}
+
+// getIssuerFromLink requests the issuer certificate.
+func (c *CertificateService) getIssuerFromLink(up string) ([]byte, error) {
+ if up == "" {
+ return nil, nil
+ }
+
+ log.Infof("acme: Requesting issuer cert from %s", up)
+
+ cert, _, err := c.get(up, false)
+ if err != nil {
+ return nil, err
+ }
+
+ _, err = x509.ParseCertificate(cert.Cert)
+ if err != nil {
+ return nil, err
+ }
+
+ return certcrypto.PEMEncode(certcrypto.DERCertificateBytes(cert.Cert)), nil
+}
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/challenge.go b/vendor/github.com/go-acme/lego/v4/acme/api/challenge.go
index 2af55fc..875dede 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/challenge.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/challenge.go
@@ -17,7 +17,6 @@ func (c *ChallengeService) New(chlgURL string) (acme.ExtendedChallenge, error) {
// Challenge initiation is done by sending a JWS payload containing the trivial JSON object `{}`.
// We use an empty struct instance as the postJSON payload here to achieve this result.
var chlng acme.ExtendedChallenge
-
resp, err := c.core.post(chlgURL, struct{}{}, &chlng)
if err != nil {
return acme.ExtendedChallenge{}, err
@@ -25,7 +24,6 @@ func (c *ChallengeService) New(chlgURL string) (acme.ExtendedChallenge, error) {
chlng.AuthorizationURL = getLink(resp.Header, "up")
chlng.RetryAfter = getRetryAfter(resp)
-
return chlng, nil
}
@@ -36,7 +34,6 @@ func (c *ChallengeService) Get(chlgURL string) (acme.ExtendedChallenge, error) {
}
var chlng acme.ExtendedChallenge
-
resp, err := c.core.postAsGet(chlgURL, &chlng)
if err != nil {
return acme.ExtendedChallenge{}, err
@@ -44,6 +41,5 @@ func (c *ChallengeService) Get(chlgURL string) (acme.ExtendedChallenge, error) {
chlng.AuthorizationURL = getLink(resp.Header, "up")
chlng.RetryAfter = getRetryAfter(resp)
-
return chlng, nil
}
diff --git a/vendor/github.com/go-acme/lego/v4/acme/api/identifier.go b/vendor/github.com/go-acme/lego/v4/acme/api/identifier.go
deleted file mode 100644
index 42a8fd3..0000000
--- a/vendor/github.com/go-acme/lego/v4/acme/api/identifier.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package api
-
-import (
- "cmp"
- "maps"
- "net"
- "slices"
-
- "github.com/go-acme/lego/v4/acme"
-)
-
-func createIdentifiers(domains []string) []acme.Identifier {
- uniqIdentifiers := make(map[string]acme.Identifier)
-
- for _, domain := range domains {
- if _, ok := uniqIdentifiers[domain]; ok {
- continue
- }
-
- ident := acme.Identifier{Value: domain, Type: "dns"}
-
- if net.ParseIP(domain) != nil {
- ident.Type = "ip"
- }
-
- uniqIdentifiers[domain] = ident
- }
-
- return slices.AppendSeq(make([]acme.Identifier, 0, len(uniqIdentifiers)), maps.Values(uniqIdentifiers))
-}
-
-// compareIdentifiers compares 2 slices of [acme.Identifier].
-func compareIdentifiers(a, b []acme.Identifier) int {
- // Clones slices to avoid modifying original slices.
- right := slices.Clone(a)
- left := slices.Clone(b)
-
- slices.SortStableFunc(right, compareIdentifier)
- slices.SortStableFunc(left, compareIdentifier)
-
- return slices.CompareFunc(right, left, compareIdentifier)
-}
-
-func compareIdentifier(right, left acme.Identifier) int {
- return cmp.Or(
- cmp.Compare(right.Type, left.Type),
- cmp.Compare(right.Value, left.Value),
- )
-}
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 04a4ac6..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
@@ -11,11 +11,10 @@ import (
// Manager Manages nonces.
type Manager struct {
- sync.Mutex
-
do *sender.Doer
nonceURL string
nonces []string
+ sync.Mutex
}
// NewManager Creates a new Manager.
@@ -37,7 +36,6 @@ func (n *Manager) Pop() (string, bool) {
nonce := n.nonces[len(n.nonces)-1]
n.nonces = n.nonces[:len(n.nonces)-1]
-
return nonce, true
}
@@ -45,7 +43,6 @@ func (n *Manager) Pop() (string, bool) {
func (n *Manager) Push(nonce string) {
n.Lock()
defer n.Unlock()
-
n.nonces = append(n.nonces, nonce)
}
@@ -54,7 +51,6 @@ func (n *Manager) Nonce() (string, error) {
if nonce, ok := n.Pop(); ok {
return nonce, nil
}
-
return n.getNonce()
}
@@ -67,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 8cd5986..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.
@@ -36,7 +36,6 @@ func (j *JWS) SetKid(kid string) {
// SignContent Signs a content with the JWS.
func (j *JWS) SignContent(url string, content []byte) (*jose.JSONWebSignature, error) {
var alg jose.SignatureAlgorithm
-
switch k := j.privKey.(type) {
case *rsa.PrivateKey:
alg = jose.RS256
@@ -55,7 +54,7 @@ func (j *JWS) SignContent(url string, content []byte) (*jose.JSONWebSignature, e
options := jose.SignerOptions{
NonceSource: j.nonces,
- ExtraHeaders: map[jose.HeaderKey]any{
+ ExtraHeaders: map[jose.HeaderKey]interface{}{
"url": url,
},
}
@@ -73,14 +72,12 @@ func (j *JWS) SignContent(url string, content []byte) (*jose.JSONWebSignature, e
if err != nil {
return nil, fmt.Errorf("failed to sign content: %w", err)
}
-
return signed, nil
}
// SignEABContent Signs an external account binding content with the JWS.
func (j *JWS) SignEABContent(url, kid string, hmac []byte) (*jose.JSONWebSignature, error) {
jwk := jose.JSONWebKey{Key: j.privKey}
-
jwkJSON, err := jwk.Public().MarshalJSON()
if err != nil {
return nil, fmt.Errorf("acme: error encoding eab jwk key: %w", err)
@@ -90,7 +87,7 @@ func (j *JWS) SignEABContent(url, kid string, hmac []byte) (*jose.JSONWebSignatu
jose.SigningKey{Algorithm: jose.HS256, Key: hmac},
&jose.SignerOptions{
EmbedJWK: false,
- ExtraHeaders: map[jose.HeaderKey]any{
+ ExtraHeaders: map[jose.HeaderKey]interface{}{
"kid": kid,
"url": url,
},
@@ -111,7 +108,6 @@ func (j *JWS) SignEABContent(url, kid string, hmac []byte) (*jose.JSONWebSignatu
// GetKeyAuthorization Gets the key authorization for a token.
func (j *JWS) GetKeyAuthorization(token string) (string, error) {
var publicKey crypto.PublicKey
-
switch k := j.privKey.(type) {
case *ecdsa.PrivateKey:
publicKey = k.Public()
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 d5db5d4..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"
@@ -27,8 +28,6 @@ type Doer struct {
// NewDoer Creates a new Doer.
func NewDoer(client *http.Client, userAgent string) *Doer {
- client.Transport = newHTTPSOnly(client)
-
return &Doer{
httpClient: client,
userAgent: userAgent,
@@ -37,7 +36,7 @@ func NewDoer(client *http.Client, userAgent string) *Doer {
// Get performs a GET request with a proper User-Agent string.
// If "response" is not provided, callers should close resp.Body when done reading from it.
-func (d *Doer) Get(url string, response any) (*http.Response, error) {
+func (d *Doer) Get(url string, response interface{}) (*http.Response, error) {
req, err := d.newRequest(http.MethodGet, url, nil)
if err != nil {
return nil, err
@@ -59,7 +58,7 @@ func (d *Doer) Head(url string) (*http.Response, error) {
// Post performs a POST request with a proper User-Agent string.
// If "response" is not provided, callers should close resp.Body when done reading from it.
-func (d *Doer) Post(url string, body io.Reader, bodyType string, response any) (*http.Response, error) {
+func (d *Doer) Post(url string, body io.Reader, bodyType string, response interface{}) (*http.Response, error) {
req, err := d.newRequest(http.MethodPost, url, body, contentType(bodyType))
if err != nil {
return nil, err
@@ -86,7 +85,7 @@ func (d *Doer) newRequest(method, uri string, body io.Reader, opts ...RequestOpt
return req, nil
}
-func (d *Doer) do(req *http.Request, response any) (*http.Response, error) {
+func (d *Doer) do(req *http.Request, response interface{}) (*http.Response, error) {
resp, err := d.httpClient.Do(req)
if err != nil {
return nil, err
@@ -97,7 +96,7 @@ func (d *Doer) do(req *http.Request, response any) (*http.Response, error) {
}
if response != nil {
- raw, err := io.ReadAll(resp.Body)
+ raw, err := ioutil.ReadAll(resp.Body)
if err != nil {
return resp, err
}
@@ -121,13 +120,12 @@ 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)
}
var errorDetails *acme.ProblemDetails
-
err = json.Unmarshal(body, &errorDetails)
if err != nil {
return fmt.Errorf("%d ::%s :: %s :: %w :: %s", resp.StatusCode, req.Method, req.URL, err, string(body))
@@ -136,46 +134,12 @@ 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
}
-
-type httpsOnly struct {
- rt http.RoundTripper
-}
-
-func newHTTPSOnly(client *http.Client) *httpsOnly {
- if client.Transport == nil {
- return &httpsOnly{rt: http.DefaultTransport}
- }
-
- return &httpsOnly{rt: client.Transport}
-}
-
-// RoundTrip ensure HTTPS is used.
-// Each ACME function is accomplished by the client sending a sequence of HTTPS requests to the server [RFC2818],
-// carrying JSON messages [RFC8259].
-// Use of HTTPS is REQUIRED.
-// https://datatracker.ietf.org/doc/html/rfc8555#section-6.1
-func (r *httpsOnly) RoundTrip(req *http.Request) (*http.Response, error) {
- if req.URL.Scheme != "https" {
- return nil, fmt.Errorf("HTTPS is required: %s", req.URL)
- }
-
- return r.rt.RoundTrip(req)
-}
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 eb5a3bb..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.29.0"
+ 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 fad6be2..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,96 +3,25 @@ package api
import (
"encoding/base64"
"errors"
- "fmt"
- "slices"
- "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-ietf-acme-profiles-00.html#section-4
- Profile string
-
- // A string uniquely identifying a previously-issued certificate which this
- // order is intended to replace.
- // - https://www.rfc-editor.org/rfc/rfc9773.html#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) {
- orderReq := acme.Order{Identifiers: createIdentifiers(domains)}
-
- 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 identifiers []acme.Identifier
+ for _, domain := range domains {
+ identifiers = append(identifiers, acme.Identifier{Type: "dns", Value: domain})
}
+ orderReq := acme.Order{Identifiers: identifiers}
+
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://www.rfc-editor.org/rfc/rfc9773.html#section-5
- orderReq.Replaces = ""
-
- resp, err = o.core.post(o.core.GetDirectory().NewOrderURL, orderReq, &order)
- if err != nil {
- return acme.ExtendedOrder{}, err
- }
- }
-
- // The server MUST return an error if it cannot fulfill the request as specified,
- // and it MUST NOT issue a certificate with contents other than those requested.
- // If the server requires the request to be modified in a certain way,
- // it should indicate the required changes using an appropriate error type and description.
- // https://www.rfc-editor.org/rfc/rfc8555#section-7.4
- //
- // Some ACME servers don't return an error,
- // and/or change the order identifiers in the response,
- // so we need to ensure that the identifiers are the same as requested.
- // Deduplication by the server is allowed.
- if compareIdentifiers(orderReq.Identifiers, order.Identifiers) != 0 {
- // Sorts identifiers to avoid error message ambiguities about the order of the identifiers.
- slices.SortStableFunc(orderReq.Identifiers, compareIdentifier)
- slices.SortStableFunc(order.Identifiers, compareIdentifier)
-
- return acme.ExtendedOrder{},
- fmt.Errorf("order identifiers have been modified by the ACME server (RFC8555 §7.4): %+v != %+v",
- orderReq.Identifiers, order.Identifiers)
+ return acme.ExtendedOrder{}, err
}
return acme.ExtendedOrder{
@@ -108,7 +37,6 @@ func (o *OrderService) Get(orderURL string) (acme.ExtendedOrder, error) {
}
var order acme.Order
-
_, err := o.core.postAsGet(orderURL, &order)
if err != nil {
return acme.ExtendedOrder{}, err
@@ -124,14 +52,13 @@ func (o *OrderService) UpdateForCSR(orderURL string, csr []byte) (acme.ExtendedO
}
var order acme.Order
-
_, err := o.core.post(orderURL, csrMsg, &order)
if err != nil {
return acme.ExtendedOrder{}, err
}
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 aca3d8d..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://www.rfc-editor.org/rfc/rfc9773.html
-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/api/service.go b/vendor/github.com/go-acme/lego/v4/acme/api/service.go
index 65518e1..6f812ee 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/api/service.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/api/service.go
@@ -23,13 +23,11 @@ func getLinks(header http.Header, rel string) []string {
linkExpr := regexp.MustCompile(`<(.+?)>(?:;[^;]+)*?;\s*rel="(.+?)"`)
var links []string
-
for _, link := range header["Link"] {
for _, m := range linkExpr.FindAllStringSubmatch(link, -1) {
if len(m) != 3 {
continue
}
-
if m[2] == rel {
links = append(links, m[1])
}
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 0af623e..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://www.rfc-editor.org/rfc/rfc9773.html
+// - 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,33 +52,27 @@ 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-ietf-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`
Location string `json:"-"`
}
// 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):
@@ -137,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.
@@ -154,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-ietf-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].
@@ -193,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://www.rfc-editor.org/rfc/rfc9773.html#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.
@@ -221,11 +176,11 @@ type Authorization struct {
// The timestamp after which the server will consider this authorization invalid,
// encoded in the format specified in RFC 3339 [RFC3339].
// This field is REQUIRED for objects with "valid" in the "status" field.
- Expires time.Time `json:"expires,omitzero"`
+ Expires time.Time `json:"expires,omitempty"`
// identifier (required, object):
// The identifier that the account is authorized to represent
- Identifier Identifier `json:"identifier"`
+ Identifier Identifier `json:"identifier,omitempty"`
// challenges (required, array of objects):
// For pending authorizations, the challenges that the client can fulfill in order to prove possession of the identifier.
@@ -245,7 +200,6 @@ type Authorization struct {
// ExtendedChallenge a extended Challenge.
type ExtendedChallenge struct {
Challenge
-
// Contains the value of the response header `Retry-After`
RetryAfter string `json:"-"`
// Contains the value of the response header `Link` rel="up"
@@ -253,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.
@@ -272,7 +226,7 @@ type Challenge struct {
// The time at which the server validated this challenge,
// encoded in the format specified in RFC 3339 [RFC3339].
// This field is REQUIRED if the "status" field is "valid".
- Validated time.Time `json:"validated,omitzero"`
+ Validated time.Time `json:"validated,omitempty"`
// error (optional, object):
// Error that occurred while the server was validating the challenge, if any,
@@ -287,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].
@@ -321,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.
@@ -343,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://www.rfc-editor.org/rfc/rfc9773.html
-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://www.rfc-editor.org/rfc/rfc9773.html#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://www.rfc-editor.org/rfc/rfc9773.html#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 161a47c..3d6a5ab 100644
--- a/vendor/github.com/go-acme/lego/v4/acme/errors.go
+++ b/vendor/github.com/go-acme/lego/v4/acme/errors.go
@@ -2,19 +2,17 @@ package acme
import (
"fmt"
- "strings"
)
// 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"`
@@ -27,34 +25,30 @@ type ProblemDetails struct {
URL string `json:"url,omitempty"`
}
-func (p *ProblemDetails) Error() string {
- var msg strings.Builder
-
- msg.WriteString(fmt.Sprintf("acme: error: %d", p.HTTPStatus))
-
- if p.Method != "" || p.URL != "" {
- msg.WriteString(fmt.Sprintf(" :: %s :: %s", p.Method, p.URL))
- }
-
- msg.WriteString(fmt.Sprintf(" :: %s :: %s", p.Type, p.Detail))
-
- for _, sub := range p.SubProblems {
- msg.WriteString(fmt.Sprintf(", problem: %q :: %s", sub.Type, sub.Detail))
- }
-
- if p.Instance != "" {
- msg.WriteString(", url: " + p.Instance)
- }
-
- return msg.String()
-}
-
// SubProblem a "subproblems".
-// - https://www.rfc-editor.org/rfc/rfc8555.html#section-6.7.1
+// - 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"`
+ 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)
+ }
+ msg += fmt.Sprintf(" :: %s :: %s", p.Type, p.Detail)
+
+ for _, sub := range p.SubProblems {
+ msg += fmt.Sprintf(", problem: %q :: %s", sub.Type, sub.Detail)
+ }
+
+ if p.Instance != "" {
+ msg += ", url: " + p.Instance
+ }
+
+ return msg
}
// NonceError represents the error which is returned
@@ -62,10 +56,3 @@ type SubProblem struct {
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://www.rfc-editor.org/rfc/rfc9773.html#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 00f0654..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")
)
@@ -57,10 +54,8 @@ type DERCertificateBytes []byte
// ParsePEMBundle parses a certificate bundle from top to bottom and returns
// a slice of x509 certificates. This function will error if no certificates are found.
func ParsePEMBundle(bundle []byte) ([]*x509.Certificate, error) {
- var (
- certificates []*x509.Certificate
- certDERBlock *pem.Block
- )
+ var certificates []*x509.Certificate
+ var certDERBlock *pem.Block
for {
certDERBlock, bundle = pem.Decode(bundle)
@@ -73,7 +68,6 @@ func ParsePEMBundle(bundle []byte) ([]*x509.Certificate, error) {
if err != nil {
return nil, err
}
-
certificates = append(certificates, cert)
}
}
@@ -88,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)
@@ -127,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:
@@ -138,44 +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
- 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,
@@ -185,13 +143,12 @@ func CreateCSR(privateKey crypto.PrivateKey, opts CSROptions) ([]byte, error) {
return x509.CreateCertificateRequest(rand.Reader, &template, privateKey)
}
-func PEMEncode(data any) []byte {
+func PEMEncode(data interface{}) []byte {
return pem.EncodeToMemory(PEMBlock(data))
}
-func PEMBlock(data any) *pem.Block {
+func PEMBlock(data interface{}) *pem.Block {
var pemBlock *pem.Block
-
switch key := data.(type) {
case *ecdsa.PrivateKey:
keyBytes, _ := x509.MarshalECPrivateKey(key)
@@ -241,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 != "" {
@@ -272,17 +209,9 @@ func ExtractDomains(cert *x509.Certificate) []string {
if sanDomain == cert.Subject.CommonName {
continue
}
-
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
}
@@ -294,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
}
@@ -303,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) {
@@ -324,14 +255,13 @@ func GeneratePemCert(privateKey *rsa.PrivateKey, domain string, extensions []pki
func generateDerCert(privateKey *rsa.PrivateKey, expiration time.Time, domain string, extensions []pkix.Extension) ([]byte, error) {
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
-
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
if err != nil {
return nil, err
}
if expiration.IsZero() {
- expiration = time.Now().AddDate(1, 0, 0)
+ expiration = time.Now().Add(365)
}
template := x509.Certificate{
@@ -344,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 49f9587..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,15 +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
}
}
@@ -46,24 +52,28 @@ 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
}
log.Infof("Deactivating auth: %s", authzURL)
-
if c.core.Authorizations.Deactivate(authzURL) != nil {
log.Infof("Unable to deactivate the authorization: %s", authzURL)
}
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 04904e7..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-ietf-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://www.rfc-editor.org/rfc/rfc9773.html#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-ietf-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://www.rfc-editor.org/rfc/rfc9773.html#section-5
- ReplacesCertID string
}
type resolver interface {
@@ -122,34 +72,24 @@ type resolver interface {
}
type CertifierOptions struct {
- KeyType certcrypto.KeyType
- Timeout time.Duration
- OverallRequestLimit int
- DisableCommonName bool
+ 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.
@@ -169,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
}
@@ -184,33 +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.
@@ -237,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
}
@@ -252,93 +178,72 @@ 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)
if err != nil {
return nil, err
}
}
- commonName := ""
- if len(domains[0]) <= 64 && !c.options.DisableCommonName {
- 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) {
@@ -347,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
@@ -443,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
@@ -460,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.
@@ -492,27 +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.
@@ -539,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
@@ -561,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,
@@ -618,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
}
@@ -647,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
}
@@ -678,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,
@@ -712,20 +554,19 @@ 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 {
sanitizedDomain, err := idna.ToASCII(domain)
if err != nil {
@@ -734,6 +575,5 @@ func sanitizeDomain(domains []string) []string {
sanitizedDomains = append(sanitizedDomains, sanitizedDomain)
}
}
-
return sanitizedDomains
}
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 15e8047..0000000
--- a/vendor/github.com/go-acme/lego/v4/certificate/renewal.go
+++ /dev/null
@@ -1,132 +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://www.rfc-editor.org/rfc/rfc9773.html#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 RFC 9773.
-//
-// - (4.1-11. Getting Renewal Information) https://www.rfc-editor.org/rfc/rfc9773.html
-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://www.rfc-editor.org/rfc/rfc9773.html
-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 RFC 9773, 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 f6d5cdb..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")
)
@@ -40,6 +40,5 @@ func GetTargetedDomain(authz acme.Authorization) string {
if authz.Wildcard {
return "*." + authz.Identifier.Value
}
-
return authz.Identifier.Value
}
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 1d106d7..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"
@@ -40,7 +39,6 @@ func CondOption(condition bool, opt ChallengeOption) ChallengeOption {
return nil
}
}
-
return opt
}
@@ -116,10 +114,9 @@ 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) {
case challenge.ProviderTimeout:
timeout, interval = provider.Timeout()
@@ -127,16 +124,15 @@ 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)
}
-
return stop, errP
})
if err != nil {
@@ -144,7 +140,6 @@ func (c *Challenge) Solve(authz acme.Authorization) error {
}
chlng.KeyAuthorization = keyAuth
-
return c.validate(c.core, domain, chlng)
}
@@ -169,7 +164,6 @@ func (c *Challenge) Sequential() (bool, time.Duration) {
if p, ok := c.provider.(sequential); ok {
return ok, p.Sequential()
}
-
return false, 0
}
@@ -178,68 +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/fqdn.go b/vendor/github.com/go-acme/lego/v4/challenge/dns01/fqdn.go
index 11ac3d0..c238c8c 100644
--- a/vendor/github.com/go-acme/lego/v4/challenge/dns01/fqdn.go
+++ b/vendor/github.com/go-acme/lego/v4/challenge/dns01/fqdn.go
@@ -1,16 +1,12 @@
package dns01
-import (
- "iter"
-
- "github.com/miekg/dns"
-)
-
// ToFqdn converts the name into a fqdn appending a trailing dot.
-//
-// Deprecated: Use [github.com/miekg/dns.Fqdn] directly.
func ToFqdn(name string) string {
- return dns.Fqdn(name)
+ n := len(name)
+ if n == 0 || name[n-1] == '.' {
+ return name
+ }
+ return name + "."
}
// UnFqdn converts the fqdn into a name removing the trailing dot.
@@ -19,36 +15,5 @@ func UnFqdn(name string) string {
if n != 0 && name[n-1] == '.' {
return name[:n-1]
}
-
return name
}
-
-// UnFqdnDomainsSeq generates a sequence of "unFQDNed" domain names derived from a domain (FQDN or not) in descending order.
-func UnFqdnDomainsSeq(fqdn string) iter.Seq[string] {
- return func(yield func(string) bool) {
- if fqdn == "" {
- return
- }
-
- for _, index := range dns.Split(fqdn) {
- if !yield(UnFqdn(fqdn[index:])) {
- return
- }
- }
- }
-}
-
-// DomainsSeq generates a sequence of domain names derived from a domain (FQDN or not) in descending order.
-func DomainsSeq(fqdn string) iter.Seq[string] {
- return func(yield func(string) bool) {
- if fqdn == "" {
- return
- }
-
- for _, index := range dns.Split(fqdn) {
- if !yield(fqdn[index:]) {
- return
- }
- }
- }
-}
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 554eb7c..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 {
@@ -81,7 +82,6 @@ func getNameservers(path string, defaults []string) []string {
func ParseNameservers(servers []string) []string {
var resolvers []string
-
for _, resolver := range servers {
// ensure all servers have a port number
if _, _, err := net.SplitHostPort(resolver); err != nil {
@@ -90,7 +90,6 @@ func ParseNameservers(servers []string) []string {
resolvers = append(resolvers, resolver)
}
}
-
return resolvers
}
@@ -100,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 {
@@ -117,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
@@ -132,9 +130,8 @@ 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
}
@@ -149,20 +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)
@@ -170,41 +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
- r *dns.Msg
- )
+ var err error
+ var in *dns.Msg
- for domain := range DomainsSeq(fqdn) {
- r, err = dnsQuery(domain, dns.TypeSOA, nameservers, true)
+ labelIndexes := dns.Split(fqdn)
+ for _, index := range labelIndexes {
+ domain := fqdn[index:]
+
+ 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
}
@@ -213,48 +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
- err error
- errAll error
- )
+ var in *dns.Msg
+ var err 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 {
@@ -270,85 +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 {
+ udp := &dns.Client{Net: "udp", Timeout: dnsTimeout}
+ in, _, err := udp.Exchange(m, ns)
+
+ if in != nil && in.Truncated {
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}
- }
-
- return r, nil
+ // 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 45e17e3..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,15 +4,10 @@ import (
"fmt"
"net"
"strings"
- "time"
"github.com/miekg/dns"
)
-// defaultNameserverPort used by authoritative NS.
-// This is for tests only.
-var defaultNameserverPort = "53"
-
// PreCheckFunc checks DNS propagation before notifying ACME that the DNS challenge is ready.
type PreCheckFunc func(fqdn, value string) (bool, error)
@@ -28,53 +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,
}
}
@@ -88,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, defaultNameserverPort)
- }
-
- 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
}
@@ -141,11 +90,9 @@ func checkNameserversPropagation(fqdn, value string, nameservers []string, addPo
var records []string
var found bool
-
for _, rr := range r.Answer {
if txt, ok := rr.(*dns.TXT); ok {
record := strings.Join(txt.Txt, "")
-
records = append(records, record)
if record == value {
found = true
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 058d1a3..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,8 +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.
@@ -100,7 +95,6 @@ func parseForwardedHeader(s string) (elements []map[string]string, err error) {
inquote := false
pos := 0
-
l := len(s)
for i := 0; i < l; i++ {
r := rune(s[i])
@@ -112,7 +106,6 @@ func parseForwardedHeader(s string) (elements []map[string]string, err error) {
pos = i
inquote = false
}
-
continue
}
@@ -121,7 +114,6 @@ func parseForwardedHeader(s string) (elements []map[string]string, err error) {
if key == "" {
return nil, fmt.Errorf("unexpected quoted string as pos %d", i)
}
-
inquote = true
pos = i + 1
@@ -138,10 +130,11 @@ 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)
cur = make(map[string]string)
key = ""
@@ -164,14 +157,11 @@ func parseForwardedHeader(s string) (elements []map[string]string, err error) {
if pos < len(s) {
val = s[pos:]
}
-
cur[key] = val
}
-
if len(cur) > 0 {
elements = append(elements, cur)
}
-
return elements, nil
}
@@ -186,19 +176,9 @@ func skipWS(s string, i int) int {
for isWS(rune(s[i+1])) {
i++
}
-
return i
}
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 a042979..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) {
@@ -74,7 +53,6 @@ func (c *Challenge) Solve(authz acme.Authorization) error {
if err != nil {
return fmt.Errorf("[%s] acme: error presenting token: %w", domain, err)
}
-
defer func() {
err := c.provider.CleanUp(authz.Identifier.Value, chlng.Token, keyAuth)
if err != nil {
@@ -82,11 +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 ab96291..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,37 +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)`.
@@ -72,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
}
@@ -90,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 {
@@ -106,31 +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
+ }
}
})
@@ -144,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 6a85992..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
@@ -16,12 +16,10 @@ func (e obtainError) Error() string {
for domain := range e {
domains = append(domains, domain)
}
-
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 aac1016..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
@@ -50,14 +50,11 @@ func NewProber(solverManager *SolverManager) *Prober {
func (p *Prober) Solve(authorizations []acme.Authorization) error {
failures := make(obtainError)
- var (
- authSolvers []*selectedAuthSolver
- authSolversSequential []*selectedAuthSolver
- )
+ var authSolvers []*selectedAuthSolver
+ var authSolversSequential []*selectedAuthSolver
// Loop through the resources, basically through the domains.
// First pass just selects a solver for each authz.
-
for _, authz := range authorizations {
domain := challenge.GetTargetedDomain(authz)
if authz.Status == acme.StatusValid {
@@ -93,7 +90,6 @@ func (p *Prober) Solve(authorizations []acme.Authorization) error {
if len(failures) > 0 {
return failures
}
-
return nil
}
@@ -106,9 +102,7 @@ func sequentialSolve(authSolvers []*selectedAuthSolver, failures obtainError) {
err := solvr.PreSolve(authSolver.authz)
if err != nil {
failures[domain] = err
-
cleanUp(authSolver.solver, authSolver.authz)
-
continue
}
}
@@ -117,9 +111,7 @@ func sequentialSolve(authSolvers []*selectedAuthSolver, failures obtainError) {
err := authSolver.solver.Solve(authSolver.authz)
if err != nil {
failures[domain] = err
-
cleanUp(authSolver.solver, authSolver.authz)
-
continue
}
@@ -136,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 {
@@ -157,7 +149,6 @@ func parallelSolve(authSolvers []*selectedAuthSolver, failures obtainError) {
// Finally solve all challenges for real
for _, authSolver := range authSolvers {
authz := authSolver.authz
-
domain := challenge.GetTargetedDomain(authz)
if failures[domain] != nil {
// already failed in previous loop
@@ -174,7 +165,6 @@ func parallelSolve(authSolvers []*selectedAuthSolver, failures obtainError) {
func cleanUp(solvr solver, authz acme.Authorization) {
if solvr, ok := solvr.(cleanup); ok {
domain := challenge.GetTargetedDomain(authz)
-
err := solvr.CleanUp(authz)
if err != nil {
log.Warnf("[%s] acme: cleaning up failed: %v ", domain, err)
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 48d9194..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
@@ -8,7 +8,7 @@ import (
"strconv"
"time"
- "github.com/cenkalti/backoff/v5"
+ "github.com/cenkalti/backoff/v4"
"github.com/go-acme/lego/v4/acme"
"github.com/go-acme/lego/v4/acme/api"
"github.com/go-acme/lego/v4/challenge"
@@ -16,7 +16,6 @@ import (
"github.com/go-acme/lego/v4/challenge/http01"
"github.com/go-acme/lego/v4/challenge/tlsalpn01"
"github.com/go-acme/lego/v4/log"
- "github.com/go-acme/lego/v4/platform/wait"
)
type byType []acme.Challenge
@@ -38,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
}
@@ -55,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)
}
@@ -71,7 +70,6 @@ func (c *SolverManager) chooseSolver(authz acme.Authorization) solver {
log.Infof("[%s] acme: use %s solver", domain, chlg.Type)
return solvr
}
-
log.Infof("[%s] acme: Could not find solver for: %s", domain, chlg.Type)
}
@@ -102,26 +100,28 @@ func validate(core *api.Core, domain string, chlg acme.Challenge) error {
// https://github.com/letsencrypt/boulder/blob/master/docs/acme-divergences.md#section-82
ra = 5
}
-
initialInterval := time.Duration(ra) * time.Second
- ctx := context.Background()
-
bo := backoff.NewExponentialBackOff()
bo.InitialInterval = initialInterval
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 {
@@ -129,12 +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 wait.Retry(ctx, operation,
- backoff.WithBackOff(bo),
- backoff.WithMaxElapsedTime(100*initialInterval))
+ return backoff.Retry(operation, backoff.WithContext(bo, ctx))
}
func checkChallengeStatus(chlng acme.ExtendedChallenge) (bool, error) {
@@ -144,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")
}
}
@@ -161,12 +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 d8e9391..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) {
@@ -80,7 +59,6 @@ func (c *Challenge) Solve(authz acme.Authorization) error {
if err != nil {
return fmt.Errorf("[%s] acme: error presenting token: %w", challenge.GetTargetedDomain(authz), err)
}
-
defer func() {
err := c.provider.CleanUp(domain, chlng.Token, keyAuth)
if err != nil {
@@ -88,12 +66,7 @@ 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)
}
@@ -110,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 d069562..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,15 +53,7 @@ func NewClient(config *Config) (*Client, error) {
solversManager := resolver.NewSolversManager(core)
prober := resolver.NewProber(solversManager)
-
- options := certificate.CertifierOptions{
- KeyType: config.Certificate.KeyType,
- Timeout: config.Certificate.Timeout,
- OverallRequestLimit: config.Certificate.OverallRequestLimit,
- DisableCommonName: config.Certificate.DisableCommonName,
- }
-
- certifier := certificate.NewCertifier(core, prober, options)
+ 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 969135a..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,10 +55,8 @@ func NewConfig(user registration.User) *Config {
}
type CertificateConfig struct {
- KeyType certcrypto.KeyType
- Timeout time.Duration
- OverallRequestLimit int
- DisableCommonName bool
+ KeyType certcrypto.KeyType
+ Timeout time.Duration
}
// createDefaultHTTPClient Creates an HTTP client with a reasonable timeout value
@@ -90,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/log/logger.go b/vendor/github.com/go-acme/lego/v4/log/logger.go
index 2f700a3..48a81fa 100644
--- a/vendor/github.com/go-acme/lego/v4/log/logger.go
+++ b/vendor/github.com/go-acme/lego/v4/log/logger.go
@@ -10,50 +10,50 @@ var Logger StdLogger = log.New(os.Stderr, "", log.LstdFlags)
// StdLogger interface for Standard Logger.
type StdLogger interface {
- Fatal(args ...any)
- Fatalln(args ...any)
- Fatalf(format string, args ...any)
- Print(args ...any)
- Println(args ...any)
- Printf(format string, args ...any)
+ Fatal(args ...interface{})
+ Fatalln(args ...interface{})
+ Fatalf(format string, args ...interface{})
+ Print(args ...interface{})
+ Println(args ...interface{})
+ Printf(format string, args ...interface{})
}
// Fatal writes a log entry.
// It uses Logger if not nil, otherwise it uses the default log.Logger.
-func Fatal(args ...any) {
+func Fatal(args ...interface{}) {
Logger.Fatal(args...)
}
// Fatalf writes a log entry.
// It uses Logger if not nil, otherwise it uses the default log.Logger.
-func Fatalf(format string, args ...any) {
+func Fatalf(format string, args ...interface{}) {
Logger.Fatalf(format, args...)
}
// Print writes a log entry.
// It uses Logger if not nil, otherwise it uses the default log.Logger.
-func Print(args ...any) {
+func Print(args ...interface{}) {
Logger.Print(args...)
}
// Println writes a log entry.
// It uses Logger if not nil, otherwise it uses the default log.Logger.
-func Println(args ...any) {
+func Println(args ...interface{}) {
Logger.Println(args...)
}
// Printf writes a log entry.
// It uses Logger if not nil, otherwise it uses the default log.Logger.
-func Printf(format string, args ...any) {
+func Printf(format string, args ...interface{}) {
Logger.Printf(format, args...)
}
// Warnf writes a log entry.
-func Warnf(format string, args ...any) {
+func Warnf(format string, args ...interface{}) {
Printf("[WARN] "+format, args...)
}
// Infof writes a log entry.
-func Infof(format string, args ...any) {
+func Infof(format string, args ...interface{}) {
Printf("[INFO] "+format, args...)
}
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 33a0d6c..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"
@@ -16,13 +17,11 @@ func Get(names ...string) (map[string]string, error) {
values := map[string]string{}
var missingEnvVars []string
-
for _, envVar := range names {
value := GetOrFile(envVar)
if value == "" {
missingEnvVars = append(missingEnvVars, envVar)
}
-
values[envVar] = value
}
@@ -56,11 +55,11 @@ 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{}
var missingEnvVars []string
-
for _, names := range groups {
if len(names) == 0 {
return nil, errors.New("undefined environment variable names")
@@ -71,7 +70,6 @@ func GetWithFallback(groups ...[]string) (map[string]string, error) {
missingEnvVars = append(missingEnvVars, envVar)
continue
}
-
values[envVar] = value
}
@@ -82,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
}
}
@@ -109,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.
+// Returns the default if the envvar cannot be find.
func GetOrDefaultString(envVar, defaultValue string) string {
- return getOrDefault(envVar, defaultValue, ParseString)
+ 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
}
@@ -152,13 +150,12 @@ func GetOrFile(envVar string) string {
}
fileVar := envVar + "_FILE"
-
fileVarValue := os.Getenv(fileVar)
if fileVarValue == "" {
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 ""
@@ -166,43 +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
-}
-
-// ParsePairs parses a raw string of comma-separated key-value pairs into a map.
-// Keys and values are separated by a colon and are trimmed of whitespace.
-func ParsePairs(raw string) (map[string]string, error) {
- result := make(map[string]string)
-
- for pair := range strings.SplitSeq(strings.TrimSuffix(raw, ","), ",") {
- data := strings.Split(pair, ":")
- if len(data) != 2 {
- return nil, fmt.Errorf("incorrect pair: %s", pair)
- }
-
- result[strings.TrimSpace(data[0])] = strings.TrimSpace(data[1])
- }
-
- return result, 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 c66f574..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,11 +1,10 @@
package wait
import (
- "context"
+ "errors"
"fmt"
"time"
- "github.com/cenkalti/backoff/v5"
"github.com/go-acme/lego/v4/log"
)
@@ -14,25 +13,21 @@ func For(msg string, timeout, interval time.Duration, f func() (bool, error)) er
log.Infof("Wait for %s [timeout: %s, interval: %s]", msg, timeout, interval)
var lastErr error
-
timeUp := time.After(timeout)
-
for {
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:
}
stop, err := f()
if stop {
- return err
+ return nil
}
-
if err != nil {
lastErr = err
}
@@ -40,13 +35,3 @@ func For(msg string, timeout, interval time.Duration, f func() (bool, error)) er
time.Sleep(interval)
}
}
-
-// Retry retries the given operation until it succeeds or the context is canceled.
-// Similar to [backoff.Retry] but with a different signature.
-func Retry(ctx context.Context, operation func() error, opts ...backoff.RetryOption) error {
- _, err := backoff.Retry(ctx, func() (any, error) {
- return nil, operation()
- }, opts...)
-
- return err
-}
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/internal/clientdebug/.gitattributes b/vendor/github.com/go-acme/lego/v4/providers/dns/internal/clientdebug/.gitattributes
deleted file mode 100644
index 0ce5804..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/internal/clientdebug/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-/testdata/** text eol=lf
diff --git a/vendor/github.com/go-acme/lego/v4/providers/dns/internal/clientdebug/client.go b/vendor/github.com/go-acme/lego/v4/providers/dns/internal/clientdebug/client.go
deleted file mode 100644
index 342577b..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/internal/clientdebug/client.go
+++ /dev/null
@@ -1,134 +0,0 @@
-package clientdebug
-
-import (
- "fmt"
- "io"
- "net/http"
- "net/http/httputil"
- "os"
- "regexp"
- "strconv"
- "strings"
-
- "github.com/go-acme/lego/v4/platform/config/env"
-)
-
-const replacement = "***"
-
-type Option func(*DumpTransport)
-
-func WithEnvKeys(keys ...string) Option {
- return func(d *DumpTransport) {
- for _, key := range keys {
- v := strings.TrimSpace(env.GetOrFile(key))
- if v == "" {
- continue
- }
-
- d.replacements = append(d.replacements, v, replacement)
- }
- }
-}
-
-func WithValues(values ...string) Option {
- return func(d *DumpTransport) {
- for _, value := range values {
- d.replacements = append(d.replacements, value, replacement)
- }
- }
-}
-
-func WithHeaders(keys ...string) Option {
- return func(d *DumpTransport) {
- d.regexps = append(d.regexps,
- regexp.MustCompile(fmt.Sprintf(`(?im)^(%s):.+$`, strings.Join(keys, "|"))))
- }
-}
-
-type DumpTransport struct {
- rt http.RoundTripper
-
- replacements []string
- replacer *strings.Replacer
-
- regexps []*regexp.Regexp
-
- writer io.Writer
-}
-
-func NewDumpTransport(rt http.RoundTripper, opts ...Option) *DumpTransport {
- if rt == nil {
- rt = http.DefaultTransport
- }
-
- d := &DumpTransport{
- rt: rt,
- writer: os.Stdout,
- }
-
- for _, opt := range opts {
- opt(d)
- }
-
- d.regexps = append(d.regexps,
- regexp.MustCompile(`(?im)^(Authorization):.+$`),
- regexp.MustCompile(`(?im)^(Token|X-Token):.+$`),
- regexp.MustCompile(`(?im)^(Auth-Token|X-Auth-Token):.+$`),
- regexp.MustCompile(`(?im)^(Api-Key|X-Api-Key|X-Api-Secret):.+$`),
- )
-
- if len(d.replacements) > 0 {
- d.replacer = strings.NewReplacer(d.replacements...)
- }
-
- return d
-}
-
-func (d *DumpTransport) RoundTrip(h *http.Request) (*http.Response, error) {
- data, _ := httputil.DumpRequestOut(h, true)
-
- _, _ = fmt.Fprintln(d.writer, "[HTTP Request]")
- _, _ = fmt.Fprintln(d.writer, d.redact(data))
-
- resp, err := d.rt.RoundTrip(h)
- if err != nil {
- return nil, err
- }
-
- data, _ = httputil.DumpResponse(resp, true)
-
- _, _ = fmt.Fprintln(d.writer, "[HTTP Response]")
- _, _ = fmt.Fprintln(d.writer, d.redact(data))
-
- return resp, err
-}
-
-func (d *DumpTransport) redact(content []byte) string {
- data := string(content)
-
- for _, r := range d.regexps {
- data = r.ReplaceAllString(data, "$1: "+replacement)
- }
-
- if d.replacer == nil {
- return data
- }
-
- return d.replacer.Replace(data)
-}
-
-// Wrap wraps an HTTP client Transport with the [DumpTransport].
-func Wrap(client *http.Client, opts ...Option) *http.Client {
- val, found := os.LookupEnv("LEGO_DEBUG_DNS_API_HTTP_CLIENT")
- if !found {
- return client
- }
-
- if ok, _ := strconv.ParseBool(val); !ok {
- return client
- }
-
- client.Transport = NewDumpTransport(client.Transport, opts...)
-
- return client
-}
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 bcab98b..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.29.0"
-
- // 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 b7e5225..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,26 +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/clientdebug"
- "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"
@@ -32,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"`
@@ -60,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
@@ -96,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
@@ -112,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)
}
@@ -142,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,
@@ -172,26 +123,22 @@ 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
-
err = d.client.Post(reqURL, reqData, &respData)
if err != nil {
return fmt.Errorf("ovh: error when call api to add record (%s): %w", reqURL, err)
@@ -199,7 +146,6 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
// Apply the change
reqURL = fmt.Sprintf("/domain/zone/%s/refresh", authZone)
-
err = d.client.Post(reqURL, nil, nil)
if err != nil {
return fmt.Errorf("ovh: error when call api to refresh zone (%s): %w", reqURL, err)
@@ -214,20 +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)
@@ -241,7 +186,6 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
// Apply the change
reqURL = fmt.Sprintf("/domain/zone/%s/refresh", authZone)
-
err = d.client.Post(reqURL, nil, nil)
if err != nil {
return fmt.Errorf("ovh: error when call api to refresh zone (%s): %w", reqURL, err)
@@ -261,34 +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
- 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()
-
- if config.HTTPClient != nil {
- client.Client = config.HTTPClient
- }
-
- client.Client = clientdebug.Wrap(client.Client)
-
- 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 f72dd4d..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/internal/client.go
+++ /dev/null
@@ -1,236 +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"
-)
-
-// APIKeyHeader API key header.
-const APIKeyHeader = "X-Api-Key"
-
-// 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(APIKeyHeader, 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 e7ead70..0000000
--- a/vendor/github.com/go-acme/lego/v4/providers/dns/pdns/pdns.go
+++ /dev/null
@@ -1,257 +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/internal/clientdebug"
- "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.HTTPClient != nil {
- client.HTTPClient = config.HTTPClient
- }
-
- client.HTTPClient = clientdebug.Wrap(client.HTTPClient)
-
- 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 {
- ctx := context.Background()
-
- 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)
- }
-
- zone, err := d.client.GetHostedZone(ctx, authZone)
- if err != nil {
- return fmt.Errorf("pdns: get hosted zone for %s: %w", authZone, 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)
-
- var records []internal.Record
- if existingRRSet != nil {
- records = existingRRSet.Records
- }
-
- records = append(records, 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: records,
- }},
- }
-
- err = d.client.UpdateRecords(ctx, zone, rrSets)
- if err != nil {
- return fmt.Errorf("pdns: update records: %w", err)
- }
-
- err = d.client.Notify(ctx, zone)
- if err != nil {
- return fmt.Errorf("pdns: notify: %w", err)
- }
-
- return nil
-}
-
-// CleanUp removes the TXT record matching the specified parameters.
-func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
- ctx := context.Background()
-
- 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)
- }
-
- zone, err := d.client.GetHostedZone(ctx, authZone)
- if err != nil {
- return fmt.Errorf("pdns: get hosted zone for %s: %w", authZone, err)
- }
-
- // Look for existing records.
- 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: update records: %w", err)
- }
-
- err = d.client.Notify(ctx, zone)
- if err != nil {
- return fmt.Errorf("pdns: notify: %w", err)
- }
-
- return nil
-}
-
-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 5d3ea25..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,13 +9,11 @@ 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"`
+ 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
@@ -160,7 +158,6 @@ func (r *Registrar) ResolveAccountByKey() (*Resource, error) {
log.Infof("acme: Trying to resolve account by key")
accMsg := acme.Account{OnlyReturnExisting: true}
-
account, err := r.core.Accounts.New(accMsg)
if err != nil {
return nil, err
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/README.md b/vendor/github.com/go-jose/go-jose/v4/README.md
deleted file mode 100644
index 55c5509..0000000
--- a/vendor/github.com/go-jose/go-jose/v4/README.md
+++ /dev/null
@@ -1,108 +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)
-
-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
-
-The forthcoming Version 5 will be released with several breaking API changes,
-and will require Golang's `encoding/json/v2`, which is currently requires
-Go 1.25 built with GOEXPERIMENT=jsonv2.
-
-Version 4 is the current stable version:
-
- import "github.com/go-jose/go-jose/v4"
-
-It supports at least the current and previous Golang release. Currently it
-requires Golang 1.24.
-
-Version 3 is only receiving critical security updates. Migration to Version 4 is recommended.
-
-Versions 1 and 2 are obsolete, but can be found in the old repository, [square/go-jose](https://github.com/square/go-jose).
-
-### 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/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/.codecov.yml b/vendor/github.com/json-iterator/go/.codecov.yml
new file mode 100644
index 0000000..955dc0b
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/.codecov.yml
@@ -0,0 +1,3 @@
+ignore:
+ - "output_tests/.*"
+
diff --git a/vendor/github.com/json-iterator/go/.gitignore b/vendor/github.com/json-iterator/go/.gitignore
new file mode 100644
index 0000000..1555653
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/.gitignore
@@ -0,0 +1,4 @@
+/vendor
+/bug_test.go
+/coverage.txt
+/.idea
diff --git a/vendor/github.com/json-iterator/go/.travis.yml b/vendor/github.com/json-iterator/go/.travis.yml
new file mode 100644
index 0000000..449e67c
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/.travis.yml
@@ -0,0 +1,14 @@
+language: go
+
+go:
+ - 1.8.x
+ - 1.x
+
+before_install:
+ - go get -t -v ./...
+
+script:
+ - ./test.sh
+
+after_success:
+ - bash <(curl -s https://codecov.io/bash)
diff --git a/vendor/github.com/json-iterator/go/Gopkg.lock b/vendor/github.com/json-iterator/go/Gopkg.lock
new file mode 100644
index 0000000..c8a9fbb
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/Gopkg.lock
@@ -0,0 +1,21 @@
+# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
+
+
+[[projects]]
+ name = "github.com/modern-go/concurrent"
+ packages = ["."]
+ revision = "e0a39a4cb4216ea8db28e22a69f4ec25610d513a"
+ version = "1.0.0"
+
+[[projects]]
+ name = "github.com/modern-go/reflect2"
+ packages = ["."]
+ revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd"
+ version = "1.0.1"
+
+[solve-meta]
+ analyzer-name = "dep"
+ analyzer-version = 1
+ inputs-digest = "ea54a775e5a354cb015502d2e7aa4b74230fc77e894f34a838b268c25ec8eeb8"
+ solver-name = "gps-cdcl"
+ solver-version = 1
diff --git a/vendor/github.com/json-iterator/go/Gopkg.toml b/vendor/github.com/json-iterator/go/Gopkg.toml
new file mode 100644
index 0000000..313a0f8
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/Gopkg.toml
@@ -0,0 +1,26 @@
+# Gopkg.toml example
+#
+# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
+# for detailed Gopkg.toml documentation.
+#
+# required = ["github.com/user/thing/cmd/thing"]
+# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
+#
+# [[constraint]]
+# name = "github.com/user/project"
+# version = "1.0.0"
+#
+# [[constraint]]
+# name = "github.com/user/project2"
+# branch = "dev"
+# source = "github.com/myfork/project2"
+#
+# [[override]]
+# name = "github.com/x/y"
+# version = "2.4.0"
+
+ignored = ["github.com/davecgh/go-spew*","github.com/google/gofuzz*","github.com/stretchr/testify*"]
+
+[[constraint]]
+ name = "github.com/modern-go/reflect2"
+ version = "1.0.1"
diff --git a/vendor/github.com/json-iterator/go/LICENSE b/vendor/github.com/json-iterator/go/LICENSE
new file mode 100644
index 0000000..2cf4f5a
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2016 json-iterator
+
+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/json-iterator/go/README.md b/vendor/github.com/json-iterator/go/README.md
new file mode 100644
index 0000000..52b111d
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/README.md
@@ -0,0 +1,87 @@
+[](https://sourcegraph.com/github.com/json-iterator/go?badge)
+[](https://pkg.go.dev/github.com/json-iterator/go)
+[](https://travis-ci.org/json-iterator/go)
+[](https://codecov.io/gh/json-iterator/go)
+[](https://goreportcard.com/report/github.com/json-iterator/go)
+[](https://raw.githubusercontent.com/json-iterator/go/master/LICENSE)
+[](https://gitter.im/json-iterator/Lobby)
+
+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
+
+
+
+Source code: https://github.com/json-iterator/go-benchmark/blob/master/src/github.com/json-iterator/go-benchmark/benchmark_medium_payload_test.go
+
+Raw Result (easyjson requires static code generation)
+
+| | ns/op | allocation bytes | allocation times |
+| --------------- | ----------- | ---------------- | ---------------- |
+| std decode | 35510 ns/op | 1960 B/op | 99 allocs/op |
+| easyjson decode | 8499 ns/op | 160 B/op | 4 allocs/op |
+| jsoniter decode | 5623 ns/op | 160 B/op | 3 allocs/op |
+| std encode | 2213 ns/op | 712 B/op | 5 allocs/op |
+| easyjson encode | 883 ns/op | 576 B/op | 3 allocs/op |
+| jsoniter encode | 837 ns/op | 384 B/op | 4 allocs/op |
+
+Always benchmark with your own workload.
+The result depends heavily on the data input.
+
+# Usage
+
+100% compatibility with standard lib
+
+Replace
+
+```go
+import "encoding/json"
+json.Marshal(&data)
+```
+
+with
+
+```go
+import jsoniter "github.com/json-iterator/go"
+
+var json = jsoniter.ConfigCompatibleWithStandardLibrary
+json.Marshal(&data)
+```
+
+Replace
+
+```go
+import "encoding/json"
+json.Unmarshal(input, &data)
+```
+
+with
+
+```go
+import jsoniter "github.com/json-iterator/go"
+
+var json = jsoniter.ConfigCompatibleWithStandardLibrary
+json.Unmarshal(input, &data)
+```
+
+[More documentation](http://jsoniter.com/migrate-from-go-std.html)
+
+# How to get
+
+```
+go get github.com/json-iterator/go
+```
+
+# Contribution Welcomed !
+
+Contributors
+
+- [thockin](https://github.com/thockin)
+- [mattn](https://github.com/mattn)
+- [cch123](https://github.com/cch123)
+- [Oleg Shaldybin](https://github.com/olegshaldybin)
+- [Jason Toffaletti](https://github.com/toffaletti)
+
+Report issue or pull request, or email taowen@gmail.com, or [](https://gitter.im/json-iterator/Lobby)
diff --git a/vendor/github.com/json-iterator/go/adapter.go b/vendor/github.com/json-iterator/go/adapter.go
new file mode 100644
index 0000000..92d2cc4
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/adapter.go
@@ -0,0 +1,150 @@
+package jsoniter
+
+import (
+ "bytes"
+ "io"
+)
+
+// RawMessage to make replace json with jsoniter
+type RawMessage []byte
+
+// Unmarshal adapts to json/encoding Unmarshal API
+//
+// Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v.
+// Refer to https://godoc.org/encoding/json#Unmarshal for more information
+func Unmarshal(data []byte, v interface{}) error {
+ return ConfigDefault.Unmarshal(data, v)
+}
+
+// UnmarshalFromString is a convenient method to read from string instead of []byte
+func UnmarshalFromString(str string, v interface{}) error {
+ return ConfigDefault.UnmarshalFromString(str, v)
+}
+
+// Get quick method to get value from deeply nested JSON structure
+func Get(data []byte, path ...interface{}) Any {
+ return ConfigDefault.Get(data, path...)
+}
+
+// Marshal adapts to json/encoding Marshal API
+//
+// Marshal returns the JSON encoding of v, adapts to json/encoding Marshal API
+// Refer to https://godoc.org/encoding/json#Marshal for more information
+func Marshal(v interface{}) ([]byte, error) {
+ return ConfigDefault.Marshal(v)
+}
+
+// MarshalIndent same as json.MarshalIndent. Prefix is not supported.
+func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
+ return ConfigDefault.MarshalIndent(v, prefix, indent)
+}
+
+// MarshalToString convenient method to write as string instead of []byte
+func MarshalToString(v interface{}) (string, error) {
+ return ConfigDefault.MarshalToString(v)
+}
+
+// NewDecoder adapts to json/stream NewDecoder API.
+//
+// NewDecoder returns a new decoder that reads from r.
+//
+// Instead of a json/encoding Decoder, an Decoder is returned
+// Refer to https://godoc.org/encoding/json#NewDecoder for more information
+func NewDecoder(reader io.Reader) *Decoder {
+ return ConfigDefault.NewDecoder(reader)
+}
+
+// Decoder reads and decodes JSON values from an input stream.
+// Decoder provides identical APIs with json/stream Decoder (Token() and UseNumber() are in progress)
+type Decoder struct {
+ iter *Iterator
+}
+
+// Decode decode JSON into interface{}
+func (adapter *Decoder) Decode(obj interface{}) error {
+ if adapter.iter.head == adapter.iter.tail && adapter.iter.reader != nil {
+ if !adapter.iter.loadMore() {
+ return io.EOF
+ }
+ }
+ adapter.iter.ReadVal(obj)
+ err := adapter.iter.Error
+ if err == io.EOF {
+ return nil
+ }
+ return adapter.iter.Error
+}
+
+// More is there more?
+func (adapter *Decoder) More() bool {
+ iter := adapter.iter
+ if iter.Error != nil {
+ return false
+ }
+ c := iter.nextToken()
+ if c == 0 {
+ return false
+ }
+ iter.unreadByte()
+ return c != ']' && c != '}'
+}
+
+// Buffered remaining buffer
+func (adapter *Decoder) Buffered() io.Reader {
+ remaining := adapter.iter.buf[adapter.iter.head:adapter.iter.tail]
+ return bytes.NewReader(remaining)
+}
+
+// UseNumber causes the Decoder to unmarshal a number into an interface{} as a
+// Number instead of as a float64.
+func (adapter *Decoder) UseNumber() {
+ cfg := adapter.iter.cfg.configBeforeFrozen
+ cfg.UseNumber = true
+ adapter.iter.cfg = cfg.frozeWithCacheReuse(adapter.iter.cfg.extraExtensions)
+}
+
+// DisallowUnknownFields causes the Decoder to return an error when the destination
+// is a struct and the input contains object keys which do not match any
+// non-ignored, exported fields in the destination.
+func (adapter *Decoder) DisallowUnknownFields() {
+ cfg := adapter.iter.cfg.configBeforeFrozen
+ cfg.DisallowUnknownFields = true
+ adapter.iter.cfg = cfg.frozeWithCacheReuse(adapter.iter.cfg.extraExtensions)
+}
+
+// NewEncoder same as json.NewEncoder
+func NewEncoder(writer io.Writer) *Encoder {
+ return ConfigDefault.NewEncoder(writer)
+}
+
+// Encoder same as json.Encoder
+type Encoder struct {
+ stream *Stream
+}
+
+// Encode encode interface{} as JSON to io.Writer
+func (adapter *Encoder) Encode(val interface{}) error {
+ adapter.stream.WriteVal(val)
+ adapter.stream.WriteRaw("\n")
+ adapter.stream.Flush()
+ return adapter.stream.Error
+}
+
+// SetIndent set the indention. Prefix is not supported
+func (adapter *Encoder) SetIndent(prefix, indent string) {
+ config := adapter.stream.cfg.configBeforeFrozen
+ config.IndentionStep = len(indent)
+ adapter.stream.cfg = config.frozeWithCacheReuse(adapter.stream.cfg.extraExtensions)
+}
+
+// SetEscapeHTML escape html by default, set to false to disable
+func (adapter *Encoder) SetEscapeHTML(escapeHTML bool) {
+ config := adapter.stream.cfg.configBeforeFrozen
+ config.EscapeHTML = escapeHTML
+ adapter.stream.cfg = config.frozeWithCacheReuse(adapter.stream.cfg.extraExtensions)
+}
+
+// Valid reports whether data is a valid JSON encoding.
+func Valid(data []byte) bool {
+ return ConfigDefault.Valid(data)
+}
diff --git a/vendor/github.com/json-iterator/go/any.go b/vendor/github.com/json-iterator/go/any.go
new file mode 100644
index 0000000..f6b8aea
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any.go
@@ -0,0 +1,325 @@
+package jsoniter
+
+import (
+ "errors"
+ "fmt"
+ "github.com/modern-go/reflect2"
+ "io"
+ "reflect"
+ "strconv"
+ "unsafe"
+)
+
+// Any generic object representation.
+// The lazy json implementation holds []byte and parse lazily.
+type Any interface {
+ LastError() error
+ ValueType() ValueType
+ MustBeValid() Any
+ ToBool() bool
+ ToInt() int
+ ToInt32() int32
+ ToInt64() int64
+ ToUint() uint
+ ToUint32() uint32
+ ToUint64() uint64
+ ToFloat32() float32
+ ToFloat64() float64
+ ToString() string
+ ToVal(val interface{})
+ Get(path ...interface{}) Any
+ Size() int
+ Keys() []string
+ GetInterface() interface{}
+ WriteTo(stream *Stream)
+}
+
+type baseAny struct{}
+
+func (any *baseAny) Get(path ...interface{}) Any {
+ return &invalidAny{baseAny{}, fmt.Errorf("GetIndex %v from simple value", path)}
+}
+
+func (any *baseAny) Size() int {
+ return 0
+}
+
+func (any *baseAny) Keys() []string {
+ return []string{}
+}
+
+func (any *baseAny) ToVal(obj interface{}) {
+ panic("not implemented")
+}
+
+// WrapInt32 turn int32 into Any interface
+func WrapInt32(val int32) Any {
+ return &int32Any{baseAny{}, val}
+}
+
+// WrapInt64 turn int64 into Any interface
+func WrapInt64(val int64) Any {
+ return &int64Any{baseAny{}, val}
+}
+
+// WrapUint32 turn uint32 into Any interface
+func WrapUint32(val uint32) Any {
+ return &uint32Any{baseAny{}, val}
+}
+
+// WrapUint64 turn uint64 into Any interface
+func WrapUint64(val uint64) Any {
+ return &uint64Any{baseAny{}, val}
+}
+
+// WrapFloat64 turn float64 into Any interface
+func WrapFloat64(val float64) Any {
+ return &floatAny{baseAny{}, val}
+}
+
+// WrapString turn string into Any interface
+func WrapString(val string) Any {
+ return &stringAny{baseAny{}, val}
+}
+
+// Wrap turn a go object into Any interface
+func Wrap(val interface{}) Any {
+ if val == nil {
+ return &nilAny{}
+ }
+ asAny, isAny := val.(Any)
+ if isAny {
+ return asAny
+ }
+ typ := reflect2.TypeOf(val)
+ switch typ.Kind() {
+ case reflect.Slice:
+ return wrapArray(val)
+ case reflect.Struct:
+ return wrapStruct(val)
+ case reflect.Map:
+ return wrapMap(val)
+ case reflect.String:
+ return WrapString(val.(string))
+ case reflect.Int:
+ if strconv.IntSize == 32 {
+ return WrapInt32(int32(val.(int)))
+ }
+ return WrapInt64(int64(val.(int)))
+ case reflect.Int8:
+ return WrapInt32(int32(val.(int8)))
+ case reflect.Int16:
+ return WrapInt32(int32(val.(int16)))
+ case reflect.Int32:
+ return WrapInt32(val.(int32))
+ case reflect.Int64:
+ return WrapInt64(val.(int64))
+ case reflect.Uint:
+ if strconv.IntSize == 32 {
+ return WrapUint32(uint32(val.(uint)))
+ }
+ return WrapUint64(uint64(val.(uint)))
+ case reflect.Uintptr:
+ if ptrSize == 32 {
+ return WrapUint32(uint32(val.(uintptr)))
+ }
+ return WrapUint64(uint64(val.(uintptr)))
+ case reflect.Uint8:
+ return WrapUint32(uint32(val.(uint8)))
+ case reflect.Uint16:
+ return WrapUint32(uint32(val.(uint16)))
+ case reflect.Uint32:
+ return WrapUint32(uint32(val.(uint32)))
+ case reflect.Uint64:
+ return WrapUint64(val.(uint64))
+ case reflect.Float32:
+ return WrapFloat64(float64(val.(float32)))
+ case reflect.Float64:
+ return WrapFloat64(val.(float64))
+ case reflect.Bool:
+ if val.(bool) == true {
+ return &trueAny{}
+ }
+ return &falseAny{}
+ }
+ return &invalidAny{baseAny{}, fmt.Errorf("unsupported type: %v", typ)}
+}
+
+// ReadAny read next JSON element as an Any object. It is a better json.RawMessage.
+func (iter *Iterator) ReadAny() Any {
+ return iter.readAny()
+}
+
+func (iter *Iterator) readAny() Any {
+ c := iter.nextToken()
+ switch c {
+ case '"':
+ iter.unreadByte()
+ return &stringAny{baseAny{}, iter.ReadString()}
+ case 'n':
+ iter.skipThreeBytes('u', 'l', 'l') // null
+ return &nilAny{}
+ case 't':
+ iter.skipThreeBytes('r', 'u', 'e') // true
+ return &trueAny{}
+ case 'f':
+ iter.skipFourBytes('a', 'l', 's', 'e') // false
+ return &falseAny{}
+ case '{':
+ return iter.readObjectAny()
+ case '[':
+ return iter.readArrayAny()
+ case '-':
+ return iter.readNumberAny(false)
+ case 0:
+ return &invalidAny{baseAny{}, errors.New("input is empty")}
+ default:
+ return iter.readNumberAny(true)
+ }
+}
+
+func (iter *Iterator) readNumberAny(positive bool) Any {
+ iter.startCapture(iter.head - 1)
+ iter.skipNumber()
+ lazyBuf := iter.stopCapture()
+ return &numberLazyAny{baseAny{}, iter.cfg, lazyBuf, nil}
+}
+
+func (iter *Iterator) readObjectAny() Any {
+ iter.startCapture(iter.head - 1)
+ iter.skipObject()
+ lazyBuf := iter.stopCapture()
+ return &objectLazyAny{baseAny{}, iter.cfg, lazyBuf, nil}
+}
+
+func (iter *Iterator) readArrayAny() Any {
+ iter.startCapture(iter.head - 1)
+ iter.skipArray()
+ lazyBuf := iter.stopCapture()
+ return &arrayLazyAny{baseAny{}, iter.cfg, lazyBuf, nil}
+}
+
+func locateObjectField(iter *Iterator, target string) []byte {
+ var found []byte
+ iter.ReadObjectCB(func(iter *Iterator, field string) bool {
+ if field == target {
+ found = iter.SkipAndReturnBytes()
+ return false
+ }
+ iter.Skip()
+ return true
+ })
+ return found
+}
+
+func locateArrayElement(iter *Iterator, target int) []byte {
+ var found []byte
+ n := 0
+ iter.ReadArrayCB(func(iter *Iterator) bool {
+ if n == target {
+ found = iter.SkipAndReturnBytes()
+ return false
+ }
+ iter.Skip()
+ n++
+ return true
+ })
+ return found
+}
+
+func locatePath(iter *Iterator, path []interface{}) Any {
+ for i, pathKeyObj := range path {
+ switch pathKey := pathKeyObj.(type) {
+ case string:
+ valueBytes := locateObjectField(iter, pathKey)
+ if valueBytes == nil {
+ return newInvalidAny(path[i:])
+ }
+ iter.ResetBytes(valueBytes)
+ case int:
+ valueBytes := locateArrayElement(iter, pathKey)
+ if valueBytes == nil {
+ return newInvalidAny(path[i:])
+ }
+ iter.ResetBytes(valueBytes)
+ case int32:
+ if '*' == pathKey {
+ return iter.readAny().Get(path[i:]...)
+ }
+ return newInvalidAny(path[i:])
+ default:
+ return newInvalidAny(path[i:])
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF {
+ return &invalidAny{baseAny{}, iter.Error}
+ }
+ return iter.readAny()
+}
+
+var anyType = reflect2.TypeOfPtr((*Any)(nil)).Elem()
+
+func createDecoderOfAny(ctx *ctx, typ reflect2.Type) ValDecoder {
+ if typ == anyType {
+ return &directAnyCodec{}
+ }
+ if typ.Implements(anyType) {
+ return &anyCodec{
+ valType: typ,
+ }
+ }
+ return nil
+}
+
+func createEncoderOfAny(ctx *ctx, typ reflect2.Type) ValEncoder {
+ if typ == anyType {
+ return &directAnyCodec{}
+ }
+ if typ.Implements(anyType) {
+ return &anyCodec{
+ valType: typ,
+ }
+ }
+ return nil
+}
+
+type anyCodec struct {
+ valType reflect2.Type
+}
+
+func (codec *anyCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ panic("not implemented")
+}
+
+func (codec *anyCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ obj := codec.valType.UnsafeIndirect(ptr)
+ any := obj.(Any)
+ any.WriteTo(stream)
+}
+
+func (codec *anyCodec) IsEmpty(ptr unsafe.Pointer) bool {
+ obj := codec.valType.UnsafeIndirect(ptr)
+ any := obj.(Any)
+ return any.Size() == 0
+}
+
+type directAnyCodec struct {
+}
+
+func (codec *directAnyCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ *(*Any)(ptr) = iter.readAny()
+}
+
+func (codec *directAnyCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ any := *(*Any)(ptr)
+ if any == nil {
+ stream.WriteNil()
+ return
+ }
+ any.WriteTo(stream)
+}
+
+func (codec *directAnyCodec) IsEmpty(ptr unsafe.Pointer) bool {
+ any := *(*Any)(ptr)
+ return any.Size() == 0
+}
diff --git a/vendor/github.com/json-iterator/go/any_array.go b/vendor/github.com/json-iterator/go/any_array.go
new file mode 100644
index 0000000..0449e9a
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_array.go
@@ -0,0 +1,278 @@
+package jsoniter
+
+import (
+ "reflect"
+ "unsafe"
+)
+
+type arrayLazyAny struct {
+ baseAny
+ cfg *frozenConfig
+ buf []byte
+ err error
+}
+
+func (any *arrayLazyAny) ValueType() ValueType {
+ return ArrayValue
+}
+
+func (any *arrayLazyAny) MustBeValid() Any {
+ return any
+}
+
+func (any *arrayLazyAny) LastError() error {
+ return any.err
+}
+
+func (any *arrayLazyAny) ToBool() bool {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ return iter.ReadArray()
+}
+
+func (any *arrayLazyAny) ToInt() int {
+ if any.ToBool() {
+ return 1
+ }
+ return 0
+}
+
+func (any *arrayLazyAny) ToInt32() int32 {
+ if any.ToBool() {
+ return 1
+ }
+ return 0
+}
+
+func (any *arrayLazyAny) ToInt64() int64 {
+ if any.ToBool() {
+ return 1
+ }
+ return 0
+}
+
+func (any *arrayLazyAny) ToUint() uint {
+ if any.ToBool() {
+ return 1
+ }
+ return 0
+}
+
+func (any *arrayLazyAny) ToUint32() uint32 {
+ if any.ToBool() {
+ return 1
+ }
+ return 0
+}
+
+func (any *arrayLazyAny) ToUint64() uint64 {
+ if any.ToBool() {
+ return 1
+ }
+ return 0
+}
+
+func (any *arrayLazyAny) ToFloat32() float32 {
+ if any.ToBool() {
+ return 1
+ }
+ return 0
+}
+
+func (any *arrayLazyAny) ToFloat64() float64 {
+ if any.ToBool() {
+ return 1
+ }
+ return 0
+}
+
+func (any *arrayLazyAny) ToString() string {
+ return *(*string)(unsafe.Pointer(&any.buf))
+}
+
+func (any *arrayLazyAny) ToVal(val interface{}) {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ iter.ReadVal(val)
+}
+
+func (any *arrayLazyAny) Get(path ...interface{}) Any {
+ if len(path) == 0 {
+ return any
+ }
+ switch firstPath := path[0].(type) {
+ case int:
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ valueBytes := locateArrayElement(iter, firstPath)
+ if valueBytes == nil {
+ return newInvalidAny(path)
+ }
+ iter.ResetBytes(valueBytes)
+ return locatePath(iter, path[1:])
+ case int32:
+ if '*' == firstPath {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ arr := make([]Any, 0)
+ iter.ReadArrayCB(func(iter *Iterator) bool {
+ found := iter.readAny().Get(path[1:]...)
+ if found.ValueType() != InvalidValue {
+ arr = append(arr, found)
+ }
+ return true
+ })
+ return wrapArray(arr)
+ }
+ return newInvalidAny(path)
+ default:
+ return newInvalidAny(path)
+ }
+}
+
+func (any *arrayLazyAny) Size() int {
+ size := 0
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ iter.ReadArrayCB(func(iter *Iterator) bool {
+ size++
+ iter.Skip()
+ return true
+ })
+ return size
+}
+
+func (any *arrayLazyAny) WriteTo(stream *Stream) {
+ stream.Write(any.buf)
+}
+
+func (any *arrayLazyAny) GetInterface() interface{} {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ return iter.Read()
+}
+
+type arrayAny struct {
+ baseAny
+ val reflect.Value
+}
+
+func wrapArray(val interface{}) *arrayAny {
+ return &arrayAny{baseAny{}, reflect.ValueOf(val)}
+}
+
+func (any *arrayAny) ValueType() ValueType {
+ return ArrayValue
+}
+
+func (any *arrayAny) MustBeValid() Any {
+ return any
+}
+
+func (any *arrayAny) LastError() error {
+ return nil
+}
+
+func (any *arrayAny) ToBool() bool {
+ return any.val.Len() != 0
+}
+
+func (any *arrayAny) ToInt() int {
+ if any.val.Len() == 0 {
+ return 0
+ }
+ return 1
+}
+
+func (any *arrayAny) ToInt32() int32 {
+ if any.val.Len() == 0 {
+ return 0
+ }
+ return 1
+}
+
+func (any *arrayAny) ToInt64() int64 {
+ if any.val.Len() == 0 {
+ return 0
+ }
+ return 1
+}
+
+func (any *arrayAny) ToUint() uint {
+ if any.val.Len() == 0 {
+ return 0
+ }
+ return 1
+}
+
+func (any *arrayAny) ToUint32() uint32 {
+ if any.val.Len() == 0 {
+ return 0
+ }
+ return 1
+}
+
+func (any *arrayAny) ToUint64() uint64 {
+ if any.val.Len() == 0 {
+ return 0
+ }
+ return 1
+}
+
+func (any *arrayAny) ToFloat32() float32 {
+ if any.val.Len() == 0 {
+ return 0
+ }
+ return 1
+}
+
+func (any *arrayAny) ToFloat64() float64 {
+ if any.val.Len() == 0 {
+ return 0
+ }
+ return 1
+}
+
+func (any *arrayAny) ToString() string {
+ str, _ := MarshalToString(any.val.Interface())
+ return str
+}
+
+func (any *arrayAny) Get(path ...interface{}) Any {
+ if len(path) == 0 {
+ return any
+ }
+ switch firstPath := path[0].(type) {
+ case int:
+ if firstPath < 0 || firstPath >= any.val.Len() {
+ return newInvalidAny(path)
+ }
+ return Wrap(any.val.Index(firstPath).Interface())
+ case int32:
+ if '*' == firstPath {
+ mappedAll := make([]Any, 0)
+ for i := 0; i < any.val.Len(); i++ {
+ mapped := Wrap(any.val.Index(i).Interface()).Get(path[1:]...)
+ if mapped.ValueType() != InvalidValue {
+ mappedAll = append(mappedAll, mapped)
+ }
+ }
+ return wrapArray(mappedAll)
+ }
+ return newInvalidAny(path)
+ default:
+ return newInvalidAny(path)
+ }
+}
+
+func (any *arrayAny) Size() int {
+ return any.val.Len()
+}
+
+func (any *arrayAny) WriteTo(stream *Stream) {
+ stream.WriteVal(any.val)
+}
+
+func (any *arrayAny) GetInterface() interface{} {
+ return any.val.Interface()
+}
diff --git a/vendor/github.com/json-iterator/go/any_bool.go b/vendor/github.com/json-iterator/go/any_bool.go
new file mode 100644
index 0000000..9452324
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_bool.go
@@ -0,0 +1,137 @@
+package jsoniter
+
+type trueAny struct {
+ baseAny
+}
+
+func (any *trueAny) LastError() error {
+ return nil
+}
+
+func (any *trueAny) ToBool() bool {
+ return true
+}
+
+func (any *trueAny) ToInt() int {
+ return 1
+}
+
+func (any *trueAny) ToInt32() int32 {
+ return 1
+}
+
+func (any *trueAny) ToInt64() int64 {
+ return 1
+}
+
+func (any *trueAny) ToUint() uint {
+ return 1
+}
+
+func (any *trueAny) ToUint32() uint32 {
+ return 1
+}
+
+func (any *trueAny) ToUint64() uint64 {
+ return 1
+}
+
+func (any *trueAny) ToFloat32() float32 {
+ return 1
+}
+
+func (any *trueAny) ToFloat64() float64 {
+ return 1
+}
+
+func (any *trueAny) ToString() string {
+ return "true"
+}
+
+func (any *trueAny) WriteTo(stream *Stream) {
+ stream.WriteTrue()
+}
+
+func (any *trueAny) Parse() *Iterator {
+ return nil
+}
+
+func (any *trueAny) GetInterface() interface{} {
+ return true
+}
+
+func (any *trueAny) ValueType() ValueType {
+ return BoolValue
+}
+
+func (any *trueAny) MustBeValid() Any {
+ return any
+}
+
+type falseAny struct {
+ baseAny
+}
+
+func (any *falseAny) LastError() error {
+ return nil
+}
+
+func (any *falseAny) ToBool() bool {
+ return false
+}
+
+func (any *falseAny) ToInt() int {
+ return 0
+}
+
+func (any *falseAny) ToInt32() int32 {
+ return 0
+}
+
+func (any *falseAny) ToInt64() int64 {
+ return 0
+}
+
+func (any *falseAny) ToUint() uint {
+ return 0
+}
+
+func (any *falseAny) ToUint32() uint32 {
+ return 0
+}
+
+func (any *falseAny) ToUint64() uint64 {
+ return 0
+}
+
+func (any *falseAny) ToFloat32() float32 {
+ return 0
+}
+
+func (any *falseAny) ToFloat64() float64 {
+ return 0
+}
+
+func (any *falseAny) ToString() string {
+ return "false"
+}
+
+func (any *falseAny) WriteTo(stream *Stream) {
+ stream.WriteFalse()
+}
+
+func (any *falseAny) Parse() *Iterator {
+ return nil
+}
+
+func (any *falseAny) GetInterface() interface{} {
+ return false
+}
+
+func (any *falseAny) ValueType() ValueType {
+ return BoolValue
+}
+
+func (any *falseAny) MustBeValid() Any {
+ return any
+}
diff --git a/vendor/github.com/json-iterator/go/any_float.go b/vendor/github.com/json-iterator/go/any_float.go
new file mode 100644
index 0000000..35fdb09
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_float.go
@@ -0,0 +1,83 @@
+package jsoniter
+
+import (
+ "strconv"
+)
+
+type floatAny struct {
+ baseAny
+ val float64
+}
+
+func (any *floatAny) Parse() *Iterator {
+ return nil
+}
+
+func (any *floatAny) ValueType() ValueType {
+ return NumberValue
+}
+
+func (any *floatAny) MustBeValid() Any {
+ return any
+}
+
+func (any *floatAny) LastError() error {
+ return nil
+}
+
+func (any *floatAny) ToBool() bool {
+ return any.ToFloat64() != 0
+}
+
+func (any *floatAny) ToInt() int {
+ return int(any.val)
+}
+
+func (any *floatAny) ToInt32() int32 {
+ return int32(any.val)
+}
+
+func (any *floatAny) ToInt64() int64 {
+ return int64(any.val)
+}
+
+func (any *floatAny) ToUint() uint {
+ if any.val > 0 {
+ return uint(any.val)
+ }
+ return 0
+}
+
+func (any *floatAny) ToUint32() uint32 {
+ if any.val > 0 {
+ return uint32(any.val)
+ }
+ return 0
+}
+
+func (any *floatAny) ToUint64() uint64 {
+ if any.val > 0 {
+ return uint64(any.val)
+ }
+ return 0
+}
+
+func (any *floatAny) ToFloat32() float32 {
+ return float32(any.val)
+}
+
+func (any *floatAny) ToFloat64() float64 {
+ return any.val
+}
+
+func (any *floatAny) ToString() string {
+ return strconv.FormatFloat(any.val, 'E', -1, 64)
+}
+
+func (any *floatAny) WriteTo(stream *Stream) {
+ stream.WriteFloat64(any.val)
+}
+
+func (any *floatAny) GetInterface() interface{} {
+ return any.val
+}
diff --git a/vendor/github.com/json-iterator/go/any_int32.go b/vendor/github.com/json-iterator/go/any_int32.go
new file mode 100644
index 0000000..1b56f39
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_int32.go
@@ -0,0 +1,74 @@
+package jsoniter
+
+import (
+ "strconv"
+)
+
+type int32Any struct {
+ baseAny
+ val int32
+}
+
+func (any *int32Any) LastError() error {
+ return nil
+}
+
+func (any *int32Any) ValueType() ValueType {
+ return NumberValue
+}
+
+func (any *int32Any) MustBeValid() Any {
+ return any
+}
+
+func (any *int32Any) ToBool() bool {
+ return any.val != 0
+}
+
+func (any *int32Any) ToInt() int {
+ return int(any.val)
+}
+
+func (any *int32Any) ToInt32() int32 {
+ return any.val
+}
+
+func (any *int32Any) ToInt64() int64 {
+ return int64(any.val)
+}
+
+func (any *int32Any) ToUint() uint {
+ return uint(any.val)
+}
+
+func (any *int32Any) ToUint32() uint32 {
+ return uint32(any.val)
+}
+
+func (any *int32Any) ToUint64() uint64 {
+ return uint64(any.val)
+}
+
+func (any *int32Any) ToFloat32() float32 {
+ return float32(any.val)
+}
+
+func (any *int32Any) ToFloat64() float64 {
+ return float64(any.val)
+}
+
+func (any *int32Any) ToString() string {
+ return strconv.FormatInt(int64(any.val), 10)
+}
+
+func (any *int32Any) WriteTo(stream *Stream) {
+ stream.WriteInt32(any.val)
+}
+
+func (any *int32Any) Parse() *Iterator {
+ return nil
+}
+
+func (any *int32Any) GetInterface() interface{} {
+ return any.val
+}
diff --git a/vendor/github.com/json-iterator/go/any_int64.go b/vendor/github.com/json-iterator/go/any_int64.go
new file mode 100644
index 0000000..c440d72
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_int64.go
@@ -0,0 +1,74 @@
+package jsoniter
+
+import (
+ "strconv"
+)
+
+type int64Any struct {
+ baseAny
+ val int64
+}
+
+func (any *int64Any) LastError() error {
+ return nil
+}
+
+func (any *int64Any) ValueType() ValueType {
+ return NumberValue
+}
+
+func (any *int64Any) MustBeValid() Any {
+ return any
+}
+
+func (any *int64Any) ToBool() bool {
+ return any.val != 0
+}
+
+func (any *int64Any) ToInt() int {
+ return int(any.val)
+}
+
+func (any *int64Any) ToInt32() int32 {
+ return int32(any.val)
+}
+
+func (any *int64Any) ToInt64() int64 {
+ return any.val
+}
+
+func (any *int64Any) ToUint() uint {
+ return uint(any.val)
+}
+
+func (any *int64Any) ToUint32() uint32 {
+ return uint32(any.val)
+}
+
+func (any *int64Any) ToUint64() uint64 {
+ return uint64(any.val)
+}
+
+func (any *int64Any) ToFloat32() float32 {
+ return float32(any.val)
+}
+
+func (any *int64Any) ToFloat64() float64 {
+ return float64(any.val)
+}
+
+func (any *int64Any) ToString() string {
+ return strconv.FormatInt(any.val, 10)
+}
+
+func (any *int64Any) WriteTo(stream *Stream) {
+ stream.WriteInt64(any.val)
+}
+
+func (any *int64Any) Parse() *Iterator {
+ return nil
+}
+
+func (any *int64Any) GetInterface() interface{} {
+ return any.val
+}
diff --git a/vendor/github.com/json-iterator/go/any_invalid.go b/vendor/github.com/json-iterator/go/any_invalid.go
new file mode 100644
index 0000000..1d859ea
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_invalid.go
@@ -0,0 +1,82 @@
+package jsoniter
+
+import "fmt"
+
+type invalidAny struct {
+ baseAny
+ err error
+}
+
+func newInvalidAny(path []interface{}) *invalidAny {
+ return &invalidAny{baseAny{}, fmt.Errorf("%v not found", path)}
+}
+
+func (any *invalidAny) LastError() error {
+ return any.err
+}
+
+func (any *invalidAny) ValueType() ValueType {
+ return InvalidValue
+}
+
+func (any *invalidAny) MustBeValid() Any {
+ panic(any.err)
+}
+
+func (any *invalidAny) ToBool() bool {
+ return false
+}
+
+func (any *invalidAny) ToInt() int {
+ return 0
+}
+
+func (any *invalidAny) ToInt32() int32 {
+ return 0
+}
+
+func (any *invalidAny) ToInt64() int64 {
+ return 0
+}
+
+func (any *invalidAny) ToUint() uint {
+ return 0
+}
+
+func (any *invalidAny) ToUint32() uint32 {
+ return 0
+}
+
+func (any *invalidAny) ToUint64() uint64 {
+ return 0
+}
+
+func (any *invalidAny) ToFloat32() float32 {
+ return 0
+}
+
+func (any *invalidAny) ToFloat64() float64 {
+ return 0
+}
+
+func (any *invalidAny) ToString() string {
+ return ""
+}
+
+func (any *invalidAny) WriteTo(stream *Stream) {
+}
+
+func (any *invalidAny) Get(path ...interface{}) Any {
+ if any.err == nil {
+ return &invalidAny{baseAny{}, fmt.Errorf("get %v from invalid", path)}
+ }
+ return &invalidAny{baseAny{}, fmt.Errorf("%v, get %v from invalid", any.err, path)}
+}
+
+func (any *invalidAny) Parse() *Iterator {
+ return nil
+}
+
+func (any *invalidAny) GetInterface() interface{} {
+ return nil
+}
diff --git a/vendor/github.com/json-iterator/go/any_nil.go b/vendor/github.com/json-iterator/go/any_nil.go
new file mode 100644
index 0000000..d04cb54
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_nil.go
@@ -0,0 +1,69 @@
+package jsoniter
+
+type nilAny struct {
+ baseAny
+}
+
+func (any *nilAny) LastError() error {
+ return nil
+}
+
+func (any *nilAny) ValueType() ValueType {
+ return NilValue
+}
+
+func (any *nilAny) MustBeValid() Any {
+ return any
+}
+
+func (any *nilAny) ToBool() bool {
+ return false
+}
+
+func (any *nilAny) ToInt() int {
+ return 0
+}
+
+func (any *nilAny) ToInt32() int32 {
+ return 0
+}
+
+func (any *nilAny) ToInt64() int64 {
+ return 0
+}
+
+func (any *nilAny) ToUint() uint {
+ return 0
+}
+
+func (any *nilAny) ToUint32() uint32 {
+ return 0
+}
+
+func (any *nilAny) ToUint64() uint64 {
+ return 0
+}
+
+func (any *nilAny) ToFloat32() float32 {
+ return 0
+}
+
+func (any *nilAny) ToFloat64() float64 {
+ return 0
+}
+
+func (any *nilAny) ToString() string {
+ return ""
+}
+
+func (any *nilAny) WriteTo(stream *Stream) {
+ stream.WriteNil()
+}
+
+func (any *nilAny) Parse() *Iterator {
+ return nil
+}
+
+func (any *nilAny) GetInterface() interface{} {
+ return nil
+}
diff --git a/vendor/github.com/json-iterator/go/any_number.go b/vendor/github.com/json-iterator/go/any_number.go
new file mode 100644
index 0000000..9d1e901
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_number.go
@@ -0,0 +1,123 @@
+package jsoniter
+
+import (
+ "io"
+ "unsafe"
+)
+
+type numberLazyAny struct {
+ baseAny
+ cfg *frozenConfig
+ buf []byte
+ err error
+}
+
+func (any *numberLazyAny) ValueType() ValueType {
+ return NumberValue
+}
+
+func (any *numberLazyAny) MustBeValid() Any {
+ return any
+}
+
+func (any *numberLazyAny) LastError() error {
+ return any.err
+}
+
+func (any *numberLazyAny) ToBool() bool {
+ return any.ToFloat64() != 0
+}
+
+func (any *numberLazyAny) ToInt() int {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ val := iter.ReadInt()
+ if iter.Error != nil && iter.Error != io.EOF {
+ any.err = iter.Error
+ }
+ return val
+}
+
+func (any *numberLazyAny) ToInt32() int32 {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ val := iter.ReadInt32()
+ if iter.Error != nil && iter.Error != io.EOF {
+ any.err = iter.Error
+ }
+ return val
+}
+
+func (any *numberLazyAny) ToInt64() int64 {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ val := iter.ReadInt64()
+ if iter.Error != nil && iter.Error != io.EOF {
+ any.err = iter.Error
+ }
+ return val
+}
+
+func (any *numberLazyAny) ToUint() uint {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ val := iter.ReadUint()
+ if iter.Error != nil && iter.Error != io.EOF {
+ any.err = iter.Error
+ }
+ return val
+}
+
+func (any *numberLazyAny) ToUint32() uint32 {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ val := iter.ReadUint32()
+ if iter.Error != nil && iter.Error != io.EOF {
+ any.err = iter.Error
+ }
+ return val
+}
+
+func (any *numberLazyAny) ToUint64() uint64 {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ val := iter.ReadUint64()
+ if iter.Error != nil && iter.Error != io.EOF {
+ any.err = iter.Error
+ }
+ return val
+}
+
+func (any *numberLazyAny) ToFloat32() float32 {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ val := iter.ReadFloat32()
+ if iter.Error != nil && iter.Error != io.EOF {
+ any.err = iter.Error
+ }
+ return val
+}
+
+func (any *numberLazyAny) ToFloat64() float64 {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ val := iter.ReadFloat64()
+ if iter.Error != nil && iter.Error != io.EOF {
+ any.err = iter.Error
+ }
+ return val
+}
+
+func (any *numberLazyAny) ToString() string {
+ return *(*string)(unsafe.Pointer(&any.buf))
+}
+
+func (any *numberLazyAny) WriteTo(stream *Stream) {
+ stream.Write(any.buf)
+}
+
+func (any *numberLazyAny) GetInterface() interface{} {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ return iter.Read()
+}
diff --git a/vendor/github.com/json-iterator/go/any_object.go b/vendor/github.com/json-iterator/go/any_object.go
new file mode 100644
index 0000000..c44ef5c
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_object.go
@@ -0,0 +1,374 @@
+package jsoniter
+
+import (
+ "reflect"
+ "unsafe"
+)
+
+type objectLazyAny struct {
+ baseAny
+ cfg *frozenConfig
+ buf []byte
+ err error
+}
+
+func (any *objectLazyAny) ValueType() ValueType {
+ return ObjectValue
+}
+
+func (any *objectLazyAny) MustBeValid() Any {
+ return any
+}
+
+func (any *objectLazyAny) LastError() error {
+ return any.err
+}
+
+func (any *objectLazyAny) ToBool() bool {
+ return true
+}
+
+func (any *objectLazyAny) ToInt() int {
+ return 0
+}
+
+func (any *objectLazyAny) ToInt32() int32 {
+ return 0
+}
+
+func (any *objectLazyAny) ToInt64() int64 {
+ return 0
+}
+
+func (any *objectLazyAny) ToUint() uint {
+ return 0
+}
+
+func (any *objectLazyAny) ToUint32() uint32 {
+ return 0
+}
+
+func (any *objectLazyAny) ToUint64() uint64 {
+ return 0
+}
+
+func (any *objectLazyAny) ToFloat32() float32 {
+ return 0
+}
+
+func (any *objectLazyAny) ToFloat64() float64 {
+ return 0
+}
+
+func (any *objectLazyAny) ToString() string {
+ return *(*string)(unsafe.Pointer(&any.buf))
+}
+
+func (any *objectLazyAny) ToVal(obj interface{}) {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ iter.ReadVal(obj)
+}
+
+func (any *objectLazyAny) Get(path ...interface{}) Any {
+ if len(path) == 0 {
+ return any
+ }
+ switch firstPath := path[0].(type) {
+ case string:
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ valueBytes := locateObjectField(iter, firstPath)
+ if valueBytes == nil {
+ return newInvalidAny(path)
+ }
+ iter.ResetBytes(valueBytes)
+ return locatePath(iter, path[1:])
+ case int32:
+ if '*' == firstPath {
+ mappedAll := map[string]Any{}
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ iter.ReadMapCB(func(iter *Iterator, field string) bool {
+ mapped := locatePath(iter, path[1:])
+ if mapped.ValueType() != InvalidValue {
+ mappedAll[field] = mapped
+ }
+ return true
+ })
+ return wrapMap(mappedAll)
+ }
+ return newInvalidAny(path)
+ default:
+ return newInvalidAny(path)
+ }
+}
+
+func (any *objectLazyAny) Keys() []string {
+ keys := []string{}
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ iter.ReadMapCB(func(iter *Iterator, field string) bool {
+ iter.Skip()
+ keys = append(keys, field)
+ return true
+ })
+ return keys
+}
+
+func (any *objectLazyAny) Size() int {
+ size := 0
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ iter.ReadObjectCB(func(iter *Iterator, field string) bool {
+ iter.Skip()
+ size++
+ return true
+ })
+ return size
+}
+
+func (any *objectLazyAny) WriteTo(stream *Stream) {
+ stream.Write(any.buf)
+}
+
+func (any *objectLazyAny) GetInterface() interface{} {
+ iter := any.cfg.BorrowIterator(any.buf)
+ defer any.cfg.ReturnIterator(iter)
+ return iter.Read()
+}
+
+type objectAny struct {
+ baseAny
+ err error
+ val reflect.Value
+}
+
+func wrapStruct(val interface{}) *objectAny {
+ return &objectAny{baseAny{}, nil, reflect.ValueOf(val)}
+}
+
+func (any *objectAny) ValueType() ValueType {
+ return ObjectValue
+}
+
+func (any *objectAny) MustBeValid() Any {
+ return any
+}
+
+func (any *objectAny) Parse() *Iterator {
+ return nil
+}
+
+func (any *objectAny) LastError() error {
+ return any.err
+}
+
+func (any *objectAny) ToBool() bool {
+ return any.val.NumField() != 0
+}
+
+func (any *objectAny) ToInt() int {
+ return 0
+}
+
+func (any *objectAny) ToInt32() int32 {
+ return 0
+}
+
+func (any *objectAny) ToInt64() int64 {
+ return 0
+}
+
+func (any *objectAny) ToUint() uint {
+ return 0
+}
+
+func (any *objectAny) ToUint32() uint32 {
+ return 0
+}
+
+func (any *objectAny) ToUint64() uint64 {
+ return 0
+}
+
+func (any *objectAny) ToFloat32() float32 {
+ return 0
+}
+
+func (any *objectAny) ToFloat64() float64 {
+ return 0
+}
+
+func (any *objectAny) ToString() string {
+ str, err := MarshalToString(any.val.Interface())
+ any.err = err
+ return str
+}
+
+func (any *objectAny) Get(path ...interface{}) Any {
+ if len(path) == 0 {
+ return any
+ }
+ switch firstPath := path[0].(type) {
+ case string:
+ field := any.val.FieldByName(firstPath)
+ if !field.IsValid() {
+ return newInvalidAny(path)
+ }
+ return Wrap(field.Interface())
+ case int32:
+ if '*' == firstPath {
+ mappedAll := map[string]Any{}
+ for i := 0; i < any.val.NumField(); i++ {
+ field := any.val.Field(i)
+ if field.CanInterface() {
+ mapped := Wrap(field.Interface()).Get(path[1:]...)
+ if mapped.ValueType() != InvalidValue {
+ mappedAll[any.val.Type().Field(i).Name] = mapped
+ }
+ }
+ }
+ return wrapMap(mappedAll)
+ }
+ return newInvalidAny(path)
+ default:
+ return newInvalidAny(path)
+ }
+}
+
+func (any *objectAny) Keys() []string {
+ keys := make([]string, 0, any.val.NumField())
+ for i := 0; i < any.val.NumField(); i++ {
+ keys = append(keys, any.val.Type().Field(i).Name)
+ }
+ return keys
+}
+
+func (any *objectAny) Size() int {
+ return any.val.NumField()
+}
+
+func (any *objectAny) WriteTo(stream *Stream) {
+ stream.WriteVal(any.val)
+}
+
+func (any *objectAny) GetInterface() interface{} {
+ return any.val.Interface()
+}
+
+type mapAny struct {
+ baseAny
+ err error
+ val reflect.Value
+}
+
+func wrapMap(val interface{}) *mapAny {
+ return &mapAny{baseAny{}, nil, reflect.ValueOf(val)}
+}
+
+func (any *mapAny) ValueType() ValueType {
+ return ObjectValue
+}
+
+func (any *mapAny) MustBeValid() Any {
+ return any
+}
+
+func (any *mapAny) Parse() *Iterator {
+ return nil
+}
+
+func (any *mapAny) LastError() error {
+ return any.err
+}
+
+func (any *mapAny) ToBool() bool {
+ return true
+}
+
+func (any *mapAny) ToInt() int {
+ return 0
+}
+
+func (any *mapAny) ToInt32() int32 {
+ return 0
+}
+
+func (any *mapAny) ToInt64() int64 {
+ return 0
+}
+
+func (any *mapAny) ToUint() uint {
+ return 0
+}
+
+func (any *mapAny) ToUint32() uint32 {
+ return 0
+}
+
+func (any *mapAny) ToUint64() uint64 {
+ return 0
+}
+
+func (any *mapAny) ToFloat32() float32 {
+ return 0
+}
+
+func (any *mapAny) ToFloat64() float64 {
+ return 0
+}
+
+func (any *mapAny) ToString() string {
+ str, err := MarshalToString(any.val.Interface())
+ any.err = err
+ return str
+}
+
+func (any *mapAny) Get(path ...interface{}) Any {
+ if len(path) == 0 {
+ return any
+ }
+ switch firstPath := path[0].(type) {
+ case int32:
+ if '*' == firstPath {
+ mappedAll := map[string]Any{}
+ for _, key := range any.val.MapKeys() {
+ keyAsStr := key.String()
+ element := Wrap(any.val.MapIndex(key).Interface())
+ mapped := element.Get(path[1:]...)
+ if mapped.ValueType() != InvalidValue {
+ mappedAll[keyAsStr] = mapped
+ }
+ }
+ return wrapMap(mappedAll)
+ }
+ return newInvalidAny(path)
+ default:
+ value := any.val.MapIndex(reflect.ValueOf(firstPath))
+ if !value.IsValid() {
+ return newInvalidAny(path)
+ }
+ return Wrap(value.Interface())
+ }
+}
+
+func (any *mapAny) Keys() []string {
+ keys := make([]string, 0, any.val.Len())
+ for _, key := range any.val.MapKeys() {
+ keys = append(keys, key.String())
+ }
+ return keys
+}
+
+func (any *mapAny) Size() int {
+ return any.val.Len()
+}
+
+func (any *mapAny) WriteTo(stream *Stream) {
+ stream.WriteVal(any.val)
+}
+
+func (any *mapAny) GetInterface() interface{} {
+ return any.val.Interface()
+}
diff --git a/vendor/github.com/json-iterator/go/any_str.go b/vendor/github.com/json-iterator/go/any_str.go
new file mode 100644
index 0000000..1f12f66
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_str.go
@@ -0,0 +1,166 @@
+package jsoniter
+
+import (
+ "fmt"
+ "strconv"
+)
+
+type stringAny struct {
+ baseAny
+ val string
+}
+
+func (any *stringAny) Get(path ...interface{}) Any {
+ if len(path) == 0 {
+ return any
+ }
+ return &invalidAny{baseAny{}, fmt.Errorf("GetIndex %v from simple value", path)}
+}
+
+func (any *stringAny) Parse() *Iterator {
+ return nil
+}
+
+func (any *stringAny) ValueType() ValueType {
+ return StringValue
+}
+
+func (any *stringAny) MustBeValid() Any {
+ return any
+}
+
+func (any *stringAny) LastError() error {
+ return nil
+}
+
+func (any *stringAny) ToBool() bool {
+ str := any.ToString()
+ if str == "0" {
+ return false
+ }
+ for _, c := range str {
+ switch c {
+ case ' ', '\n', '\r', '\t':
+ default:
+ return true
+ }
+ }
+ return false
+}
+
+func (any *stringAny) ToInt() int {
+ return int(any.ToInt64())
+
+}
+
+func (any *stringAny) ToInt32() int32 {
+ return int32(any.ToInt64())
+}
+
+func (any *stringAny) ToInt64() int64 {
+ if any.val == "" {
+ return 0
+ }
+
+ flag := 1
+ startPos := 0
+ if any.val[0] == '+' || any.val[0] == '-' {
+ startPos = 1
+ }
+
+ if any.val[0] == '-' {
+ flag = -1
+ }
+
+ endPos := startPos
+ for i := startPos; i < len(any.val); i++ {
+ if any.val[i] >= '0' && any.val[i] <= '9' {
+ endPos = i + 1
+ } else {
+ break
+ }
+ }
+ parsed, _ := strconv.ParseInt(any.val[startPos:endPos], 10, 64)
+ return int64(flag) * parsed
+}
+
+func (any *stringAny) ToUint() uint {
+ return uint(any.ToUint64())
+}
+
+func (any *stringAny) ToUint32() uint32 {
+ return uint32(any.ToUint64())
+}
+
+func (any *stringAny) ToUint64() uint64 {
+ if any.val == "" {
+ return 0
+ }
+
+ startPos := 0
+
+ if any.val[0] == '-' {
+ return 0
+ }
+ if any.val[0] == '+' {
+ startPos = 1
+ }
+
+ endPos := startPos
+ for i := startPos; i < len(any.val); i++ {
+ if any.val[i] >= '0' && any.val[i] <= '9' {
+ endPos = i + 1
+ } else {
+ break
+ }
+ }
+ parsed, _ := strconv.ParseUint(any.val[startPos:endPos], 10, 64)
+ return parsed
+}
+
+func (any *stringAny) ToFloat32() float32 {
+ return float32(any.ToFloat64())
+}
+
+func (any *stringAny) ToFloat64() float64 {
+ if len(any.val) == 0 {
+ return 0
+ }
+
+ // first char invalid
+ if any.val[0] != '+' && any.val[0] != '-' && (any.val[0] > '9' || any.val[0] < '0') {
+ return 0
+ }
+
+ // extract valid num expression from string
+ // eg 123true => 123, -12.12xxa => -12.12
+ endPos := 1
+ for i := 1; i < len(any.val); i++ {
+ if any.val[i] == '.' || any.val[i] == 'e' || any.val[i] == 'E' || any.val[i] == '+' || any.val[i] == '-' {
+ endPos = i + 1
+ continue
+ }
+
+ // end position is the first char which is not digit
+ if any.val[i] >= '0' && any.val[i] <= '9' {
+ endPos = i + 1
+ } else {
+ endPos = i
+ break
+ }
+ }
+ parsed, _ := strconv.ParseFloat(any.val[:endPos], 64)
+ return parsed
+}
+
+func (any *stringAny) ToString() string {
+ return any.val
+}
+
+func (any *stringAny) WriteTo(stream *Stream) {
+ stream.WriteString(any.val)
+}
+
+func (any *stringAny) GetInterface() interface{} {
+ return any.val
+}
diff --git a/vendor/github.com/json-iterator/go/any_uint32.go b/vendor/github.com/json-iterator/go/any_uint32.go
new file mode 100644
index 0000000..656bbd3
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_uint32.go
@@ -0,0 +1,74 @@
+package jsoniter
+
+import (
+ "strconv"
+)
+
+type uint32Any struct {
+ baseAny
+ val uint32
+}
+
+func (any *uint32Any) LastError() error {
+ return nil
+}
+
+func (any *uint32Any) ValueType() ValueType {
+ return NumberValue
+}
+
+func (any *uint32Any) MustBeValid() Any {
+ return any
+}
+
+func (any *uint32Any) ToBool() bool {
+ return any.val != 0
+}
+
+func (any *uint32Any) ToInt() int {
+ return int(any.val)
+}
+
+func (any *uint32Any) ToInt32() int32 {
+ return int32(any.val)
+}
+
+func (any *uint32Any) ToInt64() int64 {
+ return int64(any.val)
+}
+
+func (any *uint32Any) ToUint() uint {
+ return uint(any.val)
+}
+
+func (any *uint32Any) ToUint32() uint32 {
+ return any.val
+}
+
+func (any *uint32Any) ToUint64() uint64 {
+ return uint64(any.val)
+}
+
+func (any *uint32Any) ToFloat32() float32 {
+ return float32(any.val)
+}
+
+func (any *uint32Any) ToFloat64() float64 {
+ return float64(any.val)
+}
+
+func (any *uint32Any) ToString() string {
+ return strconv.FormatInt(int64(any.val), 10)
+}
+
+func (any *uint32Any) WriteTo(stream *Stream) {
+ stream.WriteUint32(any.val)
+}
+
+func (any *uint32Any) Parse() *Iterator {
+ return nil
+}
+
+func (any *uint32Any) GetInterface() interface{} {
+ return any.val
+}
diff --git a/vendor/github.com/json-iterator/go/any_uint64.go b/vendor/github.com/json-iterator/go/any_uint64.go
new file mode 100644
index 0000000..7df2fce
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_uint64.go
@@ -0,0 +1,74 @@
+package jsoniter
+
+import (
+ "strconv"
+)
+
+type uint64Any struct {
+ baseAny
+ val uint64
+}
+
+func (any *uint64Any) LastError() error {
+ return nil
+}
+
+func (any *uint64Any) ValueType() ValueType {
+ return NumberValue
+}
+
+func (any *uint64Any) MustBeValid() Any {
+ return any
+}
+
+func (any *uint64Any) ToBool() bool {
+ return any.val != 0
+}
+
+func (any *uint64Any) ToInt() int {
+ return int(any.val)
+}
+
+func (any *uint64Any) ToInt32() int32 {
+ return int32(any.val)
+}
+
+func (any *uint64Any) ToInt64() int64 {
+ return int64(any.val)
+}
+
+func (any *uint64Any) ToUint() uint {
+ return uint(any.val)
+}
+
+func (any *uint64Any) ToUint32() uint32 {
+ return uint32(any.val)
+}
+
+func (any *uint64Any) ToUint64() uint64 {
+ return any.val
+}
+
+func (any *uint64Any) ToFloat32() float32 {
+ return float32(any.val)
+}
+
+func (any *uint64Any) ToFloat64() float64 {
+ return float64(any.val)
+}
+
+func (any *uint64Any) ToString() string {
+ return strconv.FormatUint(any.val, 10)
+}
+
+func (any *uint64Any) WriteTo(stream *Stream) {
+ stream.WriteUint64(any.val)
+}
+
+func (any *uint64Any) Parse() *Iterator {
+ return nil
+}
+
+func (any *uint64Any) GetInterface() interface{} {
+ return any.val
+}
diff --git a/vendor/github.com/json-iterator/go/build.sh b/vendor/github.com/json-iterator/go/build.sh
new file mode 100644
index 0000000..b45ef68
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/build.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+set -e
+set -x
+
+if [ ! -d /tmp/build-golang/src/github.com/json-iterator ]; then
+ mkdir -p /tmp/build-golang/src/github.com/json-iterator
+ ln -s $PWD /tmp/build-golang/src/github.com/json-iterator/go
+fi
+export GOPATH=/tmp/build-golang
+go get -u github.com/golang/dep/cmd/dep
+cd /tmp/build-golang/src/github.com/json-iterator/go
+exec $GOPATH/bin/dep ensure -update
diff --git a/vendor/github.com/json-iterator/go/config.go b/vendor/github.com/json-iterator/go/config.go
new file mode 100644
index 0000000..2adcdc3
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/config.go
@@ -0,0 +1,375 @@
+package jsoniter
+
+import (
+ "encoding/json"
+ "io"
+ "reflect"
+ "sync"
+ "unsafe"
+
+ "github.com/modern-go/concurrent"
+ "github.com/modern-go/reflect2"
+)
+
+// Config customize how the API should behave.
+// The API is created from Config by Froze.
+type Config struct {
+ IndentionStep int
+ MarshalFloatWith6Digits bool
+ EscapeHTML bool
+ SortMapKeys bool
+ UseNumber bool
+ DisallowUnknownFields bool
+ TagKey string
+ OnlyTaggedField bool
+ ValidateJsonRawMessage bool
+ ObjectFieldMustBeSimpleString bool
+ CaseSensitive bool
+}
+
+// API the public interface of this package.
+// Primary Marshal and Unmarshal.
+type API interface {
+ IteratorPool
+ StreamPool
+ MarshalToString(v interface{}) (string, error)
+ Marshal(v interface{}) ([]byte, error)
+ MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
+ UnmarshalFromString(str string, v interface{}) error
+ Unmarshal(data []byte, v interface{}) error
+ Get(data []byte, path ...interface{}) Any
+ NewEncoder(writer io.Writer) *Encoder
+ NewDecoder(reader io.Reader) *Decoder
+ Valid(data []byte) bool
+ RegisterExtension(extension Extension)
+ DecoderOf(typ reflect2.Type) ValDecoder
+ EncoderOf(typ reflect2.Type) ValEncoder
+}
+
+// ConfigDefault the default API
+var ConfigDefault = Config{
+ EscapeHTML: true,
+}.Froze()
+
+// ConfigCompatibleWithStandardLibrary tries to be 100% compatible with standard library behavior
+var ConfigCompatibleWithStandardLibrary = Config{
+ EscapeHTML: true,
+ SortMapKeys: true,
+ ValidateJsonRawMessage: true,
+}.Froze()
+
+// ConfigFastest marshals float with only 6 digits precision
+var ConfigFastest = Config{
+ EscapeHTML: false,
+ MarshalFloatWith6Digits: true, // will lose precession
+ ObjectFieldMustBeSimpleString: true, // do not unescape object field
+}.Froze()
+
+type frozenConfig struct {
+ configBeforeFrozen Config
+ sortMapKeys bool
+ indentionStep int
+ objectFieldMustBeSimpleString bool
+ onlyTaggedField bool
+ disallowUnknownFields bool
+ decoderCache *concurrent.Map
+ encoderCache *concurrent.Map
+ encoderExtension Extension
+ decoderExtension Extension
+ extraExtensions []Extension
+ streamPool *sync.Pool
+ iteratorPool *sync.Pool
+ caseSensitive bool
+}
+
+func (cfg *frozenConfig) initCache() {
+ cfg.decoderCache = concurrent.NewMap()
+ cfg.encoderCache = concurrent.NewMap()
+}
+
+func (cfg *frozenConfig) addDecoderToCache(cacheKey uintptr, decoder ValDecoder) {
+ cfg.decoderCache.Store(cacheKey, decoder)
+}
+
+func (cfg *frozenConfig) addEncoderToCache(cacheKey uintptr, encoder ValEncoder) {
+ cfg.encoderCache.Store(cacheKey, encoder)
+}
+
+func (cfg *frozenConfig) getDecoderFromCache(cacheKey uintptr) ValDecoder {
+ decoder, found := cfg.decoderCache.Load(cacheKey)
+ if found {
+ return decoder.(ValDecoder)
+ }
+ return nil
+}
+
+func (cfg *frozenConfig) getEncoderFromCache(cacheKey uintptr) ValEncoder {
+ encoder, found := cfg.encoderCache.Load(cacheKey)
+ if found {
+ return encoder.(ValEncoder)
+ }
+ return nil
+}
+
+var cfgCache = concurrent.NewMap()
+
+func getFrozenConfigFromCache(cfg Config) *frozenConfig {
+ obj, found := cfgCache.Load(cfg)
+ if found {
+ return obj.(*frozenConfig)
+ }
+ return nil
+}
+
+func addFrozenConfigToCache(cfg Config, frozenConfig *frozenConfig) {
+ cfgCache.Store(cfg, frozenConfig)
+}
+
+// Froze forge API from config
+func (cfg Config) Froze() API {
+ api := &frozenConfig{
+ sortMapKeys: cfg.SortMapKeys,
+ indentionStep: cfg.IndentionStep,
+ objectFieldMustBeSimpleString: cfg.ObjectFieldMustBeSimpleString,
+ onlyTaggedField: cfg.OnlyTaggedField,
+ disallowUnknownFields: cfg.DisallowUnknownFields,
+ caseSensitive: cfg.CaseSensitive,
+ }
+ api.streamPool = &sync.Pool{
+ New: func() interface{} {
+ return NewStream(api, nil, 512)
+ },
+ }
+ api.iteratorPool = &sync.Pool{
+ New: func() interface{} {
+ return NewIterator(api)
+ },
+ }
+ api.initCache()
+ encoderExtension := EncoderExtension{}
+ decoderExtension := DecoderExtension{}
+ if cfg.MarshalFloatWith6Digits {
+ api.marshalFloatWith6Digits(encoderExtension)
+ }
+ if cfg.EscapeHTML {
+ api.escapeHTML(encoderExtension)
+ }
+ if cfg.UseNumber {
+ api.useNumber(decoderExtension)
+ }
+ if cfg.ValidateJsonRawMessage {
+ api.validateJsonRawMessage(encoderExtension)
+ }
+ api.encoderExtension = encoderExtension
+ api.decoderExtension = decoderExtension
+ api.configBeforeFrozen = cfg
+ return api
+}
+
+func (cfg Config) frozeWithCacheReuse(extraExtensions []Extension) *frozenConfig {
+ api := getFrozenConfigFromCache(cfg)
+ if api != nil {
+ return api
+ }
+ api = cfg.Froze().(*frozenConfig)
+ for _, extension := range extraExtensions {
+ api.RegisterExtension(extension)
+ }
+ addFrozenConfigToCache(cfg, api)
+ return api
+}
+
+func (cfg *frozenConfig) validateJsonRawMessage(extension EncoderExtension) {
+ encoder := &funcEncoder{func(ptr unsafe.Pointer, stream *Stream) {
+ rawMessage := *(*json.RawMessage)(ptr)
+ iter := cfg.BorrowIterator([]byte(rawMessage))
+ defer cfg.ReturnIterator(iter)
+ iter.Read()
+ if iter.Error != nil && iter.Error != io.EOF {
+ stream.WriteRaw("null")
+ } else {
+ stream.WriteRaw(string(rawMessage))
+ }
+ }, func(ptr unsafe.Pointer) bool {
+ return len(*((*json.RawMessage)(ptr))) == 0
+ }}
+ extension[reflect2.TypeOfPtr((*json.RawMessage)(nil)).Elem()] = encoder
+ extension[reflect2.TypeOfPtr((*RawMessage)(nil)).Elem()] = encoder
+}
+
+func (cfg *frozenConfig) useNumber(extension DecoderExtension) {
+ extension[reflect2.TypeOfPtr((*interface{})(nil)).Elem()] = &funcDecoder{func(ptr unsafe.Pointer, iter *Iterator) {
+ exitingValue := *((*interface{})(ptr))
+ if exitingValue != nil && reflect.TypeOf(exitingValue).Kind() == reflect.Ptr {
+ iter.ReadVal(exitingValue)
+ return
+ }
+ if iter.WhatIsNext() == NumberValue {
+ *((*interface{})(ptr)) = json.Number(iter.readNumberAsString())
+ } else {
+ *((*interface{})(ptr)) = iter.Read()
+ }
+ }}
+}
+func (cfg *frozenConfig) getTagKey() string {
+ tagKey := cfg.configBeforeFrozen.TagKey
+ if tagKey == "" {
+ return "json"
+ }
+ return tagKey
+}
+
+func (cfg *frozenConfig) RegisterExtension(extension Extension) {
+ cfg.extraExtensions = append(cfg.extraExtensions, extension)
+ copied := cfg.configBeforeFrozen
+ cfg.configBeforeFrozen = copied
+}
+
+type lossyFloat32Encoder struct {
+}
+
+func (encoder *lossyFloat32Encoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteFloat32Lossy(*((*float32)(ptr)))
+}
+
+func (encoder *lossyFloat32Encoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*float32)(ptr)) == 0
+}
+
+type lossyFloat64Encoder struct {
+}
+
+func (encoder *lossyFloat64Encoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteFloat64Lossy(*((*float64)(ptr)))
+}
+
+func (encoder *lossyFloat64Encoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*float64)(ptr)) == 0
+}
+
+// EnableLossyFloatMarshalling keeps 10**(-6) precision
+// for float variables for better performance.
+func (cfg *frozenConfig) marshalFloatWith6Digits(extension EncoderExtension) {
+ // for better performance
+ extension[reflect2.TypeOfPtr((*float32)(nil)).Elem()] = &lossyFloat32Encoder{}
+ extension[reflect2.TypeOfPtr((*float64)(nil)).Elem()] = &lossyFloat64Encoder{}
+}
+
+type htmlEscapedStringEncoder struct {
+}
+
+func (encoder *htmlEscapedStringEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ str := *((*string)(ptr))
+ stream.WriteStringWithHTMLEscaped(str)
+}
+
+func (encoder *htmlEscapedStringEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*string)(ptr)) == ""
+}
+
+func (cfg *frozenConfig) escapeHTML(encoderExtension EncoderExtension) {
+ encoderExtension[reflect2.TypeOfPtr((*string)(nil)).Elem()] = &htmlEscapedStringEncoder{}
+}
+
+func (cfg *frozenConfig) cleanDecoders() {
+ typeDecoders = map[string]ValDecoder{}
+ fieldDecoders = map[string]ValDecoder{}
+ *cfg = *(cfg.configBeforeFrozen.Froze().(*frozenConfig))
+}
+
+func (cfg *frozenConfig) cleanEncoders() {
+ typeEncoders = map[string]ValEncoder{}
+ fieldEncoders = map[string]ValEncoder{}
+ *cfg = *(cfg.configBeforeFrozen.Froze().(*frozenConfig))
+}
+
+func (cfg *frozenConfig) MarshalToString(v interface{}) (string, error) {
+ stream := cfg.BorrowStream(nil)
+ defer cfg.ReturnStream(stream)
+ stream.WriteVal(v)
+ if stream.Error != nil {
+ return "", stream.Error
+ }
+ return string(stream.Buffer()), nil
+}
+
+func (cfg *frozenConfig) Marshal(v interface{}) ([]byte, error) {
+ stream := cfg.BorrowStream(nil)
+ defer cfg.ReturnStream(stream)
+ stream.WriteVal(v)
+ if stream.Error != nil {
+ return nil, stream.Error
+ }
+ result := stream.Buffer()
+ copied := make([]byte, len(result))
+ copy(copied, result)
+ return copied, nil
+}
+
+func (cfg *frozenConfig) MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
+ if prefix != "" {
+ panic("prefix is not supported")
+ }
+ for _, r := range indent {
+ if r != ' ' {
+ panic("indent can only be space")
+ }
+ }
+ newCfg := cfg.configBeforeFrozen
+ newCfg.IndentionStep = len(indent)
+ return newCfg.frozeWithCacheReuse(cfg.extraExtensions).Marshal(v)
+}
+
+func (cfg *frozenConfig) UnmarshalFromString(str string, v interface{}) error {
+ data := []byte(str)
+ iter := cfg.BorrowIterator(data)
+ defer cfg.ReturnIterator(iter)
+ iter.ReadVal(v)
+ c := iter.nextToken()
+ if c == 0 {
+ if iter.Error == io.EOF {
+ return nil
+ }
+ return iter.Error
+ }
+ iter.ReportError("Unmarshal", "there are bytes left after unmarshal")
+ return iter.Error
+}
+
+func (cfg *frozenConfig) Get(data []byte, path ...interface{}) Any {
+ iter := cfg.BorrowIterator(data)
+ defer cfg.ReturnIterator(iter)
+ return locatePath(iter, path)
+}
+
+func (cfg *frozenConfig) Unmarshal(data []byte, v interface{}) error {
+ iter := cfg.BorrowIterator(data)
+ defer cfg.ReturnIterator(iter)
+ iter.ReadVal(v)
+ c := iter.nextToken()
+ if c == 0 {
+ if iter.Error == io.EOF {
+ return nil
+ }
+ return iter.Error
+ }
+ iter.ReportError("Unmarshal", "there are bytes left after unmarshal")
+ return iter.Error
+}
+
+func (cfg *frozenConfig) NewEncoder(writer io.Writer) *Encoder {
+ stream := NewStream(cfg, writer, 512)
+ return &Encoder{stream}
+}
+
+func (cfg *frozenConfig) NewDecoder(reader io.Reader) *Decoder {
+ iter := Parse(cfg, reader, 512)
+ return &Decoder{iter}
+}
+
+func (cfg *frozenConfig) Valid(data []byte) bool {
+ iter := cfg.BorrowIterator(data)
+ defer cfg.ReturnIterator(iter)
+ iter.Skip()
+ return iter.Error == nil
+}
diff --git a/vendor/github.com/json-iterator/go/fuzzy_mode_convert_table.md b/vendor/github.com/json-iterator/go/fuzzy_mode_convert_table.md
new file mode 100644
index 0000000..3095662
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/fuzzy_mode_convert_table.md
@@ -0,0 +1,7 @@
+| json type \ dest type | bool | int | uint | float |string|
+| --- | --- | --- | --- |--|--|
+| number | positive => true
negative => true
zero => false| 23.2 => 23
-32.1 => -32| 12.1 => 12
-12.1 => 0|as normal|same as origin|
+| string | empty string => false
string "0" => false
other strings => true | "123.32" => 123
"-123.4" => -123
"123.23xxxw" => 123
"abcde12" => 0
"-32.1" => -32| 13.2 => 13
-1.1 => 0 |12.1 => 12.1
-12.3 => -12.3
12.4xxa => 12.4
+1.1e2 =>110 |same as origin|
+| bool | true => true
false => false| true => 1
false => 0 | true => 1
false => 0 |true => 1
false => 0|true => "true"
false => "false"|
+| object | true | 0 | 0 |0|originnal json|
+| array | empty array => false
nonempty array => true| [] => 0
[1,2] => 1 | [] => 0
[1,2] => 1 |[] => 0
[1,2] => 1|original json|
\ No newline at end of file
diff --git a/vendor/github.com/json-iterator/go/iter.go b/vendor/github.com/json-iterator/go/iter.go
new file mode 100644
index 0000000..29b31cf
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter.go
@@ -0,0 +1,349 @@
+package jsoniter
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+)
+
+// ValueType the type for JSON element
+type ValueType int
+
+const (
+ // InvalidValue invalid JSON element
+ InvalidValue ValueType = iota
+ // StringValue JSON element "string"
+ StringValue
+ // NumberValue JSON element 100 or 0.10
+ NumberValue
+ // NilValue JSON element null
+ NilValue
+ // BoolValue JSON element true or false
+ BoolValue
+ // ArrayValue JSON element []
+ ArrayValue
+ // ObjectValue JSON element {}
+ ObjectValue
+)
+
+var hexDigits []byte
+var valueTypes []ValueType
+
+func init() {
+ hexDigits = make([]byte, 256)
+ for i := 0; i < len(hexDigits); i++ {
+ hexDigits[i] = 255
+ }
+ for i := '0'; i <= '9'; i++ {
+ hexDigits[i] = byte(i - '0')
+ }
+ for i := 'a'; i <= 'f'; i++ {
+ hexDigits[i] = byte((i - 'a') + 10)
+ }
+ for i := 'A'; i <= 'F'; i++ {
+ hexDigits[i] = byte((i - 'A') + 10)
+ }
+ valueTypes = make([]ValueType, 256)
+ for i := 0; i < len(valueTypes); i++ {
+ valueTypes[i] = InvalidValue
+ }
+ valueTypes['"'] = StringValue
+ valueTypes['-'] = NumberValue
+ valueTypes['0'] = NumberValue
+ valueTypes['1'] = NumberValue
+ valueTypes['2'] = NumberValue
+ valueTypes['3'] = NumberValue
+ valueTypes['4'] = NumberValue
+ valueTypes['5'] = NumberValue
+ valueTypes['6'] = NumberValue
+ valueTypes['7'] = NumberValue
+ valueTypes['8'] = NumberValue
+ valueTypes['9'] = NumberValue
+ valueTypes['t'] = BoolValue
+ valueTypes['f'] = BoolValue
+ valueTypes['n'] = NilValue
+ valueTypes['['] = ArrayValue
+ valueTypes['{'] = ObjectValue
+}
+
+// Iterator is a io.Reader like object, with JSON specific read functions.
+// Error is not returned as return value, but stored as Error member on this iterator instance.
+type Iterator struct {
+ cfg *frozenConfig
+ reader io.Reader
+ buf []byte
+ head int
+ tail int
+ depth int
+ captureStartedAt int
+ captured []byte
+ Error error
+ Attachment interface{} // open for customized decoder
+}
+
+// NewIterator creates an empty Iterator instance
+func NewIterator(cfg API) *Iterator {
+ return &Iterator{
+ cfg: cfg.(*frozenConfig),
+ reader: nil,
+ buf: nil,
+ head: 0,
+ tail: 0,
+ depth: 0,
+ }
+}
+
+// Parse creates an Iterator instance from io.Reader
+func Parse(cfg API, reader io.Reader, bufSize int) *Iterator {
+ return &Iterator{
+ cfg: cfg.(*frozenConfig),
+ reader: reader,
+ buf: make([]byte, bufSize),
+ head: 0,
+ tail: 0,
+ depth: 0,
+ }
+}
+
+// ParseBytes creates an Iterator instance from byte array
+func ParseBytes(cfg API, input []byte) *Iterator {
+ return &Iterator{
+ cfg: cfg.(*frozenConfig),
+ reader: nil,
+ buf: input,
+ head: 0,
+ tail: len(input),
+ depth: 0,
+ }
+}
+
+// ParseString creates an Iterator instance from string
+func ParseString(cfg API, input string) *Iterator {
+ return ParseBytes(cfg, []byte(input))
+}
+
+// Pool returns a pool can provide more iterator with same configuration
+func (iter *Iterator) Pool() IteratorPool {
+ return iter.cfg
+}
+
+// Reset reuse iterator instance by specifying another reader
+func (iter *Iterator) Reset(reader io.Reader) *Iterator {
+ iter.reader = reader
+ iter.head = 0
+ iter.tail = 0
+ iter.depth = 0
+ return iter
+}
+
+// ResetBytes reuse iterator instance by specifying another byte array as input
+func (iter *Iterator) ResetBytes(input []byte) *Iterator {
+ iter.reader = nil
+ iter.buf = input
+ iter.head = 0
+ iter.tail = len(input)
+ iter.depth = 0
+ return iter
+}
+
+// WhatIsNext gets ValueType of relatively next json element
+func (iter *Iterator) WhatIsNext() ValueType {
+ valueType := valueTypes[iter.nextToken()]
+ iter.unreadByte()
+ return valueType
+}
+
+func (iter *Iterator) skipWhitespacesWithoutLoadMore() bool {
+ for i := iter.head; i < iter.tail; i++ {
+ c := iter.buf[i]
+ switch c {
+ case ' ', '\n', '\t', '\r':
+ continue
+ }
+ iter.head = i
+ return false
+ }
+ return true
+}
+
+func (iter *Iterator) isObjectEnd() bool {
+ c := iter.nextToken()
+ if c == ',' {
+ return false
+ }
+ if c == '}' {
+ return true
+ }
+ iter.ReportError("isObjectEnd", "object ended prematurely, unexpected char "+string([]byte{c}))
+ return true
+}
+
+func (iter *Iterator) nextToken() byte {
+ // a variation of skip whitespaces, returning the next non-whitespace token
+ for {
+ for i := iter.head; i < iter.tail; i++ {
+ c := iter.buf[i]
+ switch c {
+ case ' ', '\n', '\t', '\r':
+ continue
+ }
+ iter.head = i + 1
+ return c
+ }
+ if !iter.loadMore() {
+ return 0
+ }
+ }
+}
+
+// ReportError record a error in iterator instance with current position.
+func (iter *Iterator) ReportError(operation string, msg string) {
+ if iter.Error != nil {
+ if iter.Error != io.EOF {
+ return
+ }
+ }
+ peekStart := iter.head - 10
+ if peekStart < 0 {
+ peekStart = 0
+ }
+ peekEnd := iter.head + 10
+ if peekEnd > iter.tail {
+ peekEnd = iter.tail
+ }
+ parsing := string(iter.buf[peekStart:peekEnd])
+ contextStart := iter.head - 50
+ if contextStart < 0 {
+ contextStart = 0
+ }
+ contextEnd := iter.head + 50
+ if contextEnd > iter.tail {
+ contextEnd = iter.tail
+ }
+ context := string(iter.buf[contextStart:contextEnd])
+ iter.Error = fmt.Errorf("%s: %s, error found in #%v byte of ...|%s|..., bigger context ...|%s|...",
+ operation, msg, iter.head-peekStart, parsing, context)
+}
+
+// CurrentBuffer gets current buffer as string for debugging purpose
+func (iter *Iterator) CurrentBuffer() string {
+ peekStart := iter.head - 10
+ if peekStart < 0 {
+ peekStart = 0
+ }
+ return fmt.Sprintf("parsing #%v byte, around ...|%s|..., whole buffer ...|%s|...", iter.head,
+ string(iter.buf[peekStart:iter.head]), string(iter.buf[0:iter.tail]))
+}
+
+func (iter *Iterator) readByte() (ret byte) {
+ if iter.head == iter.tail {
+ if iter.loadMore() {
+ ret = iter.buf[iter.head]
+ iter.head++
+ return ret
+ }
+ return 0
+ }
+ ret = iter.buf[iter.head]
+ iter.head++
+ return ret
+}
+
+func (iter *Iterator) loadMore() bool {
+ if iter.reader == nil {
+ if iter.Error == nil {
+ iter.head = iter.tail
+ iter.Error = io.EOF
+ }
+ return false
+ }
+ if iter.captured != nil {
+ iter.captured = append(iter.captured,
+ iter.buf[iter.captureStartedAt:iter.tail]...)
+ iter.captureStartedAt = 0
+ }
+ for {
+ n, err := iter.reader.Read(iter.buf)
+ if n == 0 {
+ if err != nil {
+ if iter.Error == nil {
+ iter.Error = err
+ }
+ return false
+ }
+ } else {
+ iter.head = 0
+ iter.tail = n
+ return true
+ }
+ }
+}
+
+func (iter *Iterator) unreadByte() {
+ if iter.Error != nil {
+ return
+ }
+ iter.head--
+ return
+}
+
+// Read read the next JSON element as generic interface{}.
+func (iter *Iterator) Read() interface{} {
+ valueType := iter.WhatIsNext()
+ switch valueType {
+ case StringValue:
+ return iter.ReadString()
+ case NumberValue:
+ if iter.cfg.configBeforeFrozen.UseNumber {
+ return json.Number(iter.readNumberAsString())
+ }
+ return iter.ReadFloat64()
+ case NilValue:
+ iter.skipFourBytes('n', 'u', 'l', 'l')
+ return nil
+ case BoolValue:
+ return iter.ReadBool()
+ case ArrayValue:
+ arr := []interface{}{}
+ iter.ReadArrayCB(func(iter *Iterator) bool {
+ var elem interface{}
+ iter.ReadVal(&elem)
+ arr = append(arr, elem)
+ return true
+ })
+ return arr
+ case ObjectValue:
+ obj := map[string]interface{}{}
+ iter.ReadMapCB(func(Iter *Iterator, field string) bool {
+ var elem interface{}
+ iter.ReadVal(&elem)
+ obj[field] = elem
+ return true
+ })
+ return obj
+ default:
+ iter.ReportError("Read", fmt.Sprintf("unexpected value type: %v", valueType))
+ return nil
+ }
+}
+
+// limit maximum depth of nesting, as allowed by https://tools.ietf.org/html/rfc7159#section-9
+const maxDepth = 10000
+
+func (iter *Iterator) incrementDepth() (success bool) {
+ iter.depth++
+ if iter.depth <= maxDepth {
+ return true
+ }
+ iter.ReportError("incrementDepth", "exceeded max depth")
+ return false
+}
+
+func (iter *Iterator) decrementDepth() (success bool) {
+ iter.depth--
+ if iter.depth >= 0 {
+ return true
+ }
+ iter.ReportError("decrementDepth", "unexpected negative nesting")
+ return false
+}
diff --git a/vendor/github.com/json-iterator/go/iter_array.go b/vendor/github.com/json-iterator/go/iter_array.go
new file mode 100644
index 0000000..204fe0e
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter_array.go
@@ -0,0 +1,64 @@
+package jsoniter
+
+// ReadArray read array element, tells if the array has more element to read.
+func (iter *Iterator) ReadArray() (ret bool) {
+ c := iter.nextToken()
+ switch c {
+ case 'n':
+ iter.skipThreeBytes('u', 'l', 'l')
+ return false // null
+ case '[':
+ c = iter.nextToken()
+ if c != ']' {
+ iter.unreadByte()
+ return true
+ }
+ return false
+ case ']':
+ return false
+ case ',':
+ return true
+ default:
+ iter.ReportError("ReadArray", "expect [ or , or ] or n, but found "+string([]byte{c}))
+ return
+ }
+}
+
+// ReadArrayCB read array with callback
+func (iter *Iterator) ReadArrayCB(callback func(*Iterator) bool) (ret bool) {
+ c := iter.nextToken()
+ if c == '[' {
+ if !iter.incrementDepth() {
+ return false
+ }
+ c = iter.nextToken()
+ if c != ']' {
+ iter.unreadByte()
+ if !callback(iter) {
+ iter.decrementDepth()
+ return false
+ }
+ c = iter.nextToken()
+ for c == ',' {
+ if !callback(iter) {
+ iter.decrementDepth()
+ return false
+ }
+ c = iter.nextToken()
+ }
+ if c != ']' {
+ iter.ReportError("ReadArrayCB", "expect ] in the end, but found "+string([]byte{c}))
+ iter.decrementDepth()
+ return false
+ }
+ return iter.decrementDepth()
+ }
+ return iter.decrementDepth()
+ }
+ if c == 'n' {
+ iter.skipThreeBytes('u', 'l', 'l')
+ return true // null
+ }
+ iter.ReportError("ReadArrayCB", "expect [ or n, but found "+string([]byte{c}))
+ return false
+}
diff --git a/vendor/github.com/json-iterator/go/iter_float.go b/vendor/github.com/json-iterator/go/iter_float.go
new file mode 100644
index 0000000..8a3d8b6
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter_float.go
@@ -0,0 +1,342 @@
+package jsoniter
+
+import (
+ "encoding/json"
+ "io"
+ "math/big"
+ "strconv"
+ "strings"
+ "unsafe"
+)
+
+var floatDigits []int8
+
+const invalidCharForNumber = int8(-1)
+const endOfNumber = int8(-2)
+const dotInNumber = int8(-3)
+
+func init() {
+ floatDigits = make([]int8, 256)
+ for i := 0; i < len(floatDigits); i++ {
+ floatDigits[i] = invalidCharForNumber
+ }
+ for i := int8('0'); i <= int8('9'); i++ {
+ floatDigits[i] = i - int8('0')
+ }
+ floatDigits[','] = endOfNumber
+ floatDigits[']'] = endOfNumber
+ floatDigits['}'] = endOfNumber
+ floatDigits[' '] = endOfNumber
+ floatDigits['\t'] = endOfNumber
+ floatDigits['\n'] = endOfNumber
+ floatDigits['.'] = dotInNumber
+}
+
+// ReadBigFloat read big.Float
+func (iter *Iterator) ReadBigFloat() (ret *big.Float) {
+ str := iter.readNumberAsString()
+ if iter.Error != nil && iter.Error != io.EOF {
+ return nil
+ }
+ prec := 64
+ if len(str) > prec {
+ prec = len(str)
+ }
+ val, _, err := big.ParseFloat(str, 10, uint(prec), big.ToZero)
+ if err != nil {
+ iter.Error = err
+ return nil
+ }
+ return val
+}
+
+// ReadBigInt read big.Int
+func (iter *Iterator) ReadBigInt() (ret *big.Int) {
+ str := iter.readNumberAsString()
+ if iter.Error != nil && iter.Error != io.EOF {
+ return nil
+ }
+ ret = big.NewInt(0)
+ var success bool
+ ret, success = ret.SetString(str, 10)
+ if !success {
+ iter.ReportError("ReadBigInt", "invalid big int")
+ return nil
+ }
+ return ret
+}
+
+//ReadFloat32 read float32
+func (iter *Iterator) ReadFloat32() (ret float32) {
+ c := iter.nextToken()
+ if c == '-' {
+ return -iter.readPositiveFloat32()
+ }
+ iter.unreadByte()
+ return iter.readPositiveFloat32()
+}
+
+func (iter *Iterator) readPositiveFloat32() (ret float32) {
+ i := iter.head
+ // first char
+ if i == iter.tail {
+ return iter.readFloat32SlowPath()
+ }
+ c := iter.buf[i]
+ i++
+ ind := floatDigits[c]
+ switch ind {
+ case invalidCharForNumber:
+ return iter.readFloat32SlowPath()
+ case endOfNumber:
+ iter.ReportError("readFloat32", "empty number")
+ return
+ case dotInNumber:
+ iter.ReportError("readFloat32", "leading dot is invalid")
+ return
+ case 0:
+ if i == iter.tail {
+ return iter.readFloat32SlowPath()
+ }
+ c = iter.buf[i]
+ switch c {
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ iter.ReportError("readFloat32", "leading zero is invalid")
+ return
+ }
+ }
+ value := uint64(ind)
+ // chars before dot
+non_decimal_loop:
+ for ; i < iter.tail; i++ {
+ c = iter.buf[i]
+ ind := floatDigits[c]
+ switch ind {
+ case invalidCharForNumber:
+ return iter.readFloat32SlowPath()
+ case endOfNumber:
+ iter.head = i
+ return float32(value)
+ case dotInNumber:
+ break non_decimal_loop
+ }
+ if value > uint64SafeToMultiple10 {
+ return iter.readFloat32SlowPath()
+ }
+ value = (value << 3) + (value << 1) + uint64(ind) // value = value * 10 + ind;
+ }
+ // chars after dot
+ if c == '.' {
+ i++
+ decimalPlaces := 0
+ if i == iter.tail {
+ return iter.readFloat32SlowPath()
+ }
+ for ; i < iter.tail; i++ {
+ c = iter.buf[i]
+ ind := floatDigits[c]
+ switch ind {
+ case endOfNumber:
+ if decimalPlaces > 0 && decimalPlaces < len(pow10) {
+ iter.head = i
+ return float32(float64(value) / float64(pow10[decimalPlaces]))
+ }
+ // too many decimal places
+ return iter.readFloat32SlowPath()
+ case invalidCharForNumber, dotInNumber:
+ return iter.readFloat32SlowPath()
+ }
+ decimalPlaces++
+ if value > uint64SafeToMultiple10 {
+ return iter.readFloat32SlowPath()
+ }
+ value = (value << 3) + (value << 1) + uint64(ind)
+ }
+ }
+ return iter.readFloat32SlowPath()
+}
+
+func (iter *Iterator) readNumberAsString() (ret string) {
+ strBuf := [16]byte{}
+ str := strBuf[0:0]
+load_loop:
+ for {
+ for i := iter.head; i < iter.tail; i++ {
+ c := iter.buf[i]
+ switch c {
+ case '+', '-', '.', 'e', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ str = append(str, c)
+ continue
+ default:
+ iter.head = i
+ break load_loop
+ }
+ }
+ if !iter.loadMore() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF {
+ return
+ }
+ if len(str) == 0 {
+ iter.ReportError("readNumberAsString", "invalid number")
+ }
+ return *(*string)(unsafe.Pointer(&str))
+}
+
+func (iter *Iterator) readFloat32SlowPath() (ret float32) {
+ str := iter.readNumberAsString()
+ if iter.Error != nil && iter.Error != io.EOF {
+ return
+ }
+ errMsg := validateFloat(str)
+ if errMsg != "" {
+ iter.ReportError("readFloat32SlowPath", errMsg)
+ return
+ }
+ val, err := strconv.ParseFloat(str, 32)
+ if err != nil {
+ iter.Error = err
+ return
+ }
+ return float32(val)
+}
+
+// ReadFloat64 read float64
+func (iter *Iterator) ReadFloat64() (ret float64) {
+ c := iter.nextToken()
+ if c == '-' {
+ return -iter.readPositiveFloat64()
+ }
+ iter.unreadByte()
+ return iter.readPositiveFloat64()
+}
+
+func (iter *Iterator) readPositiveFloat64() (ret float64) {
+ i := iter.head
+ // first char
+ if i == iter.tail {
+ return iter.readFloat64SlowPath()
+ }
+ c := iter.buf[i]
+ i++
+ ind := floatDigits[c]
+ switch ind {
+ case invalidCharForNumber:
+ return iter.readFloat64SlowPath()
+ case endOfNumber:
+ iter.ReportError("readFloat64", "empty number")
+ return
+ case dotInNumber:
+ iter.ReportError("readFloat64", "leading dot is invalid")
+ return
+ case 0:
+ if i == iter.tail {
+ return iter.readFloat64SlowPath()
+ }
+ c = iter.buf[i]
+ switch c {
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ iter.ReportError("readFloat64", "leading zero is invalid")
+ return
+ }
+ }
+ value := uint64(ind)
+ // chars before dot
+non_decimal_loop:
+ for ; i < iter.tail; i++ {
+ c = iter.buf[i]
+ ind := floatDigits[c]
+ switch ind {
+ case invalidCharForNumber:
+ return iter.readFloat64SlowPath()
+ case endOfNumber:
+ iter.head = i
+ return float64(value)
+ case dotInNumber:
+ break non_decimal_loop
+ }
+ if value > uint64SafeToMultiple10 {
+ return iter.readFloat64SlowPath()
+ }
+ value = (value << 3) + (value << 1) + uint64(ind) // value = value * 10 + ind;
+ }
+ // chars after dot
+ if c == '.' {
+ i++
+ decimalPlaces := 0
+ if i == iter.tail {
+ return iter.readFloat64SlowPath()
+ }
+ for ; i < iter.tail; i++ {
+ c = iter.buf[i]
+ ind := floatDigits[c]
+ switch ind {
+ case endOfNumber:
+ if decimalPlaces > 0 && decimalPlaces < len(pow10) {
+ iter.head = i
+ return float64(value) / float64(pow10[decimalPlaces])
+ }
+ // too many decimal places
+ return iter.readFloat64SlowPath()
+ case invalidCharForNumber, dotInNumber:
+ return iter.readFloat64SlowPath()
+ }
+ decimalPlaces++
+ if value > uint64SafeToMultiple10 {
+ return iter.readFloat64SlowPath()
+ }
+ value = (value << 3) + (value << 1) + uint64(ind)
+ if value > maxFloat64 {
+ return iter.readFloat64SlowPath()
+ }
+ }
+ }
+ return iter.readFloat64SlowPath()
+}
+
+func (iter *Iterator) readFloat64SlowPath() (ret float64) {
+ str := iter.readNumberAsString()
+ if iter.Error != nil && iter.Error != io.EOF {
+ return
+ }
+ errMsg := validateFloat(str)
+ if errMsg != "" {
+ iter.ReportError("readFloat64SlowPath", errMsg)
+ return
+ }
+ val, err := strconv.ParseFloat(str, 64)
+ if err != nil {
+ iter.Error = err
+ return
+ }
+ return val
+}
+
+func validateFloat(str string) string {
+ // strconv.ParseFloat is not validating `1.` or `1.e1`
+ if len(str) == 0 {
+ return "empty number"
+ }
+ if str[0] == '-' {
+ return "-- is not valid"
+ }
+ dotPos := strings.IndexByte(str, '.')
+ if dotPos != -1 {
+ if dotPos == len(str)-1 {
+ return "dot can not be last character"
+ }
+ switch str[dotPos+1] {
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ default:
+ return "missing digit after dot"
+ }
+ }
+ return ""
+}
+
+// ReadNumber read json.Number
+func (iter *Iterator) ReadNumber() (ret json.Number) {
+ return json.Number(iter.readNumberAsString())
+}
diff --git a/vendor/github.com/json-iterator/go/iter_int.go b/vendor/github.com/json-iterator/go/iter_int.go
new file mode 100644
index 0000000..d786a89
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter_int.go
@@ -0,0 +1,346 @@
+package jsoniter
+
+import (
+ "math"
+ "strconv"
+)
+
+var intDigits []int8
+
+const uint32SafeToMultiply10 = uint32(0xffffffff)/10 - 1
+const uint64SafeToMultiple10 = uint64(0xffffffffffffffff)/10 - 1
+const maxFloat64 = 1<<53 - 1
+
+func init() {
+ intDigits = make([]int8, 256)
+ for i := 0; i < len(intDigits); i++ {
+ intDigits[i] = invalidCharForNumber
+ }
+ for i := int8('0'); i <= int8('9'); i++ {
+ intDigits[i] = i - int8('0')
+ }
+}
+
+// ReadUint read uint
+func (iter *Iterator) ReadUint() uint {
+ if strconv.IntSize == 32 {
+ return uint(iter.ReadUint32())
+ }
+ return uint(iter.ReadUint64())
+}
+
+// ReadInt read int
+func (iter *Iterator) ReadInt() int {
+ if strconv.IntSize == 32 {
+ return int(iter.ReadInt32())
+ }
+ return int(iter.ReadInt64())
+}
+
+// ReadInt8 read int8
+func (iter *Iterator) ReadInt8() (ret int8) {
+ c := iter.nextToken()
+ if c == '-' {
+ val := iter.readUint32(iter.readByte())
+ if val > math.MaxInt8+1 {
+ iter.ReportError("ReadInt8", "overflow: "+strconv.FormatInt(int64(val), 10))
+ return
+ }
+ return -int8(val)
+ }
+ val := iter.readUint32(c)
+ if val > math.MaxInt8 {
+ iter.ReportError("ReadInt8", "overflow: "+strconv.FormatInt(int64(val), 10))
+ return
+ }
+ return int8(val)
+}
+
+// ReadUint8 read uint8
+func (iter *Iterator) ReadUint8() (ret uint8) {
+ val := iter.readUint32(iter.nextToken())
+ if val > math.MaxUint8 {
+ iter.ReportError("ReadUint8", "overflow: "+strconv.FormatInt(int64(val), 10))
+ return
+ }
+ return uint8(val)
+}
+
+// ReadInt16 read int16
+func (iter *Iterator) ReadInt16() (ret int16) {
+ c := iter.nextToken()
+ if c == '-' {
+ val := iter.readUint32(iter.readByte())
+ if val > math.MaxInt16+1 {
+ iter.ReportError("ReadInt16", "overflow: "+strconv.FormatInt(int64(val), 10))
+ return
+ }
+ return -int16(val)
+ }
+ val := iter.readUint32(c)
+ if val > math.MaxInt16 {
+ iter.ReportError("ReadInt16", "overflow: "+strconv.FormatInt(int64(val), 10))
+ return
+ }
+ return int16(val)
+}
+
+// ReadUint16 read uint16
+func (iter *Iterator) ReadUint16() (ret uint16) {
+ val := iter.readUint32(iter.nextToken())
+ if val > math.MaxUint16 {
+ iter.ReportError("ReadUint16", "overflow: "+strconv.FormatInt(int64(val), 10))
+ return
+ }
+ return uint16(val)
+}
+
+// ReadInt32 read int32
+func (iter *Iterator) ReadInt32() (ret int32) {
+ c := iter.nextToken()
+ if c == '-' {
+ val := iter.readUint32(iter.readByte())
+ if val > math.MaxInt32+1 {
+ iter.ReportError("ReadInt32", "overflow: "+strconv.FormatInt(int64(val), 10))
+ return
+ }
+ return -int32(val)
+ }
+ val := iter.readUint32(c)
+ if val > math.MaxInt32 {
+ iter.ReportError("ReadInt32", "overflow: "+strconv.FormatInt(int64(val), 10))
+ return
+ }
+ return int32(val)
+}
+
+// ReadUint32 read uint32
+func (iter *Iterator) ReadUint32() (ret uint32) {
+ return iter.readUint32(iter.nextToken())
+}
+
+func (iter *Iterator) readUint32(c byte) (ret uint32) {
+ ind := intDigits[c]
+ if ind == 0 {
+ iter.assertInteger()
+ return 0 // single zero
+ }
+ if ind == invalidCharForNumber {
+ iter.ReportError("readUint32", "unexpected character: "+string([]byte{byte(ind)}))
+ return
+ }
+ value := uint32(ind)
+ if iter.tail-iter.head > 10 {
+ i := iter.head
+ ind2 := intDigits[iter.buf[i]]
+ if ind2 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value
+ }
+ i++
+ ind3 := intDigits[iter.buf[i]]
+ if ind3 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*10 + uint32(ind2)
+ }
+ //iter.head = i + 1
+ //value = value * 100 + uint32(ind2) * 10 + uint32(ind3)
+ i++
+ ind4 := intDigits[iter.buf[i]]
+ if ind4 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*100 + uint32(ind2)*10 + uint32(ind3)
+ }
+ i++
+ ind5 := intDigits[iter.buf[i]]
+ if ind5 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*1000 + uint32(ind2)*100 + uint32(ind3)*10 + uint32(ind4)
+ }
+ i++
+ ind6 := intDigits[iter.buf[i]]
+ if ind6 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*10000 + uint32(ind2)*1000 + uint32(ind3)*100 + uint32(ind4)*10 + uint32(ind5)
+ }
+ i++
+ ind7 := intDigits[iter.buf[i]]
+ if ind7 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*100000 + uint32(ind2)*10000 + uint32(ind3)*1000 + uint32(ind4)*100 + uint32(ind5)*10 + uint32(ind6)
+ }
+ i++
+ ind8 := intDigits[iter.buf[i]]
+ if ind8 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*1000000 + uint32(ind2)*100000 + uint32(ind3)*10000 + uint32(ind4)*1000 + uint32(ind5)*100 + uint32(ind6)*10 + uint32(ind7)
+ }
+ i++
+ ind9 := intDigits[iter.buf[i]]
+ value = value*10000000 + uint32(ind2)*1000000 + uint32(ind3)*100000 + uint32(ind4)*10000 + uint32(ind5)*1000 + uint32(ind6)*100 + uint32(ind7)*10 + uint32(ind8)
+ iter.head = i
+ if ind9 == invalidCharForNumber {
+ iter.assertInteger()
+ return value
+ }
+ }
+ for {
+ for i := iter.head; i < iter.tail; i++ {
+ ind = intDigits[iter.buf[i]]
+ if ind == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value
+ }
+ if value > uint32SafeToMultiply10 {
+ value2 := (value << 3) + (value << 1) + uint32(ind)
+ if value2 < value {
+ iter.ReportError("readUint32", "overflow")
+ return
+ }
+ value = value2
+ continue
+ }
+ value = (value << 3) + (value << 1) + uint32(ind)
+ }
+ if !iter.loadMore() {
+ iter.assertInteger()
+ return value
+ }
+ }
+}
+
+// ReadInt64 read int64
+func (iter *Iterator) ReadInt64() (ret int64) {
+ c := iter.nextToken()
+ if c == '-' {
+ val := iter.readUint64(iter.readByte())
+ if val > math.MaxInt64+1 {
+ iter.ReportError("ReadInt64", "overflow: "+strconv.FormatUint(uint64(val), 10))
+ return
+ }
+ return -int64(val)
+ }
+ val := iter.readUint64(c)
+ if val > math.MaxInt64 {
+ iter.ReportError("ReadInt64", "overflow: "+strconv.FormatUint(uint64(val), 10))
+ return
+ }
+ return int64(val)
+}
+
+// ReadUint64 read uint64
+func (iter *Iterator) ReadUint64() uint64 {
+ return iter.readUint64(iter.nextToken())
+}
+
+func (iter *Iterator) readUint64(c byte) (ret uint64) {
+ ind := intDigits[c]
+ if ind == 0 {
+ iter.assertInteger()
+ return 0 // single zero
+ }
+ if ind == invalidCharForNumber {
+ iter.ReportError("readUint64", "unexpected character: "+string([]byte{byte(ind)}))
+ return
+ }
+ value := uint64(ind)
+ if iter.tail-iter.head > 10 {
+ i := iter.head
+ ind2 := intDigits[iter.buf[i]]
+ if ind2 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value
+ }
+ i++
+ ind3 := intDigits[iter.buf[i]]
+ if ind3 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*10 + uint64(ind2)
+ }
+ //iter.head = i + 1
+ //value = value * 100 + uint32(ind2) * 10 + uint32(ind3)
+ i++
+ ind4 := intDigits[iter.buf[i]]
+ if ind4 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*100 + uint64(ind2)*10 + uint64(ind3)
+ }
+ i++
+ ind5 := intDigits[iter.buf[i]]
+ if ind5 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*1000 + uint64(ind2)*100 + uint64(ind3)*10 + uint64(ind4)
+ }
+ i++
+ ind6 := intDigits[iter.buf[i]]
+ if ind6 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*10000 + uint64(ind2)*1000 + uint64(ind3)*100 + uint64(ind4)*10 + uint64(ind5)
+ }
+ i++
+ ind7 := intDigits[iter.buf[i]]
+ if ind7 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*100000 + uint64(ind2)*10000 + uint64(ind3)*1000 + uint64(ind4)*100 + uint64(ind5)*10 + uint64(ind6)
+ }
+ i++
+ ind8 := intDigits[iter.buf[i]]
+ if ind8 == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value*1000000 + uint64(ind2)*100000 + uint64(ind3)*10000 + uint64(ind4)*1000 + uint64(ind5)*100 + uint64(ind6)*10 + uint64(ind7)
+ }
+ i++
+ ind9 := intDigits[iter.buf[i]]
+ value = value*10000000 + uint64(ind2)*1000000 + uint64(ind3)*100000 + uint64(ind4)*10000 + uint64(ind5)*1000 + uint64(ind6)*100 + uint64(ind7)*10 + uint64(ind8)
+ iter.head = i
+ if ind9 == invalidCharForNumber {
+ iter.assertInteger()
+ return value
+ }
+ }
+ for {
+ for i := iter.head; i < iter.tail; i++ {
+ ind = intDigits[iter.buf[i]]
+ if ind == invalidCharForNumber {
+ iter.head = i
+ iter.assertInteger()
+ return value
+ }
+ if value > uint64SafeToMultiple10 {
+ value2 := (value << 3) + (value << 1) + uint64(ind)
+ if value2 < value {
+ iter.ReportError("readUint64", "overflow")
+ return
+ }
+ value = value2
+ continue
+ }
+ value = (value << 3) + (value << 1) + uint64(ind)
+ }
+ if !iter.loadMore() {
+ iter.assertInteger()
+ return value
+ }
+ }
+}
+
+func (iter *Iterator) assertInteger() {
+ if iter.head < iter.tail && iter.buf[iter.head] == '.' {
+ iter.ReportError("assertInteger", "can not decode float as int")
+ }
+}
diff --git a/vendor/github.com/json-iterator/go/iter_object.go b/vendor/github.com/json-iterator/go/iter_object.go
new file mode 100644
index 0000000..58ee89c
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter_object.go
@@ -0,0 +1,267 @@
+package jsoniter
+
+import (
+ "fmt"
+ "strings"
+)
+
+// ReadObject read one field from object.
+// If object ended, returns empty string.
+// Otherwise, returns the field name.
+func (iter *Iterator) ReadObject() (ret string) {
+ c := iter.nextToken()
+ switch c {
+ case 'n':
+ iter.skipThreeBytes('u', 'l', 'l')
+ return "" // null
+ case '{':
+ c = iter.nextToken()
+ if c == '"' {
+ iter.unreadByte()
+ field := iter.ReadString()
+ c = iter.nextToken()
+ if c != ':' {
+ iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
+ }
+ return field
+ }
+ if c == '}' {
+ return "" // end of object
+ }
+ iter.ReportError("ReadObject", `expect " after {, but found `+string([]byte{c}))
+ return
+ case ',':
+ field := iter.ReadString()
+ c = iter.nextToken()
+ if c != ':' {
+ iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
+ }
+ return field
+ case '}':
+ return "" // end of object
+ default:
+ iter.ReportError("ReadObject", fmt.Sprintf(`expect { or , or } or n, but found %s`, string([]byte{c})))
+ return
+ }
+}
+
+// CaseInsensitive
+func (iter *Iterator) readFieldHash() int64 {
+ hash := int64(0x811c9dc5)
+ c := iter.nextToken()
+ if c != '"' {
+ iter.ReportError("readFieldHash", `expect ", but found `+string([]byte{c}))
+ return 0
+ }
+ for {
+ for i := iter.head; i < iter.tail; i++ {
+ // require ascii string and no escape
+ b := iter.buf[i]
+ if b == '\\' {
+ iter.head = i
+ for _, b := range iter.readStringSlowPath() {
+ if 'A' <= b && b <= 'Z' && !iter.cfg.caseSensitive {
+ b += 'a' - 'A'
+ }
+ hash ^= int64(b)
+ hash *= 0x1000193
+ }
+ c = iter.nextToken()
+ if c != ':' {
+ iter.ReportError("readFieldHash", `expect :, but found `+string([]byte{c}))
+ return 0
+ }
+ return hash
+ }
+ if b == '"' {
+ iter.head = i + 1
+ c = iter.nextToken()
+ if c != ':' {
+ iter.ReportError("readFieldHash", `expect :, but found `+string([]byte{c}))
+ return 0
+ }
+ return hash
+ }
+ if 'A' <= b && b <= 'Z' && !iter.cfg.caseSensitive {
+ b += 'a' - 'A'
+ }
+ hash ^= int64(b)
+ hash *= 0x1000193
+ }
+ if !iter.loadMore() {
+ iter.ReportError("readFieldHash", `incomplete field name`)
+ return 0
+ }
+ }
+}
+
+func calcHash(str string, caseSensitive bool) int64 {
+ if !caseSensitive {
+ str = strings.ToLower(str)
+ }
+ hash := int64(0x811c9dc5)
+ for _, b := range []byte(str) {
+ hash ^= int64(b)
+ hash *= 0x1000193
+ }
+ return int64(hash)
+}
+
+// ReadObjectCB read object with callback, the key is ascii only and field name not copied
+func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool {
+ c := iter.nextToken()
+ var field string
+ if c == '{' {
+ if !iter.incrementDepth() {
+ return false
+ }
+ c = iter.nextToken()
+ if c == '"' {
+ iter.unreadByte()
+ field = iter.ReadString()
+ c = iter.nextToken()
+ if c != ':' {
+ iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
+ }
+ if !callback(iter, field) {
+ iter.decrementDepth()
+ return false
+ }
+ c = iter.nextToken()
+ for c == ',' {
+ field = iter.ReadString()
+ c = iter.nextToken()
+ if c != ':' {
+ iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
+ }
+ if !callback(iter, field) {
+ iter.decrementDepth()
+ return false
+ }
+ c = iter.nextToken()
+ }
+ if c != '}' {
+ iter.ReportError("ReadObjectCB", `object not ended with }`)
+ iter.decrementDepth()
+ return false
+ }
+ return iter.decrementDepth()
+ }
+ if c == '}' {
+ return iter.decrementDepth()
+ }
+ iter.ReportError("ReadObjectCB", `expect " after {, but found `+string([]byte{c}))
+ iter.decrementDepth()
+ return false
+ }
+ if c == 'n' {
+ iter.skipThreeBytes('u', 'l', 'l')
+ return true // null
+ }
+ iter.ReportError("ReadObjectCB", `expect { or n, but found `+string([]byte{c}))
+ return false
+}
+
+// ReadMapCB read map with callback, the key can be any string
+func (iter *Iterator) ReadMapCB(callback func(*Iterator, string) bool) bool {
+ c := iter.nextToken()
+ if c == '{' {
+ if !iter.incrementDepth() {
+ return false
+ }
+ c = iter.nextToken()
+ if c == '"' {
+ iter.unreadByte()
+ field := iter.ReadString()
+ if iter.nextToken() != ':' {
+ iter.ReportError("ReadMapCB", "expect : after object field, but found "+string([]byte{c}))
+ iter.decrementDepth()
+ return false
+ }
+ if !callback(iter, field) {
+ iter.decrementDepth()
+ return false
+ }
+ c = iter.nextToken()
+ for c == ',' {
+ field = iter.ReadString()
+ if iter.nextToken() != ':' {
+ iter.ReportError("ReadMapCB", "expect : after object field, but found "+string([]byte{c}))
+ iter.decrementDepth()
+ return false
+ }
+ if !callback(iter, field) {
+ iter.decrementDepth()
+ return false
+ }
+ c = iter.nextToken()
+ }
+ if c != '}' {
+ iter.ReportError("ReadMapCB", `object not ended with }`)
+ iter.decrementDepth()
+ return false
+ }
+ return iter.decrementDepth()
+ }
+ if c == '}' {
+ return iter.decrementDepth()
+ }
+ iter.ReportError("ReadMapCB", `expect " after {, but found `+string([]byte{c}))
+ iter.decrementDepth()
+ return false
+ }
+ if c == 'n' {
+ iter.skipThreeBytes('u', 'l', 'l')
+ return true // null
+ }
+ iter.ReportError("ReadMapCB", `expect { or n, but found `+string([]byte{c}))
+ return false
+}
+
+func (iter *Iterator) readObjectStart() bool {
+ c := iter.nextToken()
+ if c == '{' {
+ c = iter.nextToken()
+ if c == '}' {
+ return false
+ }
+ iter.unreadByte()
+ return true
+ } else if c == 'n' {
+ iter.skipThreeBytes('u', 'l', 'l')
+ return false
+ }
+ iter.ReportError("readObjectStart", "expect { or n, but found "+string([]byte{c}))
+ return false
+}
+
+func (iter *Iterator) readObjectFieldAsBytes() (ret []byte) {
+ str := iter.ReadStringAsSlice()
+ if iter.skipWhitespacesWithoutLoadMore() {
+ if ret == nil {
+ ret = make([]byte, len(str))
+ copy(ret, str)
+ }
+ if !iter.loadMore() {
+ return
+ }
+ }
+ if iter.buf[iter.head] != ':' {
+ iter.ReportError("readObjectFieldAsBytes", "expect : after object field, but found "+string([]byte{iter.buf[iter.head]}))
+ return
+ }
+ iter.head++
+ if iter.skipWhitespacesWithoutLoadMore() {
+ if ret == nil {
+ ret = make([]byte, len(str))
+ copy(ret, str)
+ }
+ if !iter.loadMore() {
+ return
+ }
+ }
+ if ret == nil {
+ return str
+ }
+ return ret
+}
diff --git a/vendor/github.com/json-iterator/go/iter_skip.go b/vendor/github.com/json-iterator/go/iter_skip.go
new file mode 100644
index 0000000..e91eefb
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter_skip.go
@@ -0,0 +1,130 @@
+package jsoniter
+
+import "fmt"
+
+// ReadNil reads a json object as nil and
+// returns whether it's a nil or not
+func (iter *Iterator) ReadNil() (ret bool) {
+ c := iter.nextToken()
+ if c == 'n' {
+ iter.skipThreeBytes('u', 'l', 'l') // null
+ return true
+ }
+ iter.unreadByte()
+ return false
+}
+
+// ReadBool reads a json object as BoolValue
+func (iter *Iterator) ReadBool() (ret bool) {
+ c := iter.nextToken()
+ if c == 't' {
+ iter.skipThreeBytes('r', 'u', 'e')
+ return true
+ }
+ if c == 'f' {
+ iter.skipFourBytes('a', 'l', 's', 'e')
+ return false
+ }
+ iter.ReportError("ReadBool", "expect t or f, but found "+string([]byte{c}))
+ return
+}
+
+// SkipAndReturnBytes skip next JSON element, and return its content as []byte.
+// The []byte can be kept, it is a copy of data.
+func (iter *Iterator) SkipAndReturnBytes() []byte {
+ iter.startCapture(iter.head)
+ iter.Skip()
+ return iter.stopCapture()
+}
+
+// SkipAndAppendBytes skips next JSON element and appends its content to
+// buffer, returning the result.
+func (iter *Iterator) SkipAndAppendBytes(buf []byte) []byte {
+ iter.startCaptureTo(buf, iter.head)
+ iter.Skip()
+ return iter.stopCapture()
+}
+
+func (iter *Iterator) startCaptureTo(buf []byte, captureStartedAt int) {
+ if iter.captured != nil {
+ panic("already in capture mode")
+ }
+ iter.captureStartedAt = captureStartedAt
+ iter.captured = buf
+}
+
+func (iter *Iterator) startCapture(captureStartedAt int) {
+ iter.startCaptureTo(make([]byte, 0, 32), captureStartedAt)
+}
+
+func (iter *Iterator) stopCapture() []byte {
+ if iter.captured == nil {
+ panic("not in capture mode")
+ }
+ captured := iter.captured
+ remaining := iter.buf[iter.captureStartedAt:iter.head]
+ iter.captureStartedAt = -1
+ iter.captured = nil
+ return append(captured, remaining...)
+}
+
+// Skip skips a json object and positions to relatively the next json object
+func (iter *Iterator) Skip() {
+ c := iter.nextToken()
+ switch c {
+ case '"':
+ iter.skipString()
+ case 'n':
+ iter.skipThreeBytes('u', 'l', 'l') // null
+ case 't':
+ iter.skipThreeBytes('r', 'u', 'e') // true
+ case 'f':
+ iter.skipFourBytes('a', 'l', 's', 'e') // false
+ case '0':
+ iter.unreadByte()
+ iter.ReadFloat32()
+ case '-', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ iter.skipNumber()
+ case '[':
+ iter.skipArray()
+ case '{':
+ iter.skipObject()
+ default:
+ iter.ReportError("Skip", fmt.Sprintf("do not know how to skip: %v", c))
+ return
+ }
+}
+
+func (iter *Iterator) skipFourBytes(b1, b2, b3, b4 byte) {
+ if iter.readByte() != b1 {
+ iter.ReportError("skipFourBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3, b4})))
+ return
+ }
+ if iter.readByte() != b2 {
+ iter.ReportError("skipFourBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3, b4})))
+ return
+ }
+ if iter.readByte() != b3 {
+ iter.ReportError("skipFourBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3, b4})))
+ return
+ }
+ if iter.readByte() != b4 {
+ iter.ReportError("skipFourBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3, b4})))
+ return
+ }
+}
+
+func (iter *Iterator) skipThreeBytes(b1, b2, b3 byte) {
+ if iter.readByte() != b1 {
+ iter.ReportError("skipThreeBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3})))
+ return
+ }
+ if iter.readByte() != b2 {
+ iter.ReportError("skipThreeBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3})))
+ return
+ }
+ if iter.readByte() != b3 {
+ iter.ReportError("skipThreeBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3})))
+ return
+ }
+}
diff --git a/vendor/github.com/json-iterator/go/iter_skip_sloppy.go b/vendor/github.com/json-iterator/go/iter_skip_sloppy.go
new file mode 100644
index 0000000..9303de4
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter_skip_sloppy.go
@@ -0,0 +1,163 @@
+//+build jsoniter_sloppy
+
+package jsoniter
+
+// sloppy but faster implementation, do not validate the input json
+
+func (iter *Iterator) skipNumber() {
+ for {
+ for i := iter.head; i < iter.tail; i++ {
+ c := iter.buf[i]
+ switch c {
+ case ' ', '\n', '\r', '\t', ',', '}', ']':
+ iter.head = i
+ return
+ }
+ }
+ if !iter.loadMore() {
+ return
+ }
+ }
+}
+
+func (iter *Iterator) skipArray() {
+ level := 1
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ for i := iter.head; i < iter.tail; i++ {
+ switch iter.buf[i] {
+ case '"': // If inside string, skip it
+ iter.head = i + 1
+ iter.skipString()
+ i = iter.head - 1 // it will be i++ soon
+ case '[': // If open symbol, increase level
+ level++
+ if !iter.incrementDepth() {
+ return
+ }
+ case ']': // If close symbol, increase level
+ level--
+ if !iter.decrementDepth() {
+ return
+ }
+
+ // If we have returned to the original level, we're done
+ if level == 0 {
+ iter.head = i + 1
+ return
+ }
+ }
+ }
+ if !iter.loadMore() {
+ iter.ReportError("skipObject", "incomplete array")
+ return
+ }
+ }
+}
+
+func (iter *Iterator) skipObject() {
+ level := 1
+ if !iter.incrementDepth() {
+ return
+ }
+
+ for {
+ for i := iter.head; i < iter.tail; i++ {
+ switch iter.buf[i] {
+ case '"': // If inside string, skip it
+ iter.head = i + 1
+ iter.skipString()
+ i = iter.head - 1 // it will be i++ soon
+ case '{': // If open symbol, increase level
+ level++
+ if !iter.incrementDepth() {
+ return
+ }
+ case '}': // If close symbol, increase level
+ level--
+ if !iter.decrementDepth() {
+ return
+ }
+
+ // If we have returned to the original level, we're done
+ if level == 0 {
+ iter.head = i + 1
+ return
+ }
+ }
+ }
+ if !iter.loadMore() {
+ iter.ReportError("skipObject", "incomplete object")
+ return
+ }
+ }
+}
+
+func (iter *Iterator) skipString() {
+ for {
+ end, escaped := iter.findStringEnd()
+ if end == -1 {
+ if !iter.loadMore() {
+ iter.ReportError("skipString", "incomplete string")
+ return
+ }
+ if escaped {
+ iter.head = 1 // skip the first char as last char read is \
+ }
+ } else {
+ iter.head = end
+ return
+ }
+ }
+}
+
+// adapted from: https://github.com/buger/jsonparser/blob/master/parser.go
+// Tries to find the end of string
+// Support if string contains escaped quote symbols.
+func (iter *Iterator) findStringEnd() (int, bool) {
+ escaped := false
+ for i := iter.head; i < iter.tail; i++ {
+ c := iter.buf[i]
+ if c == '"' {
+ if !escaped {
+ return i + 1, false
+ }
+ j := i - 1
+ for {
+ if j < iter.head || iter.buf[j] != '\\' {
+ // even number of backslashes
+ // either end of buffer, or " found
+ return i + 1, true
+ }
+ j--
+ if j < iter.head || iter.buf[j] != '\\' {
+ // odd number of backslashes
+ // it is \" or \\\"
+ break
+ }
+ j--
+ }
+ } else if c == '\\' {
+ escaped = true
+ }
+ }
+ j := iter.tail - 1
+ for {
+ if j < iter.head || iter.buf[j] != '\\' {
+ // even number of backslashes
+ // either end of buffer, or " found
+ return -1, false // do not end with \
+ }
+ j--
+ if j < iter.head || iter.buf[j] != '\\' {
+ // odd number of backslashes
+ // it is \" or \\\"
+ break
+ }
+ j--
+
+ }
+ return -1, true // end with \
+}
diff --git a/vendor/github.com/json-iterator/go/iter_skip_strict.go b/vendor/github.com/json-iterator/go/iter_skip_strict.go
new file mode 100644
index 0000000..6cf66d0
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter_skip_strict.go
@@ -0,0 +1,99 @@
+//+build !jsoniter_sloppy
+
+package jsoniter
+
+import (
+ "fmt"
+ "io"
+)
+
+func (iter *Iterator) skipNumber() {
+ if !iter.trySkipNumber() {
+ iter.unreadByte()
+ if iter.Error != nil && iter.Error != io.EOF {
+ return
+ }
+ iter.ReadFloat64()
+ if iter.Error != nil && iter.Error != io.EOF {
+ iter.Error = nil
+ iter.ReadBigFloat()
+ }
+ }
+}
+
+func (iter *Iterator) trySkipNumber() bool {
+ dotFound := false
+ for i := iter.head; i < iter.tail; i++ {
+ c := iter.buf[i]
+ switch c {
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ case '.':
+ if dotFound {
+ iter.ReportError("validateNumber", `more than one dot found in number`)
+ return true // already failed
+ }
+ if i+1 == iter.tail {
+ return false
+ }
+ c = iter.buf[i+1]
+ switch c {
+ case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ default:
+ iter.ReportError("validateNumber", `missing digit after dot`)
+ return true // already failed
+ }
+ dotFound = true
+ default:
+ switch c {
+ case ',', ']', '}', ' ', '\t', '\n', '\r':
+ if iter.head == i {
+ return false // if - without following digits
+ }
+ iter.head = i
+ return true // must be valid
+ }
+ return false // may be invalid
+ }
+ }
+ return false
+}
+
+func (iter *Iterator) skipString() {
+ if !iter.trySkipString() {
+ iter.unreadByte()
+ iter.ReadString()
+ }
+}
+
+func (iter *Iterator) trySkipString() bool {
+ for i := iter.head; i < iter.tail; i++ {
+ c := iter.buf[i]
+ if c == '"' {
+ iter.head = i + 1
+ return true // valid
+ } else if c == '\\' {
+ return false
+ } else if c < ' ' {
+ iter.ReportError("trySkipString",
+ fmt.Sprintf(`invalid control character found: %d`, c))
+ return true // already failed
+ }
+ }
+ return false
+}
+
+func (iter *Iterator) skipObject() {
+ iter.unreadByte()
+ iter.ReadObjectCB(func(iter *Iterator, field string) bool {
+ iter.Skip()
+ return true
+ })
+}
+
+func (iter *Iterator) skipArray() {
+ iter.unreadByte()
+ iter.ReadArrayCB(func(iter *Iterator) bool {
+ iter.Skip()
+ return true
+ })
+}
diff --git a/vendor/github.com/json-iterator/go/iter_str.go b/vendor/github.com/json-iterator/go/iter_str.go
new file mode 100644
index 0000000..adc487e
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/iter_str.go
@@ -0,0 +1,215 @@
+package jsoniter
+
+import (
+ "fmt"
+ "unicode/utf16"
+)
+
+// ReadString read string from iterator
+func (iter *Iterator) ReadString() (ret string) {
+ c := iter.nextToken()
+ if c == '"' {
+ for i := iter.head; i < iter.tail; i++ {
+ c := iter.buf[i]
+ if c == '"' {
+ ret = string(iter.buf[iter.head:i])
+ iter.head = i + 1
+ return ret
+ } else if c == '\\' {
+ break
+ } else if c < ' ' {
+ iter.ReportError("ReadString",
+ fmt.Sprintf(`invalid control character found: %d`, c))
+ return
+ }
+ }
+ return iter.readStringSlowPath()
+ } else if c == 'n' {
+ iter.skipThreeBytes('u', 'l', 'l')
+ return ""
+ }
+ iter.ReportError("ReadString", `expects " or n, but found `+string([]byte{c}))
+ return
+}
+
+func (iter *Iterator) readStringSlowPath() (ret string) {
+ var str []byte
+ var c byte
+ for iter.Error == nil {
+ c = iter.readByte()
+ if c == '"' {
+ return string(str)
+ }
+ if c == '\\' {
+ c = iter.readByte()
+ str = iter.readEscapedChar(c, str)
+ } else {
+ str = append(str, c)
+ }
+ }
+ iter.ReportError("readStringSlowPath", "unexpected end of input")
+ return
+}
+
+func (iter *Iterator) readEscapedChar(c byte, str []byte) []byte {
+ switch c {
+ case 'u':
+ r := iter.readU4()
+ if utf16.IsSurrogate(r) {
+ c = iter.readByte()
+ if iter.Error != nil {
+ return nil
+ }
+ if c != '\\' {
+ iter.unreadByte()
+ str = appendRune(str, r)
+ return str
+ }
+ c = iter.readByte()
+ if iter.Error != nil {
+ return nil
+ }
+ if c != 'u' {
+ str = appendRune(str, r)
+ return iter.readEscapedChar(c, str)
+ }
+ r2 := iter.readU4()
+ if iter.Error != nil {
+ return nil
+ }
+ combined := utf16.DecodeRune(r, r2)
+ if combined == '\uFFFD' {
+ str = appendRune(str, r)
+ str = appendRune(str, r2)
+ } else {
+ str = appendRune(str, combined)
+ }
+ } else {
+ str = appendRune(str, r)
+ }
+ case '"':
+ str = append(str, '"')
+ case '\\':
+ str = append(str, '\\')
+ case '/':
+ str = append(str, '/')
+ case 'b':
+ str = append(str, '\b')
+ case 'f':
+ str = append(str, '\f')
+ case 'n':
+ str = append(str, '\n')
+ case 'r':
+ str = append(str, '\r')
+ case 't':
+ str = append(str, '\t')
+ default:
+ iter.ReportError("readEscapedChar",
+ `invalid escape char after \`)
+ return nil
+ }
+ return str
+}
+
+// ReadStringAsSlice read string from iterator without copying into string form.
+// The []byte can not be kept, as it will change after next iterator call.
+func (iter *Iterator) ReadStringAsSlice() (ret []byte) {
+ c := iter.nextToken()
+ if c == '"' {
+ for i := iter.head; i < iter.tail; i++ {
+ // require ascii string and no escape
+ // for: field name, base64, number
+ if iter.buf[i] == '"' {
+ // fast path: reuse the underlying buffer
+ ret = iter.buf[iter.head:i]
+ iter.head = i + 1
+ return ret
+ }
+ }
+ readLen := iter.tail - iter.head
+ copied := make([]byte, readLen, readLen*2)
+ copy(copied, iter.buf[iter.head:iter.tail])
+ iter.head = iter.tail
+ for iter.Error == nil {
+ c := iter.readByte()
+ if c == '"' {
+ return copied
+ }
+ copied = append(copied, c)
+ }
+ return copied
+ }
+ iter.ReportError("ReadStringAsSlice", `expects " or n, but found `+string([]byte{c}))
+ return
+}
+
+func (iter *Iterator) readU4() (ret rune) {
+ for i := 0; i < 4; i++ {
+ c := iter.readByte()
+ if iter.Error != nil {
+ return
+ }
+ if c >= '0' && c <= '9' {
+ ret = ret*16 + rune(c-'0')
+ } else if c >= 'a' && c <= 'f' {
+ ret = ret*16 + rune(c-'a'+10)
+ } else if c >= 'A' && c <= 'F' {
+ ret = ret*16 + rune(c-'A'+10)
+ } else {
+ iter.ReportError("readU4", "expects 0~9 or a~f, but found "+string([]byte{c}))
+ return
+ }
+ }
+ return ret
+}
+
+const (
+ t1 = 0x00 // 0000 0000
+ tx = 0x80 // 1000 0000
+ t2 = 0xC0 // 1100 0000
+ t3 = 0xE0 // 1110 0000
+ t4 = 0xF0 // 1111 0000
+ t5 = 0xF8 // 1111 1000
+
+ maskx = 0x3F // 0011 1111
+ mask2 = 0x1F // 0001 1111
+ mask3 = 0x0F // 0000 1111
+ mask4 = 0x07 // 0000 0111
+
+ rune1Max = 1<<7 - 1
+ rune2Max = 1<<11 - 1
+ rune3Max = 1<<16 - 1
+
+ surrogateMin = 0xD800
+ surrogateMax = 0xDFFF
+
+ maxRune = '\U0010FFFF' // Maximum valid Unicode code point.
+ runeError = '\uFFFD' // the "error" Rune or "Unicode replacement character"
+)
+
+func appendRune(p []byte, r rune) []byte {
+ // Negative values are erroneous. Making it unsigned addresses the problem.
+ switch i := uint32(r); {
+ case i <= rune1Max:
+ p = append(p, byte(r))
+ return p
+ case i <= rune2Max:
+ p = append(p, t2|byte(r>>6))
+ p = append(p, tx|byte(r)&maskx)
+ return p
+ case i > maxRune, surrogateMin <= i && i <= surrogateMax:
+ r = runeError
+ fallthrough
+ case i <= rune3Max:
+ p = append(p, t3|byte(r>>12))
+ p = append(p, tx|byte(r>>6)&maskx)
+ p = append(p, tx|byte(r)&maskx)
+ return p
+ default:
+ p = append(p, t4|byte(r>>18))
+ p = append(p, tx|byte(r>>12)&maskx)
+ p = append(p, tx|byte(r>>6)&maskx)
+ p = append(p, tx|byte(r)&maskx)
+ return p
+ }
+}
diff --git a/vendor/github.com/json-iterator/go/jsoniter.go b/vendor/github.com/json-iterator/go/jsoniter.go
new file mode 100644
index 0000000..c2934f9
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/jsoniter.go
@@ -0,0 +1,18 @@
+// Package jsoniter implements encoding and decoding of JSON as defined in
+// RFC 4627 and provides interfaces with identical syntax of standard lib encoding/json.
+// Converting from encoding/json to jsoniter is no more than replacing the package with jsoniter
+// and variable type declarations (if any).
+// jsoniter interfaces gives 100% compatibility with code using standard lib.
+//
+// "JSON and Go"
+// (https://golang.org/doc/articles/json_and_go.html)
+// gives a description of how Marshal/Unmarshal operate
+// between arbitrary or predefined json objects and bytes,
+// and it applies to jsoniter.Marshal/Unmarshal as well.
+//
+// Besides, jsoniter.Iterator provides a different set of interfaces
+// iterating given bytes/string/reader
+// and yielding parsed elements one by one.
+// This set of interfaces reads input as required and gives
+// better performance.
+package jsoniter
diff --git a/vendor/github.com/json-iterator/go/pool.go b/vendor/github.com/json-iterator/go/pool.go
new file mode 100644
index 0000000..e2389b5
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/pool.go
@@ -0,0 +1,42 @@
+package jsoniter
+
+import (
+ "io"
+)
+
+// IteratorPool a thread safe pool of iterators with same configuration
+type IteratorPool interface {
+ BorrowIterator(data []byte) *Iterator
+ ReturnIterator(iter *Iterator)
+}
+
+// StreamPool a thread safe pool of streams with same configuration
+type StreamPool interface {
+ BorrowStream(writer io.Writer) *Stream
+ ReturnStream(stream *Stream)
+}
+
+func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream {
+ stream := cfg.streamPool.Get().(*Stream)
+ stream.Reset(writer)
+ return stream
+}
+
+func (cfg *frozenConfig) ReturnStream(stream *Stream) {
+ stream.out = nil
+ stream.Error = nil
+ stream.Attachment = nil
+ cfg.streamPool.Put(stream)
+}
+
+func (cfg *frozenConfig) BorrowIterator(data []byte) *Iterator {
+ iter := cfg.iteratorPool.Get().(*Iterator)
+ iter.ResetBytes(data)
+ return iter
+}
+
+func (cfg *frozenConfig) ReturnIterator(iter *Iterator) {
+ iter.Error = nil
+ iter.Attachment = nil
+ cfg.iteratorPool.Put(iter)
+}
diff --git a/vendor/github.com/json-iterator/go/reflect.go b/vendor/github.com/json-iterator/go/reflect.go
new file mode 100644
index 0000000..39acb32
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect.go
@@ -0,0 +1,337 @@
+package jsoniter
+
+import (
+ "fmt"
+ "reflect"
+ "unsafe"
+
+ "github.com/modern-go/reflect2"
+)
+
+// ValDecoder is an internal type registered to cache as needed.
+// Don't confuse jsoniter.ValDecoder with json.Decoder.
+// For json.Decoder's adapter, refer to jsoniter.AdapterDecoder(todo link).
+//
+// Reflection on type to create decoders, which is then cached
+// Reflection on value is avoided as we can, as the reflect.Value itself will allocate, with following exceptions
+// 1. create instance of new value, for example *int will need a int to be allocated
+// 2. append to slice, if the existing cap is not enough, allocate will be done using Reflect.New
+// 3. assignment to map, both key and value will be reflect.Value
+// For a simple struct binding, it will be reflect.Value free and allocation free
+type ValDecoder interface {
+ Decode(ptr unsafe.Pointer, iter *Iterator)
+}
+
+// ValEncoder is an internal type registered to cache as needed.
+// Don't confuse jsoniter.ValEncoder with json.Encoder.
+// For json.Encoder's adapter, refer to jsoniter.AdapterEncoder(todo godoc link).
+type ValEncoder interface {
+ IsEmpty(ptr unsafe.Pointer) bool
+ Encode(ptr unsafe.Pointer, stream *Stream)
+}
+
+type checkIsEmpty interface {
+ IsEmpty(ptr unsafe.Pointer) bool
+}
+
+type ctx struct {
+ *frozenConfig
+ prefix string
+ encoders map[reflect2.Type]ValEncoder
+ decoders map[reflect2.Type]ValDecoder
+}
+
+func (b *ctx) caseSensitive() bool {
+ if b.frozenConfig == nil {
+ // default is case-insensitive
+ return false
+ }
+ return b.frozenConfig.caseSensitive
+}
+
+func (b *ctx) append(prefix string) *ctx {
+ return &ctx{
+ frozenConfig: b.frozenConfig,
+ prefix: b.prefix + " " + prefix,
+ encoders: b.encoders,
+ decoders: b.decoders,
+ }
+}
+
+// ReadVal copy the underlying JSON into go interface, same as json.Unmarshal
+func (iter *Iterator) ReadVal(obj interface{}) {
+ depth := iter.depth
+ cacheKey := reflect2.RTypeOf(obj)
+ decoder := iter.cfg.getDecoderFromCache(cacheKey)
+ if decoder == nil {
+ typ := reflect2.TypeOf(obj)
+ if typ == nil || typ.Kind() != reflect.Ptr {
+ iter.ReportError("ReadVal", "can only unmarshal into pointer")
+ return
+ }
+ decoder = iter.cfg.DecoderOf(typ)
+ }
+ ptr := reflect2.PtrOf(obj)
+ if ptr == nil {
+ iter.ReportError("ReadVal", "can not read into nil pointer")
+ return
+ }
+ decoder.Decode(ptr, iter)
+ if iter.depth != depth {
+ iter.ReportError("ReadVal", "unexpected mismatched nesting")
+ return
+ }
+}
+
+// WriteVal copy the go interface into underlying JSON, same as json.Marshal
+func (stream *Stream) WriteVal(val interface{}) {
+ if nil == val {
+ stream.WriteNil()
+ return
+ }
+ cacheKey := reflect2.RTypeOf(val)
+ encoder := stream.cfg.getEncoderFromCache(cacheKey)
+ if encoder == nil {
+ typ := reflect2.TypeOf(val)
+ encoder = stream.cfg.EncoderOf(typ)
+ }
+ encoder.Encode(reflect2.PtrOf(val), stream)
+}
+
+func (cfg *frozenConfig) DecoderOf(typ reflect2.Type) ValDecoder {
+ cacheKey := typ.RType()
+ decoder := cfg.getDecoderFromCache(cacheKey)
+ if decoder != nil {
+ return decoder
+ }
+ ctx := &ctx{
+ frozenConfig: cfg,
+ prefix: "",
+ decoders: map[reflect2.Type]ValDecoder{},
+ encoders: map[reflect2.Type]ValEncoder{},
+ }
+ ptrType := typ.(*reflect2.UnsafePtrType)
+ decoder = decoderOfType(ctx, ptrType.Elem())
+ cfg.addDecoderToCache(cacheKey, decoder)
+ return decoder
+}
+
+func decoderOfType(ctx *ctx, typ reflect2.Type) ValDecoder {
+ decoder := getTypeDecoderFromExtension(ctx, typ)
+ if decoder != nil {
+ return decoder
+ }
+ decoder = createDecoderOfType(ctx, typ)
+ for _, extension := range extensions {
+ decoder = extension.DecorateDecoder(typ, decoder)
+ }
+ decoder = ctx.decoderExtension.DecorateDecoder(typ, decoder)
+ for _, extension := range ctx.extraExtensions {
+ decoder = extension.DecorateDecoder(typ, decoder)
+ }
+ return decoder
+}
+
+func createDecoderOfType(ctx *ctx, typ reflect2.Type) ValDecoder {
+ decoder := ctx.decoders[typ]
+ if decoder != nil {
+ return decoder
+ }
+ placeholder := &placeholderDecoder{}
+ ctx.decoders[typ] = placeholder
+ decoder = _createDecoderOfType(ctx, typ)
+ placeholder.decoder = decoder
+ return decoder
+}
+
+func _createDecoderOfType(ctx *ctx, typ reflect2.Type) ValDecoder {
+ decoder := createDecoderOfJsonRawMessage(ctx, typ)
+ if decoder != nil {
+ return decoder
+ }
+ decoder = createDecoderOfJsonNumber(ctx, typ)
+ if decoder != nil {
+ return decoder
+ }
+ decoder = createDecoderOfMarshaler(ctx, typ)
+ if decoder != nil {
+ return decoder
+ }
+ decoder = createDecoderOfAny(ctx, typ)
+ if decoder != nil {
+ return decoder
+ }
+ decoder = createDecoderOfNative(ctx, typ)
+ if decoder != nil {
+ return decoder
+ }
+ switch typ.Kind() {
+ case reflect.Interface:
+ ifaceType, isIFace := typ.(*reflect2.UnsafeIFaceType)
+ if isIFace {
+ return &ifaceDecoder{valType: ifaceType}
+ }
+ return &efaceDecoder{}
+ case reflect.Struct:
+ return decoderOfStruct(ctx, typ)
+ case reflect.Array:
+ return decoderOfArray(ctx, typ)
+ case reflect.Slice:
+ return decoderOfSlice(ctx, typ)
+ case reflect.Map:
+ return decoderOfMap(ctx, typ)
+ case reflect.Ptr:
+ return decoderOfOptional(ctx, typ)
+ default:
+ return &lazyErrorDecoder{err: fmt.Errorf("%s%s is unsupported type", ctx.prefix, typ.String())}
+ }
+}
+
+func (cfg *frozenConfig) EncoderOf(typ reflect2.Type) ValEncoder {
+ cacheKey := typ.RType()
+ encoder := cfg.getEncoderFromCache(cacheKey)
+ if encoder != nil {
+ return encoder
+ }
+ ctx := &ctx{
+ frozenConfig: cfg,
+ prefix: "",
+ decoders: map[reflect2.Type]ValDecoder{},
+ encoders: map[reflect2.Type]ValEncoder{},
+ }
+ encoder = encoderOfType(ctx, typ)
+ if typ.LikePtr() {
+ encoder = &onePtrEncoder{encoder}
+ }
+ cfg.addEncoderToCache(cacheKey, encoder)
+ return encoder
+}
+
+type onePtrEncoder struct {
+ encoder ValEncoder
+}
+
+func (encoder *onePtrEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.encoder.IsEmpty(unsafe.Pointer(&ptr))
+}
+
+func (encoder *onePtrEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ encoder.encoder.Encode(unsafe.Pointer(&ptr), stream)
+}
+
+func encoderOfType(ctx *ctx, typ reflect2.Type) ValEncoder {
+ encoder := getTypeEncoderFromExtension(ctx, typ)
+ if encoder != nil {
+ return encoder
+ }
+ encoder = createEncoderOfType(ctx, typ)
+ for _, extension := range extensions {
+ encoder = extension.DecorateEncoder(typ, encoder)
+ }
+ encoder = ctx.encoderExtension.DecorateEncoder(typ, encoder)
+ for _, extension := range ctx.extraExtensions {
+ encoder = extension.DecorateEncoder(typ, encoder)
+ }
+ return encoder
+}
+
+func createEncoderOfType(ctx *ctx, typ reflect2.Type) ValEncoder {
+ encoder := ctx.encoders[typ]
+ if encoder != nil {
+ return encoder
+ }
+ placeholder := &placeholderEncoder{}
+ ctx.encoders[typ] = placeholder
+ encoder = _createEncoderOfType(ctx, typ)
+ placeholder.encoder = encoder
+ return encoder
+}
+func _createEncoderOfType(ctx *ctx, typ reflect2.Type) ValEncoder {
+ encoder := createEncoderOfJsonRawMessage(ctx, typ)
+ if encoder != nil {
+ return encoder
+ }
+ encoder = createEncoderOfJsonNumber(ctx, typ)
+ if encoder != nil {
+ return encoder
+ }
+ encoder = createEncoderOfMarshaler(ctx, typ)
+ if encoder != nil {
+ return encoder
+ }
+ encoder = createEncoderOfAny(ctx, typ)
+ if encoder != nil {
+ return encoder
+ }
+ encoder = createEncoderOfNative(ctx, typ)
+ if encoder != nil {
+ return encoder
+ }
+ kind := typ.Kind()
+ switch kind {
+ case reflect.Interface:
+ return &dynamicEncoder{typ}
+ case reflect.Struct:
+ return encoderOfStruct(ctx, typ)
+ case reflect.Array:
+ return encoderOfArray(ctx, typ)
+ case reflect.Slice:
+ return encoderOfSlice(ctx, typ)
+ case reflect.Map:
+ return encoderOfMap(ctx, typ)
+ case reflect.Ptr:
+ return encoderOfOptional(ctx, typ)
+ default:
+ return &lazyErrorEncoder{err: fmt.Errorf("%s%s is unsupported type", ctx.prefix, typ.String())}
+ }
+}
+
+type lazyErrorDecoder struct {
+ err error
+}
+
+func (decoder *lazyErrorDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if iter.WhatIsNext() != NilValue {
+ if iter.Error == nil {
+ iter.Error = decoder.err
+ }
+ } else {
+ iter.Skip()
+ }
+}
+
+type lazyErrorEncoder struct {
+ err error
+}
+
+func (encoder *lazyErrorEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if ptr == nil {
+ stream.WriteNil()
+ } else if stream.Error == nil {
+ stream.Error = encoder.err
+ }
+}
+
+func (encoder *lazyErrorEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return false
+}
+
+type placeholderDecoder struct {
+ decoder ValDecoder
+}
+
+func (decoder *placeholderDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ decoder.decoder.Decode(ptr, iter)
+}
+
+type placeholderEncoder struct {
+ encoder ValEncoder
+}
+
+func (encoder *placeholderEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ encoder.encoder.Encode(ptr, stream)
+}
+
+func (encoder *placeholderEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.encoder.IsEmpty(ptr)
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_array.go b/vendor/github.com/json-iterator/go/reflect_array.go
new file mode 100644
index 0000000..13a0b7b
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_array.go
@@ -0,0 +1,104 @@
+package jsoniter
+
+import (
+ "fmt"
+ "github.com/modern-go/reflect2"
+ "io"
+ "unsafe"
+)
+
+func decoderOfArray(ctx *ctx, typ reflect2.Type) ValDecoder {
+ arrayType := typ.(*reflect2.UnsafeArrayType)
+ decoder := decoderOfType(ctx.append("[arrayElem]"), arrayType.Elem())
+ return &arrayDecoder{arrayType, decoder}
+}
+
+func encoderOfArray(ctx *ctx, typ reflect2.Type) ValEncoder {
+ arrayType := typ.(*reflect2.UnsafeArrayType)
+ if arrayType.Len() == 0 {
+ return emptyArrayEncoder{}
+ }
+ encoder := encoderOfType(ctx.append("[arrayElem]"), arrayType.Elem())
+ return &arrayEncoder{arrayType, encoder}
+}
+
+type emptyArrayEncoder struct{}
+
+func (encoder emptyArrayEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteEmptyArray()
+}
+
+func (encoder emptyArrayEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return true
+}
+
+type arrayEncoder struct {
+ arrayType *reflect2.UnsafeArrayType
+ elemEncoder ValEncoder
+}
+
+func (encoder *arrayEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteArrayStart()
+ elemPtr := unsafe.Pointer(ptr)
+ encoder.elemEncoder.Encode(elemPtr, stream)
+ for i := 1; i < encoder.arrayType.Len(); i++ {
+ stream.WriteMore()
+ elemPtr = encoder.arrayType.UnsafeGetIndex(ptr, i)
+ encoder.elemEncoder.Encode(elemPtr, stream)
+ }
+ stream.WriteArrayEnd()
+ if stream.Error != nil && stream.Error != io.EOF {
+ stream.Error = fmt.Errorf("%v: %s", encoder.arrayType, stream.Error.Error())
+ }
+}
+
+func (encoder *arrayEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return false
+}
+
+type arrayDecoder struct {
+ arrayType *reflect2.UnsafeArrayType
+ elemDecoder ValDecoder
+}
+
+func (decoder *arrayDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ decoder.doDecode(ptr, iter)
+ if iter.Error != nil && iter.Error != io.EOF {
+ iter.Error = fmt.Errorf("%v: %s", decoder.arrayType, iter.Error.Error())
+ }
+}
+
+func (decoder *arrayDecoder) doDecode(ptr unsafe.Pointer, iter *Iterator) {
+ c := iter.nextToken()
+ arrayType := decoder.arrayType
+ if c == 'n' {
+ iter.skipThreeBytes('u', 'l', 'l')
+ return
+ }
+ if c != '[' {
+ iter.ReportError("decode array", "expect [ or n, but found "+string([]byte{c}))
+ return
+ }
+ c = iter.nextToken()
+ if c == ']' {
+ return
+ }
+ iter.unreadByte()
+ elemPtr := arrayType.UnsafeGetIndex(ptr, 0)
+ decoder.elemDecoder.Decode(elemPtr, iter)
+ length := 1
+ for c = iter.nextToken(); c == ','; c = iter.nextToken() {
+ if length >= arrayType.Len() {
+ iter.Skip()
+ continue
+ }
+ idx := length
+ length += 1
+ elemPtr = arrayType.UnsafeGetIndex(ptr, idx)
+ decoder.elemDecoder.Decode(elemPtr, iter)
+ }
+ if c != ']' {
+ iter.ReportError("decode array", "expect ], but found "+string([]byte{c}))
+ return
+ }
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_dynamic.go b/vendor/github.com/json-iterator/go/reflect_dynamic.go
new file mode 100644
index 0000000..8b6bc8b
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_dynamic.go
@@ -0,0 +1,70 @@
+package jsoniter
+
+import (
+ "github.com/modern-go/reflect2"
+ "reflect"
+ "unsafe"
+)
+
+type dynamicEncoder struct {
+ valType reflect2.Type
+}
+
+func (encoder *dynamicEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ obj := encoder.valType.UnsafeIndirect(ptr)
+ stream.WriteVal(obj)
+}
+
+func (encoder *dynamicEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.valType.UnsafeIndirect(ptr) == nil
+}
+
+type efaceDecoder struct {
+}
+
+func (decoder *efaceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ pObj := (*interface{})(ptr)
+ obj := *pObj
+ if obj == nil {
+ *pObj = iter.Read()
+ return
+ }
+ typ := reflect2.TypeOf(obj)
+ if typ.Kind() != reflect.Ptr {
+ *pObj = iter.Read()
+ return
+ }
+ ptrType := typ.(*reflect2.UnsafePtrType)
+ ptrElemType := ptrType.Elem()
+ if iter.WhatIsNext() == NilValue {
+ if ptrElemType.Kind() != reflect.Ptr {
+ iter.skipFourBytes('n', 'u', 'l', 'l')
+ *pObj = nil
+ return
+ }
+ }
+ if reflect2.IsNil(obj) {
+ obj := ptrElemType.New()
+ iter.ReadVal(obj)
+ *pObj = obj
+ return
+ }
+ iter.ReadVal(obj)
+}
+
+type ifaceDecoder struct {
+ valType *reflect2.UnsafeIFaceType
+}
+
+func (decoder *ifaceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if iter.ReadNil() {
+ decoder.valType.UnsafeSet(ptr, decoder.valType.UnsafeNew())
+ return
+ }
+ obj := decoder.valType.UnsafeIndirect(ptr)
+ if reflect2.IsNil(obj) {
+ iter.ReportError("decode non empty interface", "can not unmarshal into nil")
+ return
+ }
+ iter.ReadVal(obj)
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_extension.go b/vendor/github.com/json-iterator/go/reflect_extension.go
new file mode 100644
index 0000000..74a97bf
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_extension.go
@@ -0,0 +1,483 @@
+package jsoniter
+
+import (
+ "fmt"
+ "github.com/modern-go/reflect2"
+ "reflect"
+ "sort"
+ "strings"
+ "unicode"
+ "unsafe"
+)
+
+var typeDecoders = map[string]ValDecoder{}
+var fieldDecoders = map[string]ValDecoder{}
+var typeEncoders = map[string]ValEncoder{}
+var fieldEncoders = map[string]ValEncoder{}
+var extensions = []Extension{}
+
+// StructDescriptor describe how should we encode/decode the struct
+type StructDescriptor struct {
+ Type reflect2.Type
+ Fields []*Binding
+}
+
+// GetField get one field from the descriptor by its name.
+// Can not use map here to keep field orders.
+func (structDescriptor *StructDescriptor) GetField(fieldName string) *Binding {
+ for _, binding := range structDescriptor.Fields {
+ if binding.Field.Name() == fieldName {
+ return binding
+ }
+ }
+ return nil
+}
+
+// Binding describe how should we encode/decode the struct field
+type Binding struct {
+ levels []int
+ Field reflect2.StructField
+ FromNames []string
+ ToNames []string
+ Encoder ValEncoder
+ Decoder ValDecoder
+}
+
+// Extension the one for all SPI. Customize encoding/decoding by specifying alternate encoder/decoder.
+// Can also rename fields by UpdateStructDescriptor.
+type Extension interface {
+ UpdateStructDescriptor(structDescriptor *StructDescriptor)
+ CreateMapKeyDecoder(typ reflect2.Type) ValDecoder
+ CreateMapKeyEncoder(typ reflect2.Type) ValEncoder
+ CreateDecoder(typ reflect2.Type) ValDecoder
+ CreateEncoder(typ reflect2.Type) ValEncoder
+ DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder
+ DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder
+}
+
+// DummyExtension embed this type get dummy implementation for all methods of Extension
+type DummyExtension struct {
+}
+
+// UpdateStructDescriptor No-op
+func (extension *DummyExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor) {
+}
+
+// CreateMapKeyDecoder No-op
+func (extension *DummyExtension) CreateMapKeyDecoder(typ reflect2.Type) ValDecoder {
+ return nil
+}
+
+// CreateMapKeyEncoder No-op
+func (extension *DummyExtension) CreateMapKeyEncoder(typ reflect2.Type) ValEncoder {
+ return nil
+}
+
+// CreateDecoder No-op
+func (extension *DummyExtension) CreateDecoder(typ reflect2.Type) ValDecoder {
+ return nil
+}
+
+// CreateEncoder No-op
+func (extension *DummyExtension) CreateEncoder(typ reflect2.Type) ValEncoder {
+ return nil
+}
+
+// DecorateDecoder No-op
+func (extension *DummyExtension) DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder {
+ return decoder
+}
+
+// DecorateEncoder No-op
+func (extension *DummyExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder {
+ return encoder
+}
+
+type EncoderExtension map[reflect2.Type]ValEncoder
+
+// UpdateStructDescriptor No-op
+func (extension EncoderExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor) {
+}
+
+// CreateDecoder No-op
+func (extension EncoderExtension) CreateDecoder(typ reflect2.Type) ValDecoder {
+ return nil
+}
+
+// CreateEncoder get encoder from map
+func (extension EncoderExtension) CreateEncoder(typ reflect2.Type) ValEncoder {
+ return extension[typ]
+}
+
+// CreateMapKeyDecoder No-op
+func (extension EncoderExtension) CreateMapKeyDecoder(typ reflect2.Type) ValDecoder {
+ return nil
+}
+
+// CreateMapKeyEncoder No-op
+func (extension EncoderExtension) CreateMapKeyEncoder(typ reflect2.Type) ValEncoder {
+ return nil
+}
+
+// DecorateDecoder No-op
+func (extension EncoderExtension) DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder {
+ return decoder
+}
+
+// DecorateEncoder No-op
+func (extension EncoderExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder {
+ return encoder
+}
+
+type DecoderExtension map[reflect2.Type]ValDecoder
+
+// UpdateStructDescriptor No-op
+func (extension DecoderExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor) {
+}
+
+// CreateMapKeyDecoder No-op
+func (extension DecoderExtension) CreateMapKeyDecoder(typ reflect2.Type) ValDecoder {
+ return nil
+}
+
+// CreateMapKeyEncoder No-op
+func (extension DecoderExtension) CreateMapKeyEncoder(typ reflect2.Type) ValEncoder {
+ return nil
+}
+
+// CreateDecoder get decoder from map
+func (extension DecoderExtension) CreateDecoder(typ reflect2.Type) ValDecoder {
+ return extension[typ]
+}
+
+// CreateEncoder No-op
+func (extension DecoderExtension) CreateEncoder(typ reflect2.Type) ValEncoder {
+ return nil
+}
+
+// DecorateDecoder No-op
+func (extension DecoderExtension) DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder {
+ return decoder
+}
+
+// DecorateEncoder No-op
+func (extension DecoderExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder {
+ return encoder
+}
+
+type funcDecoder struct {
+ fun DecoderFunc
+}
+
+func (decoder *funcDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ decoder.fun(ptr, iter)
+}
+
+type funcEncoder struct {
+ fun EncoderFunc
+ isEmptyFunc func(ptr unsafe.Pointer) bool
+}
+
+func (encoder *funcEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ encoder.fun(ptr, stream)
+}
+
+func (encoder *funcEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ if encoder.isEmptyFunc == nil {
+ return false
+ }
+ return encoder.isEmptyFunc(ptr)
+}
+
+// DecoderFunc the function form of TypeDecoder
+type DecoderFunc func(ptr unsafe.Pointer, iter *Iterator)
+
+// EncoderFunc the function form of TypeEncoder
+type EncoderFunc func(ptr unsafe.Pointer, stream *Stream)
+
+// RegisterTypeDecoderFunc register TypeDecoder for a type with function
+func RegisterTypeDecoderFunc(typ string, fun DecoderFunc) {
+ typeDecoders[typ] = &funcDecoder{fun}
+}
+
+// RegisterTypeDecoder register TypeDecoder for a typ
+func RegisterTypeDecoder(typ string, decoder ValDecoder) {
+ typeDecoders[typ] = decoder
+}
+
+// RegisterFieldDecoderFunc register TypeDecoder for a struct field with function
+func RegisterFieldDecoderFunc(typ string, field string, fun DecoderFunc) {
+ RegisterFieldDecoder(typ, field, &funcDecoder{fun})
+}
+
+// RegisterFieldDecoder register TypeDecoder for a struct field
+func RegisterFieldDecoder(typ string, field string, decoder ValDecoder) {
+ fieldDecoders[fmt.Sprintf("%s/%s", typ, field)] = decoder
+}
+
+// RegisterTypeEncoderFunc register TypeEncoder for a type with encode/isEmpty function
+func RegisterTypeEncoderFunc(typ string, fun EncoderFunc, isEmptyFunc func(unsafe.Pointer) bool) {
+ typeEncoders[typ] = &funcEncoder{fun, isEmptyFunc}
+}
+
+// RegisterTypeEncoder register TypeEncoder for a type
+func RegisterTypeEncoder(typ string, encoder ValEncoder) {
+ typeEncoders[typ] = encoder
+}
+
+// RegisterFieldEncoderFunc register TypeEncoder for a struct field with encode/isEmpty function
+func RegisterFieldEncoderFunc(typ string, field string, fun EncoderFunc, isEmptyFunc func(unsafe.Pointer) bool) {
+ RegisterFieldEncoder(typ, field, &funcEncoder{fun, isEmptyFunc})
+}
+
+// RegisterFieldEncoder register TypeEncoder for a struct field
+func RegisterFieldEncoder(typ string, field string, encoder ValEncoder) {
+ fieldEncoders[fmt.Sprintf("%s/%s", typ, field)] = encoder
+}
+
+// RegisterExtension register extension
+func RegisterExtension(extension Extension) {
+ extensions = append(extensions, extension)
+}
+
+func getTypeDecoderFromExtension(ctx *ctx, typ reflect2.Type) ValDecoder {
+ decoder := _getTypeDecoderFromExtension(ctx, typ)
+ if decoder != nil {
+ for _, extension := range extensions {
+ decoder = extension.DecorateDecoder(typ, decoder)
+ }
+ decoder = ctx.decoderExtension.DecorateDecoder(typ, decoder)
+ for _, extension := range ctx.extraExtensions {
+ decoder = extension.DecorateDecoder(typ, decoder)
+ }
+ }
+ return decoder
+}
+func _getTypeDecoderFromExtension(ctx *ctx, typ reflect2.Type) ValDecoder {
+ for _, extension := range extensions {
+ decoder := extension.CreateDecoder(typ)
+ if decoder != nil {
+ return decoder
+ }
+ }
+ decoder := ctx.decoderExtension.CreateDecoder(typ)
+ if decoder != nil {
+ return decoder
+ }
+ for _, extension := range ctx.extraExtensions {
+ decoder := extension.CreateDecoder(typ)
+ if decoder != nil {
+ return decoder
+ }
+ }
+ typeName := typ.String()
+ decoder = typeDecoders[typeName]
+ if decoder != nil {
+ return decoder
+ }
+ if typ.Kind() == reflect.Ptr {
+ ptrType := typ.(*reflect2.UnsafePtrType)
+ decoder := typeDecoders[ptrType.Elem().String()]
+ if decoder != nil {
+ return &OptionalDecoder{ptrType.Elem(), decoder}
+ }
+ }
+ return nil
+}
+
+func getTypeEncoderFromExtension(ctx *ctx, typ reflect2.Type) ValEncoder {
+ encoder := _getTypeEncoderFromExtension(ctx, typ)
+ if encoder != nil {
+ for _, extension := range extensions {
+ encoder = extension.DecorateEncoder(typ, encoder)
+ }
+ encoder = ctx.encoderExtension.DecorateEncoder(typ, encoder)
+ for _, extension := range ctx.extraExtensions {
+ encoder = extension.DecorateEncoder(typ, encoder)
+ }
+ }
+ return encoder
+}
+
+func _getTypeEncoderFromExtension(ctx *ctx, typ reflect2.Type) ValEncoder {
+ for _, extension := range extensions {
+ encoder := extension.CreateEncoder(typ)
+ if encoder != nil {
+ return encoder
+ }
+ }
+ encoder := ctx.encoderExtension.CreateEncoder(typ)
+ if encoder != nil {
+ return encoder
+ }
+ for _, extension := range ctx.extraExtensions {
+ encoder := extension.CreateEncoder(typ)
+ if encoder != nil {
+ return encoder
+ }
+ }
+ typeName := typ.String()
+ encoder = typeEncoders[typeName]
+ if encoder != nil {
+ return encoder
+ }
+ if typ.Kind() == reflect.Ptr {
+ typePtr := typ.(*reflect2.UnsafePtrType)
+ encoder := typeEncoders[typePtr.Elem().String()]
+ if encoder != nil {
+ return &OptionalEncoder{encoder}
+ }
+ }
+ return nil
+}
+
+func describeStruct(ctx *ctx, typ reflect2.Type) *StructDescriptor {
+ structType := typ.(*reflect2.UnsafeStructType)
+ embeddedBindings := []*Binding{}
+ bindings := []*Binding{}
+ for i := 0; i < structType.NumField(); i++ {
+ field := structType.Field(i)
+ tag, hastag := field.Tag().Lookup(ctx.getTagKey())
+ if ctx.onlyTaggedField && !hastag && !field.Anonymous() {
+ continue
+ }
+ if tag == "-" || field.Name() == "_" {
+ continue
+ }
+ tagParts := strings.Split(tag, ",")
+ if field.Anonymous() && (tag == "" || tagParts[0] == "") {
+ if field.Type().Kind() == reflect.Struct {
+ structDescriptor := describeStruct(ctx, field.Type())
+ for _, binding := range structDescriptor.Fields {
+ binding.levels = append([]int{i}, binding.levels...)
+ omitempty := binding.Encoder.(*structFieldEncoder).omitempty
+ binding.Encoder = &structFieldEncoder{field, binding.Encoder, omitempty}
+ binding.Decoder = &structFieldDecoder{field, binding.Decoder}
+ embeddedBindings = append(embeddedBindings, binding)
+ }
+ continue
+ } else if field.Type().Kind() == reflect.Ptr {
+ ptrType := field.Type().(*reflect2.UnsafePtrType)
+ if ptrType.Elem().Kind() == reflect.Struct {
+ structDescriptor := describeStruct(ctx, ptrType.Elem())
+ for _, binding := range structDescriptor.Fields {
+ binding.levels = append([]int{i}, binding.levels...)
+ omitempty := binding.Encoder.(*structFieldEncoder).omitempty
+ binding.Encoder = &dereferenceEncoder{binding.Encoder}
+ binding.Encoder = &structFieldEncoder{field, binding.Encoder, omitempty}
+ binding.Decoder = &dereferenceDecoder{ptrType.Elem(), binding.Decoder}
+ binding.Decoder = &structFieldDecoder{field, binding.Decoder}
+ embeddedBindings = append(embeddedBindings, binding)
+ }
+ continue
+ }
+ }
+ }
+ fieldNames := calcFieldNames(field.Name(), tagParts[0], tag)
+ fieldCacheKey := fmt.Sprintf("%s/%s", typ.String(), field.Name())
+ decoder := fieldDecoders[fieldCacheKey]
+ if decoder == nil {
+ decoder = decoderOfType(ctx.append(field.Name()), field.Type())
+ }
+ encoder := fieldEncoders[fieldCacheKey]
+ if encoder == nil {
+ encoder = encoderOfType(ctx.append(field.Name()), field.Type())
+ }
+ binding := &Binding{
+ Field: field,
+ FromNames: fieldNames,
+ ToNames: fieldNames,
+ Decoder: decoder,
+ Encoder: encoder,
+ }
+ binding.levels = []int{i}
+ bindings = append(bindings, binding)
+ }
+ return createStructDescriptor(ctx, typ, bindings, embeddedBindings)
+}
+func createStructDescriptor(ctx *ctx, typ reflect2.Type, bindings []*Binding, embeddedBindings []*Binding) *StructDescriptor {
+ structDescriptor := &StructDescriptor{
+ Type: typ,
+ Fields: bindings,
+ }
+ for _, extension := range extensions {
+ extension.UpdateStructDescriptor(structDescriptor)
+ }
+ ctx.encoderExtension.UpdateStructDescriptor(structDescriptor)
+ ctx.decoderExtension.UpdateStructDescriptor(structDescriptor)
+ for _, extension := range ctx.extraExtensions {
+ extension.UpdateStructDescriptor(structDescriptor)
+ }
+ processTags(structDescriptor, ctx.frozenConfig)
+ // merge normal & embedded bindings & sort with original order
+ allBindings := sortableBindings(append(embeddedBindings, structDescriptor.Fields...))
+ sort.Sort(allBindings)
+ structDescriptor.Fields = allBindings
+ return structDescriptor
+}
+
+type sortableBindings []*Binding
+
+func (bindings sortableBindings) Len() int {
+ return len(bindings)
+}
+
+func (bindings sortableBindings) Less(i, j int) bool {
+ left := bindings[i].levels
+ right := bindings[j].levels
+ k := 0
+ for {
+ if left[k] < right[k] {
+ return true
+ } else if left[k] > right[k] {
+ return false
+ }
+ k++
+ }
+}
+
+func (bindings sortableBindings) Swap(i, j int) {
+ bindings[i], bindings[j] = bindings[j], bindings[i]
+}
+
+func processTags(structDescriptor *StructDescriptor, cfg *frozenConfig) {
+ for _, binding := range structDescriptor.Fields {
+ shouldOmitEmpty := false
+ tagParts := strings.Split(binding.Field.Tag().Get(cfg.getTagKey()), ",")
+ for _, tagPart := range tagParts[1:] {
+ if tagPart == "omitempty" {
+ shouldOmitEmpty = true
+ } else if tagPart == "string" {
+ if binding.Field.Type().Kind() == reflect.String {
+ binding.Decoder = &stringModeStringDecoder{binding.Decoder, cfg}
+ binding.Encoder = &stringModeStringEncoder{binding.Encoder, cfg}
+ } else {
+ binding.Decoder = &stringModeNumberDecoder{binding.Decoder}
+ binding.Encoder = &stringModeNumberEncoder{binding.Encoder}
+ }
+ }
+ }
+ binding.Decoder = &structFieldDecoder{binding.Field, binding.Decoder}
+ binding.Encoder = &structFieldEncoder{binding.Field, binding.Encoder, shouldOmitEmpty}
+ }
+}
+
+func calcFieldNames(originalFieldName string, tagProvidedFieldName string, wholeTag string) []string {
+ // ignore?
+ if wholeTag == "-" {
+ return []string{}
+ }
+ // rename?
+ var fieldNames []string
+ if tagProvidedFieldName == "" {
+ fieldNames = []string{originalFieldName}
+ } else {
+ fieldNames = []string{tagProvidedFieldName}
+ }
+ // private?
+ isNotExported := unicode.IsLower(rune(originalFieldName[0])) || originalFieldName[0] == '_'
+ if isNotExported {
+ fieldNames = []string{}
+ }
+ return fieldNames
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_json_number.go b/vendor/github.com/json-iterator/go/reflect_json_number.go
new file mode 100644
index 0000000..98d45c1
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_json_number.go
@@ -0,0 +1,112 @@
+package jsoniter
+
+import (
+ "encoding/json"
+ "github.com/modern-go/reflect2"
+ "strconv"
+ "unsafe"
+)
+
+type Number string
+
+// String returns the literal text of the number.
+func (n Number) String() string { return string(n) }
+
+// Float64 returns the number as a float64.
+func (n Number) Float64() (float64, error) {
+ return strconv.ParseFloat(string(n), 64)
+}
+
+// Int64 returns the number as an int64.
+func (n Number) Int64() (int64, error) {
+ return strconv.ParseInt(string(n), 10, 64)
+}
+
+func CastJsonNumber(val interface{}) (string, bool) {
+ switch typedVal := val.(type) {
+ case json.Number:
+ return string(typedVal), true
+ case Number:
+ return string(typedVal), true
+ }
+ return "", false
+}
+
+var jsonNumberType = reflect2.TypeOfPtr((*json.Number)(nil)).Elem()
+var jsoniterNumberType = reflect2.TypeOfPtr((*Number)(nil)).Elem()
+
+func createDecoderOfJsonNumber(ctx *ctx, typ reflect2.Type) ValDecoder {
+ if typ.AssignableTo(jsonNumberType) {
+ return &jsonNumberCodec{}
+ }
+ if typ.AssignableTo(jsoniterNumberType) {
+ return &jsoniterNumberCodec{}
+ }
+ return nil
+}
+
+func createEncoderOfJsonNumber(ctx *ctx, typ reflect2.Type) ValEncoder {
+ if typ.AssignableTo(jsonNumberType) {
+ return &jsonNumberCodec{}
+ }
+ if typ.AssignableTo(jsoniterNumberType) {
+ return &jsoniterNumberCodec{}
+ }
+ return nil
+}
+
+type jsonNumberCodec struct {
+}
+
+func (codec *jsonNumberCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ switch iter.WhatIsNext() {
+ case StringValue:
+ *((*json.Number)(ptr)) = json.Number(iter.ReadString())
+ case NilValue:
+ iter.skipFourBytes('n', 'u', 'l', 'l')
+ *((*json.Number)(ptr)) = ""
+ default:
+ *((*json.Number)(ptr)) = json.Number([]byte(iter.readNumberAsString()))
+ }
+}
+
+func (codec *jsonNumberCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ number := *((*json.Number)(ptr))
+ if len(number) == 0 {
+ stream.writeByte('0')
+ } else {
+ stream.WriteRaw(string(number))
+ }
+}
+
+func (codec *jsonNumberCodec) IsEmpty(ptr unsafe.Pointer) bool {
+ return len(*((*json.Number)(ptr))) == 0
+}
+
+type jsoniterNumberCodec struct {
+}
+
+func (codec *jsoniterNumberCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ switch iter.WhatIsNext() {
+ case StringValue:
+ *((*Number)(ptr)) = Number(iter.ReadString())
+ case NilValue:
+ iter.skipFourBytes('n', 'u', 'l', 'l')
+ *((*Number)(ptr)) = ""
+ default:
+ *((*Number)(ptr)) = Number([]byte(iter.readNumberAsString()))
+ }
+}
+
+func (codec *jsoniterNumberCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ number := *((*Number)(ptr))
+ if len(number) == 0 {
+ stream.writeByte('0')
+ } else {
+ stream.WriteRaw(string(number))
+ }
+}
+
+func (codec *jsoniterNumberCodec) IsEmpty(ptr unsafe.Pointer) bool {
+ return len(*((*Number)(ptr))) == 0
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_json_raw_message.go b/vendor/github.com/json-iterator/go/reflect_json_raw_message.go
new file mode 100644
index 0000000..eba434f
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_json_raw_message.go
@@ -0,0 +1,76 @@
+package jsoniter
+
+import (
+ "encoding/json"
+ "github.com/modern-go/reflect2"
+ "unsafe"
+)
+
+var jsonRawMessageType = reflect2.TypeOfPtr((*json.RawMessage)(nil)).Elem()
+var jsoniterRawMessageType = reflect2.TypeOfPtr((*RawMessage)(nil)).Elem()
+
+func createEncoderOfJsonRawMessage(ctx *ctx, typ reflect2.Type) ValEncoder {
+ if typ == jsonRawMessageType {
+ return &jsonRawMessageCodec{}
+ }
+ if typ == jsoniterRawMessageType {
+ return &jsoniterRawMessageCodec{}
+ }
+ return nil
+}
+
+func createDecoderOfJsonRawMessage(ctx *ctx, typ reflect2.Type) ValDecoder {
+ if typ == jsonRawMessageType {
+ return &jsonRawMessageCodec{}
+ }
+ if typ == jsoniterRawMessageType {
+ return &jsoniterRawMessageCodec{}
+ }
+ return nil
+}
+
+type jsonRawMessageCodec struct {
+}
+
+func (codec *jsonRawMessageCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if iter.ReadNil() {
+ *((*json.RawMessage)(ptr)) = nil
+ } else {
+ *((*json.RawMessage)(ptr)) = iter.SkipAndReturnBytes()
+ }
+}
+
+func (codec *jsonRawMessageCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if *((*json.RawMessage)(ptr)) == nil {
+ stream.WriteNil()
+ } else {
+ stream.WriteRaw(string(*((*json.RawMessage)(ptr))))
+ }
+}
+
+func (codec *jsonRawMessageCodec) IsEmpty(ptr unsafe.Pointer) bool {
+ return len(*((*json.RawMessage)(ptr))) == 0
+}
+
+type jsoniterRawMessageCodec struct {
+}
+
+func (codec *jsoniterRawMessageCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if iter.ReadNil() {
+ *((*RawMessage)(ptr)) = nil
+ } else {
+ *((*RawMessage)(ptr)) = iter.SkipAndReturnBytes()
+ }
+}
+
+func (codec *jsoniterRawMessageCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if *((*RawMessage)(ptr)) == nil {
+ stream.WriteNil()
+ } else {
+ stream.WriteRaw(string(*((*RawMessage)(ptr))))
+ }
+}
+
+func (codec *jsoniterRawMessageCodec) IsEmpty(ptr unsafe.Pointer) bool {
+ return len(*((*RawMessage)(ptr))) == 0
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_map.go b/vendor/github.com/json-iterator/go/reflect_map.go
new file mode 100644
index 0000000..5829671
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_map.go
@@ -0,0 +1,346 @@
+package jsoniter
+
+import (
+ "fmt"
+ "github.com/modern-go/reflect2"
+ "io"
+ "reflect"
+ "sort"
+ "unsafe"
+)
+
+func decoderOfMap(ctx *ctx, typ reflect2.Type) ValDecoder {
+ mapType := typ.(*reflect2.UnsafeMapType)
+ keyDecoder := decoderOfMapKey(ctx.append("[mapKey]"), mapType.Key())
+ elemDecoder := decoderOfType(ctx.append("[mapElem]"), mapType.Elem())
+ return &mapDecoder{
+ mapType: mapType,
+ keyType: mapType.Key(),
+ elemType: mapType.Elem(),
+ keyDecoder: keyDecoder,
+ elemDecoder: elemDecoder,
+ }
+}
+
+func encoderOfMap(ctx *ctx, typ reflect2.Type) ValEncoder {
+ mapType := typ.(*reflect2.UnsafeMapType)
+ if ctx.sortMapKeys {
+ return &sortKeysMapEncoder{
+ mapType: mapType,
+ keyEncoder: encoderOfMapKey(ctx.append("[mapKey]"), mapType.Key()),
+ elemEncoder: encoderOfType(ctx.append("[mapElem]"), mapType.Elem()),
+ }
+ }
+ return &mapEncoder{
+ mapType: mapType,
+ keyEncoder: encoderOfMapKey(ctx.append("[mapKey]"), mapType.Key()),
+ elemEncoder: encoderOfType(ctx.append("[mapElem]"), mapType.Elem()),
+ }
+}
+
+func decoderOfMapKey(ctx *ctx, typ reflect2.Type) ValDecoder {
+ decoder := ctx.decoderExtension.CreateMapKeyDecoder(typ)
+ if decoder != nil {
+ return decoder
+ }
+ for _, extension := range ctx.extraExtensions {
+ decoder := extension.CreateMapKeyDecoder(typ)
+ if decoder != nil {
+ return decoder
+ }
+ }
+
+ ptrType := reflect2.PtrTo(typ)
+ if ptrType.Implements(unmarshalerType) {
+ return &referenceDecoder{
+ &unmarshalerDecoder{
+ valType: ptrType,
+ },
+ }
+ }
+ if typ.Implements(unmarshalerType) {
+ return &unmarshalerDecoder{
+ valType: typ,
+ }
+ }
+ if ptrType.Implements(textUnmarshalerType) {
+ return &referenceDecoder{
+ &textUnmarshalerDecoder{
+ valType: ptrType,
+ },
+ }
+ }
+ if typ.Implements(textUnmarshalerType) {
+ return &textUnmarshalerDecoder{
+ valType: typ,
+ }
+ }
+
+ switch typ.Kind() {
+ case reflect.String:
+ return decoderOfType(ctx, reflect2.DefaultTypeOfKind(reflect.String))
+ case reflect.Bool,
+ reflect.Uint8, reflect.Int8,
+ reflect.Uint16, reflect.Int16,
+ reflect.Uint32, reflect.Int32,
+ reflect.Uint64, reflect.Int64,
+ reflect.Uint, reflect.Int,
+ reflect.Float32, reflect.Float64,
+ reflect.Uintptr:
+ typ = reflect2.DefaultTypeOfKind(typ.Kind())
+ return &numericMapKeyDecoder{decoderOfType(ctx, typ)}
+ default:
+ return &lazyErrorDecoder{err: fmt.Errorf("unsupported map key type: %v", typ)}
+ }
+}
+
+func encoderOfMapKey(ctx *ctx, typ reflect2.Type) ValEncoder {
+ encoder := ctx.encoderExtension.CreateMapKeyEncoder(typ)
+ if encoder != nil {
+ return encoder
+ }
+ for _, extension := range ctx.extraExtensions {
+ encoder := extension.CreateMapKeyEncoder(typ)
+ if encoder != nil {
+ return encoder
+ }
+ }
+
+ if typ == textMarshalerType {
+ return &directTextMarshalerEncoder{
+ stringEncoder: ctx.EncoderOf(reflect2.TypeOf("")),
+ }
+ }
+ if typ.Implements(textMarshalerType) {
+ return &textMarshalerEncoder{
+ valType: typ,
+ stringEncoder: ctx.EncoderOf(reflect2.TypeOf("")),
+ }
+ }
+
+ switch typ.Kind() {
+ case reflect.String:
+ return encoderOfType(ctx, reflect2.DefaultTypeOfKind(reflect.String))
+ case reflect.Bool,
+ reflect.Uint8, reflect.Int8,
+ reflect.Uint16, reflect.Int16,
+ reflect.Uint32, reflect.Int32,
+ reflect.Uint64, reflect.Int64,
+ reflect.Uint, reflect.Int,
+ reflect.Float32, reflect.Float64,
+ reflect.Uintptr:
+ typ = reflect2.DefaultTypeOfKind(typ.Kind())
+ return &numericMapKeyEncoder{encoderOfType(ctx, typ)}
+ default:
+ if typ.Kind() == reflect.Interface {
+ return &dynamicMapKeyEncoder{ctx, typ}
+ }
+ return &lazyErrorEncoder{err: fmt.Errorf("unsupported map key type: %v", typ)}
+ }
+}
+
+type mapDecoder struct {
+ mapType *reflect2.UnsafeMapType
+ keyType reflect2.Type
+ elemType reflect2.Type
+ keyDecoder ValDecoder
+ elemDecoder ValDecoder
+}
+
+func (decoder *mapDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ mapType := decoder.mapType
+ c := iter.nextToken()
+ if c == 'n' {
+ iter.skipThreeBytes('u', 'l', 'l')
+ *(*unsafe.Pointer)(ptr) = nil
+ mapType.UnsafeSet(ptr, mapType.UnsafeNew())
+ return
+ }
+ if mapType.UnsafeIsNil(ptr) {
+ mapType.UnsafeSet(ptr, mapType.UnsafeMakeMap(0))
+ }
+ if c != '{' {
+ iter.ReportError("ReadMapCB", `expect { or n, but found `+string([]byte{c}))
+ return
+ }
+ c = iter.nextToken()
+ if c == '}' {
+ return
+ }
+ iter.unreadByte()
+ key := decoder.keyType.UnsafeNew()
+ decoder.keyDecoder.Decode(key, iter)
+ c = iter.nextToken()
+ if c != ':' {
+ iter.ReportError("ReadMapCB", "expect : after object field, but found "+string([]byte{c}))
+ return
+ }
+ elem := decoder.elemType.UnsafeNew()
+ decoder.elemDecoder.Decode(elem, iter)
+ decoder.mapType.UnsafeSetIndex(ptr, key, elem)
+ for c = iter.nextToken(); c == ','; c = iter.nextToken() {
+ key := decoder.keyType.UnsafeNew()
+ decoder.keyDecoder.Decode(key, iter)
+ c = iter.nextToken()
+ if c != ':' {
+ iter.ReportError("ReadMapCB", "expect : after object field, but found "+string([]byte{c}))
+ return
+ }
+ elem := decoder.elemType.UnsafeNew()
+ decoder.elemDecoder.Decode(elem, iter)
+ decoder.mapType.UnsafeSetIndex(ptr, key, elem)
+ }
+ if c != '}' {
+ iter.ReportError("ReadMapCB", `expect }, but found `+string([]byte{c}))
+ }
+}
+
+type numericMapKeyDecoder struct {
+ decoder ValDecoder
+}
+
+func (decoder *numericMapKeyDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ c := iter.nextToken()
+ if c != '"' {
+ iter.ReportError("ReadMapCB", `expect ", but found `+string([]byte{c}))
+ return
+ }
+ decoder.decoder.Decode(ptr, iter)
+ c = iter.nextToken()
+ if c != '"' {
+ iter.ReportError("ReadMapCB", `expect ", but found `+string([]byte{c}))
+ return
+ }
+}
+
+type numericMapKeyEncoder struct {
+ encoder ValEncoder
+}
+
+func (encoder *numericMapKeyEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.writeByte('"')
+ encoder.encoder.Encode(ptr, stream)
+ stream.writeByte('"')
+}
+
+func (encoder *numericMapKeyEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return false
+}
+
+type dynamicMapKeyEncoder struct {
+ ctx *ctx
+ valType reflect2.Type
+}
+
+func (encoder *dynamicMapKeyEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ obj := encoder.valType.UnsafeIndirect(ptr)
+ encoderOfMapKey(encoder.ctx, reflect2.TypeOf(obj)).Encode(reflect2.PtrOf(obj), stream)
+}
+
+func (encoder *dynamicMapKeyEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ obj := encoder.valType.UnsafeIndirect(ptr)
+ return encoderOfMapKey(encoder.ctx, reflect2.TypeOf(obj)).IsEmpty(reflect2.PtrOf(obj))
+}
+
+type mapEncoder struct {
+ mapType *reflect2.UnsafeMapType
+ keyEncoder ValEncoder
+ elemEncoder ValEncoder
+}
+
+func (encoder *mapEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if *(*unsafe.Pointer)(ptr) == nil {
+ stream.WriteNil()
+ return
+ }
+ stream.WriteObjectStart()
+ iter := encoder.mapType.UnsafeIterate(ptr)
+ for i := 0; iter.HasNext(); i++ {
+ if i != 0 {
+ stream.WriteMore()
+ }
+ key, elem := iter.UnsafeNext()
+ encoder.keyEncoder.Encode(key, stream)
+ if stream.indention > 0 {
+ stream.writeTwoBytes(byte(':'), byte(' '))
+ } else {
+ stream.writeByte(':')
+ }
+ encoder.elemEncoder.Encode(elem, stream)
+ }
+ stream.WriteObjectEnd()
+}
+
+func (encoder *mapEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ iter := encoder.mapType.UnsafeIterate(ptr)
+ return !iter.HasNext()
+}
+
+type sortKeysMapEncoder struct {
+ mapType *reflect2.UnsafeMapType
+ keyEncoder ValEncoder
+ elemEncoder ValEncoder
+}
+
+func (encoder *sortKeysMapEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if *(*unsafe.Pointer)(ptr) == nil {
+ stream.WriteNil()
+ return
+ }
+ stream.WriteObjectStart()
+ mapIter := encoder.mapType.UnsafeIterate(ptr)
+ subStream := stream.cfg.BorrowStream(nil)
+ subStream.Attachment = stream.Attachment
+ subIter := stream.cfg.BorrowIterator(nil)
+ keyValues := encodedKeyValues{}
+ for mapIter.HasNext() {
+ key, elem := mapIter.UnsafeNext()
+ subStreamIndex := subStream.Buffered()
+ encoder.keyEncoder.Encode(key, subStream)
+ if subStream.Error != nil && subStream.Error != io.EOF && stream.Error == nil {
+ stream.Error = subStream.Error
+ }
+ encodedKey := subStream.Buffer()[subStreamIndex:]
+ subIter.ResetBytes(encodedKey)
+ decodedKey := subIter.ReadString()
+ if stream.indention > 0 {
+ subStream.writeTwoBytes(byte(':'), byte(' '))
+ } else {
+ subStream.writeByte(':')
+ }
+ encoder.elemEncoder.Encode(elem, subStream)
+ keyValues = append(keyValues, encodedKV{
+ key: decodedKey,
+ keyValue: subStream.Buffer()[subStreamIndex:],
+ })
+ }
+ sort.Sort(keyValues)
+ for i, keyValue := range keyValues {
+ if i != 0 {
+ stream.WriteMore()
+ }
+ stream.Write(keyValue.keyValue)
+ }
+ if subStream.Error != nil && stream.Error == nil {
+ stream.Error = subStream.Error
+ }
+ stream.WriteObjectEnd()
+ stream.cfg.ReturnStream(subStream)
+ stream.cfg.ReturnIterator(subIter)
+}
+
+func (encoder *sortKeysMapEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ iter := encoder.mapType.UnsafeIterate(ptr)
+ return !iter.HasNext()
+}
+
+type encodedKeyValues []encodedKV
+
+type encodedKV struct {
+ key string
+ keyValue []byte
+}
+
+func (sv encodedKeyValues) Len() int { return len(sv) }
+func (sv encodedKeyValues) Swap(i, j int) { sv[i], sv[j] = sv[j], sv[i] }
+func (sv encodedKeyValues) Less(i, j int) bool { return sv[i].key < sv[j].key }
diff --git a/vendor/github.com/json-iterator/go/reflect_marshaler.go b/vendor/github.com/json-iterator/go/reflect_marshaler.go
new file mode 100644
index 0000000..3e21f37
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_marshaler.go
@@ -0,0 +1,225 @@
+package jsoniter
+
+import (
+ "encoding"
+ "encoding/json"
+ "unsafe"
+
+ "github.com/modern-go/reflect2"
+)
+
+var marshalerType = reflect2.TypeOfPtr((*json.Marshaler)(nil)).Elem()
+var unmarshalerType = reflect2.TypeOfPtr((*json.Unmarshaler)(nil)).Elem()
+var textMarshalerType = reflect2.TypeOfPtr((*encoding.TextMarshaler)(nil)).Elem()
+var textUnmarshalerType = reflect2.TypeOfPtr((*encoding.TextUnmarshaler)(nil)).Elem()
+
+func createDecoderOfMarshaler(ctx *ctx, typ reflect2.Type) ValDecoder {
+ ptrType := reflect2.PtrTo(typ)
+ if ptrType.Implements(unmarshalerType) {
+ return &referenceDecoder{
+ &unmarshalerDecoder{ptrType},
+ }
+ }
+ if ptrType.Implements(textUnmarshalerType) {
+ return &referenceDecoder{
+ &textUnmarshalerDecoder{ptrType},
+ }
+ }
+ return nil
+}
+
+func createEncoderOfMarshaler(ctx *ctx, typ reflect2.Type) ValEncoder {
+ if typ == marshalerType {
+ checkIsEmpty := createCheckIsEmpty(ctx, typ)
+ var encoder ValEncoder = &directMarshalerEncoder{
+ checkIsEmpty: checkIsEmpty,
+ }
+ return encoder
+ }
+ if typ.Implements(marshalerType) {
+ checkIsEmpty := createCheckIsEmpty(ctx, typ)
+ var encoder ValEncoder = &marshalerEncoder{
+ valType: typ,
+ checkIsEmpty: checkIsEmpty,
+ }
+ return encoder
+ }
+ ptrType := reflect2.PtrTo(typ)
+ if ctx.prefix != "" && ptrType.Implements(marshalerType) {
+ checkIsEmpty := createCheckIsEmpty(ctx, ptrType)
+ var encoder ValEncoder = &marshalerEncoder{
+ valType: ptrType,
+ checkIsEmpty: checkIsEmpty,
+ }
+ return &referenceEncoder{encoder}
+ }
+ if typ == textMarshalerType {
+ checkIsEmpty := createCheckIsEmpty(ctx, typ)
+ var encoder ValEncoder = &directTextMarshalerEncoder{
+ checkIsEmpty: checkIsEmpty,
+ stringEncoder: ctx.EncoderOf(reflect2.TypeOf("")),
+ }
+ return encoder
+ }
+ if typ.Implements(textMarshalerType) {
+ checkIsEmpty := createCheckIsEmpty(ctx, typ)
+ var encoder ValEncoder = &textMarshalerEncoder{
+ valType: typ,
+ stringEncoder: ctx.EncoderOf(reflect2.TypeOf("")),
+ checkIsEmpty: checkIsEmpty,
+ }
+ return encoder
+ }
+ // if prefix is empty, the type is the root type
+ if ctx.prefix != "" && ptrType.Implements(textMarshalerType) {
+ checkIsEmpty := createCheckIsEmpty(ctx, ptrType)
+ var encoder ValEncoder = &textMarshalerEncoder{
+ valType: ptrType,
+ stringEncoder: ctx.EncoderOf(reflect2.TypeOf("")),
+ checkIsEmpty: checkIsEmpty,
+ }
+ return &referenceEncoder{encoder}
+ }
+ return nil
+}
+
+type marshalerEncoder struct {
+ checkIsEmpty checkIsEmpty
+ valType reflect2.Type
+}
+
+func (encoder *marshalerEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ obj := encoder.valType.UnsafeIndirect(ptr)
+ if encoder.valType.IsNullable() && reflect2.IsNil(obj) {
+ stream.WriteNil()
+ return
+ }
+ marshaler := obj.(json.Marshaler)
+ bytes, err := marshaler.MarshalJSON()
+ if err != nil {
+ stream.Error = err
+ } else {
+ // html escape was already done by jsoniter
+ // but the extra '\n' should be trimed
+ l := len(bytes)
+ if l > 0 && bytes[l-1] == '\n' {
+ bytes = bytes[:l-1]
+ }
+ stream.Write(bytes)
+ }
+}
+
+func (encoder *marshalerEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.checkIsEmpty.IsEmpty(ptr)
+}
+
+type directMarshalerEncoder struct {
+ checkIsEmpty checkIsEmpty
+}
+
+func (encoder *directMarshalerEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ marshaler := *(*json.Marshaler)(ptr)
+ if marshaler == nil {
+ stream.WriteNil()
+ return
+ }
+ bytes, err := marshaler.MarshalJSON()
+ if err != nil {
+ stream.Error = err
+ } else {
+ stream.Write(bytes)
+ }
+}
+
+func (encoder *directMarshalerEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.checkIsEmpty.IsEmpty(ptr)
+}
+
+type textMarshalerEncoder struct {
+ valType reflect2.Type
+ stringEncoder ValEncoder
+ checkIsEmpty checkIsEmpty
+}
+
+func (encoder *textMarshalerEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ obj := encoder.valType.UnsafeIndirect(ptr)
+ if encoder.valType.IsNullable() && reflect2.IsNil(obj) {
+ stream.WriteNil()
+ return
+ }
+ marshaler := (obj).(encoding.TextMarshaler)
+ bytes, err := marshaler.MarshalText()
+ if err != nil {
+ stream.Error = err
+ } else {
+ str := string(bytes)
+ encoder.stringEncoder.Encode(unsafe.Pointer(&str), stream)
+ }
+}
+
+func (encoder *textMarshalerEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.checkIsEmpty.IsEmpty(ptr)
+}
+
+type directTextMarshalerEncoder struct {
+ stringEncoder ValEncoder
+ checkIsEmpty checkIsEmpty
+}
+
+func (encoder *directTextMarshalerEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ marshaler := *(*encoding.TextMarshaler)(ptr)
+ if marshaler == nil {
+ stream.WriteNil()
+ return
+ }
+ bytes, err := marshaler.MarshalText()
+ if err != nil {
+ stream.Error = err
+ } else {
+ str := string(bytes)
+ encoder.stringEncoder.Encode(unsafe.Pointer(&str), stream)
+ }
+}
+
+func (encoder *directTextMarshalerEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.checkIsEmpty.IsEmpty(ptr)
+}
+
+type unmarshalerDecoder struct {
+ valType reflect2.Type
+}
+
+func (decoder *unmarshalerDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ valType := decoder.valType
+ obj := valType.UnsafeIndirect(ptr)
+ unmarshaler := obj.(json.Unmarshaler)
+ iter.nextToken()
+ iter.unreadByte() // skip spaces
+ bytes := iter.SkipAndReturnBytes()
+ err := unmarshaler.UnmarshalJSON(bytes)
+ if err != nil {
+ iter.ReportError("unmarshalerDecoder", err.Error())
+ }
+}
+
+type textUnmarshalerDecoder struct {
+ valType reflect2.Type
+}
+
+func (decoder *textUnmarshalerDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ valType := decoder.valType
+ obj := valType.UnsafeIndirect(ptr)
+ if reflect2.IsNil(obj) {
+ ptrType := valType.(*reflect2.UnsafePtrType)
+ elemType := ptrType.Elem()
+ elem := elemType.UnsafeNew()
+ ptrType.UnsafeSet(ptr, unsafe.Pointer(&elem))
+ obj = valType.UnsafeIndirect(ptr)
+ }
+ unmarshaler := (obj).(encoding.TextUnmarshaler)
+ str := iter.ReadString()
+ err := unmarshaler.UnmarshalText([]byte(str))
+ if err != nil {
+ iter.ReportError("textUnmarshalerDecoder", err.Error())
+ }
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_native.go b/vendor/github.com/json-iterator/go/reflect_native.go
new file mode 100644
index 0000000..f88722d
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_native.go
@@ -0,0 +1,453 @@
+package jsoniter
+
+import (
+ "encoding/base64"
+ "reflect"
+ "strconv"
+ "unsafe"
+
+ "github.com/modern-go/reflect2"
+)
+
+const ptrSize = 32 << uintptr(^uintptr(0)>>63)
+
+func createEncoderOfNative(ctx *ctx, typ reflect2.Type) ValEncoder {
+ if typ.Kind() == reflect.Slice && typ.(reflect2.SliceType).Elem().Kind() == reflect.Uint8 {
+ sliceDecoder := decoderOfSlice(ctx, typ)
+ return &base64Codec{sliceDecoder: sliceDecoder}
+ }
+ typeName := typ.String()
+ kind := typ.Kind()
+ switch kind {
+ case reflect.String:
+ if typeName != "string" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*string)(nil)).Elem())
+ }
+ return &stringCodec{}
+ case reflect.Int:
+ if typeName != "int" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*int)(nil)).Elem())
+ }
+ if strconv.IntSize == 32 {
+ return &int32Codec{}
+ }
+ return &int64Codec{}
+ case reflect.Int8:
+ if typeName != "int8" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*int8)(nil)).Elem())
+ }
+ return &int8Codec{}
+ case reflect.Int16:
+ if typeName != "int16" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*int16)(nil)).Elem())
+ }
+ return &int16Codec{}
+ case reflect.Int32:
+ if typeName != "int32" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*int32)(nil)).Elem())
+ }
+ return &int32Codec{}
+ case reflect.Int64:
+ if typeName != "int64" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*int64)(nil)).Elem())
+ }
+ return &int64Codec{}
+ case reflect.Uint:
+ if typeName != "uint" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*uint)(nil)).Elem())
+ }
+ if strconv.IntSize == 32 {
+ return &uint32Codec{}
+ }
+ return &uint64Codec{}
+ case reflect.Uint8:
+ if typeName != "uint8" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*uint8)(nil)).Elem())
+ }
+ return &uint8Codec{}
+ case reflect.Uint16:
+ if typeName != "uint16" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*uint16)(nil)).Elem())
+ }
+ return &uint16Codec{}
+ case reflect.Uint32:
+ if typeName != "uint32" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*uint32)(nil)).Elem())
+ }
+ return &uint32Codec{}
+ case reflect.Uintptr:
+ if typeName != "uintptr" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*uintptr)(nil)).Elem())
+ }
+ if ptrSize == 32 {
+ return &uint32Codec{}
+ }
+ return &uint64Codec{}
+ case reflect.Uint64:
+ if typeName != "uint64" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*uint64)(nil)).Elem())
+ }
+ return &uint64Codec{}
+ case reflect.Float32:
+ if typeName != "float32" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*float32)(nil)).Elem())
+ }
+ return &float32Codec{}
+ case reflect.Float64:
+ if typeName != "float64" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*float64)(nil)).Elem())
+ }
+ return &float64Codec{}
+ case reflect.Bool:
+ if typeName != "bool" {
+ return encoderOfType(ctx, reflect2.TypeOfPtr((*bool)(nil)).Elem())
+ }
+ return &boolCodec{}
+ }
+ return nil
+}
+
+func createDecoderOfNative(ctx *ctx, typ reflect2.Type) ValDecoder {
+ if typ.Kind() == reflect.Slice && typ.(reflect2.SliceType).Elem().Kind() == reflect.Uint8 {
+ sliceDecoder := decoderOfSlice(ctx, typ)
+ return &base64Codec{sliceDecoder: sliceDecoder}
+ }
+ typeName := typ.String()
+ switch typ.Kind() {
+ case reflect.String:
+ if typeName != "string" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*string)(nil)).Elem())
+ }
+ return &stringCodec{}
+ case reflect.Int:
+ if typeName != "int" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*int)(nil)).Elem())
+ }
+ if strconv.IntSize == 32 {
+ return &int32Codec{}
+ }
+ return &int64Codec{}
+ case reflect.Int8:
+ if typeName != "int8" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*int8)(nil)).Elem())
+ }
+ return &int8Codec{}
+ case reflect.Int16:
+ if typeName != "int16" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*int16)(nil)).Elem())
+ }
+ return &int16Codec{}
+ case reflect.Int32:
+ if typeName != "int32" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*int32)(nil)).Elem())
+ }
+ return &int32Codec{}
+ case reflect.Int64:
+ if typeName != "int64" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*int64)(nil)).Elem())
+ }
+ return &int64Codec{}
+ case reflect.Uint:
+ if typeName != "uint" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*uint)(nil)).Elem())
+ }
+ if strconv.IntSize == 32 {
+ return &uint32Codec{}
+ }
+ return &uint64Codec{}
+ case reflect.Uint8:
+ if typeName != "uint8" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*uint8)(nil)).Elem())
+ }
+ return &uint8Codec{}
+ case reflect.Uint16:
+ if typeName != "uint16" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*uint16)(nil)).Elem())
+ }
+ return &uint16Codec{}
+ case reflect.Uint32:
+ if typeName != "uint32" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*uint32)(nil)).Elem())
+ }
+ return &uint32Codec{}
+ case reflect.Uintptr:
+ if typeName != "uintptr" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*uintptr)(nil)).Elem())
+ }
+ if ptrSize == 32 {
+ return &uint32Codec{}
+ }
+ return &uint64Codec{}
+ case reflect.Uint64:
+ if typeName != "uint64" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*uint64)(nil)).Elem())
+ }
+ return &uint64Codec{}
+ case reflect.Float32:
+ if typeName != "float32" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*float32)(nil)).Elem())
+ }
+ return &float32Codec{}
+ case reflect.Float64:
+ if typeName != "float64" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*float64)(nil)).Elem())
+ }
+ return &float64Codec{}
+ case reflect.Bool:
+ if typeName != "bool" {
+ return decoderOfType(ctx, reflect2.TypeOfPtr((*bool)(nil)).Elem())
+ }
+ return &boolCodec{}
+ }
+ return nil
+}
+
+type stringCodec struct {
+}
+
+func (codec *stringCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ *((*string)(ptr)) = iter.ReadString()
+}
+
+func (codec *stringCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ str := *((*string)(ptr))
+ stream.WriteString(str)
+}
+
+func (codec *stringCodec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*string)(ptr)) == ""
+}
+
+type int8Codec struct {
+}
+
+func (codec *int8Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*int8)(ptr)) = iter.ReadInt8()
+ }
+}
+
+func (codec *int8Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteInt8(*((*int8)(ptr)))
+}
+
+func (codec *int8Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*int8)(ptr)) == 0
+}
+
+type int16Codec struct {
+}
+
+func (codec *int16Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*int16)(ptr)) = iter.ReadInt16()
+ }
+}
+
+func (codec *int16Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteInt16(*((*int16)(ptr)))
+}
+
+func (codec *int16Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*int16)(ptr)) == 0
+}
+
+type int32Codec struct {
+}
+
+func (codec *int32Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*int32)(ptr)) = iter.ReadInt32()
+ }
+}
+
+func (codec *int32Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteInt32(*((*int32)(ptr)))
+}
+
+func (codec *int32Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*int32)(ptr)) == 0
+}
+
+type int64Codec struct {
+}
+
+func (codec *int64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*int64)(ptr)) = iter.ReadInt64()
+ }
+}
+
+func (codec *int64Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteInt64(*((*int64)(ptr)))
+}
+
+func (codec *int64Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*int64)(ptr)) == 0
+}
+
+type uint8Codec struct {
+}
+
+func (codec *uint8Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*uint8)(ptr)) = iter.ReadUint8()
+ }
+}
+
+func (codec *uint8Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteUint8(*((*uint8)(ptr)))
+}
+
+func (codec *uint8Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*uint8)(ptr)) == 0
+}
+
+type uint16Codec struct {
+}
+
+func (codec *uint16Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*uint16)(ptr)) = iter.ReadUint16()
+ }
+}
+
+func (codec *uint16Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteUint16(*((*uint16)(ptr)))
+}
+
+func (codec *uint16Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*uint16)(ptr)) == 0
+}
+
+type uint32Codec struct {
+}
+
+func (codec *uint32Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*uint32)(ptr)) = iter.ReadUint32()
+ }
+}
+
+func (codec *uint32Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteUint32(*((*uint32)(ptr)))
+}
+
+func (codec *uint32Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*uint32)(ptr)) == 0
+}
+
+type uint64Codec struct {
+}
+
+func (codec *uint64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*uint64)(ptr)) = iter.ReadUint64()
+ }
+}
+
+func (codec *uint64Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteUint64(*((*uint64)(ptr)))
+}
+
+func (codec *uint64Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*uint64)(ptr)) == 0
+}
+
+type float32Codec struct {
+}
+
+func (codec *float32Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*float32)(ptr)) = iter.ReadFloat32()
+ }
+}
+
+func (codec *float32Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteFloat32(*((*float32)(ptr)))
+}
+
+func (codec *float32Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*float32)(ptr)) == 0
+}
+
+type float64Codec struct {
+}
+
+func (codec *float64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*float64)(ptr)) = iter.ReadFloat64()
+ }
+}
+
+func (codec *float64Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteFloat64(*((*float64)(ptr)))
+}
+
+func (codec *float64Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*float64)(ptr)) == 0
+}
+
+type boolCodec struct {
+}
+
+func (codec *boolCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.ReadNil() {
+ *((*bool)(ptr)) = iter.ReadBool()
+ }
+}
+
+func (codec *boolCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteBool(*((*bool)(ptr)))
+}
+
+func (codec *boolCodec) IsEmpty(ptr unsafe.Pointer) bool {
+ return !(*((*bool)(ptr)))
+}
+
+type base64Codec struct {
+ sliceType *reflect2.UnsafeSliceType
+ sliceDecoder ValDecoder
+}
+
+func (codec *base64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if iter.ReadNil() {
+ codec.sliceType.UnsafeSetNil(ptr)
+ return
+ }
+ switch iter.WhatIsNext() {
+ case StringValue:
+ src := iter.ReadString()
+ dst, err := base64.StdEncoding.DecodeString(src)
+ if err != nil {
+ iter.ReportError("decode base64", err.Error())
+ } else {
+ codec.sliceType.UnsafeSet(ptr, unsafe.Pointer(&dst))
+ }
+ case ArrayValue:
+ codec.sliceDecoder.Decode(ptr, iter)
+ default:
+ iter.ReportError("base64Codec", "invalid input")
+ }
+}
+
+func (codec *base64Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if codec.sliceType.UnsafeIsNil(ptr) {
+ stream.WriteNil()
+ return
+ }
+ src := *((*[]byte)(ptr))
+ encoding := base64.StdEncoding
+ stream.writeByte('"')
+ if len(src) != 0 {
+ size := encoding.EncodedLen(len(src))
+ buf := make([]byte, size)
+ encoding.Encode(buf, src)
+ stream.buf = append(stream.buf, buf...)
+ }
+ stream.writeByte('"')
+}
+
+func (codec *base64Codec) IsEmpty(ptr unsafe.Pointer) bool {
+ return len(*((*[]byte)(ptr))) == 0
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_optional.go b/vendor/github.com/json-iterator/go/reflect_optional.go
new file mode 100644
index 0000000..fa71f47
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_optional.go
@@ -0,0 +1,129 @@
+package jsoniter
+
+import (
+ "github.com/modern-go/reflect2"
+ "unsafe"
+)
+
+func decoderOfOptional(ctx *ctx, typ reflect2.Type) ValDecoder {
+ ptrType := typ.(*reflect2.UnsafePtrType)
+ elemType := ptrType.Elem()
+ decoder := decoderOfType(ctx, elemType)
+ return &OptionalDecoder{elemType, decoder}
+}
+
+func encoderOfOptional(ctx *ctx, typ reflect2.Type) ValEncoder {
+ ptrType := typ.(*reflect2.UnsafePtrType)
+ elemType := ptrType.Elem()
+ elemEncoder := encoderOfType(ctx, elemType)
+ encoder := &OptionalEncoder{elemEncoder}
+ return encoder
+}
+
+type OptionalDecoder struct {
+ ValueType reflect2.Type
+ ValueDecoder ValDecoder
+}
+
+func (decoder *OptionalDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if iter.ReadNil() {
+ *((*unsafe.Pointer)(ptr)) = nil
+ } else {
+ if *((*unsafe.Pointer)(ptr)) == nil {
+ //pointer to null, we have to allocate memory to hold the value
+ newPtr := decoder.ValueType.UnsafeNew()
+ decoder.ValueDecoder.Decode(newPtr, iter)
+ *((*unsafe.Pointer)(ptr)) = newPtr
+ } else {
+ //reuse existing instance
+ decoder.ValueDecoder.Decode(*((*unsafe.Pointer)(ptr)), iter)
+ }
+ }
+}
+
+type dereferenceDecoder struct {
+ // only to deference a pointer
+ valueType reflect2.Type
+ valueDecoder ValDecoder
+}
+
+func (decoder *dereferenceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if *((*unsafe.Pointer)(ptr)) == nil {
+ //pointer to null, we have to allocate memory to hold the value
+ newPtr := decoder.valueType.UnsafeNew()
+ decoder.valueDecoder.Decode(newPtr, iter)
+ *((*unsafe.Pointer)(ptr)) = newPtr
+ } else {
+ //reuse existing instance
+ decoder.valueDecoder.Decode(*((*unsafe.Pointer)(ptr)), iter)
+ }
+}
+
+type OptionalEncoder struct {
+ ValueEncoder ValEncoder
+}
+
+func (encoder *OptionalEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if *((*unsafe.Pointer)(ptr)) == nil {
+ stream.WriteNil()
+ } else {
+ encoder.ValueEncoder.Encode(*((*unsafe.Pointer)(ptr)), stream)
+ }
+}
+
+func (encoder *OptionalEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return *((*unsafe.Pointer)(ptr)) == nil
+}
+
+type dereferenceEncoder struct {
+ ValueEncoder ValEncoder
+}
+
+func (encoder *dereferenceEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if *((*unsafe.Pointer)(ptr)) == nil {
+ stream.WriteNil()
+ } else {
+ encoder.ValueEncoder.Encode(*((*unsafe.Pointer)(ptr)), stream)
+ }
+}
+
+func (encoder *dereferenceEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ dePtr := *((*unsafe.Pointer)(ptr))
+ if dePtr == nil {
+ return true
+ }
+ return encoder.ValueEncoder.IsEmpty(dePtr)
+}
+
+func (encoder *dereferenceEncoder) IsEmbeddedPtrNil(ptr unsafe.Pointer) bool {
+ deReferenced := *((*unsafe.Pointer)(ptr))
+ if deReferenced == nil {
+ return true
+ }
+ isEmbeddedPtrNil, converted := encoder.ValueEncoder.(IsEmbeddedPtrNil)
+ if !converted {
+ return false
+ }
+ fieldPtr := unsafe.Pointer(deReferenced)
+ return isEmbeddedPtrNil.IsEmbeddedPtrNil(fieldPtr)
+}
+
+type referenceEncoder struct {
+ encoder ValEncoder
+}
+
+func (encoder *referenceEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ encoder.encoder.Encode(unsafe.Pointer(&ptr), stream)
+}
+
+func (encoder *referenceEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.encoder.IsEmpty(unsafe.Pointer(&ptr))
+}
+
+type referenceDecoder struct {
+ decoder ValDecoder
+}
+
+func (decoder *referenceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ decoder.decoder.Decode(unsafe.Pointer(&ptr), iter)
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_slice.go b/vendor/github.com/json-iterator/go/reflect_slice.go
new file mode 100644
index 0000000..9441d79
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_slice.go
@@ -0,0 +1,99 @@
+package jsoniter
+
+import (
+ "fmt"
+ "github.com/modern-go/reflect2"
+ "io"
+ "unsafe"
+)
+
+func decoderOfSlice(ctx *ctx, typ reflect2.Type) ValDecoder {
+ sliceType := typ.(*reflect2.UnsafeSliceType)
+ decoder := decoderOfType(ctx.append("[sliceElem]"), sliceType.Elem())
+ return &sliceDecoder{sliceType, decoder}
+}
+
+func encoderOfSlice(ctx *ctx, typ reflect2.Type) ValEncoder {
+ sliceType := typ.(*reflect2.UnsafeSliceType)
+ encoder := encoderOfType(ctx.append("[sliceElem]"), sliceType.Elem())
+ return &sliceEncoder{sliceType, encoder}
+}
+
+type sliceEncoder struct {
+ sliceType *reflect2.UnsafeSliceType
+ elemEncoder ValEncoder
+}
+
+func (encoder *sliceEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if encoder.sliceType.UnsafeIsNil(ptr) {
+ stream.WriteNil()
+ return
+ }
+ length := encoder.sliceType.UnsafeLengthOf(ptr)
+ if length == 0 {
+ stream.WriteEmptyArray()
+ return
+ }
+ stream.WriteArrayStart()
+ encoder.elemEncoder.Encode(encoder.sliceType.UnsafeGetIndex(ptr, 0), stream)
+ for i := 1; i < length; i++ {
+ stream.WriteMore()
+ elemPtr := encoder.sliceType.UnsafeGetIndex(ptr, i)
+ encoder.elemEncoder.Encode(elemPtr, stream)
+ }
+ stream.WriteArrayEnd()
+ if stream.Error != nil && stream.Error != io.EOF {
+ stream.Error = fmt.Errorf("%v: %s", encoder.sliceType, stream.Error.Error())
+ }
+}
+
+func (encoder *sliceEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.sliceType.UnsafeLengthOf(ptr) == 0
+}
+
+type sliceDecoder struct {
+ sliceType *reflect2.UnsafeSliceType
+ elemDecoder ValDecoder
+}
+
+func (decoder *sliceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ decoder.doDecode(ptr, iter)
+ if iter.Error != nil && iter.Error != io.EOF {
+ iter.Error = fmt.Errorf("%v: %s", decoder.sliceType, iter.Error.Error())
+ }
+}
+
+func (decoder *sliceDecoder) doDecode(ptr unsafe.Pointer, iter *Iterator) {
+ c := iter.nextToken()
+ sliceType := decoder.sliceType
+ if c == 'n' {
+ iter.skipThreeBytes('u', 'l', 'l')
+ sliceType.UnsafeSetNil(ptr)
+ return
+ }
+ if c != '[' {
+ iter.ReportError("decode slice", "expect [ or n, but found "+string([]byte{c}))
+ return
+ }
+ c = iter.nextToken()
+ if c == ']' {
+ sliceType.UnsafeSet(ptr, sliceType.UnsafeMakeSlice(0, 0))
+ return
+ }
+ iter.unreadByte()
+ sliceType.UnsafeGrow(ptr, 1)
+ elemPtr := sliceType.UnsafeGetIndex(ptr, 0)
+ decoder.elemDecoder.Decode(elemPtr, iter)
+ length := 1
+ for c = iter.nextToken(); c == ','; c = iter.nextToken() {
+ idx := length
+ length += 1
+ sliceType.UnsafeGrow(ptr, length)
+ elemPtr = sliceType.UnsafeGetIndex(ptr, idx)
+ decoder.elemDecoder.Decode(elemPtr, iter)
+ }
+ if c != ']' {
+ iter.ReportError("decode slice", "expect ], but found "+string([]byte{c}))
+ return
+ }
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_struct_decoder.go b/vendor/github.com/json-iterator/go/reflect_struct_decoder.go
new file mode 100644
index 0000000..92ae912
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_struct_decoder.go
@@ -0,0 +1,1097 @@
+package jsoniter
+
+import (
+ "fmt"
+ "io"
+ "strings"
+ "unsafe"
+
+ "github.com/modern-go/reflect2"
+)
+
+func decoderOfStruct(ctx *ctx, typ reflect2.Type) ValDecoder {
+ bindings := map[string]*Binding{}
+ structDescriptor := describeStruct(ctx, typ)
+ for _, binding := range structDescriptor.Fields {
+ for _, fromName := range binding.FromNames {
+ old := bindings[fromName]
+ if old == nil {
+ bindings[fromName] = binding
+ continue
+ }
+ ignoreOld, ignoreNew := resolveConflictBinding(ctx.frozenConfig, old, binding)
+ if ignoreOld {
+ delete(bindings, fromName)
+ }
+ if !ignoreNew {
+ bindings[fromName] = binding
+ }
+ }
+ }
+ fields := map[string]*structFieldDecoder{}
+ for k, binding := range bindings {
+ fields[k] = binding.Decoder.(*structFieldDecoder)
+ }
+
+ if !ctx.caseSensitive() {
+ for k, binding := range bindings {
+ if _, found := fields[strings.ToLower(k)]; !found {
+ fields[strings.ToLower(k)] = binding.Decoder.(*structFieldDecoder)
+ }
+ }
+ }
+
+ return createStructDecoder(ctx, typ, fields)
+}
+
+func createStructDecoder(ctx *ctx, typ reflect2.Type, fields map[string]*structFieldDecoder) ValDecoder {
+ if ctx.disallowUnknownFields {
+ return &generalStructDecoder{typ: typ, fields: fields, disallowUnknownFields: true}
+ }
+ knownHash := map[int64]struct{}{
+ 0: {},
+ }
+
+ switch len(fields) {
+ case 0:
+ return &skipObjectDecoder{typ}
+ case 1:
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ return &oneFieldStructDecoder{typ, fieldHash, fieldDecoder}
+ }
+ case 2:
+ var fieldHash1 int64
+ var fieldHash2 int64
+ var fieldDecoder1 *structFieldDecoder
+ var fieldDecoder2 *structFieldDecoder
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ if fieldHash1 == 0 {
+ fieldHash1 = fieldHash
+ fieldDecoder1 = fieldDecoder
+ } else {
+ fieldHash2 = fieldHash
+ fieldDecoder2 = fieldDecoder
+ }
+ }
+ return &twoFieldsStructDecoder{typ, fieldHash1, fieldDecoder1, fieldHash2, fieldDecoder2}
+ case 3:
+ var fieldName1 int64
+ var fieldName2 int64
+ var fieldName3 int64
+ var fieldDecoder1 *structFieldDecoder
+ var fieldDecoder2 *structFieldDecoder
+ var fieldDecoder3 *structFieldDecoder
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ if fieldName1 == 0 {
+ fieldName1 = fieldHash
+ fieldDecoder1 = fieldDecoder
+ } else if fieldName2 == 0 {
+ fieldName2 = fieldHash
+ fieldDecoder2 = fieldDecoder
+ } else {
+ fieldName3 = fieldHash
+ fieldDecoder3 = fieldDecoder
+ }
+ }
+ return &threeFieldsStructDecoder{typ,
+ fieldName1, fieldDecoder1,
+ fieldName2, fieldDecoder2,
+ fieldName3, fieldDecoder3}
+ case 4:
+ var fieldName1 int64
+ var fieldName2 int64
+ var fieldName3 int64
+ var fieldName4 int64
+ var fieldDecoder1 *structFieldDecoder
+ var fieldDecoder2 *structFieldDecoder
+ var fieldDecoder3 *structFieldDecoder
+ var fieldDecoder4 *structFieldDecoder
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ if fieldName1 == 0 {
+ fieldName1 = fieldHash
+ fieldDecoder1 = fieldDecoder
+ } else if fieldName2 == 0 {
+ fieldName2 = fieldHash
+ fieldDecoder2 = fieldDecoder
+ } else if fieldName3 == 0 {
+ fieldName3 = fieldHash
+ fieldDecoder3 = fieldDecoder
+ } else {
+ fieldName4 = fieldHash
+ fieldDecoder4 = fieldDecoder
+ }
+ }
+ return &fourFieldsStructDecoder{typ,
+ fieldName1, fieldDecoder1,
+ fieldName2, fieldDecoder2,
+ fieldName3, fieldDecoder3,
+ fieldName4, fieldDecoder4}
+ case 5:
+ var fieldName1 int64
+ var fieldName2 int64
+ var fieldName3 int64
+ var fieldName4 int64
+ var fieldName5 int64
+ var fieldDecoder1 *structFieldDecoder
+ var fieldDecoder2 *structFieldDecoder
+ var fieldDecoder3 *structFieldDecoder
+ var fieldDecoder4 *structFieldDecoder
+ var fieldDecoder5 *structFieldDecoder
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ if fieldName1 == 0 {
+ fieldName1 = fieldHash
+ fieldDecoder1 = fieldDecoder
+ } else if fieldName2 == 0 {
+ fieldName2 = fieldHash
+ fieldDecoder2 = fieldDecoder
+ } else if fieldName3 == 0 {
+ fieldName3 = fieldHash
+ fieldDecoder3 = fieldDecoder
+ } else if fieldName4 == 0 {
+ fieldName4 = fieldHash
+ fieldDecoder4 = fieldDecoder
+ } else {
+ fieldName5 = fieldHash
+ fieldDecoder5 = fieldDecoder
+ }
+ }
+ return &fiveFieldsStructDecoder{typ,
+ fieldName1, fieldDecoder1,
+ fieldName2, fieldDecoder2,
+ fieldName3, fieldDecoder3,
+ fieldName4, fieldDecoder4,
+ fieldName5, fieldDecoder5}
+ case 6:
+ var fieldName1 int64
+ var fieldName2 int64
+ var fieldName3 int64
+ var fieldName4 int64
+ var fieldName5 int64
+ var fieldName6 int64
+ var fieldDecoder1 *structFieldDecoder
+ var fieldDecoder2 *structFieldDecoder
+ var fieldDecoder3 *structFieldDecoder
+ var fieldDecoder4 *structFieldDecoder
+ var fieldDecoder5 *structFieldDecoder
+ var fieldDecoder6 *structFieldDecoder
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ if fieldName1 == 0 {
+ fieldName1 = fieldHash
+ fieldDecoder1 = fieldDecoder
+ } else if fieldName2 == 0 {
+ fieldName2 = fieldHash
+ fieldDecoder2 = fieldDecoder
+ } else if fieldName3 == 0 {
+ fieldName3 = fieldHash
+ fieldDecoder3 = fieldDecoder
+ } else if fieldName4 == 0 {
+ fieldName4 = fieldHash
+ fieldDecoder4 = fieldDecoder
+ } else if fieldName5 == 0 {
+ fieldName5 = fieldHash
+ fieldDecoder5 = fieldDecoder
+ } else {
+ fieldName6 = fieldHash
+ fieldDecoder6 = fieldDecoder
+ }
+ }
+ return &sixFieldsStructDecoder{typ,
+ fieldName1, fieldDecoder1,
+ fieldName2, fieldDecoder2,
+ fieldName3, fieldDecoder3,
+ fieldName4, fieldDecoder4,
+ fieldName5, fieldDecoder5,
+ fieldName6, fieldDecoder6}
+ case 7:
+ var fieldName1 int64
+ var fieldName2 int64
+ var fieldName3 int64
+ var fieldName4 int64
+ var fieldName5 int64
+ var fieldName6 int64
+ var fieldName7 int64
+ var fieldDecoder1 *structFieldDecoder
+ var fieldDecoder2 *structFieldDecoder
+ var fieldDecoder3 *structFieldDecoder
+ var fieldDecoder4 *structFieldDecoder
+ var fieldDecoder5 *structFieldDecoder
+ var fieldDecoder6 *structFieldDecoder
+ var fieldDecoder7 *structFieldDecoder
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ if fieldName1 == 0 {
+ fieldName1 = fieldHash
+ fieldDecoder1 = fieldDecoder
+ } else if fieldName2 == 0 {
+ fieldName2 = fieldHash
+ fieldDecoder2 = fieldDecoder
+ } else if fieldName3 == 0 {
+ fieldName3 = fieldHash
+ fieldDecoder3 = fieldDecoder
+ } else if fieldName4 == 0 {
+ fieldName4 = fieldHash
+ fieldDecoder4 = fieldDecoder
+ } else if fieldName5 == 0 {
+ fieldName5 = fieldHash
+ fieldDecoder5 = fieldDecoder
+ } else if fieldName6 == 0 {
+ fieldName6 = fieldHash
+ fieldDecoder6 = fieldDecoder
+ } else {
+ fieldName7 = fieldHash
+ fieldDecoder7 = fieldDecoder
+ }
+ }
+ return &sevenFieldsStructDecoder{typ,
+ fieldName1, fieldDecoder1,
+ fieldName2, fieldDecoder2,
+ fieldName3, fieldDecoder3,
+ fieldName4, fieldDecoder4,
+ fieldName5, fieldDecoder5,
+ fieldName6, fieldDecoder6,
+ fieldName7, fieldDecoder7}
+ case 8:
+ var fieldName1 int64
+ var fieldName2 int64
+ var fieldName3 int64
+ var fieldName4 int64
+ var fieldName5 int64
+ var fieldName6 int64
+ var fieldName7 int64
+ var fieldName8 int64
+ var fieldDecoder1 *structFieldDecoder
+ var fieldDecoder2 *structFieldDecoder
+ var fieldDecoder3 *structFieldDecoder
+ var fieldDecoder4 *structFieldDecoder
+ var fieldDecoder5 *structFieldDecoder
+ var fieldDecoder6 *structFieldDecoder
+ var fieldDecoder7 *structFieldDecoder
+ var fieldDecoder8 *structFieldDecoder
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ if fieldName1 == 0 {
+ fieldName1 = fieldHash
+ fieldDecoder1 = fieldDecoder
+ } else if fieldName2 == 0 {
+ fieldName2 = fieldHash
+ fieldDecoder2 = fieldDecoder
+ } else if fieldName3 == 0 {
+ fieldName3 = fieldHash
+ fieldDecoder3 = fieldDecoder
+ } else if fieldName4 == 0 {
+ fieldName4 = fieldHash
+ fieldDecoder4 = fieldDecoder
+ } else if fieldName5 == 0 {
+ fieldName5 = fieldHash
+ fieldDecoder5 = fieldDecoder
+ } else if fieldName6 == 0 {
+ fieldName6 = fieldHash
+ fieldDecoder6 = fieldDecoder
+ } else if fieldName7 == 0 {
+ fieldName7 = fieldHash
+ fieldDecoder7 = fieldDecoder
+ } else {
+ fieldName8 = fieldHash
+ fieldDecoder8 = fieldDecoder
+ }
+ }
+ return &eightFieldsStructDecoder{typ,
+ fieldName1, fieldDecoder1,
+ fieldName2, fieldDecoder2,
+ fieldName3, fieldDecoder3,
+ fieldName4, fieldDecoder4,
+ fieldName5, fieldDecoder5,
+ fieldName6, fieldDecoder6,
+ fieldName7, fieldDecoder7,
+ fieldName8, fieldDecoder8}
+ case 9:
+ var fieldName1 int64
+ var fieldName2 int64
+ var fieldName3 int64
+ var fieldName4 int64
+ var fieldName5 int64
+ var fieldName6 int64
+ var fieldName7 int64
+ var fieldName8 int64
+ var fieldName9 int64
+ var fieldDecoder1 *structFieldDecoder
+ var fieldDecoder2 *structFieldDecoder
+ var fieldDecoder3 *structFieldDecoder
+ var fieldDecoder4 *structFieldDecoder
+ var fieldDecoder5 *structFieldDecoder
+ var fieldDecoder6 *structFieldDecoder
+ var fieldDecoder7 *structFieldDecoder
+ var fieldDecoder8 *structFieldDecoder
+ var fieldDecoder9 *structFieldDecoder
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ if fieldName1 == 0 {
+ fieldName1 = fieldHash
+ fieldDecoder1 = fieldDecoder
+ } else if fieldName2 == 0 {
+ fieldName2 = fieldHash
+ fieldDecoder2 = fieldDecoder
+ } else if fieldName3 == 0 {
+ fieldName3 = fieldHash
+ fieldDecoder3 = fieldDecoder
+ } else if fieldName4 == 0 {
+ fieldName4 = fieldHash
+ fieldDecoder4 = fieldDecoder
+ } else if fieldName5 == 0 {
+ fieldName5 = fieldHash
+ fieldDecoder5 = fieldDecoder
+ } else if fieldName6 == 0 {
+ fieldName6 = fieldHash
+ fieldDecoder6 = fieldDecoder
+ } else if fieldName7 == 0 {
+ fieldName7 = fieldHash
+ fieldDecoder7 = fieldDecoder
+ } else if fieldName8 == 0 {
+ fieldName8 = fieldHash
+ fieldDecoder8 = fieldDecoder
+ } else {
+ fieldName9 = fieldHash
+ fieldDecoder9 = fieldDecoder
+ }
+ }
+ return &nineFieldsStructDecoder{typ,
+ fieldName1, fieldDecoder1,
+ fieldName2, fieldDecoder2,
+ fieldName3, fieldDecoder3,
+ fieldName4, fieldDecoder4,
+ fieldName5, fieldDecoder5,
+ fieldName6, fieldDecoder6,
+ fieldName7, fieldDecoder7,
+ fieldName8, fieldDecoder8,
+ fieldName9, fieldDecoder9}
+ case 10:
+ var fieldName1 int64
+ var fieldName2 int64
+ var fieldName3 int64
+ var fieldName4 int64
+ var fieldName5 int64
+ var fieldName6 int64
+ var fieldName7 int64
+ var fieldName8 int64
+ var fieldName9 int64
+ var fieldName10 int64
+ var fieldDecoder1 *structFieldDecoder
+ var fieldDecoder2 *structFieldDecoder
+ var fieldDecoder3 *structFieldDecoder
+ var fieldDecoder4 *structFieldDecoder
+ var fieldDecoder5 *structFieldDecoder
+ var fieldDecoder6 *structFieldDecoder
+ var fieldDecoder7 *structFieldDecoder
+ var fieldDecoder8 *structFieldDecoder
+ var fieldDecoder9 *structFieldDecoder
+ var fieldDecoder10 *structFieldDecoder
+ for fieldName, fieldDecoder := range fields {
+ fieldHash := calcHash(fieldName, ctx.caseSensitive())
+ _, known := knownHash[fieldHash]
+ if known {
+ return &generalStructDecoder{typ, fields, false}
+ }
+ knownHash[fieldHash] = struct{}{}
+ if fieldName1 == 0 {
+ fieldName1 = fieldHash
+ fieldDecoder1 = fieldDecoder
+ } else if fieldName2 == 0 {
+ fieldName2 = fieldHash
+ fieldDecoder2 = fieldDecoder
+ } else if fieldName3 == 0 {
+ fieldName3 = fieldHash
+ fieldDecoder3 = fieldDecoder
+ } else if fieldName4 == 0 {
+ fieldName4 = fieldHash
+ fieldDecoder4 = fieldDecoder
+ } else if fieldName5 == 0 {
+ fieldName5 = fieldHash
+ fieldDecoder5 = fieldDecoder
+ } else if fieldName6 == 0 {
+ fieldName6 = fieldHash
+ fieldDecoder6 = fieldDecoder
+ } else if fieldName7 == 0 {
+ fieldName7 = fieldHash
+ fieldDecoder7 = fieldDecoder
+ } else if fieldName8 == 0 {
+ fieldName8 = fieldHash
+ fieldDecoder8 = fieldDecoder
+ } else if fieldName9 == 0 {
+ fieldName9 = fieldHash
+ fieldDecoder9 = fieldDecoder
+ } else {
+ fieldName10 = fieldHash
+ fieldDecoder10 = fieldDecoder
+ }
+ }
+ return &tenFieldsStructDecoder{typ,
+ fieldName1, fieldDecoder1,
+ fieldName2, fieldDecoder2,
+ fieldName3, fieldDecoder3,
+ fieldName4, fieldDecoder4,
+ fieldName5, fieldDecoder5,
+ fieldName6, fieldDecoder6,
+ fieldName7, fieldDecoder7,
+ fieldName8, fieldDecoder8,
+ fieldName9, fieldDecoder9,
+ fieldName10, fieldDecoder10}
+ }
+ return &generalStructDecoder{typ, fields, false}
+}
+
+type generalStructDecoder struct {
+ typ reflect2.Type
+ fields map[string]*structFieldDecoder
+ disallowUnknownFields bool
+}
+
+func (decoder *generalStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ var c byte
+ for c = ','; c == ','; c = iter.nextToken() {
+ decoder.decodeOneField(ptr, iter)
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ if c != '}' {
+ iter.ReportError("struct Decode", `expect }, but found `+string([]byte{c}))
+ }
+ iter.decrementDepth()
+}
+
+func (decoder *generalStructDecoder) decodeOneField(ptr unsafe.Pointer, iter *Iterator) {
+ var field string
+ var fieldDecoder *structFieldDecoder
+ if iter.cfg.objectFieldMustBeSimpleString {
+ fieldBytes := iter.ReadStringAsSlice()
+ field = *(*string)(unsafe.Pointer(&fieldBytes))
+ fieldDecoder = decoder.fields[field]
+ if fieldDecoder == nil && !iter.cfg.caseSensitive {
+ fieldDecoder = decoder.fields[strings.ToLower(field)]
+ }
+ } else {
+ field = iter.ReadString()
+ fieldDecoder = decoder.fields[field]
+ if fieldDecoder == nil && !iter.cfg.caseSensitive {
+ fieldDecoder = decoder.fields[strings.ToLower(field)]
+ }
+ }
+ if fieldDecoder == nil {
+ if decoder.disallowUnknownFields {
+ msg := "found unknown field: " + field
+ iter.ReportError("ReadObject", msg)
+ }
+ c := iter.nextToken()
+ if c != ':' {
+ iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
+ }
+ iter.Skip()
+ return
+ }
+ c := iter.nextToken()
+ if c != ':' {
+ iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
+ }
+ fieldDecoder.Decode(ptr, iter)
+}
+
+type skipObjectDecoder struct {
+ typ reflect2.Type
+}
+
+func (decoder *skipObjectDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ valueType := iter.WhatIsNext()
+ if valueType != ObjectValue && valueType != NilValue {
+ iter.ReportError("skipObjectDecoder", "expect object or null")
+ return
+ }
+ iter.Skip()
+}
+
+type oneFieldStructDecoder struct {
+ typ reflect2.Type
+ fieldHash int64
+ fieldDecoder *structFieldDecoder
+}
+
+func (decoder *oneFieldStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ if iter.readFieldHash() == decoder.fieldHash {
+ decoder.fieldDecoder.Decode(ptr, iter)
+ } else {
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type twoFieldsStructDecoder struct {
+ typ reflect2.Type
+ fieldHash1 int64
+ fieldDecoder1 *structFieldDecoder
+ fieldHash2 int64
+ fieldDecoder2 *structFieldDecoder
+}
+
+func (decoder *twoFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ switch iter.readFieldHash() {
+ case decoder.fieldHash1:
+ decoder.fieldDecoder1.Decode(ptr, iter)
+ case decoder.fieldHash2:
+ decoder.fieldDecoder2.Decode(ptr, iter)
+ default:
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type threeFieldsStructDecoder struct {
+ typ reflect2.Type
+ fieldHash1 int64
+ fieldDecoder1 *structFieldDecoder
+ fieldHash2 int64
+ fieldDecoder2 *structFieldDecoder
+ fieldHash3 int64
+ fieldDecoder3 *structFieldDecoder
+}
+
+func (decoder *threeFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ switch iter.readFieldHash() {
+ case decoder.fieldHash1:
+ decoder.fieldDecoder1.Decode(ptr, iter)
+ case decoder.fieldHash2:
+ decoder.fieldDecoder2.Decode(ptr, iter)
+ case decoder.fieldHash3:
+ decoder.fieldDecoder3.Decode(ptr, iter)
+ default:
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type fourFieldsStructDecoder struct {
+ typ reflect2.Type
+ fieldHash1 int64
+ fieldDecoder1 *structFieldDecoder
+ fieldHash2 int64
+ fieldDecoder2 *structFieldDecoder
+ fieldHash3 int64
+ fieldDecoder3 *structFieldDecoder
+ fieldHash4 int64
+ fieldDecoder4 *structFieldDecoder
+}
+
+func (decoder *fourFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ switch iter.readFieldHash() {
+ case decoder.fieldHash1:
+ decoder.fieldDecoder1.Decode(ptr, iter)
+ case decoder.fieldHash2:
+ decoder.fieldDecoder2.Decode(ptr, iter)
+ case decoder.fieldHash3:
+ decoder.fieldDecoder3.Decode(ptr, iter)
+ case decoder.fieldHash4:
+ decoder.fieldDecoder4.Decode(ptr, iter)
+ default:
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type fiveFieldsStructDecoder struct {
+ typ reflect2.Type
+ fieldHash1 int64
+ fieldDecoder1 *structFieldDecoder
+ fieldHash2 int64
+ fieldDecoder2 *structFieldDecoder
+ fieldHash3 int64
+ fieldDecoder3 *structFieldDecoder
+ fieldHash4 int64
+ fieldDecoder4 *structFieldDecoder
+ fieldHash5 int64
+ fieldDecoder5 *structFieldDecoder
+}
+
+func (decoder *fiveFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ switch iter.readFieldHash() {
+ case decoder.fieldHash1:
+ decoder.fieldDecoder1.Decode(ptr, iter)
+ case decoder.fieldHash2:
+ decoder.fieldDecoder2.Decode(ptr, iter)
+ case decoder.fieldHash3:
+ decoder.fieldDecoder3.Decode(ptr, iter)
+ case decoder.fieldHash4:
+ decoder.fieldDecoder4.Decode(ptr, iter)
+ case decoder.fieldHash5:
+ decoder.fieldDecoder5.Decode(ptr, iter)
+ default:
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type sixFieldsStructDecoder struct {
+ typ reflect2.Type
+ fieldHash1 int64
+ fieldDecoder1 *structFieldDecoder
+ fieldHash2 int64
+ fieldDecoder2 *structFieldDecoder
+ fieldHash3 int64
+ fieldDecoder3 *structFieldDecoder
+ fieldHash4 int64
+ fieldDecoder4 *structFieldDecoder
+ fieldHash5 int64
+ fieldDecoder5 *structFieldDecoder
+ fieldHash6 int64
+ fieldDecoder6 *structFieldDecoder
+}
+
+func (decoder *sixFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ switch iter.readFieldHash() {
+ case decoder.fieldHash1:
+ decoder.fieldDecoder1.Decode(ptr, iter)
+ case decoder.fieldHash2:
+ decoder.fieldDecoder2.Decode(ptr, iter)
+ case decoder.fieldHash3:
+ decoder.fieldDecoder3.Decode(ptr, iter)
+ case decoder.fieldHash4:
+ decoder.fieldDecoder4.Decode(ptr, iter)
+ case decoder.fieldHash5:
+ decoder.fieldDecoder5.Decode(ptr, iter)
+ case decoder.fieldHash6:
+ decoder.fieldDecoder6.Decode(ptr, iter)
+ default:
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type sevenFieldsStructDecoder struct {
+ typ reflect2.Type
+ fieldHash1 int64
+ fieldDecoder1 *structFieldDecoder
+ fieldHash2 int64
+ fieldDecoder2 *structFieldDecoder
+ fieldHash3 int64
+ fieldDecoder3 *structFieldDecoder
+ fieldHash4 int64
+ fieldDecoder4 *structFieldDecoder
+ fieldHash5 int64
+ fieldDecoder5 *structFieldDecoder
+ fieldHash6 int64
+ fieldDecoder6 *structFieldDecoder
+ fieldHash7 int64
+ fieldDecoder7 *structFieldDecoder
+}
+
+func (decoder *sevenFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ switch iter.readFieldHash() {
+ case decoder.fieldHash1:
+ decoder.fieldDecoder1.Decode(ptr, iter)
+ case decoder.fieldHash2:
+ decoder.fieldDecoder2.Decode(ptr, iter)
+ case decoder.fieldHash3:
+ decoder.fieldDecoder3.Decode(ptr, iter)
+ case decoder.fieldHash4:
+ decoder.fieldDecoder4.Decode(ptr, iter)
+ case decoder.fieldHash5:
+ decoder.fieldDecoder5.Decode(ptr, iter)
+ case decoder.fieldHash6:
+ decoder.fieldDecoder6.Decode(ptr, iter)
+ case decoder.fieldHash7:
+ decoder.fieldDecoder7.Decode(ptr, iter)
+ default:
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type eightFieldsStructDecoder struct {
+ typ reflect2.Type
+ fieldHash1 int64
+ fieldDecoder1 *structFieldDecoder
+ fieldHash2 int64
+ fieldDecoder2 *structFieldDecoder
+ fieldHash3 int64
+ fieldDecoder3 *structFieldDecoder
+ fieldHash4 int64
+ fieldDecoder4 *structFieldDecoder
+ fieldHash5 int64
+ fieldDecoder5 *structFieldDecoder
+ fieldHash6 int64
+ fieldDecoder6 *structFieldDecoder
+ fieldHash7 int64
+ fieldDecoder7 *structFieldDecoder
+ fieldHash8 int64
+ fieldDecoder8 *structFieldDecoder
+}
+
+func (decoder *eightFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ switch iter.readFieldHash() {
+ case decoder.fieldHash1:
+ decoder.fieldDecoder1.Decode(ptr, iter)
+ case decoder.fieldHash2:
+ decoder.fieldDecoder2.Decode(ptr, iter)
+ case decoder.fieldHash3:
+ decoder.fieldDecoder3.Decode(ptr, iter)
+ case decoder.fieldHash4:
+ decoder.fieldDecoder4.Decode(ptr, iter)
+ case decoder.fieldHash5:
+ decoder.fieldDecoder5.Decode(ptr, iter)
+ case decoder.fieldHash6:
+ decoder.fieldDecoder6.Decode(ptr, iter)
+ case decoder.fieldHash7:
+ decoder.fieldDecoder7.Decode(ptr, iter)
+ case decoder.fieldHash8:
+ decoder.fieldDecoder8.Decode(ptr, iter)
+ default:
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type nineFieldsStructDecoder struct {
+ typ reflect2.Type
+ fieldHash1 int64
+ fieldDecoder1 *structFieldDecoder
+ fieldHash2 int64
+ fieldDecoder2 *structFieldDecoder
+ fieldHash3 int64
+ fieldDecoder3 *structFieldDecoder
+ fieldHash4 int64
+ fieldDecoder4 *structFieldDecoder
+ fieldHash5 int64
+ fieldDecoder5 *structFieldDecoder
+ fieldHash6 int64
+ fieldDecoder6 *structFieldDecoder
+ fieldHash7 int64
+ fieldDecoder7 *structFieldDecoder
+ fieldHash8 int64
+ fieldDecoder8 *structFieldDecoder
+ fieldHash9 int64
+ fieldDecoder9 *structFieldDecoder
+}
+
+func (decoder *nineFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ switch iter.readFieldHash() {
+ case decoder.fieldHash1:
+ decoder.fieldDecoder1.Decode(ptr, iter)
+ case decoder.fieldHash2:
+ decoder.fieldDecoder2.Decode(ptr, iter)
+ case decoder.fieldHash3:
+ decoder.fieldDecoder3.Decode(ptr, iter)
+ case decoder.fieldHash4:
+ decoder.fieldDecoder4.Decode(ptr, iter)
+ case decoder.fieldHash5:
+ decoder.fieldDecoder5.Decode(ptr, iter)
+ case decoder.fieldHash6:
+ decoder.fieldDecoder6.Decode(ptr, iter)
+ case decoder.fieldHash7:
+ decoder.fieldDecoder7.Decode(ptr, iter)
+ case decoder.fieldHash8:
+ decoder.fieldDecoder8.Decode(ptr, iter)
+ case decoder.fieldHash9:
+ decoder.fieldDecoder9.Decode(ptr, iter)
+ default:
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type tenFieldsStructDecoder struct {
+ typ reflect2.Type
+ fieldHash1 int64
+ fieldDecoder1 *structFieldDecoder
+ fieldHash2 int64
+ fieldDecoder2 *structFieldDecoder
+ fieldHash3 int64
+ fieldDecoder3 *structFieldDecoder
+ fieldHash4 int64
+ fieldDecoder4 *structFieldDecoder
+ fieldHash5 int64
+ fieldDecoder5 *structFieldDecoder
+ fieldHash6 int64
+ fieldDecoder6 *structFieldDecoder
+ fieldHash7 int64
+ fieldDecoder7 *structFieldDecoder
+ fieldHash8 int64
+ fieldDecoder8 *structFieldDecoder
+ fieldHash9 int64
+ fieldDecoder9 *structFieldDecoder
+ fieldHash10 int64
+ fieldDecoder10 *structFieldDecoder
+}
+
+func (decoder *tenFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if !iter.readObjectStart() {
+ return
+ }
+ if !iter.incrementDepth() {
+ return
+ }
+ for {
+ switch iter.readFieldHash() {
+ case decoder.fieldHash1:
+ decoder.fieldDecoder1.Decode(ptr, iter)
+ case decoder.fieldHash2:
+ decoder.fieldDecoder2.Decode(ptr, iter)
+ case decoder.fieldHash3:
+ decoder.fieldDecoder3.Decode(ptr, iter)
+ case decoder.fieldHash4:
+ decoder.fieldDecoder4.Decode(ptr, iter)
+ case decoder.fieldHash5:
+ decoder.fieldDecoder5.Decode(ptr, iter)
+ case decoder.fieldHash6:
+ decoder.fieldDecoder6.Decode(ptr, iter)
+ case decoder.fieldHash7:
+ decoder.fieldDecoder7.Decode(ptr, iter)
+ case decoder.fieldHash8:
+ decoder.fieldDecoder8.Decode(ptr, iter)
+ case decoder.fieldHash9:
+ decoder.fieldDecoder9.Decode(ptr, iter)
+ case decoder.fieldHash10:
+ decoder.fieldDecoder10.Decode(ptr, iter)
+ default:
+ iter.Skip()
+ }
+ if iter.isObjectEnd() {
+ break
+ }
+ }
+ if iter.Error != nil && iter.Error != io.EOF && len(decoder.typ.Type1().Name()) != 0 {
+ iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
+ }
+ iter.decrementDepth()
+}
+
+type structFieldDecoder struct {
+ field reflect2.StructField
+ fieldDecoder ValDecoder
+}
+
+func (decoder *structFieldDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ fieldPtr := decoder.field.UnsafeGet(ptr)
+ decoder.fieldDecoder.Decode(fieldPtr, iter)
+ if iter.Error != nil && iter.Error != io.EOF {
+ iter.Error = fmt.Errorf("%s: %s", decoder.field.Name(), iter.Error.Error())
+ }
+}
+
+type stringModeStringDecoder struct {
+ elemDecoder ValDecoder
+ cfg *frozenConfig
+}
+
+func (decoder *stringModeStringDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ decoder.elemDecoder.Decode(ptr, iter)
+ str := *((*string)(ptr))
+ tempIter := decoder.cfg.BorrowIterator([]byte(str))
+ defer decoder.cfg.ReturnIterator(tempIter)
+ *((*string)(ptr)) = tempIter.ReadString()
+}
+
+type stringModeNumberDecoder struct {
+ elemDecoder ValDecoder
+}
+
+func (decoder *stringModeNumberDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
+ if iter.WhatIsNext() == NilValue {
+ decoder.elemDecoder.Decode(ptr, iter)
+ return
+ }
+
+ c := iter.nextToken()
+ if c != '"' {
+ iter.ReportError("stringModeNumberDecoder", `expect ", but found `+string([]byte{c}))
+ return
+ }
+ decoder.elemDecoder.Decode(ptr, iter)
+ if iter.Error != nil {
+ return
+ }
+ c = iter.readByte()
+ if c != '"' {
+ iter.ReportError("stringModeNumberDecoder", `expect ", but found `+string([]byte{c}))
+ return
+ }
+}
diff --git a/vendor/github.com/json-iterator/go/reflect_struct_encoder.go b/vendor/github.com/json-iterator/go/reflect_struct_encoder.go
new file mode 100644
index 0000000..152e3ef
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/reflect_struct_encoder.go
@@ -0,0 +1,211 @@
+package jsoniter
+
+import (
+ "fmt"
+ "github.com/modern-go/reflect2"
+ "io"
+ "reflect"
+ "unsafe"
+)
+
+func encoderOfStruct(ctx *ctx, typ reflect2.Type) ValEncoder {
+ type bindingTo struct {
+ binding *Binding
+ toName string
+ ignored bool
+ }
+ orderedBindings := []*bindingTo{}
+ structDescriptor := describeStruct(ctx, typ)
+ for _, binding := range structDescriptor.Fields {
+ for _, toName := range binding.ToNames {
+ new := &bindingTo{
+ binding: binding,
+ toName: toName,
+ }
+ for _, old := range orderedBindings {
+ if old.toName != toName {
+ continue
+ }
+ old.ignored, new.ignored = resolveConflictBinding(ctx.frozenConfig, old.binding, new.binding)
+ }
+ orderedBindings = append(orderedBindings, new)
+ }
+ }
+ if len(orderedBindings) == 0 {
+ return &emptyStructEncoder{}
+ }
+ finalOrderedFields := []structFieldTo{}
+ for _, bindingTo := range orderedBindings {
+ if !bindingTo.ignored {
+ finalOrderedFields = append(finalOrderedFields, structFieldTo{
+ encoder: bindingTo.binding.Encoder.(*structFieldEncoder),
+ toName: bindingTo.toName,
+ })
+ }
+ }
+ return &structEncoder{typ, finalOrderedFields}
+}
+
+func createCheckIsEmpty(ctx *ctx, typ reflect2.Type) checkIsEmpty {
+ encoder := createEncoderOfNative(ctx, typ)
+ if encoder != nil {
+ return encoder
+ }
+ kind := typ.Kind()
+ switch kind {
+ case reflect.Interface:
+ return &dynamicEncoder{typ}
+ case reflect.Struct:
+ return &structEncoder{typ: typ}
+ case reflect.Array:
+ return &arrayEncoder{}
+ case reflect.Slice:
+ return &sliceEncoder{}
+ case reflect.Map:
+ return encoderOfMap(ctx, typ)
+ case reflect.Ptr:
+ return &OptionalEncoder{}
+ default:
+ return &lazyErrorEncoder{err: fmt.Errorf("unsupported type: %v", typ)}
+ }
+}
+
+func resolveConflictBinding(cfg *frozenConfig, old, new *Binding) (ignoreOld, ignoreNew bool) {
+ newTagged := new.Field.Tag().Get(cfg.getTagKey()) != ""
+ oldTagged := old.Field.Tag().Get(cfg.getTagKey()) != ""
+ if newTagged {
+ if oldTagged {
+ if len(old.levels) > len(new.levels) {
+ return true, false
+ } else if len(new.levels) > len(old.levels) {
+ return false, true
+ } else {
+ return true, true
+ }
+ } else {
+ return true, false
+ }
+ } else {
+ if oldTagged {
+ return true, false
+ }
+ if len(old.levels) > len(new.levels) {
+ return true, false
+ } else if len(new.levels) > len(old.levels) {
+ return false, true
+ } else {
+ return true, true
+ }
+ }
+}
+
+type structFieldEncoder struct {
+ field reflect2.StructField
+ fieldEncoder ValEncoder
+ omitempty bool
+}
+
+func (encoder *structFieldEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ fieldPtr := encoder.field.UnsafeGet(ptr)
+ encoder.fieldEncoder.Encode(fieldPtr, stream)
+ if stream.Error != nil && stream.Error != io.EOF {
+ stream.Error = fmt.Errorf("%s: %s", encoder.field.Name(), stream.Error.Error())
+ }
+}
+
+func (encoder *structFieldEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ fieldPtr := encoder.field.UnsafeGet(ptr)
+ return encoder.fieldEncoder.IsEmpty(fieldPtr)
+}
+
+func (encoder *structFieldEncoder) IsEmbeddedPtrNil(ptr unsafe.Pointer) bool {
+ isEmbeddedPtrNil, converted := encoder.fieldEncoder.(IsEmbeddedPtrNil)
+ if !converted {
+ return false
+ }
+ fieldPtr := encoder.field.UnsafeGet(ptr)
+ return isEmbeddedPtrNil.IsEmbeddedPtrNil(fieldPtr)
+}
+
+type IsEmbeddedPtrNil interface {
+ IsEmbeddedPtrNil(ptr unsafe.Pointer) bool
+}
+
+type structEncoder struct {
+ typ reflect2.Type
+ fields []structFieldTo
+}
+
+type structFieldTo struct {
+ encoder *structFieldEncoder
+ toName string
+}
+
+func (encoder *structEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteObjectStart()
+ isNotFirst := false
+ for _, field := range encoder.fields {
+ if field.encoder.omitempty && field.encoder.IsEmpty(ptr) {
+ continue
+ }
+ if field.encoder.IsEmbeddedPtrNil(ptr) {
+ continue
+ }
+ if isNotFirst {
+ stream.WriteMore()
+ }
+ stream.WriteObjectField(field.toName)
+ field.encoder.Encode(ptr, stream)
+ isNotFirst = true
+ }
+ stream.WriteObjectEnd()
+ if stream.Error != nil && stream.Error != io.EOF {
+ stream.Error = fmt.Errorf("%v.%s", encoder.typ, stream.Error.Error())
+ }
+}
+
+func (encoder *structEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return false
+}
+
+type emptyStructEncoder struct {
+}
+
+func (encoder *emptyStructEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.WriteEmptyObject()
+}
+
+func (encoder *emptyStructEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return false
+}
+
+type stringModeNumberEncoder struct {
+ elemEncoder ValEncoder
+}
+
+func (encoder *stringModeNumberEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ stream.writeByte('"')
+ encoder.elemEncoder.Encode(ptr, stream)
+ stream.writeByte('"')
+}
+
+func (encoder *stringModeNumberEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.elemEncoder.IsEmpty(ptr)
+}
+
+type stringModeStringEncoder struct {
+ elemEncoder ValEncoder
+ cfg *frozenConfig
+}
+
+func (encoder *stringModeStringEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ tempStream := encoder.cfg.BorrowStream(nil)
+ tempStream.Attachment = stream.Attachment
+ defer encoder.cfg.ReturnStream(tempStream)
+ encoder.elemEncoder.Encode(ptr, tempStream)
+ stream.WriteString(string(tempStream.Buffer()))
+}
+
+func (encoder *stringModeStringEncoder) IsEmpty(ptr unsafe.Pointer) bool {
+ return encoder.elemEncoder.IsEmpty(ptr)
+}
diff --git a/vendor/github.com/json-iterator/go/stream.go b/vendor/github.com/json-iterator/go/stream.go
new file mode 100644
index 0000000..23d8a3a
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/stream.go
@@ -0,0 +1,210 @@
+package jsoniter
+
+import (
+ "io"
+)
+
+// stream is a io.Writer like object, with JSON specific write functions.
+// Error is not returned as return value, but stored as Error member on this stream instance.
+type Stream struct {
+ cfg *frozenConfig
+ out io.Writer
+ buf []byte
+ Error error
+ indention int
+ Attachment interface{} // open for customized encoder
+}
+
+// NewStream create new stream instance.
+// cfg can be jsoniter.ConfigDefault.
+// out can be nil if write to internal buffer.
+// bufSize is the initial size for the internal buffer in bytes.
+func NewStream(cfg API, out io.Writer, bufSize int) *Stream {
+ return &Stream{
+ cfg: cfg.(*frozenConfig),
+ out: out,
+ buf: make([]byte, 0, bufSize),
+ Error: nil,
+ indention: 0,
+ }
+}
+
+// Pool returns a pool can provide more stream with same configuration
+func (stream *Stream) Pool() StreamPool {
+ return stream.cfg
+}
+
+// Reset reuse this stream instance by assign a new writer
+func (stream *Stream) Reset(out io.Writer) {
+ stream.out = out
+ stream.buf = stream.buf[:0]
+}
+
+// Available returns how many bytes are unused in the buffer.
+func (stream *Stream) Available() int {
+ return cap(stream.buf) - len(stream.buf)
+}
+
+// Buffered returns the number of bytes that have been written into the current buffer.
+func (stream *Stream) Buffered() int {
+ return len(stream.buf)
+}
+
+// Buffer if writer is nil, use this method to take the result
+func (stream *Stream) Buffer() []byte {
+ return stream.buf
+}
+
+// SetBuffer allows to append to the internal buffer directly
+func (stream *Stream) SetBuffer(buf []byte) {
+ stream.buf = buf
+}
+
+// Write writes the contents of p into the buffer.
+// It returns the number of bytes written.
+// If nn < len(p), it also returns an error explaining
+// why the write is short.
+func (stream *Stream) Write(p []byte) (nn int, err error) {
+ stream.buf = append(stream.buf, p...)
+ if stream.out != nil {
+ nn, err = stream.out.Write(stream.buf)
+ stream.buf = stream.buf[nn:]
+ return
+ }
+ return len(p), nil
+}
+
+// WriteByte writes a single byte.
+func (stream *Stream) writeByte(c byte) {
+ stream.buf = append(stream.buf, c)
+}
+
+func (stream *Stream) writeTwoBytes(c1 byte, c2 byte) {
+ stream.buf = append(stream.buf, c1, c2)
+}
+
+func (stream *Stream) writeThreeBytes(c1 byte, c2 byte, c3 byte) {
+ stream.buf = append(stream.buf, c1, c2, c3)
+}
+
+func (stream *Stream) writeFourBytes(c1 byte, c2 byte, c3 byte, c4 byte) {
+ stream.buf = append(stream.buf, c1, c2, c3, c4)
+}
+
+func (stream *Stream) writeFiveBytes(c1 byte, c2 byte, c3 byte, c4 byte, c5 byte) {
+ stream.buf = append(stream.buf, c1, c2, c3, c4, c5)
+}
+
+// Flush writes any buffered data to the underlying io.Writer.
+func (stream *Stream) Flush() error {
+ if stream.out == nil {
+ return nil
+ }
+ if stream.Error != nil {
+ return stream.Error
+ }
+ _, err := stream.out.Write(stream.buf)
+ if err != nil {
+ if stream.Error == nil {
+ stream.Error = err
+ }
+ return err
+ }
+ stream.buf = stream.buf[:0]
+ return nil
+}
+
+// WriteRaw write string out without quotes, just like []byte
+func (stream *Stream) WriteRaw(s string) {
+ stream.buf = append(stream.buf, s...)
+}
+
+// WriteNil write null to stream
+func (stream *Stream) WriteNil() {
+ stream.writeFourBytes('n', 'u', 'l', 'l')
+}
+
+// WriteTrue write true to stream
+func (stream *Stream) WriteTrue() {
+ stream.writeFourBytes('t', 'r', 'u', 'e')
+}
+
+// WriteFalse write false to stream
+func (stream *Stream) WriteFalse() {
+ stream.writeFiveBytes('f', 'a', 'l', 's', 'e')
+}
+
+// WriteBool write true or false into stream
+func (stream *Stream) WriteBool(val bool) {
+ if val {
+ stream.WriteTrue()
+ } else {
+ stream.WriteFalse()
+ }
+}
+
+// WriteObjectStart write { with possible indention
+func (stream *Stream) WriteObjectStart() {
+ stream.indention += stream.cfg.indentionStep
+ stream.writeByte('{')
+ stream.writeIndention(0)
+}
+
+// WriteObjectField write "field": with possible indention
+func (stream *Stream) WriteObjectField(field string) {
+ stream.WriteString(field)
+ if stream.indention > 0 {
+ stream.writeTwoBytes(':', ' ')
+ } else {
+ stream.writeByte(':')
+ }
+}
+
+// WriteObjectEnd write } with possible indention
+func (stream *Stream) WriteObjectEnd() {
+ stream.writeIndention(stream.cfg.indentionStep)
+ stream.indention -= stream.cfg.indentionStep
+ stream.writeByte('}')
+}
+
+// WriteEmptyObject write {}
+func (stream *Stream) WriteEmptyObject() {
+ stream.writeByte('{')
+ stream.writeByte('}')
+}
+
+// WriteMore write , with possible indention
+func (stream *Stream) WriteMore() {
+ stream.writeByte(',')
+ stream.writeIndention(0)
+}
+
+// WriteArrayStart write [ with possible indention
+func (stream *Stream) WriteArrayStart() {
+ stream.indention += stream.cfg.indentionStep
+ stream.writeByte('[')
+ stream.writeIndention(0)
+}
+
+// WriteEmptyArray write []
+func (stream *Stream) WriteEmptyArray() {
+ stream.writeTwoBytes('[', ']')
+}
+
+// WriteArrayEnd write ] with possible indention
+func (stream *Stream) WriteArrayEnd() {
+ stream.writeIndention(stream.cfg.indentionStep)
+ stream.indention -= stream.cfg.indentionStep
+ stream.writeByte(']')
+}
+
+func (stream *Stream) writeIndention(delta int) {
+ if stream.indention == 0 {
+ return
+ }
+ stream.writeByte('\n')
+ toWrite := stream.indention - delta
+ for i := 0; i < toWrite; i++ {
+ stream.buf = append(stream.buf, ' ')
+ }
+}
diff --git a/vendor/github.com/json-iterator/go/stream_float.go b/vendor/github.com/json-iterator/go/stream_float.go
new file mode 100644
index 0000000..826aa59
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/stream_float.go
@@ -0,0 +1,111 @@
+package jsoniter
+
+import (
+ "fmt"
+ "math"
+ "strconv"
+)
+
+var pow10 []uint64
+
+func init() {
+ pow10 = []uint64{1, 10, 100, 1000, 10000, 100000, 1000000}
+}
+
+// WriteFloat32 write float32 to stream
+func (stream *Stream) WriteFloat32(val float32) {
+ if math.IsInf(float64(val), 0) || math.IsNaN(float64(val)) {
+ stream.Error = fmt.Errorf("unsupported value: %f", val)
+ return
+ }
+ abs := math.Abs(float64(val))
+ fmt := byte('f')
+ // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
+ if abs != 0 {
+ if float32(abs) < 1e-6 || float32(abs) >= 1e21 {
+ fmt = 'e'
+ }
+ }
+ stream.buf = strconv.AppendFloat(stream.buf, float64(val), fmt, -1, 32)
+}
+
+// WriteFloat32Lossy write float32 to stream with ONLY 6 digits precision although much much faster
+func (stream *Stream) WriteFloat32Lossy(val float32) {
+ if math.IsInf(float64(val), 0) || math.IsNaN(float64(val)) {
+ stream.Error = fmt.Errorf("unsupported value: %f", val)
+ return
+ }
+ if val < 0 {
+ stream.writeByte('-')
+ val = -val
+ }
+ if val > 0x4ffffff {
+ stream.WriteFloat32(val)
+ return
+ }
+ precision := 6
+ exp := uint64(1000000) // 6
+ lval := uint64(float64(val)*float64(exp) + 0.5)
+ stream.WriteUint64(lval / exp)
+ fval := lval % exp
+ if fval == 0 {
+ return
+ }
+ stream.writeByte('.')
+ for p := precision - 1; p > 0 && fval < pow10[p]; p-- {
+ stream.writeByte('0')
+ }
+ stream.WriteUint64(fval)
+ for stream.buf[len(stream.buf)-1] == '0' {
+ stream.buf = stream.buf[:len(stream.buf)-1]
+ }
+}
+
+// WriteFloat64 write float64 to stream
+func (stream *Stream) WriteFloat64(val float64) {
+ if math.IsInf(val, 0) || math.IsNaN(val) {
+ stream.Error = fmt.Errorf("unsupported value: %f", val)
+ return
+ }
+ abs := math.Abs(val)
+ fmt := byte('f')
+ // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
+ if abs != 0 {
+ if abs < 1e-6 || abs >= 1e21 {
+ fmt = 'e'
+ }
+ }
+ stream.buf = strconv.AppendFloat(stream.buf, float64(val), fmt, -1, 64)
+}
+
+// WriteFloat64Lossy write float64 to stream with ONLY 6 digits precision although much much faster
+func (stream *Stream) WriteFloat64Lossy(val float64) {
+ if math.IsInf(val, 0) || math.IsNaN(val) {
+ stream.Error = fmt.Errorf("unsupported value: %f", val)
+ return
+ }
+ if val < 0 {
+ stream.writeByte('-')
+ val = -val
+ }
+ if val > 0x4ffffff {
+ stream.WriteFloat64(val)
+ return
+ }
+ precision := 6
+ exp := uint64(1000000) // 6
+ lval := uint64(val*float64(exp) + 0.5)
+ stream.WriteUint64(lval / exp)
+ fval := lval % exp
+ if fval == 0 {
+ return
+ }
+ stream.writeByte('.')
+ for p := precision - 1; p > 0 && fval < pow10[p]; p-- {
+ stream.writeByte('0')
+ }
+ stream.WriteUint64(fval)
+ for stream.buf[len(stream.buf)-1] == '0' {
+ stream.buf = stream.buf[:len(stream.buf)-1]
+ }
+}
diff --git a/vendor/github.com/json-iterator/go/stream_int.go b/vendor/github.com/json-iterator/go/stream_int.go
new file mode 100644
index 0000000..d1059ee
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/stream_int.go
@@ -0,0 +1,190 @@
+package jsoniter
+
+var digits []uint32
+
+func init() {
+ digits = make([]uint32, 1000)
+ for i := uint32(0); i < 1000; i++ {
+ digits[i] = (((i / 100) + '0') << 16) + ((((i / 10) % 10) + '0') << 8) + i%10 + '0'
+ if i < 10 {
+ digits[i] += 2 << 24
+ } else if i < 100 {
+ digits[i] += 1 << 24
+ }
+ }
+}
+
+func writeFirstBuf(space []byte, v uint32) []byte {
+ start := v >> 24
+ if start == 0 {
+ space = append(space, byte(v>>16), byte(v>>8))
+ } else if start == 1 {
+ space = append(space, byte(v>>8))
+ }
+ space = append(space, byte(v))
+ return space
+}
+
+func writeBuf(buf []byte, v uint32) []byte {
+ return append(buf, byte(v>>16), byte(v>>8), byte(v))
+}
+
+// WriteUint8 write uint8 to stream
+func (stream *Stream) WriteUint8(val uint8) {
+ stream.buf = writeFirstBuf(stream.buf, digits[val])
+}
+
+// WriteInt8 write int8 to stream
+func (stream *Stream) WriteInt8(nval int8) {
+ var val uint8
+ if nval < 0 {
+ val = uint8(-nval)
+ stream.buf = append(stream.buf, '-')
+ } else {
+ val = uint8(nval)
+ }
+ stream.buf = writeFirstBuf(stream.buf, digits[val])
+}
+
+// WriteUint16 write uint16 to stream
+func (stream *Stream) WriteUint16(val uint16) {
+ q1 := val / 1000
+ if q1 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[val])
+ return
+ }
+ r1 := val - q1*1000
+ stream.buf = writeFirstBuf(stream.buf, digits[q1])
+ stream.buf = writeBuf(stream.buf, digits[r1])
+ return
+}
+
+// WriteInt16 write int16 to stream
+func (stream *Stream) WriteInt16(nval int16) {
+ var val uint16
+ if nval < 0 {
+ val = uint16(-nval)
+ stream.buf = append(stream.buf, '-')
+ } else {
+ val = uint16(nval)
+ }
+ stream.WriteUint16(val)
+}
+
+// WriteUint32 write uint32 to stream
+func (stream *Stream) WriteUint32(val uint32) {
+ q1 := val / 1000
+ if q1 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[val])
+ return
+ }
+ r1 := val - q1*1000
+ q2 := q1 / 1000
+ if q2 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[q1])
+ stream.buf = writeBuf(stream.buf, digits[r1])
+ return
+ }
+ r2 := q1 - q2*1000
+ q3 := q2 / 1000
+ if q3 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[q2])
+ } else {
+ r3 := q2 - q3*1000
+ stream.buf = append(stream.buf, byte(q3+'0'))
+ stream.buf = writeBuf(stream.buf, digits[r3])
+ }
+ stream.buf = writeBuf(stream.buf, digits[r2])
+ stream.buf = writeBuf(stream.buf, digits[r1])
+}
+
+// WriteInt32 write int32 to stream
+func (stream *Stream) WriteInt32(nval int32) {
+ var val uint32
+ if nval < 0 {
+ val = uint32(-nval)
+ stream.buf = append(stream.buf, '-')
+ } else {
+ val = uint32(nval)
+ }
+ stream.WriteUint32(val)
+}
+
+// WriteUint64 write uint64 to stream
+func (stream *Stream) WriteUint64(val uint64) {
+ q1 := val / 1000
+ if q1 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[val])
+ return
+ }
+ r1 := val - q1*1000
+ q2 := q1 / 1000
+ if q2 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[q1])
+ stream.buf = writeBuf(stream.buf, digits[r1])
+ return
+ }
+ r2 := q1 - q2*1000
+ q3 := q2 / 1000
+ if q3 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[q2])
+ stream.buf = writeBuf(stream.buf, digits[r2])
+ stream.buf = writeBuf(stream.buf, digits[r1])
+ return
+ }
+ r3 := q2 - q3*1000
+ q4 := q3 / 1000
+ if q4 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[q3])
+ stream.buf = writeBuf(stream.buf, digits[r3])
+ stream.buf = writeBuf(stream.buf, digits[r2])
+ stream.buf = writeBuf(stream.buf, digits[r1])
+ return
+ }
+ r4 := q3 - q4*1000
+ q5 := q4 / 1000
+ if q5 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[q4])
+ stream.buf = writeBuf(stream.buf, digits[r4])
+ stream.buf = writeBuf(stream.buf, digits[r3])
+ stream.buf = writeBuf(stream.buf, digits[r2])
+ stream.buf = writeBuf(stream.buf, digits[r1])
+ return
+ }
+ r5 := q4 - q5*1000
+ q6 := q5 / 1000
+ if q6 == 0 {
+ stream.buf = writeFirstBuf(stream.buf, digits[q5])
+ } else {
+ stream.buf = writeFirstBuf(stream.buf, digits[q6])
+ r6 := q5 - q6*1000
+ stream.buf = writeBuf(stream.buf, digits[r6])
+ }
+ stream.buf = writeBuf(stream.buf, digits[r5])
+ stream.buf = writeBuf(stream.buf, digits[r4])
+ stream.buf = writeBuf(stream.buf, digits[r3])
+ stream.buf = writeBuf(stream.buf, digits[r2])
+ stream.buf = writeBuf(stream.buf, digits[r1])
+}
+
+// WriteInt64 write int64 to stream
+func (stream *Stream) WriteInt64(nval int64) {
+ var val uint64
+ if nval < 0 {
+ val = uint64(-nval)
+ stream.buf = append(stream.buf, '-')
+ } else {
+ val = uint64(nval)
+ }
+ stream.WriteUint64(val)
+}
+
+// WriteInt write int to stream
+func (stream *Stream) WriteInt(val int) {
+ stream.WriteInt64(int64(val))
+}
+
+// WriteUint write uint to stream
+func (stream *Stream) WriteUint(val uint) {
+ stream.WriteUint64(uint64(val))
+}
diff --git a/vendor/github.com/json-iterator/go/stream_str.go b/vendor/github.com/json-iterator/go/stream_str.go
new file mode 100644
index 0000000..54c2ba0
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/stream_str.go
@@ -0,0 +1,372 @@
+package jsoniter
+
+import (
+ "unicode/utf8"
+)
+
+// htmlSafeSet holds the value true if the ASCII character with the given
+// array position can be safely represented inside a JSON string, embedded
+// inside of HTML