From 9b9f6b65498dd9f68a80b8af1ddfb616f5b644d6 Mon Sep 17 00:00:00 2001 From: anna-cross Date: Thu, 21 Mar 2024 18:04:15 -0400 Subject: [PATCH 1/7] Refactor MDPX CLI to Remove Turbine and Use Conduit Apps Draft --- cmd/meroxa/flink/deploy.go | 160 - cmd/meroxa/global/basic_client.go | 2 - cmd/meroxa/root/apps/apps.go | 79 +- cmd/meroxa/root/apps/deploy.go | 375 +- cmd/meroxa/root/apps/deploy_test.go | 340 +- cmd/meroxa/root/apps/describe.go | 34 +- cmd/meroxa/root/apps/describe_test.go | 434 +- cmd/meroxa/root/apps/errors.go | 15 - cmd/meroxa/root/apps/init.go | 103 +- cmd/meroxa/root/apps/init_test.go | 610 +- cmd/meroxa/root/apps/list.go | 6 +- cmd/meroxa/root/apps/list_test.go | 186 +- cmd/meroxa/root/apps/open.go | 2 +- cmd/meroxa/root/apps/open_test.go | 290 +- cmd/meroxa/root/apps/remove.go | 30 +- cmd/meroxa/root/apps/run.go | 28 +- cmd/meroxa/root/apps/utils.go | 214 + cmd/meroxa/root/auth/login.go | 2 +- cmd/meroxa/root/flink/deploy.go | 147 - cmd/meroxa/root/flink/describe.go | 77 - cmd/meroxa/root/flink/flink.go | 67 - cmd/meroxa/root/flink/list.go | 68 - cmd/meroxa/root/flink/logs.go | 84 - cmd/meroxa/root/flink/remove.go | 92 - cmd/meroxa/root/root.go | 2 - cmd/meroxa/root/secrets/secrets.go | 2 +- cmd/meroxa/turbine/core.go | 72 - cmd/meroxa/turbine/core_test.go | 76 - cmd/meroxa/turbine/core_v2.go | 72 - cmd/meroxa/turbine/core_v2_test.go | 76 - cmd/meroxa/turbine/docker.go | 22 - cmd/meroxa/turbine/docker_test.go | 30 - cmd/meroxa/turbine/git.go | 119 - cmd/meroxa/turbine/git_test.go | 269 - cmd/meroxa/turbine/golang/cli.go | 29 - cmd/meroxa/turbine/golang/deploy.go | 62 - cmd/meroxa/turbine/golang/init.go | 113 - cmd/meroxa/turbine/golang/run.go | 29 - .../turbine/golang/templates/Dockerfile.tpl | 13 - cmd/meroxa/turbine/golang/utils.go | 21 - cmd/meroxa/turbine/golang/version.go | 40 - cmd/meroxa/turbine/interface.go | 23 - cmd/meroxa/turbine/internal/port.go | 19 - cmd/meroxa/turbine/javascript/cli.go | 22 - cmd/meroxa/turbine/javascript/deploy.go | 46 - cmd/meroxa/turbine/javascript/init.go | 47 - cmd/meroxa/turbine/javascript/internal/cmd.go | 42 - cmd/meroxa/turbine/javascript/run.go | 27 - cmd/meroxa/turbine/javascript/version.go | 21 - cmd/meroxa/turbine/mock/cli_mock.go | 179 - cmd/meroxa/turbine/python/cli.go | 22 - cmd/meroxa/turbine/python/deploy.go | 40 - cmd/meroxa/turbine/python/init.go | 17 - cmd/meroxa/turbine/python/internal/cmd.go | 41 - cmd/meroxa/turbine/python/run.go | 24 - cmd/meroxa/turbine/python/version.go | 22 - cmd/meroxa/turbine/ruby/cli.go | 24 - cmd/meroxa/turbine/ruby/deploy.go | 42 - cmd/meroxa/turbine/ruby/init.go | 17 - cmd/meroxa/turbine/ruby/internal/cmd.go | 43 - cmd/meroxa/turbine/ruby/internal/cmd_test.go | 33 - cmd/meroxa/turbine/ruby/mock/cli_mock.go | 5 - cmd/meroxa/turbine/ruby/run.go | 23 - cmd/meroxa/turbine/ruby/version.go | 22 - cmd/meroxa/turbine/utils.go | 304 - cmd/meroxa/turbine/utils_test.go | 317 - go.mod | 17 +- go.sum | 38 +- .../conduitio/conduit-commons/LICENSE.md | 201 - .../conduitio/conduit-commons/opencdc/data.go | 84 - .../conduit-commons/opencdc/errors.go | 32 - .../conduitio/conduit-commons/opencdc/json.go | 82 - .../conduit-commons/opencdc/metadata.go | 232 - .../conduit-commons/opencdc/operation.go | 64 - .../opencdc/operation_string.go | 27 - .../conduit-commons/opencdc/position.go | 28 - .../conduit-commons/opencdc/proto.go | 192 - .../conduit-commons/opencdc/record.go | 149 - .../conduit-commons/opencdc/serializer.go | 21 - .../proto/opencdc/v1/opencdc.pb.go | 566 -- .../proto/opencdc/v1/opencdc.proto | 95 - vendor/github.com/emirpasic/gods/LICENSE | 41 - .../emirpasic/gods/containers/containers.go | 36 - .../emirpasic/gods/containers/enumerable.go | 57 - .../emirpasic/gods/containers/iterator.go | 133 - .../gods/containers/serialization.go | 21 - .../github.com/emirpasic/gods/lists/lists.go | 34 - .../gods/lists/singlylinkedlist/enumerable.go | 78 - .../gods/lists/singlylinkedlist/iterator.go | 83 - .../lists/singlylinkedlist/serialization.go | 40 - .../singlylinkedlist/singlylinkedlist.go | 301 - .../gods/queues/linkedlistqueue/iterator.go | 73 - .../queues/linkedlistqueue/linkedlistqueue.go | 88 - .../queues/linkedlistqueue/serialization.go | 33 - .../emirpasic/gods/queues/queues.go | 27 - .../gods/stacks/linkedliststack/iterator.go | 73 - .../stacks/linkedliststack/linkedliststack.go | 85 - .../stacks/linkedliststack/serialization.go | 33 - .../emirpasic/gods/stacks/stacks.go | 26 - .../emirpasic/gods/utils/comparator.go | 251 - .../github.com/emirpasic/gods/utils/sort.go | 29 - .../github.com/emirpasic/gods/utils/utils.go | 47 - .../envoyproxy/protoc-gen-validate/LICENSE | 202 - .../protoc-gen-validate/validate/BUILD | 74 - .../protoc-gen-validate/validate/validate.h | 183 - .../validate/validate.pb.go | 4106 ------------ .../validate/validate.proto | 862 --- vendor/github.com/goccy/go-json/.codecov.yml | 32 - vendor/github.com/goccy/go-json/.gitignore | 2 - vendor/github.com/goccy/go-json/.golangci.yml | 83 - vendor/github.com/goccy/go-json/CHANGELOG.md | 425 -- vendor/github.com/goccy/go-json/LICENSE | 21 - vendor/github.com/goccy/go-json/Makefile | 39 - vendor/github.com/goccy/go-json/README.md | 529 -- vendor/github.com/goccy/go-json/color.go | 68 - vendor/github.com/goccy/go-json/decode.go | 263 - .../goccy/go-json/docker-compose.yml | 13 - vendor/github.com/goccy/go-json/encode.go | 326 - vendor/github.com/goccy/go-json/error.go | 41 - .../internal/decoder/anonymous_field.go | 41 - .../goccy/go-json/internal/decoder/array.go | 176 - .../goccy/go-json/internal/decoder/assign.go | 438 -- .../goccy/go-json/internal/decoder/bool.go | 83 - .../goccy/go-json/internal/decoder/bytes.go | 118 - .../goccy/go-json/internal/decoder/compile.go | 487 -- .../internal/decoder/compile_norace.go | 29 - .../go-json/internal/decoder/compile_race.go | 37 - .../goccy/go-json/internal/decoder/context.go | 254 - .../goccy/go-json/internal/decoder/float.go | 170 - .../goccy/go-json/internal/decoder/func.go | 146 - .../goccy/go-json/internal/decoder/int.go | 246 - .../go-json/internal/decoder/interface.go | 528 -- .../goccy/go-json/internal/decoder/invalid.go | 55 - .../goccy/go-json/internal/decoder/map.go | 280 - .../goccy/go-json/internal/decoder/number.go | 123 - .../goccy/go-json/internal/decoder/option.go | 17 - .../goccy/go-json/internal/decoder/path.go | 670 -- .../goccy/go-json/internal/decoder/ptr.go | 96 - .../goccy/go-json/internal/decoder/slice.go | 380 -- .../goccy/go-json/internal/decoder/stream.go | 556 -- .../goccy/go-json/internal/decoder/string.go | 452 -- .../goccy/go-json/internal/decoder/struct.go | 845 --- .../goccy/go-json/internal/decoder/type.go | 30 - .../goccy/go-json/internal/decoder/uint.go | 194 - .../internal/decoder/unmarshal_json.go | 104 - .../internal/decoder/unmarshal_text.go | 285 - .../internal/decoder/wrapped_string.go | 73 - .../goccy/go-json/internal/encoder/code.go | 1023 --- .../goccy/go-json/internal/encoder/compact.go | 286 - .../go-json/internal/encoder/compiler.go | 935 --- .../internal/encoder/compiler_norace.go | 32 - .../go-json/internal/encoder/compiler_race.go | 45 - .../goccy/go-json/internal/encoder/context.go | 105 - .../go-json/internal/encoder/decode_rune.go | 126 - .../goccy/go-json/internal/encoder/encoder.go | 596 -- .../goccy/go-json/internal/encoder/indent.go | 211 - .../goccy/go-json/internal/encoder/int.go | 152 - .../goccy/go-json/internal/encoder/map112.go | 9 - .../goccy/go-json/internal/encoder/map113.go | 9 - .../goccy/go-json/internal/encoder/opcode.go | 752 --- .../goccy/go-json/internal/encoder/option.go | 48 - .../goccy/go-json/internal/encoder/optype.go | 932 --- .../goccy/go-json/internal/encoder/query.go | 135 - .../goccy/go-json/internal/encoder/string.go | 459 -- .../go-json/internal/encoder/string_table.go | 415 -- .../go-json/internal/encoder/vm/debug_vm.go | 41 - .../goccy/go-json/internal/encoder/vm/hack.go | 9 - .../goccy/go-json/internal/encoder/vm/util.go | 207 - .../goccy/go-json/internal/encoder/vm/vm.go | 4859 -------------- .../internal/encoder/vm_color/debug_vm.go | 35 - .../go-json/internal/encoder/vm_color/hack.go | 9 - .../go-json/internal/encoder/vm_color/util.go | 274 - .../go-json/internal/encoder/vm_color/vm.go | 4859 -------------- .../encoder/vm_color_indent/debug_vm.go | 35 - .../internal/encoder/vm_color_indent/util.go | 297 - .../internal/encoder/vm_color_indent/vm.go | 4859 -------------- .../internal/encoder/vm_indent/debug_vm.go | 35 - .../internal/encoder/vm_indent/hack.go | 9 - .../internal/encoder/vm_indent/util.go | 230 - .../go-json/internal/encoder/vm_indent/vm.go | 4859 -------------- .../goccy/go-json/internal/errors/error.go | 183 - .../goccy/go-json/internal/runtime/rtype.go | 263 - .../go-json/internal/runtime/struct_field.go | 91 - .../goccy/go-json/internal/runtime/type.go | 100 - vendor/github.com/goccy/go-json/json.go | 371 -- vendor/github.com/goccy/go-json/option.go | 79 - vendor/github.com/goccy/go-json/path.go | 84 - vendor/github.com/goccy/go-json/query.go | 47 - vendor/github.com/golang/protobuf/AUTHORS | 3 - .../github.com/golang/protobuf/CONTRIBUTORS | 3 - vendor/github.com/golang/protobuf/LICENSE | 28 - .../golang/protobuf/jsonpb/decode.go | 530 -- .../golang/protobuf/jsonpb/encode.go | 559 -- .../github.com/golang/protobuf/jsonpb/json.go | 69 - .../golang/protobuf/proto/buffer.go | 324 - .../golang/protobuf/proto/defaults.go | 63 - .../golang/protobuf/proto/deprecated.go | 113 - .../golang/protobuf/proto/discard.go | 58 - .../golang/protobuf/proto/extensions.go | 356 - .../golang/protobuf/proto/properties.go | 306 - .../github.com/golang/protobuf/proto/proto.go | 167 - .../golang/protobuf/proto/registry.go | 317 - .../golang/protobuf/proto/text_decode.go | 801 --- .../golang/protobuf/proto/text_encode.go | 560 -- .../github.com/golang/protobuf/proto/wire.go | 78 - .../golang/protobuf/proto/wrappers.go | 34 - .../github.com/golang/protobuf/ptypes/any.go | 179 - .../golang/protobuf/ptypes/any/any.pb.go | 62 - .../github.com/golang/protobuf/ptypes/doc.go | 10 - .../golang/protobuf/ptypes/duration.go | 76 - .../protobuf/ptypes/duration/duration.pb.go | 63 - .../golang/protobuf/ptypes/timestamp.go | 112 - .../protobuf/ptypes/timestamp/timestamp.pb.go | 64 - vendor/github.com/google/uuid/CHANGELOG.md | 28 - vendor/github.com/google/uuid/CONTRIBUTING.md | 26 - vendor/github.com/google/uuid/CONTRIBUTORS | 9 - vendor/github.com/google/uuid/LICENSE | 27 - vendor/github.com/google/uuid/README.md | 21 - vendor/github.com/google/uuid/dce.go | 80 - vendor/github.com/google/uuid/doc.go | 12 - vendor/github.com/google/uuid/hash.go | 53 - vendor/github.com/google/uuid/marshal.go | 38 - vendor/github.com/google/uuid/node.go | 90 - vendor/github.com/google/uuid/node_js.go | 12 - vendor/github.com/google/uuid/node_net.go | 33 - vendor/github.com/google/uuid/null.go | 118 - vendor/github.com/google/uuid/sql.go | 59 - vendor/github.com/google/uuid/time.go | 134 - vendor/github.com/google/uuid/util.go | 43 - vendor/github.com/google/uuid/uuid.go | 365 -- vendor/github.com/google/uuid/version1.go | 44 - vendor/github.com/google/uuid/version4.go | 76 - vendor/github.com/google/uuid/version6.go | 56 - vendor/github.com/google/uuid/version7.go | 75 - vendor/github.com/heimdalr/dag/.gitignore | 3 - vendor/github.com/heimdalr/dag/.gitpod.yml | 3 - vendor/github.com/heimdalr/dag/LICENSE | 29 - vendor/github.com/heimdalr/dag/README.md | 84 - vendor/github.com/heimdalr/dag/dag.go | 1315 ---- vendor/github.com/heimdalr/dag/marshal.go | 88 - vendor/github.com/heimdalr/dag/storage.go | 75 - vendor/github.com/heimdalr/dag/visitor.go | 157 - .../github.com/meroxa/turbine-core/LICENSE.md | 4 - .../meroxa/turbine-core/pkg/app/config.go | 68 - .../meroxa/turbine-core/pkg/app/init.go | 140 - .../pkg/app/templates/golang/.gitignore | 2 - .../pkg/app/templates/golang/README.md | 221 - .../pkg/app/templates/golang/app.go | 114 - .../pkg/app/templates/golang/app.json | 8 - .../pkg/app/templates/golang/app_test.go | 15 - .../templates/golang/fixtures/demo-cdc.json | 358 -- .../golang/fixtures/demo-no-cdc.json | 166 - .../pkg/app/templates/javascript/.gitignore | 5 - .../pkg/app/templates/javascript/README.md | 186 - .../pkg/app/templates/javascript/app.json | 8 - .../javascript/fixtures/demo-cdc.json | 454 -- .../javascript/fixtures/demo-no-cdc.json | 178 - .../pkg/app/templates/javascript/index.js | 59 - .../app/templates/javascript/index.test.js | 39 - .../pkg/app/templates/javascript/package.json | 15 - .../pkg/app/templates/python/.gitignore | 6 - .../pkg/app/templates/python/README.md | 166 - .../pkg/app/templates/python/__init__.py | 3 - .../pkg/app/templates/python/app.json | 7 - .../app/templates/python/fixtures/.gitkeep | 0 .../templates/python/fixtures/demo-cdc.json | 358 -- .../python/fixtures/demo-no-cdc.json | 149 - .../pkg/app/templates/python/main.py | 77 - .../pkg/app/templates/python/requirements.txt | 7 - .../pkg/app/templates/ruby/Gemfile | 5 - .../pkg/app/templates/ruby/app.json | 7 - .../pkg/app/templates/ruby/app.rb | 67 - .../pkg/app/templates/ruby/fixtures/demo.json | 9 - .../meroxa/turbine-core/pkg/ir/error.go | 39 - .../meroxa/turbine-core/pkg/ir/schema.go | 34 - .../meroxa/turbine-core/pkg/ir/schema.json | 176 - .../meroxa/turbine-core/pkg/ir/spec.go | 328 - .../meroxa/turbine-core/v2/LICENSE.md | 4 - .../meroxa/turbine-core/v2/pkg/app/config.go | 57 - .../meroxa/turbine-core/v2/pkg/app/init.go | 159 - .../v2/pkg/app/templates/_golang/.gitignore | 2 - .../v2/pkg/app/templates/_golang/README.md | 221 - .../v2/pkg/app/templates/_golang/app.go | 104 - .../v2/pkg/app/templates/_golang/app.json | 7 - .../v2/pkg/app/templates/_golang/app_test.go | 15 - .../templates/_golang/fixtures/demo-cdc.json | 540 -- .../_golang/fixtures/demo-no-cdc.json | 218 - .../pkg/app/templates/javascript/.gitignore | 5 - .../v2/pkg/app/templates/javascript/README.md | 186 - .../v2/pkg/app/templates/javascript/app.json | 8 - .../javascript/fixtures/demo-cdc.json | 454 -- .../javascript/fixtures/demo-no-cdc.json | 178 - .../v2/pkg/app/templates/javascript/index.js | 59 - .../app/templates/javascript/index.test.js | 39 - .../pkg/app/templates/javascript/package.json | 15 - .../v2/pkg/app/templates/python/.gitignore | 6 - .../v2/pkg/app/templates/python/README.md | 166 - .../v2/pkg/app/templates/python/__init__.py | 3 - .../v2/pkg/app/templates/python/app.json | 7 - .../app/templates/python/fixtures/.gitkeep | 0 .../templates/python/fixtures/demo-cdc.json | 358 -- .../python/fixtures/demo-no-cdc.json | 149 - .../v2/pkg/app/templates/python/main.py | 77 - .../pkg/app/templates/python/requirements.txt | 7 - .../v2/pkg/app/templates/ruby/Gemfile | 5 - .../v2/pkg/app/templates/ruby/app.json | 7 - .../v2/pkg/app/templates/ruby/app.rb | 67 - .../pkg/app/templates/ruby/fixtures/demo.json | 9 - .../turbine-core/v2/pkg/client/client.go | 51 - .../v2/pkg/client/mock/client_mock.go | 190 - .../meroxa/turbine-core/v2/pkg/ir/error.go | 39 - .../meroxa/turbine-core/v2/pkg/ir/spec.go | 226 - .../v2/pkg/server/internal/fixtures.go | 60 - .../meroxa/turbine-core/v2/pkg/server/run.go | 116 - .../turbine-core/v2/pkg/server/server.go | 64 - .../v2/pkg/server/spec_builder.go | 166 - .../v2/proto/turbine/v2/turbine_v2.pb.go | 1305 ---- .../turbine/v2/turbine_v2.pb.validate.go | 1997 ------ .../v2/proto/turbine/v2/turbine_v2.proto | 103 - .../v2/proto/turbine/v2/turbine_v2_grpc.pb.go | 332 - .../santhosh-tekuri/jsonschema/v5/.gitignore | 4 - .../santhosh-tekuri/jsonschema/v5/.gitmodules | 3 - .../santhosh-tekuri/jsonschema/v5/LICENSE | 175 - .../santhosh-tekuri/jsonschema/v5/README.md | 220 - .../santhosh-tekuri/jsonschema/v5/compiler.go | 812 --- .../santhosh-tekuri/jsonschema/v5/content.go | 29 - .../santhosh-tekuri/jsonschema/v5/doc.go | 49 - .../santhosh-tekuri/jsonschema/v5/draft.go | 1454 ----- .../santhosh-tekuri/jsonschema/v5/errors.go | 129 - .../jsonschema/v5/extension.go | 116 - .../santhosh-tekuri/jsonschema/v5/format.go | 567 -- .../santhosh-tekuri/jsonschema/v5/loader.go | 60 - .../santhosh-tekuri/jsonschema/v5/output.go | 77 - .../santhosh-tekuri/jsonschema/v5/resource.go | 280 - .../santhosh-tekuri/jsonschema/v5/schema.go | 900 --- .../stretchr/testify/require/doc.go | 29 - .../testify/require/forward_requirements.go | 16 - .../stretchr/testify/require/require.go | 2031 ------ .../stretchr/testify/require/require.go.tmpl | 6 - .../testify/require/require_forward.go | 1599 ----- .../testify/require/require_forward.go.tmpl | 5 - .../stretchr/testify/require/requirements.go | 29 - vendor/golang.org/x/net/LICENSE | 27 - vendor/golang.org/x/net/PATENTS | 22 - vendor/golang.org/x/net/http/httpguts/guts.go | 50 - .../golang.org/x/net/http/httpguts/httplex.go | 352 - vendor/golang.org/x/net/http2/.gitignore | 2 - vendor/golang.org/x/net/http2/ascii.go | 53 - vendor/golang.org/x/net/http2/ciphers.go | 641 -- .../x/net/http2/client_conn_pool.go | 311 - vendor/golang.org/x/net/http2/databuffer.go | 149 - vendor/golang.org/x/net/http2/errors.go | 145 - vendor/golang.org/x/net/http2/flow.go | 120 - vendor/golang.org/x/net/http2/frame.go | 1658 ----- vendor/golang.org/x/net/http2/gotrack.go | 170 - vendor/golang.org/x/net/http2/headermap.go | 105 - vendor/golang.org/x/net/http2/hpack/encode.go | 245 - vendor/golang.org/x/net/http2/hpack/hpack.go | 523 -- .../golang.org/x/net/http2/hpack/huffman.go | 226 - .../x/net/http2/hpack/static_table.go | 188 - vendor/golang.org/x/net/http2/hpack/tables.go | 403 -- vendor/golang.org/x/net/http2/http2.go | 385 -- vendor/golang.org/x/net/http2/pipe.go | 175 - vendor/golang.org/x/net/http2/server.go | 3280 ---------- vendor/golang.org/x/net/http2/transport.go | 3234 ---------- vendor/golang.org/x/net/http2/write.go | 370 -- vendor/golang.org/x/net/http2/writesched.go | 251 - .../x/net/http2/writesched_priority.go | 451 -- .../x/net/http2/writesched_random.go | 77 - .../x/net/http2/writesched_roundrobin.go | 119 - vendor/golang.org/x/net/idna/go118.go | 13 - vendor/golang.org/x/net/idna/idna10.0.0.go | 769 --- vendor/golang.org/x/net/idna/idna9.0.0.go | 717 --- vendor/golang.org/x/net/idna/pre_go118.go | 11 - vendor/golang.org/x/net/idna/punycode.go | 217 - vendor/golang.org/x/net/idna/tables10.0.0.go | 4559 ------------- vendor/golang.org/x/net/idna/tables11.0.0.go | 4653 -------------- vendor/golang.org/x/net/idna/tables12.0.0.go | 4733 -------------- vendor/golang.org/x/net/idna/tables13.0.0.go | 4959 -------------- vendor/golang.org/x/net/idna/tables15.0.0.go | 5144 --------------- vendor/golang.org/x/net/idna/tables9.0.0.go | 4486 ------------- vendor/golang.org/x/net/idna/trie.go | 51 - vendor/golang.org/x/net/idna/trie12.0.0.go | 30 - vendor/golang.org/x/net/idna/trie13.0.0.go | 30 - vendor/golang.org/x/net/idna/trieval.go | 119 - .../x/net/internal/timeseries/timeseries.go | 525 -- vendor/golang.org/x/net/trace/events.go | 532 -- vendor/golang.org/x/net/trace/histogram.go | 365 -- vendor/golang.org/x/net/trace/trace.go | 1130 ---- .../x/text/secure/bidirule/bidirule.go | 336 - .../x/text/secure/bidirule/bidirule10.0.0.go | 11 - .../x/text/secure/bidirule/bidirule9.0.0.go | 14 - vendor/golang.org/x/text/unicode/bidi/bidi.go | 359 -- .../golang.org/x/text/unicode/bidi/bracket.go | 335 - vendor/golang.org/x/text/unicode/bidi/core.go | 1071 --- vendor/golang.org/x/text/unicode/bidi/prop.go | 206 - .../x/text/unicode/bidi/tables10.0.0.go | 1815 ------ .../x/text/unicode/bidi/tables11.0.0.go | 1887 ------ .../x/text/unicode/bidi/tables12.0.0.go | 1923 ------ .../x/text/unicode/bidi/tables13.0.0.go | 1955 ------ .../x/text/unicode/bidi/tables15.0.0.go | 2042 ------ .../x/text/unicode/bidi/tables9.0.0.go | 1781 ----- .../golang.org/x/text/unicode/bidi/trieval.go | 48 - .../genproto/googleapis/rpc/LICENSE | 202 - .../googleapis/rpc/status/status.pb.go | 203 - vendor/google.golang.org/grpc/AUTHORS | 1 - .../google.golang.org/grpc/CODE-OF-CONDUCT.md | 3 - vendor/google.golang.org/grpc/CONTRIBUTING.md | 73 - vendor/google.golang.org/grpc/GOVERNANCE.md | 1 - vendor/google.golang.org/grpc/LICENSE | 202 - vendor/google.golang.org/grpc/MAINTAINERS.md | 28 - vendor/google.golang.org/grpc/Makefile | 46 - vendor/google.golang.org/grpc/NOTICE.txt | 13 - vendor/google.golang.org/grpc/README.md | 107 - vendor/google.golang.org/grpc/SECURITY.md | 3 - .../grpc/attributes/attributes.go | 141 - vendor/google.golang.org/grpc/backoff.go | 61 - .../google.golang.org/grpc/backoff/backoff.go | 52 - .../grpc/balancer/balancer.go | 442 -- .../grpc/balancer/base/balancer.go | 264 - .../grpc/balancer/base/base.go | 71 - .../grpc/balancer/conn_state_evaluator.go | 74 - .../grpc/balancer/grpclb/state/state.go | 51 - .../grpc/balancer/roundrobin/roundrobin.go | 81 - .../grpc/balancer_wrapper.go | 380 -- .../grpc_binarylog_v1/binarylog.pb.go | 1183 ---- vendor/google.golang.org/grpc/call.go | 74 - .../grpc/channelz/channelz.go | 36 - vendor/google.golang.org/grpc/clientconn.go | 1888 ------ vendor/google.golang.org/grpc/codec.go | 50 - vendor/google.golang.org/grpc/codegen.sh | 17 - .../grpc/codes/code_string.go | 111 - vendor/google.golang.org/grpc/codes/codes.go | 250 - .../grpc/connectivity/connectivity.go | 94 - .../grpc/credentials/credentials.go | 291 - .../grpc/credentials/insecure/insecure.go | 98 - .../google.golang.org/grpc/credentials/tls.go | 251 - vendor/google.golang.org/grpc/dialoptions.go | 718 --- vendor/google.golang.org/grpc/doc.go | 26 - .../grpc/encoding/encoding.go | 130 - .../grpc/encoding/proto/proto.go | 58 - .../grpc/grpclog/component.go | 117 - .../google.golang.org/grpc/grpclog/grpclog.go | 132 - .../google.golang.org/grpc/grpclog/logger.go | 87 - .../grpc/grpclog/loggerv2.go | 258 - vendor/google.golang.org/grpc/interceptor.go | 104 - .../grpc/internal/backoff/backoff.go | 109 - .../balancer/gracefulswitch/gracefulswitch.go | 385 -- .../grpc/internal/balancerload/load.go | 46 - .../grpc/internal/binarylog/binarylog.go | 192 - .../internal/binarylog/binarylog_testutil.go | 42 - .../grpc/internal/binarylog/env_config.go | 208 - .../grpc/internal/binarylog/method_logger.go | 445 -- .../grpc/internal/binarylog/sink.go | 170 - .../grpc/internal/buffer/unbounded.go | 116 - .../grpc/internal/channelz/funcs.go | 763 --- .../grpc/internal/channelz/id.go | 75 - .../grpc/internal/channelz/logging.go | 79 - .../grpc/internal/channelz/types.go | 727 --- .../grpc/internal/channelz/types_linux.go | 51 - .../grpc/internal/channelz/types_nonlinux.go | 43 - .../grpc/internal/channelz/util_linux.go | 37 - .../grpc/internal/channelz/util_nonlinux.go | 27 - .../grpc/internal/credentials/credentials.go | 49 - .../grpc/internal/credentials/spiffe.go | 75 - .../grpc/internal/credentials/syscallconn.go | 58 - .../grpc/internal/credentials/util.go | 52 - .../grpc/internal/envconfig/envconfig.go | 69 - .../grpc/internal/envconfig/observability.go | 42 - .../grpc/internal/envconfig/xds.go | 56 - .../grpc/internal/experimental.go | 28 - .../grpc/internal/grpclog/grpclog.go | 126 - .../grpc/internal/grpclog/prefixLogger.go | 93 - .../grpc/internal/grpcrand/grpcrand.go | 95 - .../internal/grpcsync/callback_serializer.go | 100 - .../grpc/internal/grpcsync/event.go | 61 - .../grpc/internal/grpcsync/oncefunc.go | 32 - .../grpc/internal/grpcsync/pubsub.go | 121 - .../grpc/internal/grpcutil/compressor.go | 47 - .../grpc/internal/grpcutil/encode_duration.go | 63 - .../grpc/internal/grpcutil/grpcutil.go | 20 - .../grpc/internal/grpcutil/metadata.go | 40 - .../grpc/internal/grpcutil/method.go | 88 - .../grpc/internal/grpcutil/regex.go | 31 - .../grpc/internal/idle/idle.go | 278 - .../grpc/internal/internal.go | 218 - .../grpc/internal/metadata/metadata.go | 132 - .../grpc/internal/pretty/pretty.go | 82 - .../grpc/internal/resolver/config_selector.go | 167 - .../internal/resolver/dns/dns_resolver.go | 441 -- .../resolver/dns/internal/internal.go | 70 - .../resolver/passthrough/passthrough.go | 64 - .../grpc/internal/resolver/unix/unix.go | 74 - .../grpc/internal/serviceconfig/duration.go | 130 - .../internal/serviceconfig/serviceconfig.go | 180 - .../grpc/internal/status/status.go | 204 - .../grpc/internal/syscall/syscall_linux.go | 112 - .../grpc/internal/syscall/syscall_nonlinux.go | 77 - .../grpc/internal/tcp_keepalive_nonunix.go | 29 - .../grpc/internal/tcp_keepalive_unix.go | 54 - .../grpc/internal/transport/bdp_estimator.go | 141 - .../grpc/internal/transport/controlbuf.go | 1007 --- .../grpc/internal/transport/defaults.go | 55 - .../grpc/internal/transport/flowcontrol.go | 215 - .../grpc/internal/transport/handler_server.go | 488 -- .../grpc/internal/transport/http2_client.go | 1790 ------ .../grpc/internal/transport/http2_server.go | 1441 ----- .../grpc/internal/transport/http_util.go | 465 -- .../grpc/internal/transport/logging.go | 40 - .../transport/networktype/networktype.go | 46 - .../grpc/internal/transport/proxy.go | 144 - .../grpc/internal/transport/transport.go | 851 --- .../grpc/internal/xds_handshake_cluster.go | 40 - .../grpc/keepalive/keepalive.go | 85 - .../grpc/metadata/metadata.go | 297 - vendor/google.golang.org/grpc/peer/peer.go | 53 - .../google.golang.org/grpc/picker_wrapper.go | 223 - vendor/google.golang.org/grpc/pickfirst.go | 249 - vendor/google.golang.org/grpc/preloader.go | 67 - vendor/google.golang.org/grpc/regenerate.sh | 123 - .../grpc/resolver/dns/dns_resolver.go | 36 - vendor/google.golang.org/grpc/resolver/map.go | 251 - .../grpc/resolver/resolver.go | 316 - .../grpc/resolver_wrapper.go | 197 - vendor/google.golang.org/grpc/rpc_util.go | 959 --- vendor/google.golang.org/grpc/server.go | 2191 ------- .../google.golang.org/grpc/service_config.go | 347 - .../grpc/serviceconfig/serviceconfig.go | 44 - .../grpc/shared_buffer_pool.go | 154 - .../google.golang.org/grpc/stats/handlers.go | 63 - vendor/google.golang.org/grpc/stats/stats.go | 343 - .../google.golang.org/grpc/status/status.go | 162 - vendor/google.golang.org/grpc/stream.go | 1780 ----- vendor/google.golang.org/grpc/tap/tap.go | 62 - vendor/google.golang.org/grpc/trace.go | 123 - vendor/google.golang.org/grpc/version.go | 22 - vendor/google.golang.org/grpc/vet.sh | 192 - vendor/google.golang.org/protobuf/LICENSE | 27 - vendor/google.golang.org/protobuf/PATENTS | 22 - .../protobuf/encoding/protojson/decode.go | 685 -- .../protobuf/encoding/protojson/doc.go | 11 - .../protobuf/encoding/protojson/encode.go | 378 -- .../encoding/protojson/well_known_types.go | 872 --- .../protobuf/encoding/prototext/decode.go | 772 --- .../protobuf/encoding/prototext/doc.go | 7 - .../protobuf/encoding/prototext/encode.go | 376 -- .../protobuf/encoding/protowire/wire.go | 547 -- .../protobuf/internal/descfmt/stringer.go | 413 -- .../protobuf/internal/descopts/options.go | 29 - .../protobuf/internal/detrand/rand.go | 69 - .../internal/encoding/defval/default.go | 213 - .../protobuf/internal/encoding/json/decode.go | 340 - .../internal/encoding/json/decode_number.go | 254 - .../internal/encoding/json/decode_string.go | 91 - .../internal/encoding/json/decode_token.go | 192 - .../protobuf/internal/encoding/json/encode.go | 278 - .../encoding/messageset/messageset.go | 242 - .../protobuf/internal/encoding/tag/tag.go | 207 - .../protobuf/internal/encoding/text/decode.go | 686 -- .../internal/encoding/text/decode_number.go | 211 - .../internal/encoding/text/decode_string.go | 161 - .../internal/encoding/text/decode_token.go | 373 -- .../protobuf/internal/encoding/text/doc.go | 29 - .../protobuf/internal/encoding/text/encode.go | 272 - .../protobuf/internal/errors/errors.go | 89 - .../protobuf/internal/errors/is_go112.go | 40 - .../protobuf/internal/errors/is_go113.go | 13 - .../protobuf/internal/filedesc/build.go | 157 - .../protobuf/internal/filedesc/desc.go | 678 -- .../protobuf/internal/filedesc/desc_init.go | 471 -- .../protobuf/internal/filedesc/desc_lazy.go | 704 -- .../protobuf/internal/filedesc/desc_list.go | 457 -- .../internal/filedesc/desc_list_gen.go | 356 - .../protobuf/internal/filedesc/placeholder.go | 109 - .../protobuf/internal/filetype/build.go | 296 - .../protobuf/internal/flags/flags.go | 24 - .../internal/flags/proto_legacy_disable.go | 10 - .../internal/flags/proto_legacy_enable.go | 10 - .../protobuf/internal/genid/any_gen.go | 34 - .../protobuf/internal/genid/api_gen.go | 106 - .../protobuf/internal/genid/descriptor_gen.go | 1087 ---- .../protobuf/internal/genid/doc.go | 11 - .../protobuf/internal/genid/duration_gen.go | 34 - .../protobuf/internal/genid/empty_gen.go | 19 - .../protobuf/internal/genid/field_mask_gen.go | 31 - .../protobuf/internal/genid/goname.go | 25 - .../protobuf/internal/genid/map_entry.go | 16 - .../internal/genid/source_context_gen.go | 31 - .../protobuf/internal/genid/struct_gen.go | 116 - .../protobuf/internal/genid/timestamp_gen.go | 34 - .../protobuf/internal/genid/type_gen.go | 190 - .../protobuf/internal/genid/wrappers.go | 13 - .../protobuf/internal/genid/wrappers_gen.go | 175 - .../protobuf/internal/impl/api_export.go | 177 - .../protobuf/internal/impl/checkinit.go | 141 - .../protobuf/internal/impl/codec_extension.go | 223 - .../protobuf/internal/impl/codec_field.go | 830 --- .../protobuf/internal/impl/codec_gen.go | 5724 ----------------- .../protobuf/internal/impl/codec_map.go | 388 -- .../protobuf/internal/impl/codec_map_go111.go | 38 - .../protobuf/internal/impl/codec_map_go112.go | 12 - .../protobuf/internal/impl/codec_message.go | 217 - .../internal/impl/codec_messageset.go | 123 - .../protobuf/internal/impl/codec_reflect.go | 210 - .../protobuf/internal/impl/codec_tables.go | 557 -- .../protobuf/internal/impl/codec_unsafe.go | 18 - .../protobuf/internal/impl/convert.go | 495 -- .../protobuf/internal/impl/convert_list.go | 141 - .../protobuf/internal/impl/convert_map.go | 121 - .../protobuf/internal/impl/decode.go | 285 - .../protobuf/internal/impl/encode.go | 201 - .../protobuf/internal/impl/enum.go | 21 - .../protobuf/internal/impl/extension.go | 156 - .../protobuf/internal/impl/legacy_enum.go | 218 - .../protobuf/internal/impl/legacy_export.go | 92 - .../internal/impl/legacy_extension.go | 176 - .../protobuf/internal/impl/legacy_file.go | 81 - .../protobuf/internal/impl/legacy_message.go | 568 -- .../protobuf/internal/impl/merge.go | 176 - .../protobuf/internal/impl/merge_gen.go | 209 - .../protobuf/internal/impl/message.go | 284 - .../protobuf/internal/impl/message_reflect.go | 463 -- .../internal/impl/message_reflect_field.go | 543 -- .../internal/impl/message_reflect_gen.go | 249 - .../protobuf/internal/impl/pointer_reflect.go | 215 - .../protobuf/internal/impl/pointer_unsafe.go | 215 - .../protobuf/internal/impl/validate.go | 576 -- .../protobuf/internal/impl/weak.go | 74 - .../protobuf/internal/order/order.go | 89 - .../protobuf/internal/order/range.go | 115 - .../protobuf/internal/pragma/pragma.go | 29 - .../protobuf/internal/set/ints.go | 58 - .../protobuf/internal/strs/strings.go | 196 - .../protobuf/internal/strs/strings_pure.go | 28 - .../internal/strs/strings_unsafe_go120.go | 95 - .../internal/strs/strings_unsafe_go121.go | 74 - .../protobuf/internal/version/version.go | 79 - .../protobuf/proto/checkinit.go | 71 - .../protobuf/proto/decode.go | 294 - .../protobuf/proto/decode_gen.go | 603 -- .../google.golang.org/protobuf/proto/doc.go | 86 - .../protobuf/proto/encode.go | 322 - .../protobuf/proto/encode_gen.go | 97 - .../google.golang.org/protobuf/proto/equal.go | 57 - .../protobuf/proto/extension.go | 92 - .../google.golang.org/protobuf/proto/merge.go | 139 - .../protobuf/proto/messageset.go | 93 - .../google.golang.org/protobuf/proto/proto.go | 45 - .../protobuf/proto/proto_methods.go | 20 - .../protobuf/proto/proto_reflect.go | 20 - .../google.golang.org/protobuf/proto/reset.go | 43 - .../google.golang.org/protobuf/proto/size.go | 101 - .../protobuf/proto/size_gen.go | 55 - .../protobuf/proto/wrappers.go | 29 - .../protobuf/reflect/protodesc/desc.go | 285 - .../protobuf/reflect/protodesc/desc_init.go | 272 - .../reflect/protodesc/desc_resolve.go | 286 - .../reflect/protodesc/desc_validate.go | 374 -- .../protobuf/reflect/protodesc/editions.go | 177 - .../reflect/protodesc/editions_defaults.binpb | 4 - .../protobuf/reflect/protodesc/proto.go | 252 - .../protobuf/reflect/protoreflect/methods.go | 78 - .../protobuf/reflect/protoreflect/proto.go | 511 -- .../protobuf/reflect/protoreflect/source.go | 129 - .../reflect/protoreflect/source_gen.go | 554 -- .../protobuf/reflect/protoreflect/type.go | 666 -- .../protobuf/reflect/protoreflect/value.go | 285 - .../reflect/protoreflect/value_equal.go | 168 - .../reflect/protoreflect/value_pure.go | 60 - .../reflect/protoreflect/value_union.go | 438 -- .../protoreflect/value_unsafe_go120.go | 99 - .../protoreflect/value_unsafe_go121.go | 87 - .../reflect/protoregistry/registry.go | 882 --- .../protobuf/runtime/protoiface/legacy.go | 15 - .../protobuf/runtime/protoiface/methods.go | 168 - .../protobuf/runtime/protoimpl/impl.go | 44 - .../protobuf/runtime/protoimpl/version.go | 60 - .../types/descriptorpb/descriptor.pb.go | 5656 ---------------- .../protobuf/types/known/anypb/any.pb.go | 496 -- .../types/known/durationpb/duration.pb.go | 374 -- .../protobuf/types/known/emptypb/empty.pb.go | 166 - .../types/known/structpb/struct.pb.go | 810 --- .../types/known/timestamppb/timestamp.pb.go | 383 -- vendor/modules.txt | 165 +- 684 files changed, 1310 insertions(+), 213694 deletions(-) delete mode 100644 cmd/meroxa/flink/deploy.go delete mode 100644 cmd/meroxa/root/apps/errors.go create mode 100644 cmd/meroxa/root/apps/utils.go delete mode 100644 cmd/meroxa/root/flink/deploy.go delete mode 100644 cmd/meroxa/root/flink/describe.go delete mode 100644 cmd/meroxa/root/flink/flink.go delete mode 100644 cmd/meroxa/root/flink/list.go delete mode 100644 cmd/meroxa/root/flink/logs.go delete mode 100644 cmd/meroxa/root/flink/remove.go delete mode 100644 cmd/meroxa/turbine/core.go delete mode 100644 cmd/meroxa/turbine/core_test.go delete mode 100644 cmd/meroxa/turbine/core_v2.go delete mode 100644 cmd/meroxa/turbine/core_v2_test.go delete mode 100644 cmd/meroxa/turbine/docker.go delete mode 100644 cmd/meroxa/turbine/docker_test.go delete mode 100644 cmd/meroxa/turbine/git.go delete mode 100644 cmd/meroxa/turbine/git_test.go delete mode 100644 cmd/meroxa/turbine/golang/cli.go delete mode 100644 cmd/meroxa/turbine/golang/deploy.go delete mode 100644 cmd/meroxa/turbine/golang/init.go delete mode 100644 cmd/meroxa/turbine/golang/run.go delete mode 100644 cmd/meroxa/turbine/golang/templates/Dockerfile.tpl delete mode 100644 cmd/meroxa/turbine/golang/utils.go delete mode 100644 cmd/meroxa/turbine/golang/version.go delete mode 100644 cmd/meroxa/turbine/interface.go delete mode 100644 cmd/meroxa/turbine/internal/port.go delete mode 100644 cmd/meroxa/turbine/javascript/cli.go delete mode 100644 cmd/meroxa/turbine/javascript/deploy.go delete mode 100644 cmd/meroxa/turbine/javascript/init.go delete mode 100644 cmd/meroxa/turbine/javascript/internal/cmd.go delete mode 100644 cmd/meroxa/turbine/javascript/run.go delete mode 100644 cmd/meroxa/turbine/javascript/version.go delete mode 100644 cmd/meroxa/turbine/mock/cli_mock.go delete mode 100644 cmd/meroxa/turbine/python/cli.go delete mode 100644 cmd/meroxa/turbine/python/deploy.go delete mode 100644 cmd/meroxa/turbine/python/init.go delete mode 100644 cmd/meroxa/turbine/python/internal/cmd.go delete mode 100644 cmd/meroxa/turbine/python/run.go delete mode 100644 cmd/meroxa/turbine/python/version.go delete mode 100644 cmd/meroxa/turbine/ruby/cli.go delete mode 100644 cmd/meroxa/turbine/ruby/deploy.go delete mode 100644 cmd/meroxa/turbine/ruby/init.go delete mode 100644 cmd/meroxa/turbine/ruby/internal/cmd.go delete mode 100644 cmd/meroxa/turbine/ruby/internal/cmd_test.go delete mode 100644 cmd/meroxa/turbine/ruby/mock/cli_mock.go delete mode 100644 cmd/meroxa/turbine/ruby/run.go delete mode 100644 cmd/meroxa/turbine/ruby/version.go delete mode 100644 cmd/meroxa/turbine/utils.go delete mode 100644 cmd/meroxa/turbine/utils_test.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/LICENSE.md delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/data.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/errors.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/json.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/metadata.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/operation.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/operation_string.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/position.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/proto.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/record.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/opencdc/serializer.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/proto/opencdc/v1/opencdc.pb.go delete mode 100644 vendor/github.com/conduitio/conduit-commons/proto/opencdc/v1/opencdc.proto delete mode 100644 vendor/github.com/emirpasic/gods/LICENSE delete mode 100644 vendor/github.com/emirpasic/gods/containers/containers.go delete mode 100644 vendor/github.com/emirpasic/gods/containers/enumerable.go delete mode 100644 vendor/github.com/emirpasic/gods/containers/iterator.go delete mode 100644 vendor/github.com/emirpasic/gods/containers/serialization.go delete mode 100644 vendor/github.com/emirpasic/gods/lists/lists.go delete mode 100644 vendor/github.com/emirpasic/gods/lists/singlylinkedlist/enumerable.go delete mode 100644 vendor/github.com/emirpasic/gods/lists/singlylinkedlist/iterator.go delete mode 100644 vendor/github.com/emirpasic/gods/lists/singlylinkedlist/serialization.go delete mode 100644 vendor/github.com/emirpasic/gods/lists/singlylinkedlist/singlylinkedlist.go delete mode 100644 vendor/github.com/emirpasic/gods/queues/linkedlistqueue/iterator.go delete mode 100644 vendor/github.com/emirpasic/gods/queues/linkedlistqueue/linkedlistqueue.go delete mode 100644 vendor/github.com/emirpasic/gods/queues/linkedlistqueue/serialization.go delete mode 100644 vendor/github.com/emirpasic/gods/queues/queues.go delete mode 100644 vendor/github.com/emirpasic/gods/stacks/linkedliststack/iterator.go delete mode 100644 vendor/github.com/emirpasic/gods/stacks/linkedliststack/linkedliststack.go delete mode 100644 vendor/github.com/emirpasic/gods/stacks/linkedliststack/serialization.go delete mode 100644 vendor/github.com/emirpasic/gods/stacks/stacks.go delete mode 100644 vendor/github.com/emirpasic/gods/utils/comparator.go delete mode 100644 vendor/github.com/emirpasic/gods/utils/sort.go delete mode 100644 vendor/github.com/emirpasic/gods/utils/utils.go delete mode 100644 vendor/github.com/envoyproxy/protoc-gen-validate/LICENSE delete mode 100644 vendor/github.com/envoyproxy/protoc-gen-validate/validate/BUILD delete mode 100644 vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.h delete mode 100644 vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.pb.go delete mode 100644 vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.proto delete mode 100644 vendor/github.com/goccy/go-json/.codecov.yml delete mode 100644 vendor/github.com/goccy/go-json/.gitignore delete mode 100644 vendor/github.com/goccy/go-json/.golangci.yml delete mode 100644 vendor/github.com/goccy/go-json/CHANGELOG.md delete mode 100644 vendor/github.com/goccy/go-json/LICENSE delete mode 100644 vendor/github.com/goccy/go-json/Makefile delete mode 100644 vendor/github.com/goccy/go-json/README.md delete mode 100644 vendor/github.com/goccy/go-json/color.go delete mode 100644 vendor/github.com/goccy/go-json/decode.go delete mode 100644 vendor/github.com/goccy/go-json/docker-compose.yml delete mode 100644 vendor/github.com/goccy/go-json/encode.go delete mode 100644 vendor/github.com/goccy/go-json/error.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/array.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/assign.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/bool.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/bytes.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/compile.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/compile_race.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/context.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/float.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/func.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/int.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/interface.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/invalid.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/map.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/number.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/option.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/path.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/ptr.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/slice.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/stream.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/string.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/struct.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/type.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/uint.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/code.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compact.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compiler.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/context.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/decode_rune.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/encoder.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/indent.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/int.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/map112.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/map113.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/opcode.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/option.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/optype.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/query.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/string.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/string_table.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/hack.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/hack.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/hack.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/errors/error.go delete mode 100644 vendor/github.com/goccy/go-json/internal/runtime/rtype.go delete mode 100644 vendor/github.com/goccy/go-json/internal/runtime/struct_field.go delete mode 100644 vendor/github.com/goccy/go-json/internal/runtime/type.go delete mode 100644 vendor/github.com/goccy/go-json/json.go delete mode 100644 vendor/github.com/goccy/go-json/option.go delete mode 100644 vendor/github.com/goccy/go-json/path.go delete mode 100644 vendor/github.com/goccy/go-json/query.go delete mode 100644 vendor/github.com/golang/protobuf/AUTHORS delete mode 100644 vendor/github.com/golang/protobuf/CONTRIBUTORS delete mode 100644 vendor/github.com/golang/protobuf/LICENSE delete mode 100644 vendor/github.com/golang/protobuf/jsonpb/decode.go delete mode 100644 vendor/github.com/golang/protobuf/jsonpb/encode.go delete mode 100644 vendor/github.com/golang/protobuf/jsonpb/json.go delete mode 100644 vendor/github.com/golang/protobuf/proto/buffer.go delete mode 100644 vendor/github.com/golang/protobuf/proto/defaults.go delete mode 100644 vendor/github.com/golang/protobuf/proto/deprecated.go delete mode 100644 vendor/github.com/golang/protobuf/proto/discard.go delete mode 100644 vendor/github.com/golang/protobuf/proto/extensions.go delete mode 100644 vendor/github.com/golang/protobuf/proto/properties.go delete mode 100644 vendor/github.com/golang/protobuf/proto/proto.go delete mode 100644 vendor/github.com/golang/protobuf/proto/registry.go delete mode 100644 vendor/github.com/golang/protobuf/proto/text_decode.go delete mode 100644 vendor/github.com/golang/protobuf/proto/text_encode.go delete mode 100644 vendor/github.com/golang/protobuf/proto/wire.go delete mode 100644 vendor/github.com/golang/protobuf/proto/wrappers.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/any.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/any/any.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/doc.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/duration.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/timestamp.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go delete mode 100644 vendor/github.com/google/uuid/CHANGELOG.md delete mode 100644 vendor/github.com/google/uuid/CONTRIBUTING.md delete mode 100644 vendor/github.com/google/uuid/CONTRIBUTORS delete mode 100644 vendor/github.com/google/uuid/LICENSE delete mode 100644 vendor/github.com/google/uuid/README.md delete mode 100644 vendor/github.com/google/uuid/dce.go delete mode 100644 vendor/github.com/google/uuid/doc.go delete mode 100644 vendor/github.com/google/uuid/hash.go delete mode 100644 vendor/github.com/google/uuid/marshal.go delete mode 100644 vendor/github.com/google/uuid/node.go delete mode 100644 vendor/github.com/google/uuid/node_js.go delete mode 100644 vendor/github.com/google/uuid/node_net.go delete mode 100644 vendor/github.com/google/uuid/null.go delete mode 100644 vendor/github.com/google/uuid/sql.go delete mode 100644 vendor/github.com/google/uuid/time.go delete mode 100644 vendor/github.com/google/uuid/util.go delete mode 100644 vendor/github.com/google/uuid/uuid.go delete mode 100644 vendor/github.com/google/uuid/version1.go delete mode 100644 vendor/github.com/google/uuid/version4.go delete mode 100644 vendor/github.com/google/uuid/version6.go delete mode 100644 vendor/github.com/google/uuid/version7.go delete mode 100644 vendor/github.com/heimdalr/dag/.gitignore delete mode 100644 vendor/github.com/heimdalr/dag/.gitpod.yml delete mode 100644 vendor/github.com/heimdalr/dag/LICENSE delete mode 100644 vendor/github.com/heimdalr/dag/README.md delete mode 100644 vendor/github.com/heimdalr/dag/dag.go delete mode 100644 vendor/github.com/heimdalr/dag/marshal.go delete mode 100644 vendor/github.com/heimdalr/dag/storage.go delete mode 100644 vendor/github.com/heimdalr/dag/visitor.go delete mode 100644 vendor/github.com/meroxa/turbine-core/LICENSE.md delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/config.go delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/init.go delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/golang/.gitignore delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/golang/README.md delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/golang/app.go delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/golang/app.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/golang/app_test.go delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/golang/fixtures/demo-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/golang/fixtures/demo-no-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/javascript/.gitignore delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/javascript/README.md delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/javascript/app.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/javascript/fixtures/demo-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/javascript/fixtures/demo-no-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/javascript/index.js delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/javascript/index.test.js delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/javascript/package.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/python/.gitignore delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/python/README.md delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/python/__init__.py delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/python/app.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/python/fixtures/.gitkeep delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/python/fixtures/demo-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/python/fixtures/demo-no-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/python/main.py delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/python/requirements.txt delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/ruby/Gemfile delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/ruby/app.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/ruby/app.rb delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/app/templates/ruby/fixtures/demo.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/ir/error.go delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/ir/schema.go delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/ir/schema.json delete mode 100644 vendor/github.com/meroxa/turbine-core/pkg/ir/spec.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/LICENSE.md delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/config.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/init.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/_golang/.gitignore delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/_golang/README.md delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/_golang/app.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/_golang/app.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/_golang/app_test.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/_golang/fixtures/demo-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/_golang/fixtures/demo-no-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/javascript/.gitignore delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/javascript/README.md delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/javascript/app.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/javascript/fixtures/demo-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/javascript/fixtures/demo-no-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/javascript/index.js delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/javascript/index.test.js delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/javascript/package.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/python/.gitignore delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/python/README.md delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/python/__init__.py delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/python/app.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/python/fixtures/.gitkeep delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/python/fixtures/demo-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/python/fixtures/demo-no-cdc.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/python/main.py delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/python/requirements.txt delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/ruby/Gemfile delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/ruby/app.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/ruby/app.rb delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/app/templates/ruby/fixtures/demo.json delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/client/client.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/client/mock/client_mock.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/ir/error.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/ir/spec.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/server/internal/fixtures.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/server/run.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/server/server.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/pkg/server/spec_builder.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/proto/turbine/v2/turbine_v2.pb.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/proto/turbine/v2/turbine_v2.pb.validate.go delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/proto/turbine/v2/turbine_v2.proto delete mode 100644 vendor/github.com/meroxa/turbine-core/v2/proto/turbine/v2/turbine_v2_grpc.pb.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/.gitignore delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/.gitmodules delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/LICENSE delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/README.md delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/compiler.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/content.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/doc.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/draft.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/errors.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/extension.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/format.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/loader.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/output.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/resource.go delete mode 100644 vendor/github.com/santhosh-tekuri/jsonschema/v5/schema.go delete mode 100644 vendor/github.com/stretchr/testify/require/doc.go delete mode 100644 vendor/github.com/stretchr/testify/require/forward_requirements.go delete mode 100644 vendor/github.com/stretchr/testify/require/require.go delete mode 100644 vendor/github.com/stretchr/testify/require/require.go.tmpl delete mode 100644 vendor/github.com/stretchr/testify/require/require_forward.go delete mode 100644 vendor/github.com/stretchr/testify/require/require_forward.go.tmpl delete mode 100644 vendor/github.com/stretchr/testify/require/requirements.go delete mode 100644 vendor/golang.org/x/net/LICENSE delete mode 100644 vendor/golang.org/x/net/PATENTS delete mode 100644 vendor/golang.org/x/net/http/httpguts/guts.go delete mode 100644 vendor/golang.org/x/net/http/httpguts/httplex.go delete mode 100644 vendor/golang.org/x/net/http2/.gitignore delete mode 100644 vendor/golang.org/x/net/http2/ascii.go delete mode 100644 vendor/golang.org/x/net/http2/ciphers.go delete mode 100644 vendor/golang.org/x/net/http2/client_conn_pool.go delete mode 100644 vendor/golang.org/x/net/http2/databuffer.go delete mode 100644 vendor/golang.org/x/net/http2/errors.go delete mode 100644 vendor/golang.org/x/net/http2/flow.go delete mode 100644 vendor/golang.org/x/net/http2/frame.go delete mode 100644 vendor/golang.org/x/net/http2/gotrack.go delete mode 100644 vendor/golang.org/x/net/http2/headermap.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/encode.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/hpack.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/huffman.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/static_table.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/tables.go delete mode 100644 vendor/golang.org/x/net/http2/http2.go delete mode 100644 vendor/golang.org/x/net/http2/pipe.go delete mode 100644 vendor/golang.org/x/net/http2/server.go delete mode 100644 vendor/golang.org/x/net/http2/transport.go delete mode 100644 vendor/golang.org/x/net/http2/write.go delete mode 100644 vendor/golang.org/x/net/http2/writesched.go delete mode 100644 vendor/golang.org/x/net/http2/writesched_priority.go delete mode 100644 vendor/golang.org/x/net/http2/writesched_random.go delete mode 100644 vendor/golang.org/x/net/http2/writesched_roundrobin.go delete mode 100644 vendor/golang.org/x/net/idna/go118.go delete mode 100644 vendor/golang.org/x/net/idna/idna10.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/idna9.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/pre_go118.go delete mode 100644 vendor/golang.org/x/net/idna/punycode.go delete mode 100644 vendor/golang.org/x/net/idna/tables10.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/tables11.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/tables12.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/tables13.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/tables15.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/tables9.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/trie.go delete mode 100644 vendor/golang.org/x/net/idna/trie12.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/trie13.0.0.go delete mode 100644 vendor/golang.org/x/net/idna/trieval.go delete mode 100644 vendor/golang.org/x/net/internal/timeseries/timeseries.go delete mode 100644 vendor/golang.org/x/net/trace/events.go delete mode 100644 vendor/golang.org/x/net/trace/histogram.go delete mode 100644 vendor/golang.org/x/net/trace/trace.go delete mode 100644 vendor/golang.org/x/text/secure/bidirule/bidirule.go delete mode 100644 vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go delete mode 100644 vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/bidi.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/bracket.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/core.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/prop.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/tables15.0.0.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/trieval.go delete mode 100644 vendor/google.golang.org/genproto/googleapis/rpc/LICENSE delete mode 100644 vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go delete mode 100644 vendor/google.golang.org/grpc/AUTHORS delete mode 100644 vendor/google.golang.org/grpc/CODE-OF-CONDUCT.md delete mode 100644 vendor/google.golang.org/grpc/CONTRIBUTING.md delete mode 100644 vendor/google.golang.org/grpc/GOVERNANCE.md delete mode 100644 vendor/google.golang.org/grpc/LICENSE delete mode 100644 vendor/google.golang.org/grpc/MAINTAINERS.md delete mode 100644 vendor/google.golang.org/grpc/Makefile delete mode 100644 vendor/google.golang.org/grpc/NOTICE.txt delete mode 100644 vendor/google.golang.org/grpc/README.md delete mode 100644 vendor/google.golang.org/grpc/SECURITY.md delete mode 100644 vendor/google.golang.org/grpc/attributes/attributes.go delete mode 100644 vendor/google.golang.org/grpc/backoff.go delete mode 100644 vendor/google.golang.org/grpc/backoff/backoff.go delete mode 100644 vendor/google.golang.org/grpc/balancer/balancer.go delete mode 100644 vendor/google.golang.org/grpc/balancer/base/balancer.go delete mode 100644 vendor/google.golang.org/grpc/balancer/base/base.go delete mode 100644 vendor/google.golang.org/grpc/balancer/conn_state_evaluator.go delete mode 100644 vendor/google.golang.org/grpc/balancer/grpclb/state/state.go delete mode 100644 vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go delete mode 100644 vendor/google.golang.org/grpc/balancer_wrapper.go delete mode 100644 vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go delete mode 100644 vendor/google.golang.org/grpc/call.go delete mode 100644 vendor/google.golang.org/grpc/channelz/channelz.go delete mode 100644 vendor/google.golang.org/grpc/clientconn.go delete mode 100644 vendor/google.golang.org/grpc/codec.go delete mode 100644 vendor/google.golang.org/grpc/codegen.sh delete mode 100644 vendor/google.golang.org/grpc/codes/code_string.go delete mode 100644 vendor/google.golang.org/grpc/codes/codes.go delete mode 100644 vendor/google.golang.org/grpc/connectivity/connectivity.go delete mode 100644 vendor/google.golang.org/grpc/credentials/credentials.go delete mode 100644 vendor/google.golang.org/grpc/credentials/insecure/insecure.go delete mode 100644 vendor/google.golang.org/grpc/credentials/tls.go delete mode 100644 vendor/google.golang.org/grpc/dialoptions.go delete mode 100644 vendor/google.golang.org/grpc/doc.go delete mode 100644 vendor/google.golang.org/grpc/encoding/encoding.go delete mode 100644 vendor/google.golang.org/grpc/encoding/proto/proto.go delete mode 100644 vendor/google.golang.org/grpc/grpclog/component.go delete mode 100644 vendor/google.golang.org/grpc/grpclog/grpclog.go delete mode 100644 vendor/google.golang.org/grpc/grpclog/logger.go delete mode 100644 vendor/google.golang.org/grpc/grpclog/loggerv2.go delete mode 100644 vendor/google.golang.org/grpc/interceptor.go delete mode 100644 vendor/google.golang.org/grpc/internal/backoff/backoff.go delete mode 100644 vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go delete mode 100644 vendor/google.golang.org/grpc/internal/balancerload/load.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/binarylog.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/binarylog_testutil.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/env_config.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/method_logger.go delete mode 100644 vendor/google.golang.org/grpc/internal/binarylog/sink.go delete mode 100644 vendor/google.golang.org/grpc/internal/buffer/unbounded.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/funcs.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/id.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/logging.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/types.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/types_linux.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/types_nonlinux.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/util_linux.go delete mode 100644 vendor/google.golang.org/grpc/internal/channelz/util_nonlinux.go delete mode 100644 vendor/google.golang.org/grpc/internal/credentials/credentials.go delete mode 100644 vendor/google.golang.org/grpc/internal/credentials/spiffe.go delete mode 100644 vendor/google.golang.org/grpc/internal/credentials/syscallconn.go delete mode 100644 vendor/google.golang.org/grpc/internal/credentials/util.go delete mode 100644 vendor/google.golang.org/grpc/internal/envconfig/envconfig.go delete mode 100644 vendor/google.golang.org/grpc/internal/envconfig/observability.go delete mode 100644 vendor/google.golang.org/grpc/internal/envconfig/xds.go delete mode 100644 vendor/google.golang.org/grpc/internal/experimental.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpclog/grpclog.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpclog/prefixLogger.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/callback_serializer.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/event.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/oncefunc.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcsync/pubsub.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/compressor.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/encode_duration.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/grpcutil.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/metadata.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/method.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcutil/regex.go delete mode 100644 vendor/google.golang.org/grpc/internal/idle/idle.go delete mode 100644 vendor/google.golang.org/grpc/internal/internal.go delete mode 100644 vendor/google.golang.org/grpc/internal/metadata/metadata.go delete mode 100644 vendor/google.golang.org/grpc/internal/pretty/pretty.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/config_selector.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/passthrough/passthrough.go delete mode 100644 vendor/google.golang.org/grpc/internal/resolver/unix/unix.go delete mode 100644 vendor/google.golang.org/grpc/internal/serviceconfig/duration.go delete mode 100644 vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go delete mode 100644 vendor/google.golang.org/grpc/internal/status/status.go delete mode 100644 vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go delete mode 100644 vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go delete mode 100644 vendor/google.golang.org/grpc/internal/tcp_keepalive_nonunix.go delete mode 100644 vendor/google.golang.org/grpc/internal/tcp_keepalive_unix.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/controlbuf.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/defaults.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/flowcontrol.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/handler_server.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/http2_client.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/http2_server.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/http_util.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/logging.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/networktype/networktype.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/proxy.go delete mode 100644 vendor/google.golang.org/grpc/internal/transport/transport.go delete mode 100644 vendor/google.golang.org/grpc/internal/xds_handshake_cluster.go delete mode 100644 vendor/google.golang.org/grpc/keepalive/keepalive.go delete mode 100644 vendor/google.golang.org/grpc/metadata/metadata.go delete mode 100644 vendor/google.golang.org/grpc/peer/peer.go delete mode 100644 vendor/google.golang.org/grpc/picker_wrapper.go delete mode 100644 vendor/google.golang.org/grpc/pickfirst.go delete mode 100644 vendor/google.golang.org/grpc/preloader.go delete mode 100644 vendor/google.golang.org/grpc/regenerate.sh delete mode 100644 vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go delete mode 100644 vendor/google.golang.org/grpc/resolver/map.go delete mode 100644 vendor/google.golang.org/grpc/resolver/resolver.go delete mode 100644 vendor/google.golang.org/grpc/resolver_wrapper.go delete mode 100644 vendor/google.golang.org/grpc/rpc_util.go delete mode 100644 vendor/google.golang.org/grpc/server.go delete mode 100644 vendor/google.golang.org/grpc/service_config.go delete mode 100644 vendor/google.golang.org/grpc/serviceconfig/serviceconfig.go delete mode 100644 vendor/google.golang.org/grpc/shared_buffer_pool.go delete mode 100644 vendor/google.golang.org/grpc/stats/handlers.go delete mode 100644 vendor/google.golang.org/grpc/stats/stats.go delete mode 100644 vendor/google.golang.org/grpc/status/status.go delete mode 100644 vendor/google.golang.org/grpc/stream.go delete mode 100644 vendor/google.golang.org/grpc/tap/tap.go delete mode 100644 vendor/google.golang.org/grpc/trace.go delete mode 100644 vendor/google.golang.org/grpc/version.go delete mode 100644 vendor/google.golang.org/grpc/vet.sh delete mode 100644 vendor/google.golang.org/protobuf/LICENSE delete mode 100644 vendor/google.golang.org/protobuf/PATENTS delete mode 100644 vendor/google.golang.org/protobuf/encoding/protojson/decode.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/protojson/doc.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/protojson/encode.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/prototext/decode.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/prototext/doc.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/prototext/encode.go delete mode 100644 vendor/google.golang.org/protobuf/encoding/protowire/wire.go delete mode 100644 vendor/google.golang.org/protobuf/internal/descfmt/stringer.go delete mode 100644 vendor/google.golang.org/protobuf/internal/descopts/options.go delete mode 100644 vendor/google.golang.org/protobuf/internal/detrand/rand.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/defval/default.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/decode.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/decode_number.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/decode_string.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/decode_token.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/json/encode.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/text/decode.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/text/decode_string.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/text/decode_token.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/text/doc.go delete mode 100644 vendor/google.golang.org/protobuf/internal/encoding/text/encode.go delete mode 100644 vendor/google.golang.org/protobuf/internal/errors/errors.go delete mode 100644 vendor/google.golang.org/protobuf/internal/errors/is_go112.go delete mode 100644 vendor/google.golang.org/protobuf/internal/errors/is_go113.go delete mode 100644 vendor/google.golang.org/protobuf/internal/filedesc/build.go delete mode 100644 vendor/google.golang.org/protobuf/internal/filedesc/desc.go delete mode 100644 vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go delete mode 100644 vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go delete mode 100644 vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go delete mode 100644 vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go delete mode 100644 vendor/google.golang.org/protobuf/internal/filetype/build.go delete mode 100644 vendor/google.golang.org/protobuf/internal/flags/flags.go delete mode 100644 vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go delete mode 100644 vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/any_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/api_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/doc.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/duration_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/empty_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/goname.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/map_entry.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/struct_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/type_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/wrappers.go delete mode 100644 vendor/google.golang.org/protobuf/internal/genid/wrappers_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/api_export.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/checkinit.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_extension.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_field.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_map.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_message.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_tables.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/convert.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/convert_list.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/convert_map.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/decode.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/encode.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/enum.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/extension.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/legacy_export.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/legacy_file.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/legacy_message.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/merge.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/merge_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/message.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/message_reflect.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/validate.go delete mode 100644 vendor/google.golang.org/protobuf/internal/impl/weak.go delete mode 100644 vendor/google.golang.org/protobuf/internal/order/order.go delete mode 100644 vendor/google.golang.org/protobuf/internal/order/range.go delete mode 100644 vendor/google.golang.org/protobuf/internal/pragma/pragma.go delete mode 100644 vendor/google.golang.org/protobuf/internal/set/ints.go delete mode 100644 vendor/google.golang.org/protobuf/internal/strs/strings.go delete mode 100644 vendor/google.golang.org/protobuf/internal/strs/strings_pure.go delete mode 100644 vendor/google.golang.org/protobuf/internal/strs/strings_unsafe_go120.go delete mode 100644 vendor/google.golang.org/protobuf/internal/strs/strings_unsafe_go121.go delete mode 100644 vendor/google.golang.org/protobuf/internal/version/version.go delete mode 100644 vendor/google.golang.org/protobuf/proto/checkinit.go delete mode 100644 vendor/google.golang.org/protobuf/proto/decode.go delete mode 100644 vendor/google.golang.org/protobuf/proto/decode_gen.go delete mode 100644 vendor/google.golang.org/protobuf/proto/doc.go delete mode 100644 vendor/google.golang.org/protobuf/proto/encode.go delete mode 100644 vendor/google.golang.org/protobuf/proto/encode_gen.go delete mode 100644 vendor/google.golang.org/protobuf/proto/equal.go delete mode 100644 vendor/google.golang.org/protobuf/proto/extension.go delete mode 100644 vendor/google.golang.org/protobuf/proto/merge.go delete mode 100644 vendor/google.golang.org/protobuf/proto/messageset.go delete mode 100644 vendor/google.golang.org/protobuf/proto/proto.go delete mode 100644 vendor/google.golang.org/protobuf/proto/proto_methods.go delete mode 100644 vendor/google.golang.org/protobuf/proto/proto_reflect.go delete mode 100644 vendor/google.golang.org/protobuf/proto/reset.go delete mode 100644 vendor/google.golang.org/protobuf/proto/size.go delete mode 100644 vendor/google.golang.org/protobuf/proto/size_gen.go delete mode 100644 vendor/google.golang.org/protobuf/proto/wrappers.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protodesc/desc.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protodesc/editions.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protodesc/editions_defaults.binpb delete mode 100644 vendor/google.golang.org/protobuf/reflect/protodesc/proto.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/methods.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/source.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/type.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/value.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/value_equal.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go120.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe_go121.go delete mode 100644 vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go delete mode 100644 vendor/google.golang.org/protobuf/runtime/protoiface/legacy.go delete mode 100644 vendor/google.golang.org/protobuf/runtime/protoiface/methods.go delete mode 100644 vendor/google.golang.org/protobuf/runtime/protoimpl/impl.go delete mode 100644 vendor/google.golang.org/protobuf/runtime/protoimpl/version.go delete mode 100644 vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go delete mode 100644 vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go delete mode 100644 vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go delete mode 100644 vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go delete mode 100644 vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go delete mode 100644 vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go diff --git a/cmd/meroxa/flink/deploy.go b/cmd/meroxa/flink/deploy.go deleted file mode 100644 index 28ded0211..000000000 --- a/cmd/meroxa/flink/deploy.go +++ /dev/null @@ -1,160 +0,0 @@ -package flink - -import ( - "bufio" - "bytes" - "context" - "encoding/json" - "fmt" - "os" - "os/exec" - "path/filepath" - "regexp" - "strings" - - "github.com/google/uuid" - "github.com/meroxa/cli/log" - "github.com/meroxa/turbine-core/pkg/ir" - "golang.org/x/mod/semver" -) - -const ( - irFilename = "meroxa-ir.json" - majorJavaVersion = "v11" - modeEnvVar = "MEROXA_PLATFORM" - outputEnvVar = "MEROXA_OUTPUT" - irVal = "EMIT_IR" -) - -func doesJobUseMeroxaPlatform(ctx context.Context, jarPath string) (bool, error) { - // TODO: This approach is fine for now but may prove to be too naive in the future - // https://github.com/meroxa/product/issues/953 - cmd := exec.CommandContext(ctx, "jar", "-tf", jarPath) - output, err := cmd.Output() - if err != nil { - return false, err - } - - scanner := bufio.NewScanner(bytes.NewBuffer(output)) - scanner.Split(bufio.ScanLines) - - for scanner.Scan() { - if strings.Contains(scanner.Text(), "com.meroxa") { - return true, nil - } - } - - return false, nil -} - -func GetIRSpec(ctx context.Context, jarPath string, secrets map[string]string, l log.Logger) (*ir.DeploymentSpec, error) { - if os.Getenv("UNIT_TEST") != "" { - return nil, nil - } - - verifyJavaVersion(ctx, l) - - usesMeroxa, err := doesJobUseMeroxaPlatform(ctx, jarPath) - if err != nil { - return nil, err - } - - if !usesMeroxa { - return nil, nil - } - - cwd, err := os.Getwd() - if err != nil { - return nil, err - } - irFilepath := filepath.Join(cwd, irFilename) - - // The submitted jar is executed with some special env vars set to inform the `MeroxaExecutionEnvironment` to - // short circuit execution and emit an IR spec instead - // https://github.com/meroxa/flink-platform-prototype/blob/main/src/main/java/com/meroxa/flink/MeroxaExecutionEnvironment.java#L64-L69 - cmd := exec.CommandContext(ctx, "java", "-jar", jarPath) - cmd.Env = append( - cmd.Environ(), - fmt.Sprintf("%s=%s", modeEnvVar, irVal), - fmt.Sprintf("%s=%s", outputEnvVar, irFilename)) - output, err := cmd.CombinedOutput() // all java output goes to stderr, so that's fun - defer func() { - _ = os.Remove(irFilepath) - }() - if err != nil { - return nil, fmt.Errorf("%s\n%v", output, err) - } - - _, err = os.Stat(irFilepath) - if err != nil { - // @TODO try the docker way because the jar is skinny - // Otherwise, there are no Meroxa* classes in this main class - return nil, nil - } - - b, err := os.ReadFile(irFilepath) - if err != nil { - return nil, err - } - - // @TODO assess the scope of updating validateCollections to use the ConnectorSpec - var spec ir.DeploymentSpec - if err = json.Unmarshal(b, &spec); err != nil { - return nil, err - } - - spec.Secrets = secrets - // workarounds to validate spec - spec.Definition.Metadata.SpecVersion = ir.LatestSpecVersion - spec.Definition.Metadata.Turbine.Language = "js" // java and flink are not acceptable yet - spec.Definition.Metadata.Turbine.Version = majorJavaVersion - - // hardcode all sources to one destination as streams - destinationUUID := "" - var sourceUUIDs []string - for _, cs := range spec.Connectors { - if cs.Type == ir.ConnectorDestination { - destinationUUID = cs.UUID - } else { - sourceUUIDs = append(sourceUUIDs, cs.UUID) - } - } - - for _, u := range sourceUUIDs { - ss := ir.StreamSpec{ - UUID: uuid.New().String(), - FromUUID: u, - ToUUID: destinationUUID, - Name: u + "_" + destinationUUID, - } - spec.Streams = append(spec.Streams, ss) - } - return &spec, nil -} - -func verifyJavaVersion(ctx context.Context, l log.Logger) { - cmd := exec.CommandContext(ctx, "java", "-version") - output, err := cmd.CombinedOutput() - if err != nil { - l.Warnf(ctx, - "warning: unable to verify local Java version is compatible with the Meroxa Platform; jar's must be compiled for %s", - majorJavaVersion) - return - } - - // looks like 'openjdk version "11.0.19" 2023-04-18' - r := regexp.MustCompile(`version "([0-9.]+.[0-9.]+.[0-9.]+)"`) - matches := r.FindStringSubmatch(string(output)) - if len(matches) > 0 { - version := "v" + matches[1] - comparison := semver.Compare(semver.Major(version), majorJavaVersion) - if comparison == 0 { - return - } - l.Warnf(ctx, - "warning: local Java version %q is incompatible with the Meroxa Platform; jar's must be compiled for %s", - version, - majorJavaVersion) - } - return -} diff --git a/cmd/meroxa/global/basic_client.go b/cmd/meroxa/global/basic_client.go index 4c21011ec..e14b6199b 100644 --- a/cmd/meroxa/global/basic_client.go +++ b/cmd/meroxa/global/basic_client.go @@ -248,7 +248,6 @@ func (c *client) newRequestMultiPart( req.Header.Set("Authorization", accessToken) } - fmt.Println("Content-Type header already set.") } req.Header.Set("User-Agent", c.userAgent) @@ -313,7 +312,6 @@ func (c *client) newRequest( req.Header.Set("Authorization", accessToken) } - fmt.Println("Content-Type header already set.") } req.Header.Add("Content-Type", jsonContentType) req.Header.Add("Accept", jsonContentType) diff --git a/cmd/meroxa/root/apps/apps.go b/cmd/meroxa/root/apps/apps.go index 5a676698e..4ece6dc30 100644 --- a/cmd/meroxa/root/apps/apps.go +++ b/cmd/meroxa/root/apps/apps.go @@ -24,18 +24,11 @@ import ( "strconv" "time" - "github.com/meroxa/turbine-core/v2/pkg/ir" - "github.com/meroxa/cli/cmd/meroxa/builder" + "github.com/meroxa/cli/cmd/meroxa/global" - "github.com/meroxa/cli/cmd/meroxa/turbine" - turbineGo "github.com/meroxa/cli/cmd/meroxa/turbine/golang" - turbineJS "github.com/meroxa/cli/cmd/meroxa/turbine/javascript" - turbinePY "github.com/meroxa/cli/cmd/meroxa/turbine/python" - turbineRb "github.com/meroxa/cli/cmd/meroxa/turbine/ruby" pb "github.com/pocketbase/pocketbase/tools/types" - "github.com/meroxa/cli/log" "github.com/meroxa/cli/utils/display" "github.com/spf13/cobra" ) @@ -50,27 +43,36 @@ const ( ApplicationStateDegraded ApplicationState = "degraded" ApplicationStateFailed ApplicationState = "failed" - collectionName = "apps" + deploymentCollection = "conduitdeployments" + applicationCollection = "conduitapps" ) var displayDetails = display.Details{ - "Name": "name", - "State": "state", - "SpecVersion": "specVersion", - "Created": "created", - "Updated": "updated", + "Name": "name", + "State": "state", + "ApplicationSpec": "stream_tech", + "Config": "config", + "PipelineFilenames": "pipelines_filenames", + // "PipelineEnriched": "pipeline_enriched", + // "PipelineOriginal": "pipeline_original", + "Created": "created", + "Updated": "updated", } // Application represents the Meroxa Application type within the Meroxa API. type Application struct { - ID string `json:"id"` - Name string `json:"name"` - State ApplicationState `json:"state"` - Spec map[string]interface{} `json:"spec"` - SpecVersion string `json:"specVersion"` - Created AppTime `json:"created"` - Updated AppTime `json:"updated"` - Image string `json:"imageArchive"` + ID string `json:"id"` + Name string `json:"name"` + State string `json:"state"` + ApplicationSpec string `json:"stream_tech"` + Config string `json:"config"` + PipelineFilenames string `json:"pipeline_filenames"` + PipelineEnriched string `json:"pipeline_enriched"` + PipelineOriginal string `json:"pipeline_original"` + + Created AppTime `json:"created"` + Updated AppTime `json:"updated"` + Archive string `json:"archive"` } type Applications struct { @@ -126,7 +128,7 @@ func (*Apps) Usage() string { func (*Apps) Docs() builder.Docs { return builder.Docs{ - Short: "Manage Turbine Data Applications", + Short: "Manage Conduit Data Applications", } } @@ -142,43 +144,20 @@ func (*Apps) SubCommands() []*cobra.Command { } } -// getTurbineCLIFromLanguage will return the appropriate turbine.CLI based on language. -func getTurbineCLIFromLanguage(logger log.Logger, lang ir.Lang, path string) (turbine.CLI, error) { - switch lang { - case "go", turbine.GoLang: - return turbineGo.New(logger, path), nil - case "js", turbine.JavaScript, turbine.NodeJs: - return turbineJS.New(logger, path), nil - case "py", turbine.Python3, turbine.Python: - return turbinePY.New(logger, path), nil - case "rb", turbine.Ruby: - return turbineRb.New(logger, path), nil - } - return nil, newLangUnsupportedError(lang) -} - type appsClient interface { AddHeader(string, string) } -func addTurbineHeaders(c appsClient, lang ir.Lang, version string) { - c.AddHeader("Meroxa-CLI-App-Lang", string(lang)) - if lang == ir.JavaScript { - version = fmt.Sprintf("%s:cli%s", version, turbineJS.TurbineJSVersion) - } - c.AddHeader("Meroxa-CLI-App-Version", version) -} - func RetrieveApplicationByNameOrID(ctx context.Context, client global.BasicClient, nameOrID, path string) (*Applications, error) { var getPath string apps := Applications{} if path != "" { var err error - if getPath, err = turbine.GetPath(path); err != nil { + if getPath, err = GetPath(path); err != nil { return nil, err } - config, err := turbine.ReadConfigFile(getPath) + config, err := ReadConfigFile(getPath) if err != nil { return nil, err } @@ -186,7 +165,7 @@ func RetrieveApplicationByNameOrID(ctx context.Context, client global.BasicClien a := &url.Values{} a.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", config.Name, config.Name)) - response, err := client.CollectionRequest(ctx, "GET", collectionName, "", nil, *a) + response, err := client.CollectionRequest(ctx, "GET", applicationCollection, "", nil, *a) if err != nil { return nil, err } @@ -198,7 +177,7 @@ func RetrieveApplicationByNameOrID(ctx context.Context, client global.BasicClien a := &url.Values{} a.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", nameOrID, nameOrID)) - response, err := client.CollectionRequest(ctx, "GET", collectionName, "", nil, *a) + response, err := client.CollectionRequest(ctx, "GET", applicationCollection, "", nil, *a) if err != nil { return nil, err } diff --git a/cmd/meroxa/root/apps/deploy.go b/cmd/meroxa/root/apps/deploy.go index 2691d857a..3bad9df29 100644 --- a/cmd/meroxa/root/apps/deploy.go +++ b/cmd/meroxa/root/apps/deploy.go @@ -17,6 +17,8 @@ limitations under the License. package apps import ( + "archive/tar" + "bytes" "compress/gzip" "context" "encoding/json" @@ -24,45 +26,39 @@ import ( "io" "net/http" "os" - "os/exec" "path/filepath" - "regexp" - "strings" "time" "github.com/meroxa/cli/cmd/meroxa/builder" "github.com/meroxa/cli/cmd/meroxa/global" - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/config" "github.com/meroxa/cli/log" - "github.com/meroxa/turbine-core/v2/pkg/ir" ) type Deploy struct { flags struct { Path string `long:"path" usage:"Path to the app directory (default is local directory)"` - Spec string `long:"spec" usage:"Deployment specification version to use to build and deploy the app" hidden:"true"` } - client global.BasicClient - config config.Config - logger log.Logger - turbineCLI turbine.CLI - appConfig *turbine.AppConfig - configAppName string - appName string - gitBranch string - path string - lang ir.Lang - fnName string // is this still necessary? - appTarName string - specVersion string - gitSha string + client global.BasicClient + logger log.Logger + appName string + path string + gitSha string +} + +type ApplicationDeployment struct { + ID string `json:"id"` + State ApplicationState `json:"state"` + ApplicationSpec map[string]interface{} `json:"app_spec"` + ProcessorsPlugins map[string]interface{} `json:"processors_plugins"` + PipelineFilenames map[string]interface{} `json:"pipelines_filenames"` + Created AppTime `json:"created"` + Updated AppTime `json:"updated"` + Archive string `json:"archive"` } var ( _ builder.CommandWithBasicClient = (*Deploy)(nil) - _ builder.CommandWithConfig = (*Deploy)(nil) _ builder.CommandWithDocs = (*Deploy)(nil) _ builder.CommandWithExecute = (*Deploy)(nil) _ builder.CommandWithFlags = (*Deploy)(nil) @@ -75,7 +71,7 @@ func (*Deploy) Usage() string { func (*Deploy) Docs() builder.Docs { return builder.Docs{ - Short: "Deploy a Turbine Data Application", + Short: "Deploy a Conduit Data Application", Long: `This command will deploy the application specified in '--path' (or current working directory if not specified) to our Meroxa Platform. If deployment was successful, you should expect an application you'll be able to fully manage @@ -86,10 +82,6 @@ meroxa apps deploy --path ./my-app } } -func (d *Deploy) Config(cfg config.Config) { - d.config = cfg -} - func (d *Deploy) BasicClient(client global.BasicClient) { d.client = client @@ -107,320 +99,99 @@ func (d *Deploy) Logger(logger log.Logger) { d.logger = logger } -func (d *Deploy) getPlatformImage(ctx context.Context) error { - var ( - err error - buildPath string - ) - - d.logger.StartSpinner("\t", fmt.Sprintf("Creating Dockerfile before uploading source in %s", d.path)) - buildPath, err = d.turbineCLI.CreateDockerfile(ctx, d.appName) - if err != nil { - return err - } - defer d.turbineCLI.CleanupDockerfile(d.logger, d.path) - d.logger.StopSpinnerWithStatus("Dockerfile created", log.Successful) - - d.appTarName = fmt.Sprintf("turbine-%s.tar.gz", d.appName) - - if err = d.buildAndRunImage(ctx); err != nil { - return err - } - - d.logger.StartSpinner("\t", fmt.Sprintf("Saving and uploading %q image", d.appName)) - - if err = d.saveImageAsTar(ctx); err != nil { - return err - } - - d.logger.StopSpinnerWithStatus(fmt.Sprintf("%q successfully created in %q", d.appTarName, buildPath), log.Successful) - return nil -} - -func (d *Deploy) runDockerImage(ctx context.Context) error { - // docker run -d --rm -p 8080:80 -t simple-with-process-mdpx-demo - cmd := exec.CommandContext( - ctx, - "docker", - "run", - "-d", - "--rm", - "-p", - "8080:8080", - "-t", - d.appName, - ) - - cmd.Dir = d.path - cmd.Env = os.Environ() - - out, err := cmd.CombinedOutput() - if err != nil { - return fmt.Errorf("\ndocker run failed: %v", string(out)) - } - return nil -} - -func (d *Deploy) buildAndRunImage(ctx context.Context) error { - d.logger.StartSpinner("\t", fmt.Sprintf("Creating function image in %s", d.path)) - cmd := exec.CommandContext( - ctx, - "docker", - "build", - "-t", - d.appName, - ".", - ) - - cmd.Dir = d.path - cmd.Env = os.Environ() - - out, err := cmd.CombinedOutput() - if err != nil { - return fmt.Errorf("\ndocker build failed: %v", string(out)) - } - - d.fnName = d.appName - - return d.runDockerImage(ctx) -} - -func (d *Deploy) saveImageAsTar(ctx context.Context) error { - app := fmt.Sprintf("%s:latest", d.appName) - appTar := fmt.Sprintf("%s.tar", d.appName) - cmd := exec.CommandContext( - ctx, - "docker", - "save", - "-o", - appTar, - app, - ) - - cmd.Dir = d.path - cmd.Env = os.Environ() - out, err := cmd.CombinedOutput() - if err != nil { - return fmt.Errorf("\ndocker run failed: %v - %v", err.Error(), string(out)) - } - - err = d.gzipImageTar(ctx, appTar) - return err -} - -func (d *Deploy) gzipImageTar(_ context.Context, appTar string) error { - reader, err := os.Open(filepath.Join(d.path, appTar)) - if err != nil { - return err - } - - filename := filepath.Base(filepath.Join(d.path, appTar)) - target := filepath.Join(d.path, d.appTarName) - writer, err := os.Create(target) - if err != nil { - return err - } - defer writer.Close() - - archiver := gzip.NewWriter(writer) - archiver.Name = filename - defer archiver.Close() - - _, err = io.Copy(archiver, reader) - if err != nil { - return err - } - - err = os.Remove(filepath.Join(d.path, appTar)) - return err -} - -// validateLanguage stops execution of the deployment in case language is not supported. -// It also consolidates lang used in API in case user specified a supported language using an unexpected name. -func (d *Deploy) validateLanguage() error { - switch d.lang { - case "go", turbine.GoLang: - d.lang = ir.GoLang - case "js", turbine.JavaScript, turbine.NodeJs: - d.lang = ir.JavaScript - case "py", turbine.Python3, turbine.Python: - d.lang = ir.Python - case "rb", turbine.Ruby: - d.lang = ir.Ruby - default: - return newLangUnsupportedError(d.lang) - } - return nil -} - -// readFromAppJSON will validate app JSON provided by customer has the right formation including supported language. -func (d *Deploy) readFromAppJSON(ctx context.Context) error { - var err error - - d.logger.Info(ctx, "Validating your app.json...") +func (d *Deploy) gzipConduitApp(src string, buf io.Writer) error { + zr := gzip.NewWriter(buf) + tw := tar.NewWriter(zr) - if d.path, err = turbine.GetPath(d.flags.Path); err != nil { - return err - } - - // exit early if app config is loaded - if d.appConfig != nil { - return d.validateLanguage() - } - - d.lang, err = turbine.GetLangFromAppJSON(d.logger, d.path) - if err != nil { - return err - } - - d.configAppName, err = turbine.GetAppNameFromAppJSON(d.logger, d.path) - if err != nil { - return err - } - if d.appConfig, err = turbine.ReadConfigFile(d.path); err != nil { - return err - } - - if d.gitBranch, err = turbine.GetGitBranch(d.path); err != nil { - return err - } - d.appName = d.prepareAppName(ctx) - - return nil -} - -func (d *Deploy) prepareAppName(ctx context.Context) string { - if turbine.GitMainBranch(d.gitBranch) { - return d.configAppName - } - - // git branch names can contain a lot of characters that make Docker unhappy - reg := regexp.MustCompile("[^a-z0-9-_]+") - sanitizedBranch := reg.ReplaceAllString(strings.ToLower(d.gitBranch), "-") - appName := fmt.Sprintf("%s-%s", d.configAppName, sanitizedBranch) - d.logger.Infof( - ctx, - "\t%s Feature branch (%s) detected, setting app name to %s...", - d.logger.SuccessfulCheck(), - d.gitBranch, - appName, - ) - - return appName -} - -func (d *Deploy) assignDeploymentValues(ctx context.Context) error { - var err error - - // Always default to the latest spec version. - d.specVersion = ir.LatestSpecVersion + // walk through every file in the folder + filepath.Walk(src, func(file string, fi os.FileInfo, err error) error { + // generate tar header + header, err := tar.FileInfoHeader(fi, file) + if err != nil { + return err + } - if d.flags.Spec != "" { - d.specVersion = d.flags.Spec - } + header.Name = filepath.ToSlash(file) - if err = ir.ValidateSpecVersion(d.specVersion); err != nil { - return err - } + // write header + if err := tw.WriteHeader(header); err != nil { + return err + } + // if not a dir, write file content + if !fi.IsDir() { + data, err := os.Open(file) + if err != nil { + return err + } + if _, err := io.Copy(tw, data); err != nil { + return err + } + } + return nil + }) - if err = d.readFromAppJSON(ctx); err != nil { + if err := tw.Close(); err != nil { return err } - - if d.turbineCLI, err = getTurbineCLIFromLanguage(d.logger, d.lang, d.path); err != nil { + if err := zr.Close(); err != nil { return err } - + // return nil } func (d *Deploy) getGitInfo(ctx context.Context) error { var err error - - if err = d.turbineCLI.CheckUncommittedChanges(ctx, d.logger, d.path); err != nil { + if err = CheckUncommittedChanges(ctx, d.logger, d.path); err != nil { return err } - d.gitSha, err = d.turbineCLI.GetGitSha(ctx, d.path) + d.gitSha, err = GetGitSha(ctx, d.path) return err } -func (d *Deploy) createApplicationRequest(ctx context.Context) (*Application, error) { - specStr, err := d.turbineCLI.GetDeploymentSpec(ctx, d.fnName) - if err != nil { - return nil, err - } - var spec map[string]interface{} - if specStr != "" { - if unmarshalErr := json.Unmarshal([]byte(specStr), &spec); unmarshalErr != nil { - return nil, fmt.Errorf("failed to parse deployment spec into json") - } - } - return &Application{ - Name: d.appName, - SpecVersion: d.specVersion, - Spec: spec, - }, nil -} - func (d *Deploy) Execute(ctx context.Context) error { var err error - if err = d.assignDeploymentValues(ctx); err != nil { + if err = d.getGitInfo(ctx); err != nil { //nolint:shadow return err } - turbineLibVersion, err := d.turbineCLI.GetVersion(ctx) + d.path, err = GetPath(d.flags.Path) if err != nil { return err } - addTurbineHeaders(d.client, d.lang, turbineLibVersion) - if err = d.getGitInfo(ctx); err != nil { //nolint:shadow - return err - } + fmt.Println(d.path) - gracefulStop, err := d.turbineCLI.StartGrpcServer(ctx, d.gitSha) - if err != nil { - return err - } - defer gracefulStop() + var buf bytes.Buffer + d.gzipConduitApp(d.path, &buf) - input, err := d.createApplicationRequest(ctx) + // write the .tar.gzip + file, err := os.CreateTemp("", "temp_conduit.tar.gzip") if err != nil { - return err + panic(err) + } + if _, err := io.Copy(file, &buf); err != nil { + panic(err) } - /* TODO: Enable when function integration is done - - d.logger.Infof(ctx, "Preparing to deploy application %q...", d.appName) - - if err = d.getPlatformImage(ctx); err != nil { - return err - } - - file := filepath.Join(d.path, d.appTarName) - if _, err = os.Stat(file); err != nil { - if errors.Is(err, os.ErrNotExist) { - return fmt.Errorf("turbine archive %q does not exist: %w", file, err) - } - - return err - } + fmt.Println(file.Name()) + files := map[string]string{ + "archive": file.Name(), + } - files := map[string]string{ - "imageArchive": file, - } - */ + fmt.Println(files) response, err := d.client.CollectionRequestMultipart( ctx, http.MethodPost, - collectionName, + deploymentCollection, "", - input, nil, - map[string]string{}, // TODO: change back to files from above + nil, + // map[string]string{}, + files, ) if err != nil { return err @@ -433,10 +204,10 @@ func (d *Deploy) Execute(ctx context.Context) error { } dashboardURL := fmt.Sprintf("%s/apps/%s/detail", global.GetMeroxaAPIURL(), apps.ID) - output := fmt.Sprintf("Application %q successfully deployed!\n\n ✨ To view your application, visit %s", + fmt.Sprintf("Application %q successfully deployed!\n\n ✨ To view your application, visit %s", d.appName, dashboardURL) - d.logger.StopSpinnerWithStatus(output, log.Successful) + //d.logger.StopSpinnerWithStatus(output, log.Successful) return nil } diff --git a/cmd/meroxa/root/apps/deploy_test.go b/cmd/meroxa/root/apps/deploy_test.go index 0cbcc16e0..5463e9a7f 100644 --- a/cmd/meroxa/root/apps/deploy_test.go +++ b/cmd/meroxa/root/apps/deploy_test.go @@ -1,172 +1,172 @@ package apps -import ( - "context" - "fmt" - "testing" - - basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock" - turbineMock "github.com/meroxa/cli/cmd/meroxa/turbine/mock" - - "github.com/golang/mock/gomock" - "github.com/meroxa/cli/cmd/meroxa/builder" - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/log" - "github.com/meroxa/cli/utils" - "github.com/meroxa/turbine-core/v2/pkg/ir" - "github.com/stretchr/testify/require" -) - -func TestDeployAppFlags(t *testing.T) { - expectedFlags := []struct { - name string - required bool - shorthand string - hidden bool - }{ - {name: "path", required: false}, - {name: "spec", required: false, hidden: true}, - } - - c := builder.BuildCobraCommand(&Deploy{}) - - for _, f := range expectedFlags { - cf := c.Flags().Lookup(f.name) - if cf == nil { - t.Fatalf("expected flag \"%s\" to be present", f.name) - } - - if f.shorthand != cf.Shorthand { - t.Fatalf("expected shorthand \"%s\" got \"%s\" for flag \"%s\"", f.shorthand, cf.Shorthand, f.name) - } - - if f.required && !utils.IsFlagRequired(cf) { - t.Fatalf("expected flag \"%s\" to be required", f.name) - } - - if cf.Hidden != f.hidden { - if cf.Hidden { - t.Fatalf("expected flag \"%s\" not to be hidden", f.name) - } else { - t.Fatalf("expected flag \"%s\" to be hidden", f.name) - } - } - } -} - -func TestValidateLanguage(t *testing.T) { - tests := []struct { - name string - languages []ir.Lang - wantErr bool - }{ - { - name: "Successfully validate golang", - languages: []ir.Lang{"go", "golang"}, - }, - { - name: "Successfully validate javascript", - languages: []ir.Lang{"js", "javascript", "nodejs"}, - }, - { - name: "Successfully validate python", - languages: []ir.Lang{"py", "python", "python3"}, - }, - { - name: "Successfully validate ruby", - languages: []ir.Lang{"rb", "ruby"}, - }, - { - name: "Reject unsupported languages", - languages: []ir.Lang{"cobol", "crystal", "g@rbAg3"}, - wantErr: true, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - for _, lang := range tc.languages { - test := Deploy{lang: lang} - err := test.validateLanguage() - - if err != nil { - require.Equal(t, newLangUnsupportedError(lang), err) - } else { - require.Equal(t, tc.wantErr, err != nil) - } - } - }) - } -} - -func TestGetPlatformImage(t *testing.T) { - t.Skipf("Update this test based on latest implementation") - ctx := context.Background() - logger := log.NewTestLogger() - appName := "my-app" - buildPath := "" - err := fmt.Errorf("nope") - - tests := []struct { - name string - meroxaClient func(*gomock.Controller) *basicMock.MockBasicClient - mockTurbineCLI func(*gomock.Controller) turbine.CLI - err error - }{ - { - name: "Successfully get platform image", - meroxaClient: func(ctrl *gomock.Controller) *basicMock.MockBasicClient { - client := basicMock.NewMockBasicClient(ctrl) - // client.EXPECT().CollectionRequest(ctx, "POST", "apps", "", nil, nil, &Application{}) - return client - }, - mockTurbineCLI: func(ctrl *gomock.Controller) turbine.CLI { - mockTurbineCLI := turbineMock.NewMockCLI(ctrl) - mockTurbineCLI.EXPECT(). - CreateDockerfile(ctx, appName). - Return(buildPath, nil) - mockTurbineCLI.EXPECT(). - CleanupDockerfile(logger, buildPath). - Return() - return mockTurbineCLI - }, - err: nil, - }, - { - name: "Fail to get platform image", - meroxaClient: func(ctrl *gomock.Controller) *basicMock.MockBasicClient { - client := basicMock.NewMockBasicClient(ctrl) - // client.EXPECT().CollectionRequest(ctx, "POST", "apps", "", nil, nil, &Application{}) - return client - }, - mockTurbineCLI: func(ctrl *gomock.Controller) turbine.CLI { - mockTurbineCLI := turbineMock.NewMockCLI(ctrl) - mockTurbineCLI.EXPECT(). - CreateDockerfile(ctx, appName). - Return("", err) - return mockTurbineCLI - }, - err: err, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - ctrl := gomock.NewController(t) - d := &Deploy{ - client: tc.meroxaClient(ctrl), - turbineCLI: tc.mockTurbineCLI(ctrl), - logger: logger, - appName: appName, - } - - err := d.getPlatformImage(ctx) - if err != nil { - require.NotEmpty(t, tc.err) - require.Equal(t, tc.err, err) - } else { - require.Empty(t, tc.err) - } - }) - } -} +// import ( +// "context" +// "fmt" +// "testing" + +// basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock" +// turbineMock "github.com/meroxa/cli/cmd/meroxa/turbine/mock" + +// "github.com/golang/mock/gomock" +// "github.com/meroxa/cli/cmd/meroxa/builder" +// "github.com/meroxa/cli/cmd/meroxa/turbine" +// "github.com/meroxa/cli/log" +// "github.com/meroxa/cli/utils" +// "github.com/meroxa/turbine-core/v2/pkg/ir" +// "github.com/stretchr/testify/require" +// ) + +// func TestDeployAppFlags(t *testing.T) { +// expectedFlags := []struct { +// name string +// required bool +// shorthand string +// hidden bool +// }{ +// {name: "path", required: false}, +// {name: "spec", required: false, hidden: true}, +// } + +// c := builder.BuildCobraCommand(&Deploy{}) + +// for _, f := range expectedFlags { +// cf := c.Flags().Lookup(f.name) +// if cf == nil { +// t.Fatalf("expected flag \"%s\" to be present", f.name) +// } + +// if f.shorthand != cf.Shorthand { +// t.Fatalf("expected shorthand \"%s\" got \"%s\" for flag \"%s\"", f.shorthand, cf.Shorthand, f.name) +// } + +// if f.required && !utils.IsFlagRequired(cf) { +// t.Fatalf("expected flag \"%s\" to be required", f.name) +// } + +// if cf.Hidden != f.hidden { +// if cf.Hidden { +// t.Fatalf("expected flag \"%s\" not to be hidden", f.name) +// } else { +// t.Fatalf("expected flag \"%s\" to be hidden", f.name) +// } +// } +// } +// } + +// func TestValidateLanguage(t *testing.T) { +// tests := []struct { +// name string +// languages []ir.Lang +// wantErr bool +// }{ +// { +// name: "Successfully validate golang", +// languages: []ir.Lang{"go", "golang"}, +// }, +// { +// name: "Successfully validate javascript", +// languages: []ir.Lang{"js", "javascript", "nodejs"}, +// }, +// { +// name: "Successfully validate python", +// languages: []ir.Lang{"py", "python", "python3"}, +// }, +// { +// name: "Successfully validate ruby", +// languages: []ir.Lang{"rb", "ruby"}, +// }, +// { +// name: "Reject unsupported languages", +// languages: []ir.Lang{"cobol", "crystal", "g@rbAg3"}, +// wantErr: true, +// }, +// } + +// for _, tc := range tests { +// t.Run(tc.name, func(t *testing.T) { +// for _, lang := range tc.languages { +// test := Deploy{lang: lang} +// err := test.validateLanguage() + +// if err != nil { +// require.Equal(t, newLangUnsupportedError(lang), err) +// } else { +// require.Equal(t, tc.wantErr, err != nil) +// } +// } +// }) +// } +// } + +// func TestGetPlatformImage(t *testing.T) { +// t.Skipf("Update this test based on latest implementation") +// ctx := context.Background() +// logger := log.NewTestLogger() +// appName := "my-app" +// buildPath := "" +// err := fmt.Errorf("nope") + +// tests := []struct { +// name string +// meroxaClient func(*gomock.Controller) *basicMock.MockBasicClient +// mockTurbineCLI func(*gomock.Controller) turbine.CLI +// err error +// }{ +// { +// name: "Successfully get platform image", +// meroxaClient: func(ctrl *gomock.Controller) *basicMock.MockBasicClient { +// client := basicMock.NewMockBasicClient(ctrl) +// // client.EXPECT().CollectionRequest(ctx, "POST", "apps", "", nil, nil, &Application{}) +// return client +// }, +// mockTurbineCLI: func(ctrl *gomock.Controller) turbine.CLI { +// mockTurbineCLI := turbineMock.NewMockCLI(ctrl) +// mockTurbineCLI.EXPECT(). +// CreateDockerfile(ctx, appName). +// Return(buildPath, nil) +// mockTurbineCLI.EXPECT(). +// CleanupDockerfile(logger, buildPath). +// Return() +// return mockTurbineCLI +// }, +// err: nil, +// }, +// { +// name: "Fail to get platform image", +// meroxaClient: func(ctrl *gomock.Controller) *basicMock.MockBasicClient { +// client := basicMock.NewMockBasicClient(ctrl) +// // client.EXPECT().CollectionRequest(ctx, "POST", "apps", "", nil, nil, &Application{}) +// return client +// }, +// mockTurbineCLI: func(ctrl *gomock.Controller) turbine.CLI { +// mockTurbineCLI := turbineMock.NewMockCLI(ctrl) +// mockTurbineCLI.EXPECT(). +// CreateDockerfile(ctx, appName). +// Return("", err) +// return mockTurbineCLI +// }, +// err: err, +// }, +// } + +// for _, tc := range tests { +// t.Run(tc.name, func(t *testing.T) { +// ctrl := gomock.NewController(t) +// d := &Deploy{ +// client: tc.meroxaClient(ctrl), +// turbineCLI: tc.mockTurbineCLI(ctrl), +// logger: logger, +// appName: appName, +// } + +// err := d.getPlatformImage(ctx) +// if err != nil { +// require.NotEmpty(t, tc.err) +// require.Equal(t, tc.err, err) +// } else { +// require.Empty(t, tc.err) +// } +// }) +// } +// } diff --git a/cmd/meroxa/root/apps/describe.go b/cmd/meroxa/root/apps/describe.go index 1a9b5d252..c720c4cc8 100644 --- a/cmd/meroxa/root/apps/describe.go +++ b/cmd/meroxa/root/apps/describe.go @@ -22,10 +22,8 @@ import ( "github.com/meroxa/cli/cmd/meroxa/builder" "github.com/meroxa/cli/cmd/meroxa/global" - "github.com/meroxa/cli/cmd/meroxa/turbine" "github.com/meroxa/cli/log" "github.com/meroxa/cli/utils/display" - "github.com/meroxa/turbine-core/v2/pkg/ir" ) var ( @@ -38,11 +36,9 @@ var ( ) type Describe struct { - client global.BasicClient - logger log.Logger - turbineCLI turbine.CLI - lang ir.Lang - args struct { + client global.BasicClient + logger log.Logger + args struct { nameOrUUID string } flags struct { @@ -60,7 +56,7 @@ func (d *Describe) Flags() []builder.Flag { func (d *Describe) Docs() builder.Docs { return builder.Docs{ - Short: "Describe a Turbine Data Application", + Short: "Describe a Conduit Data Application", Long: `This command will fetch details about the Application specified in '--path' (or current working directory if not specified) on our Meroxa Platform, or the Application specified by the given ID or Application Name.`, @@ -75,26 +71,6 @@ func (d *Describe) Execute(ctx context.Context) error { apps := &Applications{} var err error - config, err := turbine.ReadConfigFile(d.flags.Path) - if err != nil { - return err - } - d.lang = config.Language - - if d.turbineCLI == nil { - if d.turbineCLI, err = getTurbineCLIFromLanguage(d.logger, d.lang, d.flags.Path); err != nil { - if err != nil { - return err - } - } - } - - turbineVersion, err := d.turbineCLI.GetVersion(ctx) - if err != nil { - return err - } - addTurbineHeaders(d.client, d.lang, turbineVersion) - apps, err = RetrieveApplicationByNameOrID(ctx, d.client, d.args.nameOrUUID, d.flags.Path) if err != nil { return err @@ -103,7 +79,7 @@ func (d *Describe) Execute(ctx context.Context) error { for _, app := range apps.Items { d.logger.Info(ctx, display.PrintTable(app, displayDetails)) d.logger.JSON(ctx, app) - dashboardURL := fmt.Sprintf("%s/apps/%s/detail", global.GetMeroxaAPIURL(), app.ID) + dashboardURL := fmt.Sprintf("%s/conduitapps/%s/detail", global.GetMeroxaAPIURL(), app.ID) d.logger.Info(ctx, fmt.Sprintf("\n ✨ To view your application, visit %s", dashboardURL)) } diff --git a/cmd/meroxa/root/apps/describe_test.go b/cmd/meroxa/root/apps/describe_test.go index 6d0b3ad57..9b8c8d06a 100644 --- a/cmd/meroxa/root/apps/describe_test.go +++ b/cmd/meroxa/root/apps/describe_test.go @@ -16,220 +16,220 @@ limitations under the License. package apps -import ( - "context" - "encoding/json" - "errors" - "fmt" - "io" - "net/http" - "net/url" - "os" - "path/filepath" - "strings" - "testing" - - "github.com/google/uuid" - basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock" - turbineMock "github.com/meroxa/cli/cmd/meroxa/turbine/mock" - "github.com/meroxa/turbine-core/pkg/ir" - "github.com/stretchr/testify/require" - - "github.com/golang/mock/gomock" - - "github.com/meroxa/cli/log" -) - -const ( - body = `{ - "page":1, - "perPage":30, - "totalItems":1, - "totalPages":1, - "items":[ - { - "collectionId":"gnhz55oi6tulkvs", - "collectionName":"apps", - "created":"2023-10-25 22:40:21.297Z", - "id":"b0p2ok0dcjisn4z", - "name":"my-env", - "specVersion":"0.2.0", - "state":"running", - "updated":"2023-10-25 22:40:21.297Z", - "spec":{ - "connectors":[ - { - "collection":"collection_name", - "resource":"source_name", - "type":"source", - "uuid":"5ce244be-e404-4fc1-b486-a35ee200fd27" - }, - { - "collection":"collection_archive", - "resource":"destination_name", - "type":"destination", - "uuid":"0362c2df-6e99-445e-b95e-a798e69a651f" - } - ], - "definition":{ - "git_sha":"f7baf1e05df0becdf946847b8f7411d22988a3d7\n", - "metadata":{ - "spec_version":"0.2.0", - "turbine":{ - "language":"golang", - "version":"v2.1.3" - } - } - }, - "functions":[ - { - "image":"turbine-newgo.tar.gz", - "name":"anonymize", - "uuid":"04b0d690-dd44-4df3-8636-6f0c4dfb5c93" - } - ], - "streams":[ - { - "from_uuid":"5ce244be-e404-4fc1-b486-a35ee200fd27", - "name":"5ce244be-e404-4fc1-b486-a35ee200fd27_04b0d690-dd44-4df3-8636-6f0c4dfb5c93", - "to_uuid":"04b0d690-dd44-4df3-8636-6f0c4dfb5c93", - "uuid":"ef1e3681-fbaa-4bff-9d21-6e010bcdec3e" - }, - { - "from_uuid":"04b0d690-dd44-4df3-8636-6f0c4dfb5c93", - "name":"04b0d690-dd44-4df3-8636-6f0c4dfb5c93_0362c2df-6e99-445e-b95e-a798e69a651f", - "to_uuid":"0362c2df-6e99-445e-b95e-a798e69a651f", - "uuid":"06c89e49-753d-4a54-81f1-ee1e036003e6" - } - ] - } - } - ] - }` -) - -func TestDescribeApplicationArgs(t *testing.T) { - tests := []struct { - args []string - err error - name string - }{ - {args: nil, err: errors.New("requires app name or UUID"), name: ""}, - {args: []string{"ApplicationName"}, err: nil, name: "ApplicationName"}, - } - - for _, tt := range tests { - ar := &Describe{} - err := ar.ParseArgs(tt.args) - - if err != nil && tt.err.Error() != err.Error() { - t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) - } - - if tt.name != ar.args.nameOrUUID { - t.Fatalf("expected \"%s\" got \"%s\"", tt.name, ar.args.nameOrUUID) - } - } -} - -func TestDescribeApplicationExecution(t *testing.T) { - ctx := context.Background() - ctrl := gomock.NewController(t) - client := basicMock.NewMockBasicClient(ctrl) - logger := log.NewTestLogger() - mockTurbineCLI := turbineMock.NewMockCLI(ctrl) - - path := filepath.Join(os.TempDir(), uuid.NewString()) - appName := "my-env" - appTime := AppTime{} - err := appTime.UnmarshalJSON([]byte(`"2023-10-25 22:40:21.297Z"`)) - if err != nil { - t.Fatalf("not expected error, got \"%s\"", err.Error()) - } - - i := &Init{ - logger: logger, - args: struct{ appName string }{appName: appName}, - flags: struct { - Lang string "long:\"lang\" short:\"l\" usage:\"language to use (js|go|py)\" required:\"true\"" - Path string "long:\"path\" usage:\"path where application will be initialized (current directory as default)\"" - ModVendor bool "long:\"mod-vendor\" usage:\"whether to download modules to vendor or globally while initializing a Go application\"" - SkipModInit bool "long:\"skip-mod-init\" usage:\"whether to run 'go mod init' while initializing a Go application\"" - }{ - Lang: string(ir.GoLang), - Path: path, - ModVendor: false, - SkipModInit: true, - }, - } - - a := &Application{ - Name: appName, - State: "running", - SpecVersion: "0.2.0", - Created: appTime, - Updated: appTime, - } - - err = i.Execute(ctx) - defer func(path string) { - os.RemoveAll(path) - }(path) - require.NoError(t, err) - - filter := &url.Values{} - filter.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", a.Name, a.Name)) - - httpResp := &http.Response{ - Body: io.NopCloser(strings.NewReader(body)), - Status: "200 OK", - StatusCode: 200, - } - client.EXPECT().CollectionRequest(ctx, "GET", collectionName, "", nil, *filter).Return( - httpResp, - nil, - ) - - mockTurbineCLI.EXPECT().GetVersion(ctx).Return("1.0", nil) - client.EXPECT().AddHeader("Meroxa-CLI-App-Lang", string(ir.GoLang)).Times(1) - client.EXPECT().AddHeader("Meroxa-CLI-App-Version", gomock.Any()).Times(1) - - dc := &Describe{ - client: client, - logger: logger, - turbineCLI: mockTurbineCLI, - args: struct{ nameOrUUID string }{nameOrUUID: a.Name}, - flags: struct { - Path string "long:\"path\" usage:\"Path to the app directory (default is local directory)\"" - }{Path: filepath.Join(path, appName)}, - } - - err = dc.Execute(ctx) - if err != nil { - t.Fatalf("not expected error, got %q", err.Error()) - } - - gotJSONOutput := logger.JSONOutput() - - var gotApp Application - err = json.Unmarshal([]byte(gotJSONOutput), &gotApp) - if err != nil { - t.Fatalf("not expected error, got %q", err.Error()) - } - - if gotApp.Name != a.Name { - t.Fatalf("expected \"%s\" got \"%s\"", a.Name, gotApp.Name) - } - if gotApp.SpecVersion != a.SpecVersion { - t.Fatalf("expected \"%s\" got \"%s\"", a.SpecVersion, gotApp.SpecVersion) - } - if gotApp.State != a.State { - t.Fatalf("expected \"%s\" got \"%s\"", a.State, gotApp.State) - } - if gotApp.Created.String() != a.Created.String() { - t.Fatalf("expected \"%s\" got \"%s\"", a.Created.String(), gotApp.Created.String()) - } - if gotApp.Updated.String() != a.Updated.String() { - t.Fatalf("expected \"%s\" got \"%s\"", a.Updated.String(), gotApp.Updated.String()) - } -} +// import ( +// "context" +// "encoding/json" +// "errors" +// "fmt" +// "io" +// "net/http" +// "net/url" +// "os" +// "path/filepath" +// "strings" +// "testing" + +// "github.com/google/uuid" +// basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock" +// turbineMock "github.com/meroxa/cli/cmd/meroxa/turbine/mock" +// "github.com/meroxa/turbine-core/pkg/ir" +// "github.com/stretchr/testify/require" + +// "github.com/golang/mock/gomock" + +// "github.com/meroxa/cli/log" +// ) + +// const ( +// body = `{ +// "page":1, +// "perPage":30, +// "totalItems":1, +// "totalPages":1, +// "items":[ +// { +// "collectionId":"gnhz55oi6tulkvs", +// "collectionName":"apps", +// "created":"2023-10-25 22:40:21.297Z", +// "id":"b0p2ok0dcjisn4z", +// "name":"my-env", +// "specVersion":"0.2.0", +// "state":"running", +// "updated":"2023-10-25 22:40:21.297Z", +// "spec":{ +// "connectors":[ +// { +// "collection":"collection_name", +// "resource":"source_name", +// "type":"source", +// "uuid":"5ce244be-e404-4fc1-b486-a35ee200fd27" +// }, +// { +// "collection":"collection_archive", +// "resource":"destination_name", +// "type":"destination", +// "uuid":"0362c2df-6e99-445e-b95e-a798e69a651f" +// } +// ], +// "definition":{ +// "git_sha":"f7baf1e05df0becdf946847b8f7411d22988a3d7\n", +// "metadata":{ +// "spec_version":"0.2.0", +// "turbine":{ +// "language":"golang", +// "version":"v2.1.3" +// } +// } +// }, +// "functions":[ +// { +// "image":"turbine-newgo.tar.gz", +// "name":"anonymize", +// "uuid":"04b0d690-dd44-4df3-8636-6f0c4dfb5c93" +// } +// ], +// "streams":[ +// { +// "from_uuid":"5ce244be-e404-4fc1-b486-a35ee200fd27", +// "name":"5ce244be-e404-4fc1-b486-a35ee200fd27_04b0d690-dd44-4df3-8636-6f0c4dfb5c93", +// "to_uuid":"04b0d690-dd44-4df3-8636-6f0c4dfb5c93", +// "uuid":"ef1e3681-fbaa-4bff-9d21-6e010bcdec3e" +// }, +// { +// "from_uuid":"04b0d690-dd44-4df3-8636-6f0c4dfb5c93", +// "name":"04b0d690-dd44-4df3-8636-6f0c4dfb5c93_0362c2df-6e99-445e-b95e-a798e69a651f", +// "to_uuid":"0362c2df-6e99-445e-b95e-a798e69a651f", +// "uuid":"06c89e49-753d-4a54-81f1-ee1e036003e6" +// } +// ] +// } +// } +// ] +// }` +// ) + +// func TestDescribeApplicationArgs(t *testing.T) { +// tests := []struct { +// args []string +// err error +// name string +// }{ +// {args: nil, err: errors.New("requires app name or UUID"), name: ""}, +// {args: []string{"ApplicationName"}, err: nil, name: "ApplicationName"}, +// } + +// for _, tt := range tests { +// ar := &Describe{} +// err := ar.ParseArgs(tt.args) + +// if err != nil && tt.err.Error() != err.Error() { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) +// } + +// if tt.name != ar.args.nameOrUUID { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.name, ar.args.nameOrUUID) +// } +// } +// } + +// func TestDescribeApplicationExecution(t *testing.T) { +// ctx := context.Background() +// ctrl := gomock.NewController(t) +// client := basicMock.NewMockBasicClient(ctrl) +// logger := log.NewTestLogger() +// mockTurbineCLI := turbineMock.NewMockCLI(ctrl) + +// path := filepath.Join(os.TempDir(), uuid.NewString()) +// appName := "my-env" +// appTime := AppTime{} +// err := appTime.UnmarshalJSON([]byte(`"2023-10-25 22:40:21.297Z"`)) +// if err != nil { +// t.Fatalf("not expected error, got \"%s\"", err.Error()) +// } + +// i := &Init{ +// logger: logger, +// args: struct{ appName string }{appName: appName}, +// flags: struct { +// Lang string "long:\"lang\" short:\"l\" usage:\"language to use (js|go|py)\" required:\"true\"" +// Path string "long:\"path\" usage:\"path where application will be initialized (current directory as default)\"" +// ModVendor bool "long:\"mod-vendor\" usage:\"whether to download modules to vendor or globally while initializing a Go application\"" +// SkipModInit bool "long:\"skip-mod-init\" usage:\"whether to run 'go mod init' while initializing a Go application\"" +// }{ +// Lang: string(ir.GoLang), +// Path: path, +// ModVendor: false, +// SkipModInit: true, +// }, +// } + +// a := &Application{ +// Name: appName, +// State: "running", +// SpecVersion: "0.2.0", +// Created: appTime, +// Updated: appTime, +// } + +// err = i.Execute(ctx) +// defer func(path string) { +// os.RemoveAll(path) +// }(path) +// require.NoError(t, err) + +// filter := &url.Values{} +// filter.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", a.Name, a.Name)) + +// httpResp := &http.Response{ +// Body: io.NopCloser(strings.NewReader(body)), +// Status: "200 OK", +// StatusCode: 200, +// } +// client.EXPECT().CollectionRequest(ctx, "GET", collectionName, "", nil, *filter).Return( +// httpResp, +// nil, +// ) + +// mockTurbineCLI.EXPECT().GetVersion(ctx).Return("1.0", nil) +// client.EXPECT().AddHeader("Meroxa-CLI-App-Lang", string(ir.GoLang)).Times(1) +// client.EXPECT().AddHeader("Meroxa-CLI-App-Version", gomock.Any()).Times(1) + +// dc := &Describe{ +// client: client, +// logger: logger, +// turbineCLI: mockTurbineCLI, +// args: struct{ nameOrUUID string }{nameOrUUID: a.Name}, +// flags: struct { +// Path string "long:\"path\" usage:\"Path to the app directory (default is local directory)\"" +// }{Path: filepath.Join(path, appName)}, +// } + +// err = dc.Execute(ctx) +// if err != nil { +// t.Fatalf("not expected error, got %q", err.Error()) +// } + +// gotJSONOutput := logger.JSONOutput() + +// var gotApp Application +// err = json.Unmarshal([]byte(gotJSONOutput), &gotApp) +// if err != nil { +// t.Fatalf("not expected error, got %q", err.Error()) +// } + +// if gotApp.Name != a.Name { +// t.Fatalf("expected \"%s\" got \"%s\"", a.Name, gotApp.Name) +// } +// if gotApp.SpecVersion != a.SpecVersion { +// t.Fatalf("expected \"%s\" got \"%s\"", a.SpecVersion, gotApp.SpecVersion) +// } +// if gotApp.State != a.State { +// t.Fatalf("expected \"%s\" got \"%s\"", a.State, gotApp.State) +// } +// if gotApp.Created.String() != a.Created.String() { +// t.Fatalf("expected \"%s\" got \"%s\"", a.Created.String(), gotApp.Created.String()) +// } +// if gotApp.Updated.String() != a.Updated.String() { +// t.Fatalf("expected \"%s\" got \"%s\"", a.Updated.String(), gotApp.Updated.String()) +// } +// } diff --git a/cmd/meroxa/root/apps/errors.go b/cmd/meroxa/root/apps/errors.go deleted file mode 100644 index 32824f0f1..000000000 --- a/cmd/meroxa/root/apps/errors.go +++ /dev/null @@ -1,15 +0,0 @@ -package apps - -import ( - "fmt" - - "github.com/meroxa/turbine-core/v2/pkg/ir" -) - -func newLangUnsupportedError(lang ir.Lang) error { - return fmt.Errorf( - `language %q not supported. `+ - `supported languages "javascript", "golang", "python", and "ruby (beta)"`, - lang, - ) -} diff --git a/cmd/meroxa/root/apps/init.go b/cmd/meroxa/root/apps/init.go index e9d018200..d5297c0d4 100644 --- a/cmd/meroxa/root/apps/init.go +++ b/cmd/meroxa/root/apps/init.go @@ -4,24 +4,17 @@ import ( "context" "errors" "fmt" - "path/filepath" "regexp" "strings" "github.com/meroxa/cli/cmd/meroxa/builder" - "github.com/meroxa/cli/cmd/meroxa/turbine" - turbineGo "github.com/meroxa/cli/cmd/meroxa/turbine/golang" - turbineJS "github.com/meroxa/cli/cmd/meroxa/turbine/javascript" - turbinePY "github.com/meroxa/cli/cmd/meroxa/turbine/python" - turbineRb "github.com/meroxa/cli/cmd/meroxa/turbine/ruby" + "github.com/meroxa/cli/log" - "github.com/meroxa/turbine-core/v2/pkg/ir" ) type Init struct { - logger log.Logger - turbineCLI turbine.CLI - path string + logger log.Logger + path string args struct { appName string @@ -101,7 +94,6 @@ func (i *Init) Execute(ctx context.Context) error { err error name = i.args.appName - lang = strings.ToLower(i.flags.Lang) ) name, err = validateAppName(name) @@ -109,62 +101,47 @@ func (i *Init) Execute(ctx context.Context) error { return err } - i.path, err = turbine.GetPath(i.flags.Path) + i.path, err = GetPath(i.flags.Path) if err != nil { return err } - i.logger.StartSpinner("\t", fmt.Sprintf("Initializing application %q in %q...", name, i.path)) - if i.turbineCLI == nil { - i.turbineCLI, err = newTurbineCLI(i.logger, lang, i.path) - if err != nil { - i.logger.StopSpinnerWithStatus("\t", log.Failed) - return err - } - } - - if err = i.turbineCLI.Init(ctx, name); err != nil { - i.logger.StopSpinnerWithStatus("\t", log.Failed) - return err - } - i.logger.StopSpinnerWithStatus("Application directory created!", log.Successful) - - if lang == "go" || lang == string(ir.GoLang) { - if err = turbineGo.GoInit(i.logger, i.path+"/"+name, i.flags.SkipModInit, i.flags.ModVendor); err != nil { - i.logger.StopSpinnerWithStatus("\t", log.Failed) - return err - } - } - - i.logger.StartSpinner("\t", "Running git initialization...") - if err = i.turbineCLI.GitInit(ctx, i.path+"/"+name); err != nil { - i.logger.StopSpinnerWithStatus( - "\tThe final step to 'git init' the Application repo failed. Please complete this step manually.", - log.Failed) - return err - } - i.logger.StopSpinnerWithStatus("Git initialized successfully!", log.Successful) - - appPath := filepath.Join(i.path, name) - - i.logger.Infof(ctx, "Turbine Data Application successfully initialized!\n"+ - "You can start interacting with Meroxa in your app located at \"%s\".\n"+ - "Your Application will not be visible in the Meroxa Dashboard until after deployment.", appPath) + // i.logger.StartSpinner("\t", fmt.Sprintf("Initializing application %q in %q...", name, i.path)) + // if i.turbineCLI == nil { + // i.turbineCLI, err = newTurbineCLI(i.logger, lang, i.path) + // if err != nil { + // i.logger.StopSpinnerWithStatus("\t", log.Failed) + // return err + // } + // } + + // if err = i.turbineCLI.Init(ctx, name); err != nil { + // i.logger.StopSpinnerWithStatus("\t", log.Failed) + // return err + // } + // i.logger.StopSpinnerWithStatus("Application directory created!", log.Successful) + + // if lang == "go" || lang == string(ir.GoLang) { + // if err = turbineGo.GoInit(i.logger, i.path+"/"+name, i.flags.SkipModInit, i.flags.ModVendor); err != nil { + // i.logger.StopSpinnerWithStatus("\t", log.Failed) + // return err + // } + // } + + // i.logger.StartSpinner("\t", "Running git initialization...") + // if err = i.turbineCLI.GitInit(ctx, i.path+"/"+name); err != nil { + // i.logger.StopSpinnerWithStatus( + // "\tThe final step to 'git init' the Application repo failed. Please complete this step manually.", + // log.Failed) + // return err + // } + // i.logger.StopSpinnerWithStatus("Git initialized successfully!", log.Successful) + + // appPath := filepath.Join(i.path, name) + + // i.logger.Infof(ctx, "Turbine Data Application successfully initialized!\n"+ + // "You can start interacting with Meroxa in your app located at \"%s\".\n"+ + // "Your Application will not be visible in the Meroxa Dashboard until after deployment.", appPath) return nil } - -func newTurbineCLI(logger log.Logger, lang, path string) (turbine.CLI, error) { - switch lang { - case "go", turbine.GoLang: - return turbineGo.New(logger, path), nil - case "js", turbine.JavaScript, turbine.NodeJs: - return turbineJS.New(logger, path), nil - case "py", turbine.Python3, turbine.Python: - return turbinePY.New(logger, path), nil - case "rb", turbine.Ruby: - return turbineRb.New(logger, path), nil - default: - return nil, newLangUnsupportedError(ir.Lang(lang)) - } -} diff --git a/cmd/meroxa/root/apps/init_test.go b/cmd/meroxa/root/apps/init_test.go index 0b4295cfc..0851e9fb2 100644 --- a/cmd/meroxa/root/apps/init_test.go +++ b/cmd/meroxa/root/apps/init_test.go @@ -1,333 +1,333 @@ package apps -import ( - "context" - "errors" - "fmt" - "go/build" - "os" - "path/filepath" - "testing" +// import ( +// "context" +// "errors" +// "fmt" +// "go/build" +// "os" +// "path/filepath" +// "testing" - "github.com/golang/mock/gomock" - "github.com/google/uuid" +// "github.com/golang/mock/gomock" +// "github.com/google/uuid" - "github.com/meroxa/cli/cmd/meroxa/builder" - mockturbinecli "github.com/meroxa/cli/cmd/meroxa/turbine/mock" - "github.com/meroxa/cli/log" - "github.com/meroxa/cli/utils" - "github.com/meroxa/turbine-core/pkg/ir" -) +// "github.com/meroxa/cli/cmd/meroxa/builder" +// mockturbinecli "github.com/meroxa/cli/cmd/meroxa/turbine/mock" +// "github.com/meroxa/cli/log" +// "github.com/meroxa/cli/utils" +// "github.com/meroxa/turbine-core/pkg/ir" +// ) -func TestInitAppArgs(t *testing.T) { - tests := []struct { - args []string - err error - appName string - }{ - {args: nil, err: errors.New("requires an application name"), appName: ""}, - {args: []string{"my-app-name"}, err: nil, appName: "my-app-name"}, - } +// func TestInitAppArgs(t *testing.T) { +// tests := []struct { +// args []string +// err error +// appName string +// }{ +// {args: nil, err: errors.New("requires an application name"), appName: ""}, +// {args: []string{"my-app-name"}, err: nil, appName: "my-app-name"}, +// } - for _, tt := range tests { - cc := &Init{} - err := cc.ParseArgs(tt.args) +// for _, tt := range tests { +// cc := &Init{} +// err := cc.ParseArgs(tt.args) - if err != nil && tt.err.Error() != err.Error() { - t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) - } +// if err != nil && tt.err.Error() != err.Error() { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) +// } - if tt.appName != cc.args.appName { - t.Fatalf("expected \"%s\" got \"%s\"", tt.appName, cc.args.appName) - } - } -} +// if tt.appName != cc.args.appName { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.appName, cc.args.appName) +// } +// } +// } -func TestInitAppFlags(t *testing.T) { - expectedFlags := []struct { - name string - required bool - shorthand string - hidden bool - }{ - {name: "lang", shorthand: "l", required: true}, - {name: "path", required: false}, - } +// func TestInitAppFlags(t *testing.T) { +// expectedFlags := []struct { +// name string +// required bool +// shorthand string +// hidden bool +// }{ +// {name: "lang", shorthand: "l", required: true}, +// {name: "path", required: false}, +// } - c := builder.BuildCobraCommand(&Init{}) +// c := builder.BuildCobraCommand(&Init{}) - for _, f := range expectedFlags { - cf := c.Flags().Lookup(f.name) - if cf == nil { - t.Fatalf("expected flag \"%s\" to be present", f.name) - } +// for _, f := range expectedFlags { +// cf := c.Flags().Lookup(f.name) +// if cf == nil { +// t.Fatalf("expected flag \"%s\" to be present", f.name) +// } - if f.shorthand != cf.Shorthand { - t.Fatalf("expected shorthand \"%s\" got \"%s\" for flag \"%s\"", f.shorthand, cf.Shorthand, f.name) - } +// if f.shorthand != cf.Shorthand { +// t.Fatalf("expected shorthand \"%s\" got \"%s\" for flag \"%s\"", f.shorthand, cf.Shorthand, f.name) +// } - if f.required && !utils.IsFlagRequired(cf) { - t.Fatalf("expected flag \"%s\" to be required", f.name) - } +// if f.required && !utils.IsFlagRequired(cf) { +// t.Fatalf("expected flag \"%s\" to be required", f.name) +// } - if cf.Hidden != f.hidden { - if cf.Hidden { - t.Fatalf("expected flag \"%s\" not to be hidden", f.name) - } else { - t.Fatalf("expected flag \"%s\" to be hidden", f.name) - } - } - } -} +// if cf.Hidden != f.hidden { +// if cf.Hidden { +// t.Fatalf("expected flag \"%s\" not to be hidden", f.name) +// } else { +// t.Fatalf("expected flag \"%s\" to be hidden", f.name) +// } +// } +// } +// } -func TestGoInitExecute(t *testing.T) { - gopath := os.Getenv("GOPATH") - if gopath == "" { - gopath = build.Default.GOPATH - } - if gopath == "" { - t.Fatal("GOPATH isnt defined") - } - tests := []struct { - desc string - path string - skipModInit bool - effectiveSkipModInit bool - vendor bool - err error - }{ - { - desc: "Init without go mod init", - path: func() string { - return filepath.Join(gopath, "src/github.com/meroxa/tests", uuid.New().String()) //nolint:gocritic - }(), - skipModInit: true, - vendor: false, - err: nil, - }, - { - desc: "Init with go mod init and without vendoring", - path: func() string { - return filepath.Join(gopath, "src/github.com/meroxa/tests", uuid.New().String()) //nolint:gocritic - }(), - skipModInit: false, - vendor: false, - err: nil, - }, - { - desc: "Init with go mod init and with vendoring", - path: func() string { - return filepath.Join(gopath, "src/github.com/meroxa/tests", uuid.New().String()) //nolint:gocritic - }(), - skipModInit: false, - vendor: true, - err: nil, - }, - { - desc: "Init without go mod init and with vendor flag", - path: func() string { - return filepath.Join(gopath, "src/github.com/meroxa/tests", uuid.New().String()) //nolint:gocritic - }(), - skipModInit: true, - vendor: true, - err: nil, - }, - { - desc: "Init without go mod init because the path is not under GOPATH and with vendor flag", - path: func() string { - return filepath.Join(os.TempDir(), uuid.New().String()) //nolint:gocritic - }(), - skipModInit: false, - effectiveSkipModInit: true, - vendor: true, - err: nil, - }, - } +// func TestGoInitExecute(t *testing.T) { +// gopath := os.Getenv("GOPATH") +// if gopath == "" { +// gopath = build.Default.GOPATH +// } +// if gopath == "" { +// t.Fatal("GOPATH isnt defined") +// } +// tests := []struct { +// desc string +// path string +// skipModInit bool +// effectiveSkipModInit bool +// vendor bool +// err error +// }{ +// { +// desc: "Init without go mod init", +// path: func() string { +// return filepath.Join(gopath, "src/github.com/meroxa/tests", uuid.New().String()) //nolint:gocritic +// }(), +// skipModInit: true, +// vendor: false, +// err: nil, +// }, +// { +// desc: "Init with go mod init and without vendoring", +// path: func() string { +// return filepath.Join(gopath, "src/github.com/meroxa/tests", uuid.New().String()) //nolint:gocritic +// }(), +// skipModInit: false, +// vendor: false, +// err: nil, +// }, +// { +// desc: "Init with go mod init and with vendoring", +// path: func() string { +// return filepath.Join(gopath, "src/github.com/meroxa/tests", uuid.New().String()) //nolint:gocritic +// }(), +// skipModInit: false, +// vendor: true, +// err: nil, +// }, +// { +// desc: "Init without go mod init and with vendor flag", +// path: func() string { +// return filepath.Join(gopath, "src/github.com/meroxa/tests", uuid.New().String()) //nolint:gocritic +// }(), +// skipModInit: true, +// vendor: true, +// err: nil, +// }, +// { +// desc: "Init without go mod init because the path is not under GOPATH and with vendor flag", +// path: func() string { +// return filepath.Join(os.TempDir(), uuid.New().String()) //nolint:gocritic +// }(), +// skipModInit: false, +// effectiveSkipModInit: true, +// vendor: true, +// err: nil, +// }, +// } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - cc := &Init{} - cc.Logger(log.NewTestLogger()) - cc.flags.Path = tt.path - cc.flags.Lang = string(ir.GoLang) - cc.flags.ModVendor = tt.vendor - cc.flags.SkipModInit = tt.skipModInit - cc.args.appName = "app-name" +// for _, tt := range tests { +// t.Run(tt.desc, func(t *testing.T) { +// cc := &Init{} +// cc.Logger(log.NewTestLogger()) +// cc.flags.Path = tt.path +// cc.flags.Lang = string(ir.GoLang) +// cc.flags.ModVendor = tt.vendor +// cc.flags.SkipModInit = tt.skipModInit +// cc.args.appName = "app-name" - err := cc.Execute(context.Background()) - if err != nil { - if tt.err == nil { - t.Fatalf("unexpected error \"%s\"", err) - } else if tt.err.Error() != err.Error() { - t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) - } - } +// err := cc.Execute(context.Background()) +// if err != nil { +// if tt.err == nil { +// t.Fatalf("unexpected error \"%s\"", err) +// } else if tt.err.Error() != err.Error() { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) +// } +// } - if err == nil && tt.err == nil { - if !tt.skipModInit && !tt.effectiveSkipModInit { - p, _ := filepath.Abs(filepath.Join(tt.path, cc.args.appName, "go.mod")) - if _, err := os.Stat(p); os.IsNotExist(err) { - t.Fatalf("expected file \"%s\" to be created", p) - } +// if err == nil && tt.err == nil { +// if !tt.skipModInit && !tt.effectiveSkipModInit { +// p, _ := filepath.Abs(filepath.Join(tt.path, cc.args.appName, "go.mod")) +// if _, err := os.Stat(p); os.IsNotExist(err) { +// t.Fatalf("expected file \"%s\" to be created", p) +// } - if tt.vendor { - p, _ = filepath.Abs(filepath.Join(tt.path, cc.args.appName, "go.mod")) - if _, err := os.Stat(p); os.IsNotExist(err) { - t.Fatalf("expected directory \"%s\" to be created", p) - } - } - } - } - os.RemoveAll(tt.path) - }) - } -} +// if tt.vendor { +// p, _ = filepath.Abs(filepath.Join(tt.path, cc.args.appName, "go.mod")) +// if _, err := os.Stat(p); os.IsNotExist(err) { +// t.Fatalf("expected directory \"%s\" to be created", p) +// } +// } +// } +// } +// os.RemoveAll(tt.path) +// }) +// } +// } -func TestJsPyAndRbInitExecute(t *testing.T) { - tests := []struct { - desc string - path string - language ir.Lang - name string - err error - }{ - { - desc: "Successful Javascript init", - path: "/does/not/matter", - language: ir.JavaScript, - name: "js-init", - err: nil, - }, - { - desc: "Unsuccessful Javascript init", - path: "/does/not/matter", - language: ir.JavaScript, - name: "js-init", - err: fmt.Errorf("not good"), - }, - { - desc: "Successful Python init", - path: "/does/not/matter", - language: ir.Python, - name: "py-init", - err: nil, - }, - { - desc: "Unsuccessful Python init", - path: "/does/not/matter", - language: ir.Python, - name: "py-init", - err: fmt.Errorf("not good"), - }, - { - desc: "Successful Ruby init", - path: "/does/not/matter", - language: ir.Ruby, - name: "rb-init", - err: nil, - }, - { - desc: "Unsuccessful Ruby init", - path: "/does/not/matter", - language: ir.Ruby, - name: "rb-init", - err: fmt.Errorf("not good"), - }, - } +// func TestJsPyAndRbInitExecute(t *testing.T) { +// tests := []struct { +// desc string +// path string +// language ir.Lang +// name string +// err error +// }{ +// { +// desc: "Successful Javascript init", +// path: "/does/not/matter", +// language: ir.JavaScript, +// name: "js-init", +// err: nil, +// }, +// { +// desc: "Unsuccessful Javascript init", +// path: "/does/not/matter", +// language: ir.JavaScript, +// name: "js-init", +// err: fmt.Errorf("not good"), +// }, +// { +// desc: "Successful Python init", +// path: "/does/not/matter", +// language: ir.Python, +// name: "py-init", +// err: nil, +// }, +// { +// desc: "Unsuccessful Python init", +// path: "/does/not/matter", +// language: ir.Python, +// name: "py-init", +// err: fmt.Errorf("not good"), +// }, +// { +// desc: "Successful Ruby init", +// path: "/does/not/matter", +// language: ir.Ruby, +// name: "rb-init", +// err: nil, +// }, +// { +// desc: "Unsuccessful Ruby init", +// path: "/does/not/matter", +// language: ir.Ruby, +// name: "rb-init", +// err: fmt.Errorf("not good"), +// }, +// } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - ctx := context.Background() - mockCtrl := gomock.NewController(t) +// for _, tt := range tests { +// t.Run(tt.desc, func(t *testing.T) { +// ctx := context.Background() +// mockCtrl := gomock.NewController(t) - i := &Init{} - i.Logger(log.NewTestLogger()) - i.flags.Path = tt.path - i.args.appName = tt.name - i.flags.Lang = string(tt.language) +// i := &Init{} +// i.Logger(log.NewTestLogger()) +// i.flags.Path = tt.path +// i.args.appName = tt.name +// i.flags.Lang = string(tt.language) - mock := mockturbinecli.NewMockCLI(mockCtrl) - if tt.err == nil { - mock.EXPECT().Init(ctx, tt.name) - mock.EXPECT().GitInit(ctx, filepath.Join(tt.path, tt.name)) - } else { - mock.EXPECT().Init(ctx, tt.name).Return(tt.err) - } - i.turbineCLI = mock +// mock := mockturbinecli.NewMockCLI(mockCtrl) +// if tt.err == nil { +// mock.EXPECT().Init(ctx, tt.name) +// mock.EXPECT().GitInit(ctx, filepath.Join(tt.path, tt.name)) +// } else { +// mock.EXPECT().Init(ctx, tt.name).Return(tt.err) +// } +// i.turbineCLI = mock - err := i.Execute(ctx) - if err != nil { - if tt.err == nil { - t.Fatalf("unexpected error \"%s\"", err) - } else if tt.err.Error() != err.Error() { - t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) - } - } +// err := i.Execute(ctx) +// if err != nil { +// if tt.err == nil { +// t.Fatalf("unexpected error \"%s\"", err) +// } else if tt.err.Error() != err.Error() { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) +// } +// } - if err == nil && tt.err != nil { - t.Fatalf("did not find expected error: %s", tt.err.Error()) - } - }) - } -} +// if err == nil && tt.err != nil { +// t.Fatalf("did not find expected error: %s", tt.err.Error()) +// } +// }) +// } +// } -func TestAppNameValidation(t *testing.T) { - tests := []struct { - desc string - inputName string - outputName string - err error - }{ - { - desc: "Valid app name", - inputName: "perfect-name", - outputName: "perfect-name", - err: nil, - }, - { - desc: "Valid capitalized app name", - inputName: "Perfect-name", - outputName: "perfect-name", - err: nil, - }, - { - desc: "Valid app name with underscore", - inputName: "perfect_name", - outputName: "perfect_name", - err: nil, - }, - { - desc: "Invalid app name - leading number", - inputName: "3otherwisegoodname", - outputName: "", - err: fmt.Errorf("invalid application name: %s; should start with a letter, be alphanumeric,"+ - " and only have dashes as separators", "3otherwisegoodname"), - }, - { - desc: "Invalid app name - invalid characters", - inputName: "!ch@os", - outputName: "", - err: fmt.Errorf("invalid application name: %s; should start with a letter, be alphanumeric,"+ - " and only have dashes as separators", "!ch@os"), - }, - } +// func TestAppNameValidation(t *testing.T) { +// tests := []struct { +// desc string +// inputName string +// outputName string +// err error +// }{ +// { +// desc: "Valid app name", +// inputName: "perfect-name", +// outputName: "perfect-name", +// err: nil, +// }, +// { +// desc: "Valid capitalized app name", +// inputName: "Perfect-name", +// outputName: "perfect-name", +// err: nil, +// }, +// { +// desc: "Valid app name with underscore", +// inputName: "perfect_name", +// outputName: "perfect_name", +// err: nil, +// }, +// { +// desc: "Invalid app name - leading number", +// inputName: "3otherwisegoodname", +// outputName: "", +// err: fmt.Errorf("invalid application name: %s; should start with a letter, be alphanumeric,"+ +// " and only have dashes as separators", "3otherwisegoodname"), +// }, +// { +// desc: "Invalid app name - invalid characters", +// inputName: "!ch@os", +// outputName: "", +// err: fmt.Errorf("invalid application name: %s; should start with a letter, be alphanumeric,"+ +// " and only have dashes as separators", "!ch@os"), +// }, +// } - for _, tt := range tests { - t.Run(tt.desc, func(t *testing.T) { - output, err := validateAppName(tt.inputName) - if err != nil { - if tt.err == nil { - t.Fatalf("unexpected error \"%s\"", err) - } else if tt.err.Error() != err.Error() { - t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) - } - } +// for _, tt := range tests { +// t.Run(tt.desc, func(t *testing.T) { +// output, err := validateAppName(tt.inputName) +// if err != nil { +// if tt.err == nil { +// t.Fatalf("unexpected error \"%s\"", err) +// } else if tt.err.Error() != err.Error() { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) +// } +// } - if err == nil && tt.err == nil { - if output != tt.outputName { - t.Fatalf("expected \"%s\" got \"%s\"", tt.outputName, output) - } - } - }) - } -} +// if err == nil && tt.err == nil { +// if output != tt.outputName { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.outputName, output) +// } +// } +// }) +// } +// } diff --git a/cmd/meroxa/root/apps/list.go b/cmd/meroxa/root/apps/list.go index 0c51eaf73..a392efdc0 100644 --- a/cmd/meroxa/root/apps/list.go +++ b/cmd/meroxa/root/apps/list.go @@ -46,7 +46,7 @@ func (l *List) Usage() string { func (l *List) Docs() builder.Docs { return builder.Docs{ - Short: "List Turbine Data Applications", + Short: "List Conduit Data Applications", } } @@ -58,7 +58,7 @@ func (l *List) Execute(ctx context.Context) error { var err error apps := &Applications{} - response, err := l.client.CollectionRequest(ctx, "GET", collectionName, "", nil, nil) + response, err := l.client.CollectionRequest(ctx, "GET", applicationCollection, "", nil, nil) if err != nil { return err } @@ -71,7 +71,7 @@ func (l *List) Execute(ctx context.Context) error { l.logger.Info(ctx, display.PrintList(apps.Items, displayDetails)) l.logger.JSON(ctx, apps) - output := fmt.Sprintf("\n ✨ To view your applications, visit %s/apps", global.GetMeroxaAPIURL()) + output := fmt.Sprintf("\n ✨ To view your applications, visit %s/conduitapps", global.GetMeroxaAPIURL()) l.logger.Info(ctx, output) return nil } diff --git a/cmd/meroxa/root/apps/list_test.go b/cmd/meroxa/root/apps/list_test.go index e759fc083..ef2c0d95f 100644 --- a/cmd/meroxa/root/apps/list_test.go +++ b/cmd/meroxa/root/apps/list_test.go @@ -16,98 +16,94 @@ limitations under the License. package apps -import ( - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "net/url" - "strings" - "testing" - - "github.com/meroxa/cli/log" - - "github.com/golang/mock/gomock" - basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock" -) - -func TestListApplicationExecution(t *testing.T) { - ctx := context.Background() - ctrl := gomock.NewController(t) - client := basicMock.NewMockBasicClient(ctrl) - logger := log.NewTestLogger() - - appTime := AppTime{} - err := appTime.UnmarshalJSON([]byte(`"2023-10-25 22:40:21.297Z"`)) - if err != nil { - t.Fatalf("not expected error, got \"%s\"", err.Error()) - } - - a := &Application{ - Name: "my-env", - State: "running", - SpecVersion: "0.2.0", - Created: appTime, - Updated: appTime, - } - - a2 := &Application{ - Name: "my-env2", - State: "creating", - SpecVersion: "0.2.0", - Created: appTime, - Updated: appTime, - } - - allApps := []Application{*a, *a2} - - filter := &url.Values{} - filter.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", a.Name, a.Name)) - - httpResp := &http.Response{ - Body: io.NopCloser(strings.NewReader(body)), - Status: "200 OK", - StatusCode: 200, - } - client.EXPECT().CollectionRequest(ctx, "GET", collectionName, "", nil, nil).Return( - httpResp, - nil, - ) - - list := &List{ - client: client, - logger: logger, - } - - err = list.Execute(ctx) - if err != nil { - t.Fatalf("not expected error, got %q", err.Error()) - } - - gotJSONOutput := logger.JSONOutput() - - var gotApp Applications - err = json.Unmarshal([]byte(gotJSONOutput), &gotApp) - if err != nil { - t.Fatalf("not expected error, got %q", err.Error()) - } - - for i, app := range gotApp.Items { - if app.Name != allApps[i].Name { - t.Fatalf("expected \"%s\" got \"%s\"", a.Name, app.Name) - } - if app.SpecVersion != allApps[i].SpecVersion { - t.Fatalf("expected \"%s\" got \"%s\"", a.SpecVersion, app.SpecVersion) - } - if app.State != allApps[i].State { - t.Fatalf("expected \"%s\" got \"%s\"", a.State, app.State) - } - if app.Created.String() != allApps[i].Created.String() { - t.Fatalf("expected \"%s\" got \"%s\"", a.Created.String(), app.Created.String()) - } - if app.Updated.String() != allApps[i].Updated.String() { - t.Fatalf("expected \"%s\" got \"%s\"", a.Updated.String(), app.Updated.String()) - } - } -} +// import ( +// "context" +// "encoding/json" +// "fmt" +// "io" +// "net/http" +// "net/url" +// "strings" +// "testing" + +// "github.com/meroxa/cli/log" + +// "github.com/golang/mock/gomock" +// basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock" +// ) + +// func TestListApplicationExecution(t *testing.T) { +// ctx := context.Background() +// ctrl := gomock.NewController(t) +// client := basicMock.NewMockBasicClient(ctrl) +// logger := log.NewTestLogger() + +// appTime := AppTime{} +// err := appTime.UnmarshalJSON([]byte(`"2023-10-25 22:40:21.297Z"`)) +// if err != nil { +// t.Fatalf("not expected error, got \"%s\"", err.Error()) +// } + +// a := &Application{ +// Name: "my-env", +// State: "running", +// Created: appTime, +// Updated: appTime, +// } + +// a2 := &Application{ +// Name: "my-env2", +// State: "creating", +// Created: appTime, +// Updated: appTime, +// } + +// allApps := []Application{*a, *a2} + +// filter := &url.Values{} +// filter.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", a.Name, a.Name)) + +// httpResp := &http.Response{ +// Body: io.NopCloser(strings.NewReader(body)), +// Status: "200 OK", +// StatusCode: 200, +// } +// client.EXPECT().CollectionRequest(ctx, "GET", applicationCollection, "", nil, nil).Return( +// httpResp, +// nil, +// ) + +// list := &List{ +// client: client, +// logger: logger, +// } + +// err = list.Execute(ctx) +// if err != nil { +// t.Fatalf("not expected error, got %q", err.Error()) +// } + +// gotJSONOutput := logger.JSONOutput() + +// var gotApp Applications +// err = json.Unmarshal([]byte(gotJSONOutput), &gotApp) +// if err != nil { +// t.Fatalf("not expected error, got %q", err.Error()) +// } + +// for i, app := range gotApp.Items { +// if app.Name != allApps[i].Name { +// t.Fatalf("expected \"%s\" got \"%s\"", a.Name, app.Name) +// } + +// if app.State != allApps[i].State { +// t.Fatalf("expected \"%s\" got \"%s\"", a.State, app.State) +// } +// if app.Created.String() != allApps[i].Created.String() { +// t.Fatalf("expected \"%s\" got \"%s\"", a.Created.String(), app.Created.String()) +// } +// if app.Updated.String() != allApps[i].Updated.String() { +// t.Fatalf("expected \"%s\" got \"%s\"", a.Updated.String(), app.Updated.String()) +// } +// } +// } diff --git a/cmd/meroxa/root/apps/open.go b/cmd/meroxa/root/apps/open.go index a8526314c..b23ba4780 100644 --- a/cmd/meroxa/root/apps/open.go +++ b/cmd/meroxa/root/apps/open.go @@ -84,7 +84,7 @@ func (o *Open) ParseArgs(args []string) error { func (o *Open) Docs() builder.Docs { return builder.Docs{ - Short: "Open the link to a Turbine Data Application in the Dashboard", + Short: "Open the link to a Conduit Data Application in the Dashboard", Example: `meroxa apps open # assumes that the Application is in the current directory meroxa apps open --path /my/app meroxa apps open NAMEorUUID`, diff --git a/cmd/meroxa/root/apps/open_test.go b/cmd/meroxa/root/apps/open_test.go index 07007d82a..98e9450e4 100644 --- a/cmd/meroxa/root/apps/open_test.go +++ b/cmd/meroxa/root/apps/open_test.go @@ -16,148 +16,148 @@ limitations under the License. package apps -import ( - "context" - "errors" - "fmt" - "io" - "net/http" - "net/url" - "os" - "strings" - "testing" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/meroxa/cli/cmd/meroxa/builder" - basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock" - "github.com/meroxa/cli/log" - "github.com/meroxa/cli/utils" -) - -func TestOpenAppArgs(t *testing.T) { - tests := []struct { - args []string - err error - appName string - }{ - {args: []string{"my-app-name"}, err: nil, appName: "my-app-name"}, - } - - for _, tt := range tests { - cc := &Open{} - err := cc.ParseArgs(tt.args) - - if err != nil && tt.err.Error() != err.Error() { - t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) - } - - if tt.appName != cc.args.NameOrUUID { - t.Fatalf("expected \"%s\" got \"%s\"", tt.appName, cc.args.NameOrUUID) - } - } -} - -func TestOpenAppFlags(t *testing.T) { - expectedFlags := []struct { - name string - required bool - shorthand string - hidden bool - }{ - {name: "path", required: false}, - } - - c := builder.BuildCobraCommand(&Open{}) - - for _, f := range expectedFlags { - cf := c.Flags().Lookup(f.name) - require.NotNil(t, cf) - assert.Equal(t, f.shorthand, cf.Shorthand) - assert.Equal(t, f.required, utils.IsFlagRequired(cf)) - assert.Equal(t, f.hidden, cf.Hidden) - } -} - -type mockOpener struct { - startURL string -} - -func (m *mockOpener) Start(URL string) error { - m.startURL = URL - return nil -} - -func TestOpenAppExecution(t *testing.T) { - ctx := context.Background() - - testCases := []struct { - desc string - appArg string - tenant string - appFlag string - appPath string - expectURL string - apiURL string - wantErr error - }{ - { - desc: "Successfully open app link with arg", - appArg: "app-name", - tenant: "test", - expectURL: "https://test.na1.meroxa.cloud/apps/b0p2ok0dcjisn4z/detail", - appPath: "", - apiURL: "https://test.na1.meroxa.cloud", - }, - { - desc: "Fail with bad path", - appFlag: os.TempDir(), - wantErr: errors.New("supply either ID/Name argument or --path flag"), - }, - } - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - ctrl := gomock.NewController(t) - client := basicMock.NewMockBasicClient(ctrl) - logger := log.NewTestLogger() - os.Setenv("UNIT_TEST", "true") - os.Setenv("MEROXA_API_URL", tc.apiURL) - - filter := &url.Values{} - filter.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", tc.appArg, tc.appArg)) - - httpResp := &http.Response{ - Body: io.NopCloser(strings.NewReader(body)), - Status: "200 OK", - StatusCode: 200, - } - if tc.wantErr == nil { - client.EXPECT().CollectionRequest(ctx, "GET", collectionName, "", nil, *filter).Return( - httpResp, - nil, - ) - } - - opener := &mockOpener{} - o := &Open{ - logger: logger, - Opener: opener, - args: struct { - NameOrUUID string - }{NameOrUUID: tc.appArg}, - path: tc.appPath, - client: client, - } - - err := o.Execute(ctx) - - if tc.wantErr != nil { - require.Error(t, err) - require.Contains(t, err.Error(), tc.wantErr.Error()) - } - require.Equal(t, opener.startURL, tc.expectURL) - }) - } -} +// import ( +// "context" +// "errors" +// "fmt" +// "io" +// "net/http" +// "net/url" +// "os" +// "strings" +// "testing" + +// "github.com/golang/mock/gomock" +// "github.com/stretchr/testify/assert" +// "github.com/stretchr/testify/require" + +// "github.com/meroxa/cli/cmd/meroxa/builder" +// basicMock "github.com/meroxa/cli/cmd/meroxa/global/mock" +// "github.com/meroxa/cli/log" +// "github.com/meroxa/cli/utils" +// ) + +// func TestOpenAppArgs(t *testing.T) { +// tests := []struct { +// args []string +// err error +// appName string +// }{ +// {args: []string{"my-app-name"}, err: nil, appName: "my-app-name"}, +// } + +// for _, tt := range tests { +// cc := &Open{} +// err := cc.ParseArgs(tt.args) + +// if err != nil && tt.err.Error() != err.Error() { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) +// } + +// if tt.appName != cc.args.NameOrUUID { +// t.Fatalf("expected \"%s\" got \"%s\"", tt.appName, cc.args.NameOrUUID) +// } +// } +// } + +// func TestOpenAppFlags(t *testing.T) { +// expectedFlags := []struct { +// name string +// required bool +// shorthand string +// hidden bool +// }{ +// {name: "path", required: false}, +// } + +// c := builder.BuildCobraCommand(&Open{}) + +// for _, f := range expectedFlags { +// cf := c.Flags().Lookup(f.name) +// require.NotNil(t, cf) +// assert.Equal(t, f.shorthand, cf.Shorthand) +// assert.Equal(t, f.required, utils.IsFlagRequired(cf)) +// assert.Equal(t, f.hidden, cf.Hidden) +// } +// } + +// type mockOpener struct { +// startURL string +// } + +// func (m *mockOpener) Start(URL string) error { +// m.startURL = URL +// return nil +// } + +// func TestOpenAppExecution(t *testing.T) { +// ctx := context.Background() + +// testCases := []struct { +// desc string +// appArg string +// tenant string +// appFlag string +// appPath string +// expectURL string +// apiURL string +// wantErr error +// }{ +// { +// desc: "Successfully open app link with arg", +// appArg: "app-name", +// tenant: "test", +// expectURL: "https://test.na1.meroxa.cloud/apps/b0p2ok0dcjisn4z/detail", +// appPath: "", +// apiURL: "https://test.na1.meroxa.cloud", +// }, +// { +// desc: "Fail with bad path", +// appFlag: os.TempDir(), +// wantErr: errors.New("supply either ID/Name argument or --path flag"), +// }, +// } +// for _, tc := range testCases { +// t.Run(tc.desc, func(t *testing.T) { +// ctrl := gomock.NewController(t) +// client := basicMock.NewMockBasicClient(ctrl) +// logger := log.NewTestLogger() +// os.Setenv("UNIT_TEST", "true") +// os.Setenv("MEROXA_API_URL", tc.apiURL) + +// filter := &url.Values{} +// filter.Add("filter", fmt.Sprintf("(id='%s' || name='%s')", tc.appArg, tc.appArg)) + +// httpResp := &http.Response{ +// Body: io.NopCloser(strings.NewReader(body)), +// Status: "200 OK", +// StatusCode: 200, +// } +// if tc.wantErr == nil { +// client.EXPECT().CollectionRequest(ctx, "GET", collectionName, "", nil, *filter).Return( +// httpResp, +// nil, +// ) +// } + +// opener := &mockOpener{} +// o := &Open{ +// logger: logger, +// Opener: opener, +// args: struct { +// NameOrUUID string +// }{NameOrUUID: tc.appArg}, +// path: tc.appPath, +// client: client, +// } + +// err := o.Execute(ctx) + +// if tc.wantErr != nil { +// require.Error(t, err) +// require.Contains(t, err.Error(), tc.wantErr.Error()) +// } +// require.Equal(t, opener.startURL, tc.expectURL) +// }) +// } +// } diff --git a/cmd/meroxa/root/apps/remove.go b/cmd/meroxa/root/apps/remove.go index 0a45a045b..e94078934 100644 --- a/cmd/meroxa/root/apps/remove.go +++ b/cmd/meroxa/root/apps/remove.go @@ -26,16 +26,12 @@ import ( "github.com/meroxa/cli/cmd/meroxa/builder" "github.com/meroxa/cli/cmd/meroxa/global" - "github.com/meroxa/cli/cmd/meroxa/turbine" "github.com/meroxa/cli/log" - "github.com/meroxa/turbine-core/v2/pkg/ir" ) type Remove struct { - client global.BasicClient - logger log.Logger - lang ir.Lang - turbineCLI turbine.CLI + client global.BasicClient + logger log.Logger args struct { nameOrUUID string @@ -56,7 +52,7 @@ func (r *Remove) Flags() []builder.Flag { func (r *Remove) Docs() builder.Docs { return builder.Docs{ - Short: "Remove a Turbine Data Application", + Short: "Remove a Conduit Data Application", Long: `This command will remove the Application specified in '--path' (or current working directory if not specified) previously deployed on our Meroxa Platform, or the Application specified by the given name or UUID identifier.`, @@ -83,31 +79,13 @@ func (r *Remove) Execute(ctx context.Context) error { apps := &Applications{} var err error - config, err := turbine.ReadConfigFile(r.flags.Path) - if err != nil { - return err - } - - r.lang = config.Language - if r.turbineCLI == nil { - if r.turbineCLI, err = getTurbineCLIFromLanguage(r.logger, r.lang, r.flags.Path); err != nil { - return err - } - } - - turbineVersion, err := r.turbineCLI.GetVersion(ctx) - if err != nil { - return err - } - addTurbineHeaders(r.client, r.lang, turbineVersion) - apps, err = RetrieveApplicationByNameOrID(ctx, r.client, r.args.nameOrUUID, r.flags.Path) if err != nil { return err } r.logger.Infof(ctx, "Removing application %q...", r.args.nameOrUUID) - response, err := r.client.CollectionRequest(ctx, "DELETE", collectionName, apps.Items[0].ID, nil, nil) + response, err := r.client.CollectionRequest(ctx, "DELETE", applicationCollection, apps.Items[0].ID, nil, nil) if err != nil { return err } diff --git a/cmd/meroxa/root/apps/run.go b/cmd/meroxa/root/apps/run.go index f205394ac..3a566c9a1 100644 --- a/cmd/meroxa/root/apps/run.go +++ b/cmd/meroxa/root/apps/run.go @@ -20,16 +20,13 @@ import ( "context" "github.com/meroxa/cli/cmd/meroxa/builder" - "github.com/meroxa/cli/cmd/meroxa/turbine" "github.com/meroxa/cli/log" ) type Run struct { - path string - config *turbine.AppConfig + path string - logger log.Logger - turbineCLI turbine.CLI + logger log.Logger flags struct { Path string `long:"path" usage:"path of application to run"` @@ -49,7 +46,7 @@ func (*Run) Usage() string { func (*Run) Docs() builder.Docs { return builder.Docs{ - Short: "Execute a Turbine Data Application locally", + Short: "Execute a Conduit Data Application locally", Long: "meroxa apps run will build your app locally to then run it locally in --path.", Example: `meroxa apps run # assumes you run it from the app directory meroxa apps run --path ../go-demo # it'll use lang defined in your app.json @@ -66,23 +63,6 @@ func (r *Run) Flags() []builder.Flag { } func (r *Run) Execute(ctx context.Context) error { - if r.turbineCLI != nil { - return r.turbineCLI.Run(ctx) - } - - var err error - if r.config == nil { - if r.path, err = turbine.GetPath(r.flags.Path); err != nil { - return err - } - if r.config, err = turbine.ReadConfigFile(r.path); err != nil { - return err - } - } - - if r.turbineCLI, err = getTurbineCLIFromLanguage(r.logger, r.config.Language, r.path); err != nil { - return err - } - return r.turbineCLI.Run(ctx) + return nil } diff --git a/cmd/meroxa/root/apps/utils.go b/cmd/meroxa/root/apps/utils.go new file mode 100644 index 000000000..e0d5becf8 --- /dev/null +++ b/cmd/meroxa/root/apps/utils.go @@ -0,0 +1,214 @@ +package apps + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "os" + "os/exec" + "path" + "path/filepath" + "regexp" + "strings" + + "github.com/meroxa/cli/log" + "golang.org/x/mod/semver" +) + +type AppConfig struct { + Name string `json:"name"` + Environment string `json:"environment"` + Resources map[string]string `json:"resources"` + Vendor string `json:"vendor"` + ModuleInit string `json:"module_init"` +} + +var prefetched *AppConfig + +func GetPath(flag string) (string, error) { + if flag == "" { + flag = "." + } + var err error + flag, err = filepath.Abs(flag) + if err != nil { + return "", err + } + return flag, nil +} + +// GetAppNameFromAppJSON returns specified app name in users' app.json. +func GetAppNameFromAppJSON(l log.Logger, pwd string) (string, error) { + l.StartSpinner("\t", "Reading application name from app.json...") + appConfig, err := ReadConfigFile(pwd) + if err != nil { + return "", err + } + + if appConfig.Name == "" { + l.StopSpinnerWithStatus("`name` should be specified in your app.json", log.Failed) + return "", fmt.Errorf("add `name` to your app.json") + } + l.StopSpinnerWithStatus(fmt.Sprintf("Checked your application name is %q", appConfig.Name), log.Successful) + return appConfig.Name, nil +} + +// SetModuleInitInAppJSON returns whether to run mod init. +func SetModuleInitInAppJSON(pwd string, skipInit bool) error { + appConfig, err := ReadConfigFile(pwd) + if err != nil { + return err + } + appConfig.ModuleInit = "true" + if skipInit { + appConfig.ModuleInit = "false" + } + return WriteConfigFile(pwd, appConfig) +} + +func GitInit(ctx context.Context, appPath string) error { + if appPath == "" { + return errors.New("path is required") + } + + isGitOlderThan228, err := checkGitVersion(ctx) + if err != nil { + return err + } + + cmd := exec.CommandContext(ctx, "git", "init", appPath) + if out, err := cmd.CombinedOutput(); err != nil { + return fmt.Errorf(string(out)) + } + + if !isGitOlderThan228 { + cmd = exec.CommandContext(ctx, "git", "config", "init.defaultBranch", "main") + cmd.Dir = appPath + if out, err := cmd.CombinedOutput(); err != nil { + return errors.New(string(out)) + } + } + cmd = exec.CommandContext(ctx, "git", "checkout", "-b", "main") + cmd.Dir = appPath + if out, err := cmd.CombinedOutput(); err != nil { + return errors.New(string(out)) + } + + return nil +} + +// CheckUncommittedChanges prints warnings about uncommitted tracked and untracked files. +func CheckUncommittedChanges(ctx context.Context, l log.Logger, appPath string) error { + l.Info(ctx, "Checking for uncommitted changes...") + cmd := exec.Command("git", "status", "--porcelain=v2") + cmd.Dir = appPath + output, err := cmd.Output() + if err != nil { + return err + } + all := string(output) + lines := strings.Split(strings.TrimSpace(all), "\n") + if len(lines) > 0 && lines[0] != "" { + cmd = exec.Command("git", "status") + output, err = cmd.Output() + if err != nil { + return err + } + l.Error(ctx, string(output)) + return fmt.Errorf("unable to proceed with deployment because of uncommitted changes") + } + l.Infof(ctx, "\t%s No uncommitted changes!", l.SuccessfulCheck()) + return nil +} + +// GetGitSha will return the latest gitSha that will be used to create an application. +func GetGitSha(ctx context.Context, appPath string) (string, error) { + // Gets latest git sha + cmd := exec.CommandContext(ctx, "git", "rev-parse", "HEAD") + cmd.Dir = appPath + output, err := cmd.CombinedOutput() + if err != nil { + return "", fmt.Errorf("%s: %v", cmd.String(), string(output)) + } + + return string(output), nil +} + +func checkGitVersion(ctx context.Context) (bool, error) { + cmd := exec.CommandContext(ctx, "git", "version") + out, err := cmd.CombinedOutput() + if err != nil { + return false, errors.New(string(out)) + } + // looks like "git version 2.38.1" + r := regexp.MustCompile("git version ([0-9.]+)") + matches := r.FindStringSubmatch(string(out)) + if len(matches) > 0 { + comparison := semver.Compare("2.28", matches[1]) + return comparison >= 1, nil + } + return true, nil +} + +func GitMainBranch(branch string) bool { + switch branch { + case "main", "master": + return true + } + + return false +} + +func GetGitBranch(appPath string) (string, error) { + cmd := exec.Command("git", "branch", "--show-current") + cmd.Dir = appPath + output, err := cmd.Output() + if err != nil { + return "", err + } + return strings.TrimSpace(string(output)), nil +} + +// ReadConfigFile will read the content of an app.json based on path. +func ReadConfigFile(appPath string) (*AppConfig, error) { + var appConfig AppConfig + + if prefetched == nil || os.Getenv("UNIT_TEST") != "" { + appConfigPath := path.Join(appPath, "app.json") + appConfigBytes, err := os.ReadFile(appConfigPath) + if err != nil { + return &appConfig, fmt.Errorf("could not find an app.json file on path %q."+ + " Try a different value for `--path`", appPath) + } + if err := json.Unmarshal(appConfigBytes, &appConfig); err != nil { + return &appConfig, err + } + prefetched = &appConfig + } + + return prefetched, nil +} + +func WriteConfigFile(appPath string, cfg *AppConfig) error { + appConfigPath := path.Join(appPath, "app.json") + data, err := json.MarshalIndent(cfg, "", " ") + if err != nil { + return err + } + err = os.WriteFile(appConfigPath, data, 0o664) + if err != nil { + return fmt.Errorf("%v\n"+ + "unable to update app.json file on path %q. Maybe try using a different value for `--path`", err, appPath) + } + return nil +} + +// SwitchToAppDirectory switches temporarily to the application's directory. +func SwitchToAppDirectory(appPath string) (string, error) { + pwd, err := os.Getwd() + if err != nil { + return pwd, err + } + return pwd, os.Chdir(appPath) +} diff --git a/cmd/meroxa/root/auth/login.go b/cmd/meroxa/root/auth/login.go index 83edc0933..50932247e 100644 --- a/cmd/meroxa/root/auth/login.go +++ b/cmd/meroxa/root/auth/login.go @@ -58,7 +58,7 @@ func (l *Login) Usage() string { func (l *Login) Docs() builder.Docs { return builder.Docs{ - Short: "Login to a Conduit Platform tenant", + Short: "Login to a Meroxa Platform tenant", } } diff --git a/cmd/meroxa/root/flink/deploy.go b/cmd/meroxa/root/flink/deploy.go deleted file mode 100644 index 5f8a4a78c..000000000 --- a/cmd/meroxa/root/flink/deploy.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -Copyright © 2022 Meroxa Inc - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package flink - -import ( - "context" - "fmt" - "path/filepath" - - "github.com/meroxa/cli/cmd/meroxa/builder" - "github.com/meroxa/cli/cmd/meroxa/flink" - "github.com/meroxa/cli/cmd/meroxa/global" - "github.com/meroxa/cli/config" - "github.com/meroxa/cli/log" - "github.com/meroxa/cli/utils" -) - -type Deploy struct { - args struct { - Name string - } - - flags struct { - Jar string `long:"jar" required:"true" usage:"Path to Flink Job jar file"` - Secrets []string `short:"s" long:"secret" usage:"environment variables to inject into the Flink Job (e.g.: --secret API_KEY=$API_KEY --secret ACCESS_KEY=abcdef)"` //nolint:lll - } - - client global.BasicClient - config config.Config - logger log.Logger -} - -var ( - _ builder.CommandWithBasicClient = (*Deploy)(nil) - _ builder.CommandWithConfig = (*Deploy)(nil) - _ builder.CommandWithDocs = (*Deploy)(nil) - _ builder.CommandWithExecute = (*Deploy)(nil) - _ builder.CommandWithArgs = (*Deploy)(nil) - _ builder.CommandWithFlags = (*Deploy)(nil) - _ builder.CommandWithLogger = (*Deploy)(nil) -) - -func (*Deploy) Usage() string { - return "deploy NAME --jar /home/job.jar" -} - -func (*Deploy) Docs() builder.Docs { - return builder.Docs{ - Short: "Deploy a Flink Job", - } -} - -func (d *Deploy) Config(cfg config.Config) { - d.config = cfg -} - -func (d *Deploy) BasicClient(client global.BasicClient) { - d.client = client -} - -func (d *Deploy) ParseArgs(args []string) error { - if len(args) > 0 { - d.args.Name = args[0] - } - return nil -} - -func (d *Deploy) Flags() []builder.Flag { - return builder.BuildFlags(&d.flags) -} - -func (d *Deploy) Logger(logger log.Logger) { - d.logger = logger -} - -func (d *Deploy) Execute(ctx context.Context) error { - jarPath := d.flags.Jar - if jarPath == "" { - return fmt.Errorf("the path to your Flink Job jar file must be provided to the --jar flag") - } - - if filepath.Ext(jarPath) != ".jar" { - return fmt.Errorf("please provide a JAR file to the --jar flag") - } - - name := d.args.Name - if name == "" { - return fmt.Errorf("the name of your Flink Job be provided as an argument") - } - - secrets := utils.StringSliceToStringMap(d.flags.Secrets) - _, err := flink.GetIRSpec(ctx, jarPath, secrets, d.logger) - if err != nil { - d.logger.Warnf(ctx, "failed to extract IR spec: %v\n", err) - // non-blocking - } - - d.logger.StartSpinner("\t", "Fetching Meroxa Platform source...") - - d.logger.StopSpinnerWithStatus("Platform source fetched", log.Successful) - - // Logging happens inside UploadFile - - // Creqte flink job - - d.logger.StopSpinnerWithStatus("Flink job created", log.Successful) - return nil -} - -/* -func (d *Deploy) addIntegrations(ctx context.Context, spec *ir.DeploymentSpec) error { - d.logger.StartSpinner("\t", "Checking Meroxa integrations...") - successMsg := "Finished checking Meroxa integrations" - if spec != nil { - var bytes []byte - bytes, err := json.Marshal(spec) - if err != nil { - d.logger.Errorf(ctx, "\t ð„‚ Unable to add Meroxa integrations to request") - d.logger.StopSpinnerWithStatus("\t", log.Failed) - return err - } - var inputSpec map[string]interface{} - if unmarshalErr := json.Unmarshal(bytes, &inputSpec); unmarshalErr != nil { - d.logger.Errorf(ctx, "\t ð„‚ Unable to add Meroxa integrations to request") - d.logger.StopSpinnerWithStatus("\t", log.Failed) - return unmarshalErr - } - successMsg = "Added Meroxa integrations to request" - } - d.logger.StopSpinnerWithStatus(successMsg, log.Successful) - return nil -} -*/ diff --git a/cmd/meroxa/root/flink/describe.go b/cmd/meroxa/root/flink/describe.go deleted file mode 100644 index 2b9138745..000000000 --- a/cmd/meroxa/root/flink/describe.go +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright © 2023 Meroxa Inc - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package flink - -import ( - "context" - "errors" - - "github.com/meroxa/cli/cmd/meroxa/builder" - "github.com/meroxa/cli/cmd/meroxa/global" - "github.com/meroxa/cli/log" -) - -var ( - _ builder.CommandWithDocs = (*Describe)(nil) - _ builder.CommandWithArgs = (*Describe)(nil) - _ builder.CommandWithBasicClient = (*Describe)(nil) - _ builder.CommandWithLogger = (*Describe)(nil) - _ builder.CommandWithExecute = (*Describe)(nil) -) - -type Describe struct { - client global.BasicClient - logger log.Logger - - args struct { - NameOrUUID string - } -} - -func (d *Describe) Usage() string { - return "describe" -} - -func (d *Describe) Docs() builder.Docs { - return builder.Docs{ - Short: "Describe the details of a Flink Job", - } -} - -func (d *Describe) Execute(ctx context.Context) error { - // Get flink joob. - output := "\n ✨ To view your Flink Jobs, visit https://dashboard.meroxa.io/apps" - d.logger.Info(ctx, output) - return nil -} - -func (d *Describe) Logger(logger log.Logger) { - d.logger = logger -} - -func (d *Describe) BasicClient(client global.BasicClient) { - d.client = client -} - -func (d *Describe) ParseArgs(args []string) error { - if len(args) < 1 { - return errors.New("requires Flink Job name or UUID") - } - - d.args.NameOrUUID = args[0] - return nil -} diff --git a/cmd/meroxa/root/flink/flink.go b/cmd/meroxa/root/flink/flink.go deleted file mode 100644 index 56b2a7629..000000000 --- a/cmd/meroxa/root/flink/flink.go +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright © 2022 Meroxa Inc - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package flink - -import ( - "fmt" - - "github.com/spf13/cobra" - - "github.com/meroxa/cli/cmd/meroxa/builder" -) - -type Job struct{} - -var ( - _ builder.CommandWithDocs = (*Job)(nil) - _ builder.CommandWithAliases = (*Job)(nil) - _ builder.CommandWithSubCommands = (*Job)(nil) - _ builder.CommandWithFeatureFlag = (*Job)(nil) - _ builder.CommandWithHidden = (*Job)(nil) -) - -func (*Job) Usage() string { - return "jobs" -} - -func (*Job) Docs() builder.Docs { - return builder.Docs{ - Short: "Manage Flink Jobs", - } -} - -func (*Job) Aliases() []string { - return []string{"job", "flink"} -} - -func (*Job) SubCommands() []*cobra.Command { - return []*cobra.Command{ - builder.BuildCobraCommand(&Deploy{}), - builder.BuildCobraCommand(&Describe{}), - builder.BuildCobraCommand(&Logs{}), - builder.BuildCobraCommand(&Remove{}), - builder.BuildCobraCommand(&List{}), - } -} - -func (*Job) FeatureFlag() (string, error) { - return "flink", fmt.Errorf(`no access to the Meroxa Flink Jobs feature`) -} - -func (*Job) Hidden() bool { - return true -} diff --git a/cmd/meroxa/root/flink/list.go b/cmd/meroxa/root/flink/list.go deleted file mode 100644 index 30dd352bf..000000000 --- a/cmd/meroxa/root/flink/list.go +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright © 2023 Meroxa Inc - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package flink - -import ( - "context" - - "github.com/meroxa/cli/cmd/meroxa/builder" - "github.com/meroxa/cli/cmd/meroxa/global" - "github.com/meroxa/cli/log" -) - -var ( - _ builder.CommandWithDocs = (*List)(nil) - _ builder.CommandWithBasicClient = (*List)(nil) - _ builder.CommandWithLogger = (*List)(nil) - _ builder.CommandWithExecute = (*List)(nil) - _ builder.CommandWithAliases = (*List)(nil) -) - -type List struct { - client global.BasicClient - logger log.Logger -} - -func (l *List) Usage() string { - return "list" -} - -func (l *List) Docs() builder.Docs { - return builder.Docs{ - Short: "List Flink jobs", - } -} - -func (l *List) Aliases() []string { - return []string{"ls"} -} - -func (l *List) Execute(ctx context.Context) error { - // List flink jobs. - output := "\n ✨ To view your Flink Jobs, visit https://dashboard.meroxa.io/apps" - l.logger.Info(ctx, output) - - return nil -} - -func (l *List) Logger(logger log.Logger) { - l.logger = logger -} - -func (l *List) BasicClient(client global.BasicClient) { - l.client = client -} diff --git a/cmd/meroxa/root/flink/logs.go b/cmd/meroxa/root/flink/logs.go deleted file mode 100644 index a20ab71c1..000000000 --- a/cmd/meroxa/root/flink/logs.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright © 2022 Meroxa Inc - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package flink - -import ( - "context" - "errors" - - "github.com/meroxa/cli/cmd/meroxa/builder" - "github.com/meroxa/cli/cmd/meroxa/global" - "github.com/meroxa/cli/log" -) - -var ( - _ builder.CommandWithAliases = (*Logs)(nil) - _ builder.CommandWithDocs = (*Logs)(nil) - _ builder.CommandWithArgs = (*Logs)(nil) - _ builder.CommandWithBasicClient = (*Logs)(nil) - _ builder.CommandWithLogger = (*Logs)(nil) - _ builder.CommandWithExecute = (*Logs)(nil) -) - -type Logs struct { - client global.BasicClient - logger log.Logger - - args struct { - NameOrUUID string - } -} - -func (*Logs) Aliases() []string { - return []string{"log"} -} - -func (l *Logs) Usage() string { - return `logs [NameOrUUID] [--path pwd]` -} - -func (l *Logs) Docs() builder.Docs { - return builder.Docs{ - Short: "View relevant logs to the state of the given Flink Job", - Example: `meroxa jobs logs my-flink-job-name -meroxa jobs logs my-flink-job-uuid`, - } -} - -func (l *Logs) Execute(ctx context.Context) error { - // Get flink job logs. - output := "\n ✨ To view your Flink Logs, visit https://dashboard.meroxa.io/apps" - l.logger.Info(ctx, output) - return nil -} - -func (l *Logs) BasicClient(client global.BasicClient) { - l.client = client -} - -func (l *Logs) Logger(logger log.Logger) { - l.logger = logger -} - -func (l *Logs) ParseArgs(args []string) error { - if len(args) < 1 { - return errors.New("requires Flink Job name or UUID") - } - - l.args.NameOrUUID = args[0] - return nil -} diff --git a/cmd/meroxa/root/flink/remove.go b/cmd/meroxa/root/flink/remove.go deleted file mode 100644 index 488a66b8d..000000000 --- a/cmd/meroxa/root/flink/remove.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -Copyright © 2022 Meroxa Inc - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package flink - -import ( - "context" - "errors" - - "github.com/meroxa/cli/cmd/meroxa/builder" - "github.com/meroxa/cli/cmd/meroxa/global" - "github.com/meroxa/cli/log" -) - -type Remove struct { - client global.BasicClient - logger log.Logger - - args struct { - NameOrUUID string - } -} - -func (r *Remove) Usage() string { - return "remove NAMEorUUID" -} - -func (r *Remove) Docs() builder.Docs { - return builder.Docs{ - Short: "Remove Flink Job", - } -} - -func (r *Remove) ValueToConfirm(_ context.Context) (wantInput string) { - return r.args.NameOrUUID -} - -func (r *Remove) Execute(ctx context.Context) error { - r.logger.Infof(ctx, "Removing Flink Job %q...", r.args.NameOrUUID) - - // Get flink job . - - // Delete flink job. - - r.logger.Infof(ctx, "Flink Job %q successfully removed", r.args.NameOrUUID) - - return nil -} - -func (r *Remove) Logger(logger log.Logger) { - r.logger = logger -} - -func (r *Remove) BasicClient(client global.BasicClient) { - r.client = client -} - -func (r *Remove) ParseArgs(args []string) error { - if len(args) < 1 { - return errors.New("requires Flink Job name or UUID") - } - - r.args.NameOrUUID = args[0] - return nil -} - -func (r *Remove) Aliases() []string { - return []string{"rm", "delete"} -} - -var ( - _ builder.CommandWithDocs = (*Remove)(nil) - _ builder.CommandWithAliases = (*Remove)(nil) - _ builder.CommandWithArgs = (*Remove)(nil) - _ builder.CommandWithBasicClient = (*Remove)(nil) - _ builder.CommandWithLogger = (*Remove)(nil) - _ builder.CommandWithExecute = (*Remove)(nil) - _ builder.CommandWithConfirmWithValue = (*Remove)(nil) -) diff --git a/cmd/meroxa/root/root.go b/cmd/meroxa/root/root.go index 8a3d13014..3a1e903df 100644 --- a/cmd/meroxa/root/root.go +++ b/cmd/meroxa/root/root.go @@ -26,7 +26,6 @@ import ( "github.com/meroxa/cli/cmd/meroxa/root/apps" "github.com/meroxa/cli/cmd/meroxa/root/auth" "github.com/meroxa/cli/cmd/meroxa/root/config" - "github.com/meroxa/cli/cmd/meroxa/root/flink" "github.com/meroxa/cli/cmd/meroxa/root/login" "github.com/meroxa/cli/cmd/meroxa/root/logout" "github.com/meroxa/cli/cmd/meroxa/root/open" @@ -71,7 +70,6 @@ Using the CLI you are able to create and manage sophisticated data pipelines wit cmd.AddCommand(builder.BuildCobraCommand(&auth.Auth{})) cmd.AddCommand(builder.BuildCobraCommand(&apps.Apps{})) cmd.AddCommand(builder.BuildCobraCommand(&config.Config{})) - cmd.AddCommand(builder.BuildCobraCommand(&flink.Job{})) cmd.AddCommand(builder.BuildCobraCommand(&login.Login{})) cmd.AddCommand(builder.BuildCobraCommand(&logout.Logout{})) cmd.AddCommand(builder.BuildCobraCommand(&open.Open{})) diff --git a/cmd/meroxa/root/secrets/secrets.go b/cmd/meroxa/root/secrets/secrets.go index b1e130358..7966cbd66 100644 --- a/cmd/meroxa/root/secrets/secrets.go +++ b/cmd/meroxa/root/secrets/secrets.go @@ -90,7 +90,7 @@ func (*Secrets) Usage() string { func (*Secrets) Docs() builder.Docs { return builder.Docs{ - Short: "Manage Turbine Data Applications", + Short: "Manage Conduit Application Secrets", } } diff --git a/cmd/meroxa/turbine/core.go b/cmd/meroxa/turbine/core.go deleted file mode 100644 index 1c486d93d..000000000 --- a/cmd/meroxa/turbine/core.go +++ /dev/null @@ -1,72 +0,0 @@ -package turbine - -import ( - "context" - "time" - - "github.com/meroxa/cli/cmd/meroxa/turbine/internal" - "github.com/meroxa/turbine-core/v2/pkg/client" - "github.com/meroxa/turbine-core/v2/pkg/server" - pb "github.com/meroxa/turbine-core/v2/proto/turbine/v2" -) - -type Core struct { - grpcListenAddress string - builder server.Server - runner server.Server - client client.Client -} - -func NewCore() *Core { - return &Core{ - runner: server.NewRunServer(), - grpcListenAddress: internal.RandomLocalAddr(), - builder: server.NewSpecBuilderServer(), - } -} - -func (t *Core) Start(ctx context.Context) (string, error) { - var ( - err error - retries = time.Tick(3 * time.Second) - ) - - go t.builder.RunAddr(ctx, t.grpcListenAddress) - - // NB: Spin until server is ready. - // Ideally, server should communicate readyness but until then we wait. - for range retries { - t.client, err = client.DialTimeout(t.grpcListenAddress, time.Second) - if err == nil { - return t.grpcListenAddress, nil - } - } - - return "", err -} - -func (t *Core) Stop() (func(), error) { - return func() { - t.client.Close() - t.builder.GracefulStop() - }, nil -} - -func (t *Core) Run(ctx context.Context) (func(), string) { - go t.runner.RunAddr(ctx, t.grpcListenAddress) - return t.runner.GracefulStop, t.grpcListenAddress -} - -func (t *Core) GetDeploymentSpec(ctx context.Context, imageName string) (string, error) { - ctx, cancel := context.WithTimeout(ctx, time.Second) - defer cancel() - - resp, err := t.client.GetSpec(ctx, &pb.GetSpecRequest{ - Image: imageName, - }) - if err != nil { - return "", err - } - - return string(resp.Spec), nil -} diff --git a/cmd/meroxa/turbine/core_test.go b/cmd/meroxa/turbine/core_test.go deleted file mode 100644 index eeaf208b7..000000000 --- a/cmd/meroxa/turbine/core_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package turbine - -import ( - "context" - "errors" - "strings" - "testing" - - "github.com/golang/mock/gomock" - "github.com/meroxa/turbine-core/v2/pkg/client" - mock_client "github.com/meroxa/turbine-core/v2/pkg/client/mock" - pb "github.com/meroxa/turbine-core/v2/proto/turbine/v2" - "github.com/stretchr/testify/require" -) - -func Test_GetDeploymentSpec(t *testing.T) { - ctx := context.Background() - - tests := []struct { - name string - core func(ctrl *gomock.Controller) *Core - wantErr error - wantSpec string - }{ - { - name: "get spec", - core: func(ctrl *gomock.Controller) *Core { - return &Core{ - client: func() client.Client { - m := mock_client.NewMockClient(ctrl) - m.EXPECT(). - GetSpec(gomock.Any(), &pb.GetSpecRequest{ - Image: "image", - }). - Times(1). - Return(&pb.GetSpecResponse{ - Spec: []byte("spec"), - }, nil) - return m - }(), - } - }, - wantSpec: "spec", - }, - { - name: "fail to get spec", - core: func(ctrl *gomock.Controller) *Core { - return &Core{ - client: func() client.Client { - m := mock_client.NewMockClient(ctrl) - m.EXPECT(). - GetSpec(gomock.Any(), &pb.GetSpecRequest{ - Image: "image", - }). - Times(1). - Return(nil, errors.New("something went wrong")) - return m - }(), - } - }, - wantErr: errors.New("something went wrong"), - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - ctrl := gomock.NewController(t) - c := tc.core(ctrl) - spec, err := c.GetDeploymentSpec(ctx, "image") - if tc.wantErr != nil && !strings.Contains(err.Error(), tc.wantErr.Error()) { - t.Fatalf("want: %v, got: %v", tc.wantErr, err) - } - require.Equal(t, tc.wantSpec, spec) - }) - } -} diff --git a/cmd/meroxa/turbine/core_v2.go b/cmd/meroxa/turbine/core_v2.go deleted file mode 100644 index ab1764e2b..000000000 --- a/cmd/meroxa/turbine/core_v2.go +++ /dev/null @@ -1,72 +0,0 @@ -package turbine - -import ( - "context" - "time" - - "github.com/meroxa/cli/cmd/meroxa/turbine/internal" - - "github.com/meroxa/turbine-core/v2/pkg/client" - "github.com/meroxa/turbine-core/v2/pkg/server" - pb "github.com/meroxa/turbine-core/v2/proto/turbine/v2" -) - -type CoreV2 struct { - grpcListenAddress string - builder server.Server - runner server.Server - client client.Client -} - -func NewCoreV2() *CoreV2 { - return &CoreV2{ - runner: server.NewRunServer(), - grpcListenAddress: internal.RandomLocalAddr(), - builder: server.NewSpecBuilderServer(), - } -} - -func (t *CoreV2) Start(ctx context.Context) (string, error) { - var ( - err error - retries = time.Tick(3 * time.Second) - ) - - go t.builder.RunAddr(ctx, t.grpcListenAddress) - - // NB: Spin until server is ready. - // Ideally, server should communicate readyness but until then we wait. - for range retries { - t.client, err = client.DialTimeout(t.grpcListenAddress, time.Second) - if err == nil { - return t.grpcListenAddress, nil - } - } - - return "", err -} - -func (t *CoreV2) Stop() (func(), error) { - return func() { - t.client.Close() - t.builder.GracefulStop() - }, nil -} - -func (t *CoreV2) Run(ctx context.Context) (func(), string) { - go t.runner.RunAddr(ctx, t.grpcListenAddress) - return t.runner.GracefulStop, t.grpcListenAddress -} - -func (t *CoreV2) GetDeploymentSpec(ctx context.Context, imageName string) (string, error) { - ctx, cancel := context.WithTimeout(ctx, time.Second) - defer cancel() - resp, err := t.client.GetSpec(ctx, &pb.GetSpecRequest{ - Image: imageName, - }) - if err != nil { - return "", err - } - - return string(resp.Spec), nil -} diff --git a/cmd/meroxa/turbine/core_v2_test.go b/cmd/meroxa/turbine/core_v2_test.go deleted file mode 100644 index 2427af56e..000000000 --- a/cmd/meroxa/turbine/core_v2_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package turbine - -import ( - "context" - "errors" - "strings" - "testing" - - "github.com/golang/mock/gomock" - "github.com/meroxa/turbine-core/v2/pkg/client" - mock_client "github.com/meroxa/turbine-core/v2/pkg/client/mock" - pb "github.com/meroxa/turbine-core/v2/proto/turbine/v2" - "github.com/stretchr/testify/require" -) - -func Test_GetDeploymentSpecV2(t *testing.T) { - ctx := context.Background() - - tests := []struct { - name string - core func(ctrl *gomock.Controller) *CoreV2 - wantErr error - wantSpec string - }{ - { - name: "get spec", - core: func(ctrl *gomock.Controller) *CoreV2 { - return &CoreV2{ - client: func() client.Client { - m := mock_client.NewMockClient(ctrl) - m.EXPECT(). - GetSpec(gomock.Any(), &pb.GetSpecRequest{ - Image: "image", - }). - Times(1). - Return(&pb.GetSpecResponse{ - Spec: []byte("spec"), - }, nil) - return m - }(), - } - }, - wantSpec: "spec", - }, - { - name: "fail to get spec", - core: func(ctrl *gomock.Controller) *CoreV2 { - return &CoreV2{ - client: func() client.Client { - m := mock_client.NewMockClient(ctrl) - m.EXPECT(). - GetSpec(gomock.Any(), &pb.GetSpecRequest{ - Image: "image", - }). - Times(1). - Return(nil, errors.New("something went wrong")) - return m - }(), - } - }, - wantErr: errors.New("something went wrong"), - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - ctrl := gomock.NewController(t) - c := tc.core(ctrl) - spec, err := c.GetDeploymentSpec(ctx, "image") - if tc.wantErr != nil && !strings.Contains(err.Error(), tc.wantErr.Error()) { - t.Fatalf("want: %v, got: %v", tc.wantErr, err) - } - require.Equal(t, tc.wantSpec, spec) - }) - } -} diff --git a/cmd/meroxa/turbine/docker.go b/cmd/meroxa/turbine/docker.go deleted file mode 100644 index c97d7f5fe..000000000 --- a/cmd/meroxa/turbine/docker.go +++ /dev/null @@ -1,22 +0,0 @@ -package turbine - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/meroxa/cli/log" -) - -type Docker struct{} - -func (d *Docker) CleanupDockerfile(logger log.Logger, path string) { - logger.StartSpinner("\t", fmt.Sprintf("Removing Dockerfile created for your application in %s...", path)) - // We clean up Dockerfile as last step - - if err := os.Remove(filepath.Join(path, "Dockerfile")); err != nil { - logger.StopSpinnerWithStatus(fmt.Sprintf("Unable to remove Dockerfile: %v", err), log.Failed) - } else { - logger.StopSpinnerWithStatus("Dockerfile removed", log.Successful) - } -} diff --git a/cmd/meroxa/turbine/docker_test.go b/cmd/meroxa/turbine/docker_test.go deleted file mode 100644 index 0997dcf50..000000000 --- a/cmd/meroxa/turbine/docker_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package turbine - -import ( - "os" - "path/filepath" - "testing" - - "github.com/meroxa/cli/log" - "github.com/stretchr/testify/require" -) - -func TestCleanupDockerfile(t *testing.T) { - var d Docker - - logger := log.NewTestLogger() - - appPath, err := makeTmpDir() - require.NoError(t, err) - - dockerfilePath := filepath.Join(appPath, "Dockerfile") - err = os.WriteFile(dockerfilePath, []byte(""), 0o644) - require.NoError(t, err) - - _, err = os.Stat(dockerfilePath) - require.NoError(t, err) - - d.CleanupDockerfile(logger, appPath) - _, err = os.Stat(dockerfilePath) - require.True(t, os.IsNotExist(err)) -} diff --git a/cmd/meroxa/turbine/git.go b/cmd/meroxa/turbine/git.go deleted file mode 100644 index efc22270b..000000000 --- a/cmd/meroxa/turbine/git.go +++ /dev/null @@ -1,119 +0,0 @@ -package turbine - -import ( - "context" - "errors" - "fmt" - "os/exec" - "regexp" - "strings" - - "golang.org/x/mod/semver" - - "github.com/meroxa/cli/log" -) - -type Git struct{} - -func (g *Git) GitInit(ctx context.Context, appPath string) error { - if appPath == "" { - return errors.New("path is required") - } - - isGitOlderThan228, err := checkGitVersion(ctx) - if err != nil { - return err - } - - cmd := exec.CommandContext(ctx, "git", "init", appPath) - if out, err := cmd.CombinedOutput(); err != nil { - return fmt.Errorf(string(out)) - } - - if !isGitOlderThan228 { - cmd = exec.CommandContext(ctx, "git", "config", "init.defaultBranch", "main") - cmd.Dir = appPath - if out, err := cmd.CombinedOutput(); err != nil { - return errors.New(string(out)) - } - } - cmd = exec.CommandContext(ctx, "git", "checkout", "-b", "main") - cmd.Dir = appPath - if out, err := cmd.CombinedOutput(); err != nil { - return errors.New(string(out)) - } - - return nil -} - -// CheckUncommittedChanges prints warnings about uncommitted tracked and untracked files. -func (g *Git) CheckUncommittedChanges(ctx context.Context, l log.Logger, appPath string) error { - l.Info(ctx, "Checking for uncommitted changes...") - cmd := exec.Command("git", "status", "--porcelain=v2") - cmd.Dir = appPath - output, err := cmd.Output() - if err != nil { - return err - } - all := string(output) - lines := strings.Split(strings.TrimSpace(all), "\n") - if len(lines) > 0 && lines[0] != "" { - cmd = exec.Command("git", "status") - output, err = cmd.Output() - if err != nil { - return err - } - l.Error(ctx, string(output)) - return fmt.Errorf("unable to proceed with deployment because of uncommitted changes") - } - l.Infof(ctx, "\t%s No uncommitted changes!", l.SuccessfulCheck()) - return nil -} - -// GetGitSha will return the latest gitSha that will be used to create an application. -func (g *Git) GetGitSha(ctx context.Context, appPath string) (string, error) { - // Gets latest git sha - cmd := exec.CommandContext(ctx, "git", "rev-parse", "HEAD") - cmd.Dir = appPath - output, err := cmd.CombinedOutput() - if err != nil { - return "", fmt.Errorf("%s: %v", cmd.String(), string(output)) - } - - return string(output), nil -} - -func checkGitVersion(ctx context.Context) (bool, error) { - cmd := exec.CommandContext(ctx, "git", "version") - out, err := cmd.CombinedOutput() - if err != nil { - return false, errors.New(string(out)) - } - // looks like "git version 2.38.1" - r := regexp.MustCompile("git version ([0-9.]+)") - matches := r.FindStringSubmatch(string(out)) - if len(matches) > 0 { - comparison := semver.Compare("2.28", matches[1]) - return comparison >= 1, nil - } - return true, nil -} - -func GitMainBranch(branch string) bool { - switch branch { - case "main", "master": - return true - } - - return false -} - -func GetGitBranch(appPath string) (string, error) { - cmd := exec.Command("git", "branch", "--show-current") - cmd.Dir = appPath - output, err := cmd.Output() - if err != nil { - return "", err - } - return strings.TrimSpace(string(output)), nil -} diff --git a/cmd/meroxa/turbine/git_test.go b/cmd/meroxa/turbine/git_test.go deleted file mode 100644 index a4871f3f9..000000000 --- a/cmd/meroxa/turbine/git_test.go +++ /dev/null @@ -1,269 +0,0 @@ -package turbine - -import ( - "context" - "errors" - "fmt" - "os" - "os/exec" - "path/filepath" - "testing" - - "github.com/google/uuid" - "github.com/meroxa/cli/log" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestGitInit(t *testing.T) { - var g Git - testDir := os.TempDir() + "/tests" + uuid.New().String() - - tests := []struct { - path string - err error - }{ - {path: "", err: errors.New("path is required")}, - {path: testDir, err: nil}, - } - - for _, tt := range tests { - if tt.path != "" { - err := os.Mkdir(tt.path, os.ModePerm) - require.NoError(t, err) - } - - err := g.GitInit(context.Background(), tt.path) - if err != nil { - if tt.err == nil { - t.Fatalf("unexpected error \"%s\"", err) - } else if tt.err.Error() != err.Error() { - t.Fatalf("expected \"%s\" got \"%s\"", tt.err, err) - } - } - - if tt.err == nil { - if _, err := os.Stat(testDir + "/.git"); os.IsNotExist(err) { - t.Fatalf("expected directory \"%s\" to be created", testDir) - } - } - } - - os.RemoveAll(testDir) -} - -func TestCheckGitVersion(t *testing.T) { - val, err := checkGitVersion(context.Background()) - require.NoError(t, err) - assert.False(t, val) -} - -//nolint:funlen,gocyclo -func TestCheckUncommittedChanges(t *testing.T) { - var g Git - - if gh := os.Getenv("GITHUB_WORKSPACE"); gh != "" { - t.Skipf("skipping git test in github action") - } - - ctx := context.Background() - logger := log.NewTestLogger() - - tests := []struct { - desc string - setup func() (string, error) - branch string - shaErr error - checksErr error - }{ - { - desc: "Successfully pass all git commands", - setup: func() (string, error) { - appPath, err := makeTmpDir() - if err != nil { - return "", err - } - - err = g.GitInit(ctx, appPath) - if err != nil { - return "", err - } - - // create file - dockerfilePath := filepath.Join(appPath, "Dockerfile") - err = os.WriteFile(dockerfilePath, []byte(""), 0o644) - if err != nil { - return "", err - } - - // add file - cmd := exec.Command("git", "add", "Dockerfile") - cmd.Dir = appPath - output, err := cmd.CombinedOutput() - if err != nil { - return "", fmt.Errorf("%s", string(output)) - } - - // commit file - cmd = exec.Command("git", "commit", "-m", "first") - cmd.Dir = appPath - output, err = cmd.CombinedOutput() - if err != nil { - return "", fmt.Errorf("%s", string(output)) - } - - return appPath, nil - }, - branch: "main", - }, - { - desc: "Fail uncommitted changes", - setup: func() (string, error) { - appPath, err := makeTmpDir() - if err != nil { - return "", err - } - - err = g.GitInit(ctx, appPath) - if err != nil { - return "", err - } - - // create file - dockerfilePath := filepath.Join(appPath, "Dockerfile") - err = os.WriteFile(dockerfilePath, []byte(""), 0o644) - if err != nil { - return "", err - } - - // feature branch - cmd := exec.Command("git", "checkout", "-b", "unit-test") - cmd.Dir = appPath - output, err := cmd.CombinedOutput() - if err != nil { - return "", fmt.Errorf("%s", string(output)) - } - - // add file - cmd = exec.Command("git", "add", "Dockerfile") - cmd.Dir = appPath - output, err = cmd.CombinedOutput() - if err != nil { - return "", fmt.Errorf("%s", string(output)) - } - - // commit file - cmd = exec.Command("git", "commit", "-m", "first") - cmd.Dir = appPath - output, err = cmd.CombinedOutput() - if err != nil { - return "", fmt.Errorf("%s", string(output)) - } - - // create second file - makefilePath := filepath.Join(appPath, "Makefile") - err = os.WriteFile(makefilePath, []byte(""), 0o644) - if err != nil { - return "", err - } - - // add second file - cmd = exec.Command("git", "add", "Makefile") - cmd.Dir = appPath - output, err = cmd.CombinedOutput() - if err != nil { - return "", fmt.Errorf("%s", string(output)) - } - - return appPath, nil - }, - branch: "unit-test", - checksErr: fmt.Errorf("unable to proceed with deployment because of uncommitted changes"), - }, - { - desc: "Fail git SHA check", - setup: func() (string, error) { - appPath, err := makeTmpDir() - if err != nil { - return "", err - } - - err = g.GitInit(ctx, appPath) - if err != nil { - return "", err - } - - return appPath, nil - }, - branch: "main", - //nolint:revive - shaErr: fmt.Errorf( - `/usr/bin/git rev-parse HEAD: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. -Use '--' to separate paths from revisions, like this: -'git [...] -- [...]' -HEAD -`), - }, - } - for _, tc := range tests { - t.Run(tc.desc, func(t *testing.T) { - path, err := tc.setup() - require.NoError(t, err) - - branch, err := GetGitBranch(path) - require.NoError(t, err) - assert.Equal(t, tc.branch, branch) - - _, err = g.GetGitSha(ctx, path) - if err != nil { - if tc.shaErr == nil { - t.Fatalf("unepxected error: %v", err) - } - assert.Equal(t, tc.shaErr.Error(), err.Error()) - } else { - require.NoError(t, err) - } - - err = g.CheckUncommittedChanges(ctx, logger, path) - if err != nil { - if tc.checksErr == nil { - t.Fatalf("unepxected error: %v", err) - } - assert.Equal(t, tc.checksErr.Error(), err.Error()) - } else { - require.NoError(t, err) - } - }) - } -} - -func TestGitMainBranch(t *testing.T) { - tests := []struct { - name string - input string - output bool - }{ - { - name: "Process main branch", - input: "main", - output: true, - }, - { - name: "Process master branch", - input: "master", - output: true, - }, - { - name: "Process other branch", - input: "anything-else", - output: false, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - val := GitMainBranch(tc.input) - assert.Equal(t, tc.output, val) - }) - } -} diff --git a/cmd/meroxa/turbine/golang/cli.go b/cmd/meroxa/turbine/golang/cli.go deleted file mode 100644 index f29d9fc53..000000000 --- a/cmd/meroxa/turbine/golang/cli.go +++ /dev/null @@ -1,29 +0,0 @@ -package turbinego - -import ( - "context" - - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/log" -) - -type turbineGoCLI struct { - logger log.Logger - appPath string - core *turbine.CoreV2 - - *turbine.Git - *turbine.Docker -} - -func New(l log.Logger, appPath string) turbine.CLI { - return &turbineGoCLI{ - logger: l, - appPath: appPath, - core: turbine.NewCoreV2(), - } -} - -func (t *turbineGoCLI) GetDeploymentSpec(ctx context.Context, image string) (string, error) { - return t.core.GetDeploymentSpec(ctx, image) -} diff --git a/cmd/meroxa/turbine/golang/deploy.go b/cmd/meroxa/turbine/golang/deploy.go deleted file mode 100644 index 28c3d08a8..000000000 --- a/cmd/meroxa/turbine/golang/deploy.go +++ /dev/null @@ -1,62 +0,0 @@ -package turbinego - -import ( - "context" - "embed" - "os" - "os/exec" - "path" - "text/template" - - "github.com/meroxa/cli/cmd/meroxa/turbine" -) - -//go:embed templates -var templates embed.FS - -func (t *turbineGoCLI) CreateDockerfile(_ context.Context, appName string) (string, error) { - f, err := os.Create(path.Join(t.appPath, "Dockerfile")) - if err != nil { - return "", err - } - defer f.Close() - - tpl, err := template.ParseFS(templates, "templates/Dockerfile.tpl") - if err != nil { - return "", err - } - if err := tpl.Execute(f, map[string]string{ - "GoVersion": "1.20", - "AppName": appName, - }); err != nil { - return "", err - } - - return t.appPath, nil -} - -func (t *turbineGoCLI) StartGrpcServer(ctx context.Context, gitSha string) (func(), error) { - grpcListenAddress, err := t.core.Start(ctx) - if err != nil { - return nil, err - } - - cmd := exec.Command("go", []string{ - "run", - "./...", - "build", - "-gitsha", gitSha, - "-turbine-core-server", grpcListenAddress, - "-app-path", t.appPath, - }...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Dir = t.appPath - cmd.Env = os.Environ() - - if _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger); err != nil { - return nil, err - } - - return t.core.Stop() -} diff --git a/cmd/meroxa/turbine/golang/init.go b/cmd/meroxa/turbine/golang/init.go deleted file mode 100644 index 334281dc1..000000000 --- a/cmd/meroxa/turbine/golang/init.go +++ /dev/null @@ -1,113 +0,0 @@ -package turbinego - -import ( - "context" - "fmt" - "go/build" - "os" - "os/exec" - "path/filepath" - "strings" - - utils "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/log" - "github.com/meroxa/turbine-core/v2/pkg/app" - "github.com/meroxa/turbine-core/v2/pkg/ir" -) - -func (t *turbineGoCLI) Init(_ context.Context, appName string) error { - return app.NewAppInit(appName, ir.GoLang, t.appPath).Init() -} - -func GoInit(l log.Logger, appPath string, skipInit, vendor bool) error { - l.StartSpinner("\t", "Running golang module initializing...") - skipLog := "skipping go module initialization\n\tFor guidance, visit " + - "https://docs.meroxa.com/turbine/go/troubleshooting#go-mod-init-for-new-turbine-streaming-applications" - goPath := os.Getenv("GOPATH") - if goPath == "" { - goPath = build.Default.GOPATH - } - if goPath == "" { - l.StopSpinnerWithStatus("$GOPATH not set up; "+skipLog, log.Warning) - return nil - } - i := strings.Index(appPath, filepath.Join(goPath, "src")) - if i == -1 || i != 0 { - l.StopSpinnerWithStatus(fmt.Sprintf("%s is not under $GOPATH/src; %s", appPath, skipLog), log.Warning) - return nil - } - - // temporarily switching to the app's directory - pwd, err := utils.SwitchToAppDirectory(appPath) - if err != nil { - l.StopSpinnerWithStatus("\t", log.Failed) - return err - } - - // initialize the user's module - err = utils.SetModuleInitInAppJSON(appPath, skipInit) - if err != nil { - l.StopSpinnerWithStatus("\t", log.Failed) - return err - } - - err = modulesInit(l, appPath, skipInit, vendor) - if err != nil { - l.StopSpinnerWithStatus("\t", log.Failed) - return err - } - - return os.Chdir(pwd) -} - -func modulesInit(l log.Logger, appPath string, skipInit, vendor bool) error { - if skipInit { - return nil - } - - cmd := exec.Command("go", "mod", "init") - output, err := cmd.CombinedOutput() - if err != nil { - l.StopSpinnerWithStatus(fmt.Sprintf("%s", string(output)), log.Failed) - return err - } - successLog := "go mod init succeeded" - goPath := os.Getenv("GOPATH") - if goPath == "" { - successLog += fmt.Sprintf(" (while assuming GOPATH is %s)", build.Default.GOPATH) - } - l.StopSpinnerWithStatus(successLog+"!", log.Successful) - - err = GoGetDeps(l) - if err != nil { - return err - } - - // download dependencies - err = utils.SetVendorInAppJSON(appPath, vendor) - if err != nil { - return err - } - - // tidy - goTidy := exec.Command("go", "mod", "tidy") - if _, err = goTidy.CombinedOutput(); err != nil { - return err - } - - depsLog := "Downloading dependencies" - cmd = exec.Command("go", "mod", "download") - if vendor { - depsLog += " to vendor" - cmd = exec.Command("go", "mod", "vendor") - } - depsLog += "..." - l.StartSpinner("\t", depsLog) - output, err = cmd.CombinedOutput() - if err != nil { - l.StopSpinnerWithStatus(fmt.Sprintf("%s", string(output)), log.Failed) - return err - } - l.StopSpinnerWithStatus("Downloaded all other dependencies successfully!", log.Successful) - return nil -} diff --git a/cmd/meroxa/turbine/golang/run.go b/cmd/meroxa/turbine/golang/run.go deleted file mode 100644 index 0becda644..000000000 --- a/cmd/meroxa/turbine/golang/run.go +++ /dev/null @@ -1,29 +0,0 @@ -package turbinego - -import ( - "context" - "os" - "os/exec" - - "github.com/meroxa/cli/cmd/meroxa/turbine" -) - -func (t *turbineGoCLI) Run(ctx context.Context) error { - gracefulStop, grpcListenAddress := t.core.Run(ctx) - defer gracefulStop() - - cmd := exec.Command("go", []string{ - "run", "./...", "build", - "-gitsha", "devel", - "-turbine-core-server", grpcListenAddress, - "-app-path", t.appPath, - "-run-process", - }...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Dir = t.appPath - cmd.Env = os.Environ() - - _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger) - return err -} diff --git a/cmd/meroxa/turbine/golang/templates/Dockerfile.tpl b/cmd/meroxa/turbine/golang/templates/Dockerfile.tpl deleted file mode 100644 index df4eda777..000000000 --- a/cmd/meroxa/turbine/golang/templates/Dockerfile.tpl +++ /dev/null @@ -1,13 +0,0 @@ -FROM golang:{{.GoVersion}} as builder -WORKDIR /builder -COPY . . -ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 -RUN go build -tags server -o {{ .AppName }} ./... - -FROM gcr.io/distroless/static -USER nobody -WORKDIR /app -COPY --from=builder /builder/app.json /app -COPY --from=builder /builder/{{ .AppName }} /app - -ENTRYPOINT ["/app/{{ .AppName }}", "server", "-serve-func"] \ No newline at end of file diff --git a/cmd/meroxa/turbine/golang/utils.go b/cmd/meroxa/turbine/golang/utils.go deleted file mode 100644 index 719ae63df..000000000 --- a/cmd/meroxa/turbine/golang/utils.go +++ /dev/null @@ -1,21 +0,0 @@ -package turbinego - -import ( - "fmt" - "os/exec" - - "github.com/meroxa/cli/log" -) - -// GoGetDeps updates the latest Meroxa mods. -func GoGetDeps(l log.Logger) error { - l.StartSpinner("\t", "Getting latest turbine-go and turbine-go/running dependencies...") - cmd := exec.Command("go", "get", "-u", "github.com/meroxa/turbine-go/v2@latest") - output, err := cmd.CombinedOutput() - if err != nil { - l.StopSpinnerWithStatus(fmt.Sprintf("%s", string(output)), log.Failed) - return err - } - l.StopSpinnerWithStatus("Downloaded latest turbine-go and turbine-go dependencies successfully!", log.Successful) - return nil -} diff --git a/cmd/meroxa/turbine/golang/version.go b/cmd/meroxa/turbine/golang/version.go deleted file mode 100644 index 1d0971e7a..000000000 --- a/cmd/meroxa/turbine/golang/version.go +++ /dev/null @@ -1,40 +0,0 @@ -package turbinego - -import ( - "context" - "fmt" - "os/exec" - "strings" -) - -// GetVersion will return the tag or hash of the turbine-go dependency of a given app. -func (t *turbineGoCLI) GetVersion(ctx context.Context) (string, error) { - var cmd *exec.Cmd - - cmd = exec.CommandContext( - ctx, - "go", - "list", "-m", "-f", "'{{ .Version }}'", "github.com/meroxa/turbine-go/v3") - cmd.Dir = t.appPath - fmtErr := fmt.Errorf( - "unable to determine the version of turbine-go used by the Meroxa Application at %s", - t.appPath) - - stdout, err := cmd.CombinedOutput() - if err != nil { - return "", fmtErr - } - - version := strings.TrimSpace(string(stdout)) - chars := []rune(version) - if chars[0] == 'v' { - // Looks like v0.0.0-20221024132549-e6470e58b719 - const sections = 3 - parts := strings.Split(version, "-") - if len(parts) < sections { - return "", fmtErr - } - version = parts[2] - } - return version, nil -} diff --git a/cmd/meroxa/turbine/interface.go b/cmd/meroxa/turbine/interface.go deleted file mode 100644 index 7d99df250..000000000 --- a/cmd/meroxa/turbine/interface.go +++ /dev/null @@ -1,23 +0,0 @@ -//go:generate mockgen -source=interface.go -package=mock -destination=mock/cli_mock.go CLI - -package turbine - -import ( - "context" - - "github.com/meroxa/cli/log" -) - -type CLI interface { - GitInit(context.Context, string) error - CheckUncommittedChanges(context.Context, log.Logger, string) error - CleanupDockerfile(log.Logger, string) - GetGitSha(context.Context, string) (string, error) - GetDeploymentSpec(context.Context, string) (string, error) - // NeedsToBuild(context.Context) (bool, error) - GetVersion(context.Context) (string, error) - Init(context.Context, string) error - Run(context.Context) error - CreateDockerfile(context.Context, string) (string, error) - StartGrpcServer(context.Context, string) (func(), error) -} diff --git a/cmd/meroxa/turbine/internal/port.go b/cmd/meroxa/turbine/internal/port.go deleted file mode 100644 index a2c7f9324..000000000 --- a/cmd/meroxa/turbine/internal/port.go +++ /dev/null @@ -1,19 +0,0 @@ -package internal - -import ( - "math/rand" - "net" - "strconv" - "time" -) - -const ( - startPort = 50000 - endPort = 60000 -) - -func RandomLocalAddr() string { - r := rand.New(rand.NewSource(time.Now().UTC().UnixNano())) - port := startPort + r.Intn(endPort-startPort) - return net.JoinHostPort("localhost", strconv.Itoa(port)) -} diff --git a/cmd/meroxa/turbine/javascript/cli.go b/cmd/meroxa/turbine/javascript/cli.go deleted file mode 100644 index 621318b24..000000000 --- a/cmd/meroxa/turbine/javascript/cli.go +++ /dev/null @@ -1,22 +0,0 @@ -package turbinejs - -import ( - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/log" -) - -type turbineJsCLI struct { - logger log.Logger - appPath string - *turbine.Core - *turbine.Git - *turbine.Docker -} - -func New(l log.Logger, appPath string) turbine.CLI { - return &turbineJsCLI{ - logger: l, - appPath: appPath, - Core: turbine.NewCore(), - } -} diff --git a/cmd/meroxa/turbine/javascript/deploy.go b/cmd/meroxa/turbine/javascript/deploy.go deleted file mode 100644 index 61bbbc7e9..000000000 --- a/cmd/meroxa/turbine/javascript/deploy.go +++ /dev/null @@ -1,46 +0,0 @@ -package turbinejs - -import ( - "context" - - "github.com/meroxa/cli/cmd/meroxa/turbine" - - "github.com/meroxa/cli/cmd/meroxa/turbine/javascript/internal" -) - -var TurbineJSVersion = "1.3.8" - -func (t *turbineJsCLI) CreateDockerfile(ctx context.Context, _ string) (string, error) { - cmd := internal.NewTurbineCmd( - ctx, - t.appPath, - internal.TurbineCommandBuild, - map[string]string{}, - t.appPath, - ) - _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger) - return t.appPath, err -} - -func (t *turbineJsCLI) StartGrpcServer(ctx context.Context, gitSha string) (func(), error) { - grpcListenAddress, err := t.Core.Start(ctx) - if err != nil { - return nil, err - } - - cmd := internal.NewTurbineCmd( - ctx, - t.appPath, - internal.TurbineCommandRecord, - map[string]string{ - "TURBINE_CORE_SERVER": grpcListenAddress, - }, - gitSha, - ) - - if _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger); err != nil { - return nil, err - } - - return t.Core.Stop() -} diff --git a/cmd/meroxa/turbine/javascript/init.go b/cmd/meroxa/turbine/javascript/init.go deleted file mode 100644 index 865762a44..000000000 --- a/cmd/meroxa/turbine/javascript/init.go +++ /dev/null @@ -1,47 +0,0 @@ -package turbinejs - -import ( - "context" - "os" - "os/exec" - - "github.com/meroxa/turbine-core/pkg/app" - - utils "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/turbine-core/pkg/ir" -) - -func (t *turbineJsCLI) Init(_ context.Context, appName string) error { - a := &app.AppInit{ - AppName: appName, - Language: ir.JavaScript, - Path: t.appPath, - } - err := a.Init() - if err != nil { - return err - } - - err = jsInit(t.appPath + "/" + appName) - if err != nil { - return err - } - - return nil -} - -func jsInit(appPath string) error { - // temporarily switching to the app's directory - pwd, err := utils.SwitchToAppDirectory(appPath) - if err != nil { - return err - } - - cmd := exec.Command("npm", "install") - _, err = cmd.CombinedOutput() - if err != nil { - return err - } - - return os.Chdir(pwd) -} diff --git a/cmd/meroxa/turbine/javascript/internal/cmd.go b/cmd/meroxa/turbine/javascript/internal/cmd.go deleted file mode 100644 index a1fa08eb3..000000000 --- a/cmd/meroxa/turbine/javascript/internal/cmd.go +++ /dev/null @@ -1,42 +0,0 @@ -package internal - -import ( - "context" - "fmt" - "os" - "os/exec" - "path" - "strings" -) - -type TurbineCommand string - -const ( - TurbineCommandRun TurbineCommand = "turbine-js-run" - TurbineCommandRecord TurbineCommand = "turbine-js-record" - TurbineCommandBuild TurbineCommand = "turbine-js-dockerfile" - TurbineCommandVersion TurbineCommand = "turbine-js-version" -) - -func RunTurbineCmd(ctx context.Context, appPath string, command TurbineCommand, env map[string]string, flags ...string) (string, error) { - cmd := NewTurbineCmd(ctx, appPath, command, env, flags...) - cmd.Stderr = nil - cmd.Stdout = nil - out, err := cmd.CombinedOutput() - return strings.TrimSpace(string(out)), err -} - -func NewTurbineCmd(ctx context.Context, appPath string, command TurbineCommand, env map[string]string, args ...string) *exec.Cmd { - cmd := exec.CommandContext(ctx, "node", append([]string{ - path.Join(appPath, "node_modules", "@meroxa", "turbine-js", "bin", string(command)), - }, args...)...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Dir = appPath - cmd.Env = os.Environ() - - for k, v := range env { - cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, v)) - } - return cmd -} diff --git a/cmd/meroxa/turbine/javascript/run.go b/cmd/meroxa/turbine/javascript/run.go deleted file mode 100644 index a881acc40..000000000 --- a/cmd/meroxa/turbine/javascript/run.go +++ /dev/null @@ -1,27 +0,0 @@ -package turbinejs - -import ( - "context" - - utils "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/cmd/meroxa/turbine/javascript/internal" -) - -// Run calls turbine-js to exercise the app. -func (t *turbineJsCLI) Run(ctx context.Context) error { - gracefulStop, grpcListenAddress := t.Core.Run(ctx) - defer gracefulStop() - - cmd := internal.NewTurbineCmd( - ctx, - t.appPath, - internal.TurbineCommandRun, - map[string]string{ - "TURBINE_CORE_SERVER": grpcListenAddress, - }, - "devel", - ) - - _, err := utils.RunCmdWithErrorDetection(ctx, cmd, t.logger) - return err -} diff --git a/cmd/meroxa/turbine/javascript/version.go b/cmd/meroxa/turbine/javascript/version.go deleted file mode 100644 index 87592d3d1..000000000 --- a/cmd/meroxa/turbine/javascript/version.go +++ /dev/null @@ -1,21 +0,0 @@ -package turbinejs - -import ( - "context" - "fmt" - - "github.com/meroxa/cli/cmd/meroxa/turbine/javascript/internal" -) - -func (t *turbineJsCLI) GetVersion(ctx context.Context) (string, error) { - ver, err := internal.RunTurbineCmd( - ctx, - t.appPath, - internal.TurbineCommandVersion, - map[string]string{}, - ) - if err != nil { - return "", fmt.Errorf("cannot determine turbine-js module version in %s", t.appPath) - } - return ver, nil -} diff --git a/cmd/meroxa/turbine/mock/cli_mock.go b/cmd/meroxa/turbine/mock/cli_mock.go deleted file mode 100644 index 563a6f4da..000000000 --- a/cmd/meroxa/turbine/mock/cli_mock.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: interface.go - -// Package mock is a generated GoMock package. -package mock - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - log "github.com/meroxa/cli/log" -) - -// MockCLI is a mock of CLI interface. -type MockCLI struct { - ctrl *gomock.Controller - recorder *MockCLIMockRecorder -} - -// MockCLIMockRecorder is the mock recorder for MockCLI. -type MockCLIMockRecorder struct { - mock *MockCLI -} - -// NewMockCLI creates a new mock instance. -func NewMockCLI(ctrl *gomock.Controller) *MockCLI { - mock := &MockCLI{ctrl: ctrl} - mock.recorder = &MockCLIMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockCLI) EXPECT() *MockCLIMockRecorder { - return m.recorder -} - -// CheckUncommittedChanges mocks base method. -func (m *MockCLI) CheckUncommittedChanges(arg0 context.Context, arg1 log.Logger, arg2 string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CheckUncommittedChanges", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// CheckUncommittedChanges indicates an expected call of CheckUncommittedChanges. -func (mr *MockCLIMockRecorder) CheckUncommittedChanges(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckUncommittedChanges", reflect.TypeOf((*MockCLI)(nil).CheckUncommittedChanges), arg0, arg1, arg2) -} - -// CleanupDockerfile mocks base method. -func (m *MockCLI) CleanupDockerfile(arg0 log.Logger, arg1 string) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "CleanupDockerfile", arg0, arg1) -} - -// CleanupDockerfile indicates an expected call of CleanupDockerfile. -func (mr *MockCLIMockRecorder) CleanupDockerfile(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CleanupDockerfile", reflect.TypeOf((*MockCLI)(nil).CleanupDockerfile), arg0, arg1) -} - -// CreateDockerfile mocks base method. -func (m *MockCLI) CreateDockerfile(arg0 context.Context, arg1 string) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateDockerfile", arg0, arg1) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CreateDockerfile indicates an expected call of CreateDockerfile. -func (mr *MockCLIMockRecorder) CreateDockerfile(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateDockerfile", reflect.TypeOf((*MockCLI)(nil).CreateDockerfile), arg0, arg1) -} - -// GetDeploymentSpec mocks base method. -func (m *MockCLI) GetDeploymentSpec(arg0 context.Context, arg1 string) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetDeploymentSpec", arg0, arg1) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetDeploymentSpec indicates an expected call of GetDeploymentSpec. -func (mr *MockCLIMockRecorder) GetDeploymentSpec(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDeploymentSpec", reflect.TypeOf((*MockCLI)(nil).GetDeploymentSpec), arg0, arg1) -} - -// GetGitSha mocks base method. -func (m *MockCLI) GetGitSha(arg0 context.Context, arg1 string) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetGitSha", arg0, arg1) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetGitSha indicates an expected call of GetGitSha. -func (mr *MockCLIMockRecorder) GetGitSha(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGitSha", reflect.TypeOf((*MockCLI)(nil).GetGitSha), arg0, arg1) -} - -// GetVersion mocks base method. -func (m *MockCLI) GetVersion(arg0 context.Context) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetVersion", arg0) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetVersion indicates an expected call of GetVersion. -func (mr *MockCLIMockRecorder) GetVersion(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVersion", reflect.TypeOf((*MockCLI)(nil).GetVersion), arg0) -} - -// GitInit mocks base method. -func (m *MockCLI) GitInit(arg0 context.Context, arg1 string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GitInit", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// GitInit indicates an expected call of GitInit. -func (mr *MockCLIMockRecorder) GitInit(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GitInit", reflect.TypeOf((*MockCLI)(nil).GitInit), arg0, arg1) -} - -// Init mocks base method. -func (m *MockCLI) Init(arg0 context.Context, arg1 string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Init", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// Init indicates an expected call of Init. -func (mr *MockCLIMockRecorder) Init(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockCLI)(nil).Init), arg0, arg1) -} - -// Run mocks base method. -func (m *MockCLI) Run(arg0 context.Context) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Run", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Run indicates an expected call of Run. -func (mr *MockCLIMockRecorder) Run(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockCLI)(nil).Run), arg0) -} - -// StartGrpcServer mocks base method. -func (m *MockCLI) StartGrpcServer(arg0 context.Context, arg1 string) (func(), error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StartGrpcServer", arg0, arg1) - ret0, _ := ret[0].(func()) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StartGrpcServer indicates an expected call of StartGrpcServer. -func (mr *MockCLIMockRecorder) StartGrpcServer(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartGrpcServer", reflect.TypeOf((*MockCLI)(nil).StartGrpcServer), arg0, arg1) -} diff --git a/cmd/meroxa/turbine/python/cli.go b/cmd/meroxa/turbine/python/cli.go deleted file mode 100644 index 930284db8..000000000 --- a/cmd/meroxa/turbine/python/cli.go +++ /dev/null @@ -1,22 +0,0 @@ -package turbinepy - -import ( - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/log" -) - -type turbinePyCLI struct { - logger log.Logger - appPath string - *turbine.Core - *turbine.Git - *turbine.Docker -} - -func New(l log.Logger, appPath string) turbine.CLI { - return &turbinePyCLI{ - logger: l, - appPath: appPath, - Core: turbine.NewCore(), - } -} diff --git a/cmd/meroxa/turbine/python/deploy.go b/cmd/meroxa/turbine/python/deploy.go deleted file mode 100644 index 5146a132d..000000000 --- a/cmd/meroxa/turbine/python/deploy.go +++ /dev/null @@ -1,40 +0,0 @@ -package turbinepy - -import ( - "context" - - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/cmd/meroxa/turbine/python/internal" -) - -func (t *turbinePyCLI) CreateDockerfile(ctx context.Context, _ string) (string, error) { - cmd := internal.NewTurbineCmd(t.appPath, - internal.TurbineCommandBuild, - map[string]string{}, - t.appPath, - ) - _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger) - return t.appPath, err -} - -func (t *turbinePyCLI) StartGrpcServer(ctx context.Context, gitSha string) (func(), error) { - grpcListenAddress, err := t.Core.Start(ctx) - if err != nil { - return nil, err - } - - cmd := internal.NewTurbineCmd(t.appPath, - internal.TurbineCommandRecord, - map[string]string{ - "TURBINE_CORE_SERVER": grpcListenAddress, - }, - t.appPath, - gitSha, - ) - - if _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger); err != nil { - return nil, err - } - - return t.Core.Stop() -} diff --git a/cmd/meroxa/turbine/python/init.go b/cmd/meroxa/turbine/python/init.go deleted file mode 100644 index 37aa3b509..000000000 --- a/cmd/meroxa/turbine/python/init.go +++ /dev/null @@ -1,17 +0,0 @@ -package turbinepy - -import ( - "context" - - "github.com/meroxa/turbine-core/pkg/app" - "github.com/meroxa/turbine-core/pkg/ir" -) - -func (t *turbinePyCLI) Init(_ context.Context, appName string) error { - a := &app.AppInit{ - AppName: appName, - Language: ir.Python, - Path: t.appPath, - } - return a.Init() -} diff --git a/cmd/meroxa/turbine/python/internal/cmd.go b/cmd/meroxa/turbine/python/internal/cmd.go deleted file mode 100644 index bec349ebd..000000000 --- a/cmd/meroxa/turbine/python/internal/cmd.go +++ /dev/null @@ -1,41 +0,0 @@ -package internal - -import ( - "fmt" - "os" - "os/exec" - "strings" -) - -type TurbineCommand string - -const ( - TurbineCommandRun TurbineCommand = "run" - TurbineCommandRecord TurbineCommand = "record" - TurbineCommandBuild TurbineCommand = "build" - TurbineCommandVersion TurbineCommand = `version` -) - -func RunTurbineCmd(appPath string, command TurbineCommand, env map[string]string, flags ...string) (string, error) { - cmd := NewTurbineCmd(appPath, command, env, flags...) - cmd.Stderr = nil - cmd.Stdout = nil - cmd.Dir = appPath - out, err := cmd.CombinedOutput() - return strings.TrimSpace(string(out)), err -} - -func NewTurbineCmd(appPath string, command TurbineCommand, env map[string]string, flags ...string) *exec.Cmd { - cmd := exec.Command("turbine-py", append([]string{ - string(command), - }, flags...)...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Dir = appPath - cmd.Env = os.Environ() - - for k, v := range env { - cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, v)) - } - return cmd -} diff --git a/cmd/meroxa/turbine/python/run.go b/cmd/meroxa/turbine/python/run.go deleted file mode 100644 index 65a5939ba..000000000 --- a/cmd/meroxa/turbine/python/run.go +++ /dev/null @@ -1,24 +0,0 @@ -package turbinepy - -import ( - "context" - - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/cmd/meroxa/turbine/python/internal" -) - -func (t *turbinePyCLI) Run(ctx context.Context) error { - gracefulStop, grpcListenAddress := t.Core.Run(ctx) - defer gracefulStop() - - cmd := internal.NewTurbineCmd(t.appPath, - internal.TurbineCommandRun, - map[string]string{ - "TURBINE_CORE_SERVER": grpcListenAddress, - }, - t.appPath, - "", - ) - _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger) - return err -} diff --git a/cmd/meroxa/turbine/python/version.go b/cmd/meroxa/turbine/python/version.go deleted file mode 100644 index f2c4beaa1..000000000 --- a/cmd/meroxa/turbine/python/version.go +++ /dev/null @@ -1,22 +0,0 @@ -package turbinepy - -import ( - "context" - "fmt" - - "github.com/meroxa/cli/cmd/meroxa/turbine/python/internal" -) - -// GetVersion calls turbine-py to get its version used by the given app. -func (t *turbinePyCLI) GetVersion(_ context.Context) (string, error) { - ver, err := internal.RunTurbineCmd( - t.appPath, - internal.TurbineCommandVersion, - map[string]string{}, - t.appPath, - ) - if err != nil { - return "", fmt.Errorf("cannot determine turbine-py version in %s", t.appPath) - } - return ver, nil -} diff --git a/cmd/meroxa/turbine/ruby/cli.go b/cmd/meroxa/turbine/ruby/cli.go deleted file mode 100644 index 9938a8ba6..000000000 --- a/cmd/meroxa/turbine/ruby/cli.go +++ /dev/null @@ -1,24 +0,0 @@ -//go:generate mockgen -source=cli.go -package=mock -destination=mock/cli_mock.go - -package turbinerb - -import ( - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/log" -) - -type turbineRbCLI struct { - logger log.Logger - appPath string - *turbine.Core - *turbine.Git - *turbine.Docker -} - -func New(l log.Logger, appPath string) turbine.CLI { - return &turbineRbCLI{ - logger: l, - appPath: appPath, - Core: turbine.NewCore(), - } -} diff --git a/cmd/meroxa/turbine/ruby/deploy.go b/cmd/meroxa/turbine/ruby/deploy.go deleted file mode 100644 index e47c4e97b..000000000 --- a/cmd/meroxa/turbine/ruby/deploy.go +++ /dev/null @@ -1,42 +0,0 @@ -package turbinerb - -import ( - "context" - - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/cmd/meroxa/turbine/ruby/internal" -) - -func (t *turbineRbCLI) CreateDockerfile(ctx context.Context, _ string) (string, error) { - cmd := internal.NewTurbineCmd( - ctx, - t.appPath, - internal.TurbineCommandBuild, - map[string]string{}, - ) - _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger) - return t.appPath, err -} - -func (t *turbineRbCLI) StartGrpcServer(ctx context.Context, gitSha string) (func(), error) { - grpcListenAddress, err := t.Core.Start(ctx) - if err != nil { - return nil, err - } - - cmd := internal.NewTurbineCmd( - ctx, - t.appPath, - internal.TurbineCommandRecord, - map[string]string{ - "TURBINE_CORE_SERVER": grpcListenAddress, - }, - gitSha, - ) - - if _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger); err != nil { - return nil, err - } - - return t.Core.Stop() -} diff --git a/cmd/meroxa/turbine/ruby/init.go b/cmd/meroxa/turbine/ruby/init.go deleted file mode 100644 index e620f2e95..000000000 --- a/cmd/meroxa/turbine/ruby/init.go +++ /dev/null @@ -1,17 +0,0 @@ -package turbinerb - -import ( - "context" - - "github.com/meroxa/turbine-core/pkg/app" - "github.com/meroxa/turbine-core/pkg/ir" -) - -func (t *turbineRbCLI) Init(_ context.Context, appName string) error { - a := &app.AppInit{ - AppName: appName, - Language: ir.Ruby, - Path: t.appPath, - } - return a.Init() -} diff --git a/cmd/meroxa/turbine/ruby/internal/cmd.go b/cmd/meroxa/turbine/ruby/internal/cmd.go deleted file mode 100644 index 78c1fa78c..000000000 --- a/cmd/meroxa/turbine/ruby/internal/cmd.go +++ /dev/null @@ -1,43 +0,0 @@ -package internal - -import ( - "context" - "fmt" - "os" - "os/exec" - "path" - "strings" -) - -type TurbineCommand string - -const ( - TurbineCommandRun TurbineCommand = "TurbineRb.run" - TurbineCommandRecord TurbineCommand = "TurbineRb.record" - TurbineCommandBuild TurbineCommand = "TurbineRb.build" - TurbineCommandVersion TurbineCommand = `puts Gem.loaded_specs["turbine_rb"].version.version` -) - -func RunTurbineCmd(ctx context.Context, appPath string, command TurbineCommand, env map[string]string, flags ...string) (string, error) { - cmd := NewTurbineCmd(ctx, appPath, command, env, flags...) - cmd.Stderr = nil - cmd.Stdout = nil - out, err := cmd.CombinedOutput() - return strings.TrimSpace(string(out)), err -} - -func NewTurbineCmd(ctx context.Context, appPath string, command TurbineCommand, env map[string]string, flags ...string) *exec.Cmd { - cmd := exec.CommandContext(ctx, "ruby", append([]string{ - "-r", path.Join(appPath, "app"), - "-e", string(command), - }, flags...)...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Dir = appPath - cmd.Env = os.Environ() - - for k, v := range env { - cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, v)) - } - return cmd -} diff --git a/cmd/meroxa/turbine/ruby/internal/cmd_test.go b/cmd/meroxa/turbine/ruby/internal/cmd_test.go deleted file mode 100644 index 42e7865f0..000000000 --- a/cmd/meroxa/turbine/ruby/internal/cmd_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package internal_test - -import ( - "context" - "os" - "testing" - - "github.com/meroxa/cli/cmd/meroxa/turbine/ruby/internal" - "github.com/stretchr/testify/assert" -) - -func Test_NewTurbineCmd(t *testing.T) { - ctx := context.Background() - cmd := internal.NewTurbineCmd( - ctx, - "/my/path", - internal.TurbineCommandRun, - map[string]string{ - "foo": "bar", - "x": "y", - }) - - assert.Equal(t, cmd.Stdout, os.Stdout) - assert.Equal(t, cmd.Stderr, os.Stderr) - assert.Equal(t, cmd.Dir, "/my/path") - assert.Equal(t, cmd.Args, []string{ - "ruby", - "-r", "/my/path/app", - "-e", "TurbineRb.run", - }) - assert.Contains(t, cmd.Env, "foo=bar") - assert.Contains(t, cmd.Env, "x=y") -} diff --git a/cmd/meroxa/turbine/ruby/mock/cli_mock.go b/cmd/meroxa/turbine/ruby/mock/cli_mock.go deleted file mode 100644 index 05a500ddc..000000000 --- a/cmd/meroxa/turbine/ruby/mock/cli_mock.go +++ /dev/null @@ -1,5 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: cli.go - -// Package mock is a generated GoMock package. -package mock diff --git a/cmd/meroxa/turbine/ruby/run.go b/cmd/meroxa/turbine/ruby/run.go deleted file mode 100644 index bb95f0a89..000000000 --- a/cmd/meroxa/turbine/ruby/run.go +++ /dev/null @@ -1,23 +0,0 @@ -package turbinerb - -import ( - "context" - - "github.com/meroxa/cli/cmd/meroxa/turbine" - "github.com/meroxa/cli/cmd/meroxa/turbine/ruby/internal" -) - -func (t *turbineRbCLI) Run(ctx context.Context) error { - gracefulStop, grpcListenAddress := t.Core.Run(ctx) - defer gracefulStop() - - cmd := internal.NewTurbineCmd( - ctx, - t.appPath, - internal.TurbineCommandRun, - map[string]string{ - "TURBINE_CORE_SERVER": grpcListenAddress, - }) - _, err := turbine.RunCmdWithErrorDetection(ctx, cmd, t.logger) - return err -} diff --git a/cmd/meroxa/turbine/ruby/version.go b/cmd/meroxa/turbine/ruby/version.go deleted file mode 100644 index 0355212ac..000000000 --- a/cmd/meroxa/turbine/ruby/version.go +++ /dev/null @@ -1,22 +0,0 @@ -package turbinerb - -import ( - "context" - "fmt" - - "github.com/meroxa/cli/cmd/meroxa/turbine/ruby/internal" -) - -// GetVersion will return the version of turbine-rb dependency of a given app. -func (t *turbineRbCLI) GetVersion(ctx context.Context) (string, error) { - ver, err := internal.RunTurbineCmd( - ctx, - t.appPath, - internal.TurbineCommandVersion, - map[string]string{}, - ) - if err != nil { - return "", fmt.Errorf("cannot determine turbine-rb gem version in %s", t.appPath) - } - return ver, nil -} diff --git a/cmd/meroxa/turbine/utils.go b/cmd/meroxa/turbine/utils.go deleted file mode 100644 index daf38a4bd..000000000 --- a/cmd/meroxa/turbine/utils.go +++ /dev/null @@ -1,304 +0,0 @@ -package turbine - -import ( - "bytes" - "context" - "encoding/json" - "errors" - "fmt" - "net/http" - "os" - "os/exec" - "path" - "path/filepath" - "regexp" - "strings" - - "github.com/meroxa/cli/log" - "github.com/meroxa/turbine-core/v2/pkg/ir" -) - -const ( - GoLang = "golang" - JavaScript = "javascript" - NodeJs = "nodejs" - Python = "python" - Python3 = "python3" - Ruby = "ruby" - - grpcFuncCollectionErr = "invalid ProcessCollectionRequest.Collection: embedded message failed validation | " + - "caused by: invalid Collection.Name: value length must be at least 1 runes" - grpcDestCollectionErr = "invalid WriteCollectionRequest.SourceCollection: embedded message failed validation | " + - "caused by: invalid Collection.Name: value length must be at least 1 runes" - missingSourceCollectionErr = `missing source or source collection, please ensure that you have configured your source correctly: -https://docs.meroxa.com/turbine/troubleshooting#troubleshooting-checklist"` -) - -type AppConfig struct { - Name string `json:"name"` - Environment string `json:"environment"` - Language ir.Lang `json:"language"` - Resources map[string]string `json:"resources"` - Vendor string `json:"vendor"` - ModuleInit string `json:"module_init"` -} - -var prefetched *AppConfig - -func GetPath(flag string) (string, error) { - if flag == "" { - flag = "." - } - var err error - flag, err = filepath.Abs(flag) - if err != nil { - return "", err - } - return flag, nil -} - -// GetLangFromAppJSON returns specified language in users' app.json. -func GetLangFromAppJSON(l log.Logger, pwd string) (ir.Lang, error) { - l.StartSpinner("\t", "Determining application language from app.json...") - appConfig, err := ReadConfigFile(pwd) - if err != nil { - l.StopSpinnerWithStatus("Something went wrong reading your app.json", log.Failed) - return "", err - } - - if appConfig.Language == "" { - l.StopSpinnerWithStatus("`language` should be specified in your app.json", log.Failed) - return "", fmt.Errorf("add key `language` to your app.json") - } - l.StopSpinnerWithStatus(fmt.Sprintf("Checked your language is %q", appConfig.Language), log.Successful) - return appConfig.Language, nil -} - -// GetAppNameFromAppJSON returns specified app name in users' app.json. -func GetAppNameFromAppJSON(l log.Logger, pwd string) (string, error) { - l.StartSpinner("\t", "Reading application name from app.json...") - appConfig, err := ReadConfigFile(pwd) - if err != nil { - return "", err - } - - if appConfig.Name == "" { - l.StopSpinnerWithStatus("`name` should be specified in your app.json", log.Failed) - return "", fmt.Errorf("add `name` to your app.json") - } - l.StopSpinnerWithStatus(fmt.Sprintf("Checked your application name is %q", appConfig.Name), log.Successful) - return appConfig.Name, nil -} - -// SetModuleInitInAppJSON returns whether to run mod init. -func SetModuleInitInAppJSON(pwd string, skipInit bool) error { - appConfig, err := ReadConfigFile(pwd) - if err != nil { - return err - } - appConfig.ModuleInit = "true" - if skipInit { - appConfig.ModuleInit = "false" - } - return WriteConfigFile(pwd, appConfig) -} - -// SetVendorInAppJSON returns whether to vendor modules. -func SetVendorInAppJSON(pwd string, vendor bool) error { - appConfig, err := ReadConfigFile(pwd) - if err != nil { - return err - } - appConfig.Vendor = "false" - if vendor { - appConfig.Vendor = "true" - } - return WriteConfigFile(pwd, appConfig) -} - -// ReadConfigFile will read the content of an app.json based on path. -func ReadConfigFile(appPath string) (*AppConfig, error) { - var appConfig AppConfig - - if prefetched == nil || os.Getenv("UNIT_TEST") != "" { - appConfigPath := path.Join(appPath, "app.json") - appConfigBytes, err := os.ReadFile(appConfigPath) - if err != nil { - return &appConfig, fmt.Errorf("could not find an app.json file on path %q."+ - " Try a different value for `--path`", appPath) - } - if err := json.Unmarshal(appConfigBytes, &appConfig); err != nil { - return &appConfig, err - } - prefetched = &appConfig - } - - return prefetched, nil -} - -func WriteConfigFile(appPath string, cfg *AppConfig) error { - appConfigPath := path.Join(appPath, "app.json") - data, err := json.MarshalIndent(cfg, "", " ") - if err != nil { - return err - } - err = os.WriteFile(appConfigPath, data, 0o664) - if err != nil { - return fmt.Errorf("%v\n"+ - "unable to update app.json file on path %q. Maybe try using a different value for `--path`", err, appPath) - } - return nil -} - -func GetTurbineResponseFromOutput(output string) (string, error) { - r := regexp.MustCompile("turbine-response: ([^\r\n]*)") - match := r.FindStringSubmatch(output) - if match == nil || len(match) < 2 { - return "", fmt.Errorf("output is formatted unexpectedly") - } - - trimmed := strings.TrimSpace(match[1]) - return trimmed, nil -} - -// RunCmdWithErrorDetection checks exit codes and stderr for failures and logs on success. -func RunCmdWithErrorDetection(ctx context.Context, cmd *exec.Cmd, logger log.Logger) (string, error) { - stdout, stderr := bytes.NewBuffer(nil), bytes.NewBuffer(nil) - cmd.Stdout = stdout - cmd.Stderr = stderr - err := cmd.Run() - stdOutMsg := stdout.String() - stdErrMsg := stderr.String() - - if err != nil || stdErrMsg != "" { - var errMsg, errLog string - if err != nil { - errMsg = err.Error() - } - if stdErrMsg != "" { - // ignore most npm messages - errorLogs := trimNonNpmErrorLines(stdErrMsg) - if len(errorLogs) > 0 { - errLog = errorLogs - } - } else if errMsg != "" { - errLog = errMsg - } - if errLog != "" { - if stdOutMsg != "" { - errLog = stdOutMsg + errLog - } - - if strings.Contains(errLog, "rpc error") { - logger.Debug(ctx, errLog) - errLog = clarifyGrpcErrors(errLog) - } - - return "", errors.New(errLog) - } - } - return stdOutMsg, nil -} - -func trimNonNpmErrorLines(output string) string { - ignoreThese := []string{"npm info", "npm timing", "npm http", "npm notice", "npm warn"} - allLines := strings.Split(output, "\n") - errorLines := []string{} - - for _, line := range allLines { - skip := false - for _, ignore := range ignoreThese { - if strings.HasPrefix(line, ignore) { - skip = true - break - } - } - if !skip { - errorLines = append(errorLines, line) - } - } - - return strings.Join(errorLines, "\n") -} - -// TODO: remove this and refactor error handling from turbine-core grpc requests -// This is needed temporarily to provide a more actionable error when the app has no sources defined. -// Longer-term, we need to have more specific, actionable errors rather than grpc validation -// errors surfaced to CLI output. -func clarifyGrpcErrors(errLog string) string { - switch { - case strings.Contains(errLog, grpcFuncCollectionErr): - return missingSourceCollectionErr - case strings.Contains(errLog, grpcDestCollectionErr): - return missingSourceCollectionErr - } - return errLog -} - -// SwitchToAppDirectory switches temporarily to the application's directory. -func SwitchToAppDirectory(appPath string) (string, error) { - pwd, err := os.Getwd() - if err != nil { - return pwd, err - } - return pwd, os.Chdir(appPath) -} - -func UploadFile(ctx context.Context, logger log.Logger, filePath, url string) error { - logger.StartSpinner("\t", "Uploading source...") - - var clientErr error - var res *http.Response - client := &http.Client{} - - retries := 3 - for retries > 0 { - fh, err := os.Open(filePath) - if err != nil { - logger.StopSpinnerWithStatus("\t Failed to open source file", log.Failed) - return err - } - defer func(fh *os.File) { - fh.Close() - }(fh) - - req, err := http.NewRequestWithContext(ctx, "PUT", url, fh) - if err != nil { - logger.StopSpinnerWithStatus("\t Failed to make new request", log.Failed) - return err - } - - fi, err := fh.Stat() - if err != nil { - logger.StopSpinnerWithStatus("\t Failed to stat source file", log.Failed) - return err - } - req.Header.Set("Accept", "*/*") - req.Header.Set("Content-Type", "multipart/form-data") - req.Header.Set("Accept-Encoding", "gzip, deflate, br") - req.Header.Set("Connection", "keep-alive") - - req.ContentLength = fi.Size() - - res, clientErr = client.Do(req) - if clientErr != nil || (res.StatusCode < http.StatusOK || res.StatusCode >= http.StatusMultipleChoices) { - retries-- - } else { - break - } - } - - if res != nil && res.Body != nil { - defer res.Body.Close() - } - if clientErr != nil || (res.StatusCode < http.StatusOK || res.StatusCode >= http.StatusMultipleChoices) { - logger.StopSpinnerWithStatus("\t Failed to upload build source file", log.Failed) - if clientErr == nil { - clientErr = fmt.Errorf("upload failed: %s", res.Status) - } - return clientErr - } - - logger.StopSpinnerWithStatus("Source uploaded", log.Successful) - return nil -} diff --git a/cmd/meroxa/turbine/utils_test.go b/cmd/meroxa/turbine/utils_test.go deleted file mode 100644 index 70561921c..000000000 --- a/cmd/meroxa/turbine/utils_test.go +++ /dev/null @@ -1,317 +0,0 @@ -package turbine - -import ( - "context" - "fmt" - "net/http" - "net/http/httptest" - "os" - "os/exec" - "path/filepath" - "strings" - "testing" - - "github.com/google/uuid" - "github.com/meroxa/cli/log" - "github.com/meroxa/turbine-core/v2/pkg/ir" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestReadAndWriteConfigFile(t *testing.T) { - logger := log.NewTestLogger() - appPath, err := makeTmpDir() - require.NoError(t, err) - - os.Setenv("UNIT_TEST", "true") - defer func() { - os.Setenv("UNIT_TEST", "") - }() - - tests := []struct { - name string - path string - input AppConfig - err error - }{ - { - name: "Successfully read and write AppConfig", - path: appPath, - input: AppConfig{ - Name: "my-name", - Language: ir.JavaScript, - Vendor: "false", - ModuleInit: "true", - }, - err: nil, - }, - { - name: "Fail to read and write AppConfig", - path: "#nope$", - input: AppConfig{ - Name: "my-name2", - Language: ir.Python, - Vendor: "false", - ModuleInit: "true", - }, - err: fmt.Errorf(`open #nope$/app.json: no such file or directory -unable to update app.json file on path "#nope$". Maybe try using a different value for ` + "`" + "--path" + "`"), - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - err := WriteConfigFile(tc.path, &tc.input) - if err != nil { - if tc.err == nil { - t.Fatalf("unexpected error: %v", err) - } - assert.Equal(t, tc.err, err) - return - } - require.NoError(t, err) - require.NoError(t, tc.err) - - lang, err := GetLangFromAppJSON(logger, tc.path) - require.NoError(t, err) - require.Equal(t, tc.input.Language, lang) - - name, err := GetAppNameFromAppJSON(logger, tc.path) - require.NoError(t, err) - require.Equal(t, tc.input.Name, name) - - read, err := ReadConfigFile(tc.path) - require.NoError(t, err) - require.Equal(t, tc.input.Vendor, read.Vendor) - require.Equal(t, tc.input.ModuleInit, read.ModuleInit) - - err = SetVendorInAppJSON(tc.path, true) - require.NoError(t, err) - err = SetModuleInitInAppJSON(tc.path, true) - require.NoError(t, err) - - read, err = ReadConfigFile(tc.path) - require.NoError(t, err) - require.Equal(t, "true", read.Vendor) - require.Equal(t, "false", read.ModuleInit) - }) - } -} - -func TestGetTurbineResponseFromOutput(t *testing.T) { - tests := []struct { - name string - input string - output string - err error - }{ - { - name: "Successfully parse output", - input: "hey\nturbine-response: very important message\nnot important", - output: "very important message", - }, - { - name: "Successfully parse empty string", - input: "hey\nturbine-response: \nnot important", - output: "", - }, - { - name: "Successfully parse with carriage returns", - input: "hey\nturbine-response: 1.7.0\r\nthis is from windows!", - output: "1.7.0", - }, - { - name: "Successfully parse with carriage returns plus some spaces", - input: "hey\nturbine-response: 1.7.0 \r\nthis is from windows!", - output: "1.7.0", - }, - { - name: "Fail to find output", - input: "ABC", - err: fmt.Errorf("output is formatted unexpectedly"), - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - val, err := GetTurbineResponseFromOutput(tc.input) - if err != nil { - if tc.err == nil { - t.Fatalf("unexpected err: %v", err) - } else { - assert.Equal(t, tc.err, err) - } - } else { - assert.Equal(t, tc.output, val) - } - }) - } -} - -func TestGetPath(t *testing.T) { - cwd, err := os.Getwd() - require.NoError(t, err) - - tests := []struct { - name string - input string - output string - }{ - { - name: "Successfully get path with no input", - input: "", - output: cwd, - }, - { - name: "Successfully get path with . input", - input: ".", - output: cwd, - }, - { - name: "Handle non-existent path", - input: "/does+|/not`/exist&", - output: "/does+|/not`/exist&", - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - val, err := GetPath(tc.input) - require.NoError(t, err) - assert.Equal(t, tc.output, val) - }) - } -} - -func TestRunCMDWithErrorDetection(t *testing.T) { - ctx := context.Background() - logger := log.NewTestLogger() - - tests := []struct { - name string - input *exec.Cmd - output string - err error - }{ - { - name: "Successfully execute command", - input: exec.Command("date"), - err: nil, - }, - { - name: "Fail to find command", - input: exec.Command("not-a-thing"), - err: fmt.Errorf("exec: \"not-a-thing\": executable file not found in $PATH"), - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - val, err := RunCmdWithErrorDetection(ctx, tc.input, logger) - if err != nil { - if tc.err == nil { - t.Fatalf("unexpected err: %v", err) - } else { - assert.Equal(t, tc.err, err) - assert.Equal(t, tc.output, val) - } - } else { - require.NoError(t, err) - } - }) - } -} - -func Test_trimNonNpmErrorLines(t *testing.T) { - tests := []struct { - name string - input string - output string - }{ - { - name: "Successfully remove errors", - input: "hi\nnpm warn secrets\nnpm error no good\nmessage", - output: "hi\nnpm error no good\nmessage", - }, - { - name: "Nothing to remove", - input: "hi\nmessage", - output: "hi\nmessage", - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - val := trimNonNpmErrorLines(tc.input) - assert.Equal(t, tc.output, val) - }) - } -} - -func makeTmpDir() (string, error) { - basePath := os.TempDir() - dirName := uuid.NewString() - appPath := filepath.Join(basePath, dirName) - err := os.MkdirAll(appPath, os.ModePerm) - return appPath, err -} - -func TestUploadFile(t *testing.T) { - ctx := context.Background() - retries := 0 - testCases := []struct { - name string - server func(int) *httptest.Server - status int - retries int - output string - err error - }{ - { - name: "Successfully upload file", - server: func(status int) *httptest.Server { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - retries++ - w.WriteHeader(status) - })) - return server - }, - status: http.StatusOK, - retries: 1, - output: "Source uploaded", - }, - { - name: "Fail to upload file", - server: func(status int) *httptest.Server { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - retries++ - w.WriteHeader(status) - })) - return server - }, - status: http.StatusInternalServerError, - retries: 3, - output: "Failed to upload build source file", - err: fmt.Errorf("upload failed: 500 Internal Server Error"), - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - retries = 0 - logger := log.NewTestLogger() - logger.StartSpinner("", "") - server := tc.server(tc.status) - err := UploadFile(ctx, logger, "utils.go", server.URL) - if tc.err != nil { - assert.Equal(t, tc.err, err) - } else { - require.NoError(t, err) - } - assert.Equal(t, tc.retries, retries) - output := logger.SpinnerOutput() - assert.True(t, strings.Contains(output, tc.output)) - server.Close() - }) - } -} diff --git a/go.mod b/go.mod index ca2c88d65..41a80487a 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/fatih/color v1.15.0 github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.6.0 - github.com/google/uuid v1.5.0 github.com/gorilla/mux v1.8.0 github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect @@ -23,30 +22,22 @@ require ( require ( github.com/briandowns/spinner v1.23.0 - github.com/meroxa/turbine-core v0.0.0-20230815153536-e0c914b74ea1 github.com/stretchr/testify v1.8.4 github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 golang.org/x/mod v0.14.0 - google.golang.org/protobuf v1.32.0 // indirect ) -require github.com/meroxa/turbine-core/v2 v2.0.1 - require ( - github.com/conduitio/conduit-commons v0.0.0-20240103200651-5a5746611a8e // indirect - github.com/goccy/go-json v0.10.2 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) require ( github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dewski/jsonpath v0.0.0-20210103075638-af6da8f1a897 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/heimdalr/dag v1.4.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/kelseyhightower/envconfig v1.4.0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -58,19 +49,15 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.3.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.10.0 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect - golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/grpc v1.60.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 70c767dd7..90bab88d3 100644 --- a/go.sum +++ b/go.sum @@ -52,8 +52,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/conduitio/conduit-commons v0.0.0-20240103200651-5a5746611a8e h1:v0bwYB9rByFyg0CId+mJrw5qxPUsVWpgcP/QHVP7fyg= -github.com/conduitio/conduit-commons v0.0.0-20240103200651-5a5746611a8e/go.mod h1:lnHoVI2Vqhwjfacvr6J3A7UpkZrOtay6TJwaMhL47fc= github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -62,16 +60,12 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dewski/jsonpath v0.0.0-20210103075638-af6da8f1a897 h1:ry3d3QiAwu3vz1i9XIjgsg310jpt4mLAYyDVc8oWSMs= github.com/dewski/jsonpath v0.0.0-20210103075638-af6da8f1a897/go.mod h1:kR1CX3jQ2R/XHk+Lm1tHx7F1xhKlwCy2tMtS7jDUqtc= -github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= -github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= -github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= @@ -81,10 +75,6 @@ github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbS 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-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= -github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= -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/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 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= @@ -112,9 +102,6 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 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= @@ -126,7 +113,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -144,9 +130,6 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/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/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= @@ -156,8 +139,6 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/heimdalr/dag v1.4.0 h1:zG3JA4RDVLc55k3AXAgfwa+EgBNZ0TkfOO3C29Ucpmg= -github.com/heimdalr/dag v1.4.0/go.mod h1:OCh6ghKmU0hPjtwMqWBoNxPmtRioKd1xSu7Zs4sbIqM= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -169,6 +150,7 @@ github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -177,8 +159,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ= -github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= 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-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -186,10 +166,6 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/meroxa/turbine-core v0.0.0-20230815153536-e0c914b74ea1 h1:4tx5X9TVepTLVYP2ZOokKwkCSBldtGZh69kArXZaI9c= -github.com/meroxa/turbine-core v0.0.0-20230815153536-e0c914b74ea1/go.mod h1:03beJfCWdChsKHzbhiDlOcYKyAKkrtoC3y8ualUFOrI= -github.com/meroxa/turbine-core/v2 v2.0.1 h1:/KyBDtEF7kQPys27OLJuOrKl9mUfFv9U3rQ+TFC9PVA= -github.com/meroxa/turbine-core/v2 v2.0.1/go.mod h1:DvSqZnPmz8gUOS2ZQ59FDphuLHVA84SgdVDdBwQwJLg= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/nirasan/go-oauth-pkce-code-verifier v0.0.0-20170819232839-0fbfe93532da h1:qiPWuGGr+1GQE6s9NPSK8iggR/6x/V+0snIoOPYsBgc= @@ -217,8 +193,6 @@ github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9c github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA= github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= @@ -339,8 +313,6 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v 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-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= 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= @@ -534,8 +506,6 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -552,8 +522,6 @@ google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= 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= @@ -564,10 +532,6 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/vendor/github.com/conduitio/conduit-commons/LICENSE.md b/vendor/github.com/conduitio/conduit-commons/LICENSE.md deleted file mode 100644 index daaf7d2f4..000000000 --- a/vendor/github.com/conduitio/conduit-commons/LICENSE.md +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2023 Meroxa, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/data.go b/vendor/github.com/conduitio/conduit-commons/opencdc/data.go deleted file mode 100644 index 3b7c8b358..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/data.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright © 2023 Meroxa, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package opencdc - -import ( - "bytes" - "fmt" - - opencdcv1 "github.com/conduitio/conduit-commons/proto/opencdc/v1" - "github.com/goccy/go-json" -) - -// Data is a structure that contains some bytes. The only structs implementing -// Data are RawData and StructuredData. -type Data interface { - isData() // Ensure structs outside of this package can't implement this interface. - Bytes() []byte - Clone() Data - ToProto(*opencdcv1.Data) error -} - -type Change struct { - // Before contains the data before the operation occurred. This field is - // optional and should only be populated for operations OperationUpdate - // OperationDelete (if the system supports fetching the data before the - // operation). - Before Data `json:"before"` - // After contains the data after the operation occurred. This field should - // be populated for all operations except OperationDelete. - After Data `json:"after"` -} - -// StructuredData contains data in form of a map with string keys and arbitrary -// values. -type StructuredData map[string]interface{} - -func (StructuredData) isData() {} - -func (d StructuredData) Bytes() []byte { - b, err := json.Marshal(d) - if err != nil { - // Unlikely to happen, records travel from/to plugins through GRPC. - // If the content can be marshaled as protobuf it can be as JSON. - panic(fmt.Errorf("error while marshaling StructuredData as JSON: %w", err)) - } - return b -} - -func (d StructuredData) Clone() Data { - cloned := make(map[string]any, len(d)) - for k, v := range d { - if vmap, ok := v.(map[string]any); ok { - cloned[k] = StructuredData(vmap).Clone() - } else { - cloned[k] = v - } - } - return StructuredData(cloned) -} - -// RawData contains unstructured data in form of a byte slice. -type RawData []byte - -func (RawData) isData() {} - -func (d RawData) Bytes() []byte { - return d -} - -func (d RawData) Clone() Data { - return RawData(bytes.Clone(d)) -} diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/errors.go b/vendor/github.com/conduitio/conduit-commons/opencdc/errors.go deleted file mode 100644 index 4b47984eb..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/errors.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright © 2023 Meroxa, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package opencdc - -import ( - "errors" -) - -var ( - // ErrMetadataFieldNotFound is returned in metadata utility functions when a - // metadata field is not found. - ErrMetadataFieldNotFound = errors.New("metadata field not found") - // ErrUnknownOperation is returned when trying to parse an Operation string - // and encountering an unknown operation. - ErrUnknownOperation = errors.New("unknown operation") - - // ErrInvalidProtoDataType is returned when trying to convert a proto data - // type to raw or structured data. - ErrInvalidProtoDataType = errors.New("invalid proto data type") -) diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/json.go b/vendor/github.com/conduitio/conduit-commons/opencdc/json.go deleted file mode 100644 index 2935fe64b..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/json.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright © 2023 Meroxa, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package opencdc - -import ( - "fmt" - - "github.com/goccy/go-json" -) - -func (r *Record) UnmarshalJSON(b []byte) error { - var raw struct { - Position Position `json:"position"` - Operation Operation `json:"operation"` - Metadata Metadata `json:"metadata"` - Payload struct { - Before json.RawMessage `json:"before"` - After json.RawMessage `json:"after"` - } `json:"payload"` - Key json.RawMessage `json:"key"` - } - - err := json.Unmarshal(b, &raw) - if err != nil { - return err //nolint:wrapcheck // no additional context to add - } - - key, err := dataUnmarshalJSON(raw.Key) - if err != nil { - return err - } - - payloadBefore, err := dataUnmarshalJSON(raw.Payload.Before) - if err != nil { - return err - } - - payloadAfter, err := dataUnmarshalJSON(raw.Payload.After) - if err != nil { - return err - } - - r.Position = raw.Position - r.Operation = raw.Operation - r.Metadata = raw.Metadata - r.Key = key - r.Payload = Change{ - Before: payloadBefore, - After: payloadAfter, - } - - return nil -} - -func dataUnmarshalJSON(b []byte) (Data, error) { - if b[0] == '"' { - var data RawData - err := json.Unmarshal(b, &data) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal raw data: %w", err) - } - return data, nil - } - var data StructuredData - err := json.Unmarshal(b, &data) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal structured data: %w", err) - } - return data, nil -} diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/metadata.go b/vendor/github.com/conduitio/conduit-commons/opencdc/metadata.go deleted file mode 100644 index 0d83772e9..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/metadata.go +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright © 2023 Meroxa, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package opencdc - -import ( - "fmt" - "strconv" - "time" -) - -const ( - // OpenCDCVersion is a constant that should be used as the value in the - // metadata field MetadataVersion. It ensures the OpenCDC format version can - // be easily identified in case the record gets marshaled into a different - // untyped format (e.g. JSON). - OpenCDCVersion = "v1" - - // MetadataOpenCDCVersion is a Record.Metadata key for the version of the - // OpenCDC format (e.g. "v1"). This field exists to ensure the OpenCDC - // format version can be easily identified in case the record gets marshaled - // into a different untyped format (e.g. JSON). - MetadataOpenCDCVersion = "opencdc.version" - // MetadataCreatedAt is a Record.Metadata key for the time when the record - // was created in the 3rd party system. The expected format is a unix - // timestamp in nanoseconds. - MetadataCreatedAt = "opencdc.createdAt" - // MetadataReadAt is a Record.Metadata key for the time when the record was - // read from the 3rd party system. The expected format is a unix timestamp - // in nanoseconds. - MetadataReadAt = "opencdc.readAt" - - // MetadataConduitSourcePluginName is a Record.Metadata key for the name of - // the source plugin that created this record. - MetadataConduitSourcePluginName = "conduit.source.plugin.name" - // MetadataConduitSourcePluginVersion is a Record.Metadata key for the - // version of the source plugin that created this record. - MetadataConduitSourcePluginVersion = "conduit.source.plugin.version" - // MetadataConduitDestinationPluginName is a Record.Metadata key for the - // name of the destination plugin that has written this record - // (only available in records once they are written by a destination). - MetadataConduitDestinationPluginName = "conduit.destination.plugin.name" - // MetadataConduitDestinationPluginVersion is a Record.Metadata key for the - // version of the destination plugin that has written this record - // (only available in records once they are written by a destination). - MetadataConduitDestinationPluginVersion = "conduit.destination.plugin.version" - - // MetadataConduitSourceConnectorID is a Record.Metadata key for the ID of - // the source connector that received this record. - MetadataConduitSourceConnectorID = "conduit.source.connector.id" - // MetadataConduitDLQNackError is a Record.Metadata key for the error that - // caused a record to be nacked and pushed to the dead-letter queue. - MetadataConduitDLQNackError = "conduit.dlq.nack.error" - // MetadataConduitDLQNackNodeID is a Record.Metadata key for the ID of the - // internal node that nacked the record. - MetadataConduitDLQNackNodeID = "conduit.dlq.nack.node.id" -) - -type Metadata map[string]string - -// SetOpenCDCVersion sets the metadata value for key MetadataVersion to the -// current version of OpenCDC used. -func (m Metadata) SetOpenCDCVersion() { - m[MetadataOpenCDCVersion] = OpenCDCVersion -} - -// GetOpenCDCVersion returns the value for key -// MetadataOpenCDCVersion. If the value does not exist or is empty the -// function returns ErrMetadataFieldNotFound. -func (m Metadata) GetOpenCDCVersion() (string, error) { - return m.getValue(MetadataOpenCDCVersion) -} - -// GetCreatedAt parses the value for key MetadataCreatedAt as a unix -// timestamp. If the value does not exist or the value is empty the function -// returns ErrMetadataFieldNotFound. If the value is not a valid unix timestamp -// in nanoseconds the function returns an error. -func (m Metadata) GetCreatedAt() (time.Time, error) { - raw, err := m.getValue(MetadataCreatedAt) - if err != nil { - return time.Time{}, err - } - - unixNano, err := strconv.ParseInt(raw, 10, 64) - if err != nil { - return time.Time{}, fmt.Errorf("failed to parse value for %q: %w", MetadataCreatedAt, err) - } - - return time.Unix(0, unixNano), nil -} - -// SetCreatedAt sets the metadata value for key MetadataCreatedAt as a -// unix timestamp in nanoseconds. -func (m Metadata) SetCreatedAt(createdAt time.Time) { - m[MetadataCreatedAt] = strconv.FormatInt(createdAt.UnixNano(), 10) -} - -// GetReadAt parses the value for key MetadataReadAt as a unix -// timestamp. If the value does not exist or the value is empty the function -// returns ErrMetadataFieldNotFound. If the value is not a valid unix timestamp -// in nanoseconds the function returns an error. -func (m Metadata) GetReadAt() (time.Time, error) { - raw, err := m.getValue(MetadataReadAt) - if err != nil { - return time.Time{}, err - } - - unixNano, err := strconv.ParseInt(raw, 10, 64) - if err != nil { - return time.Time{}, fmt.Errorf("failed to parse value for %q: %w", MetadataReadAt, err) - } - - return time.Unix(0, unixNano), nil -} - -// SetReadAt sets the metadata value for key MetadataReadAt as a unix -// timestamp in nanoseconds. -func (m Metadata) SetReadAt(createdAt time.Time) { - m[MetadataReadAt] = strconv.FormatInt(createdAt.UnixNano(), 10) -} - -// GetConduitSourcePluginName returns the value for key -// MetadataConduitSourcePluginName. If the value does not exist or is empty the -// function returns ErrMetadataFieldNotFound. -func (m Metadata) GetConduitSourcePluginName() (string, error) { - return m.getValue(MetadataConduitSourcePluginName) -} - -// SetConduitSourcePluginName sets the metadata value for key -// MetadataConduitSourcePluginName. -func (m Metadata) SetConduitSourcePluginName(name string) { - m[MetadataConduitSourcePluginName] = name -} - -// GetConduitSourcePluginVersion returns the value for key -// MetadataConduitSourcePluginVersion. If the value does not exist or is empty -// the function returns ErrMetadataFieldNotFound. -func (m Metadata) GetConduitSourcePluginVersion() (string, error) { - return m.getValue(MetadataConduitSourcePluginVersion) -} - -// SetConduitSourcePluginVersion sets the metadata value for key -// MetadataConduitSourcePluginVersion. -func (m Metadata) SetConduitSourcePluginVersion(version string) { - m[MetadataConduitSourcePluginVersion] = version -} - -// GetConduitDestinationPluginName returns the value for key -// MetadataConduitDestinationPluginName. If the value does not exist or is empty -// the function returns ErrMetadataFieldNotFound. -func (m Metadata) GetConduitDestinationPluginName() (string, error) { - return m.getValue(MetadataConduitDestinationPluginName) -} - -// SetConduitDestinationPluginName sets the metadata value for key -// MetadataConduitDestinationPluginName. -func (m Metadata) SetConduitDestinationPluginName(name string) { - m[MetadataConduitDestinationPluginName] = name -} - -// GetConduitDestinationPluginVersion returns the value for key -// MetadataConduitDestinationPluginVersion. If the value does not exist or is -// empty the function returns ErrMetadataFieldNotFound. -func (m Metadata) GetConduitDestinationPluginVersion() (string, error) { - return m.getValue(MetadataConduitDestinationPluginVersion) -} - -// SetConduitDestinationPluginVersion sets the metadata value for key -// MetadataConduitDestinationPluginVersion. -func (m Metadata) SetConduitDestinationPluginVersion(version string) { - m[MetadataConduitDestinationPluginVersion] = version -} - -// GetConduitSourceConnectorID returns the value for key -// MetadataConduitSourceConnectorID. If the value does not exist or is empty the -// function returns ErrMetadataFieldNotFound. -func (m Metadata) GetConduitSourceConnectorID() (string, error) { - return m.getValue(MetadataConduitSourceConnectorID) -} - -// SetConduitSourceConnectorID sets the metadata value for key -// MetadataConduitSourceConnectorID. -func (m Metadata) SetConduitSourceConnectorID(id string) { - m[MetadataConduitSourceConnectorID] = id -} - -// GetConduitDLQNackError returns the value for key -// MetadataConduitDLQNackError. If the value does not exist or is empty the -// function returns ErrMetadataFieldNotFound. -func (m Metadata) GetConduitDLQNackError() (string, error) { - return m.getValue(MetadataConduitDLQNackError) -} - -// SetConduitDLQNackError sets the metadata value for key -// MetadataConduitDLQNackError. -func (m Metadata) SetConduitDLQNackError(err string) { - m[MetadataConduitDLQNackError] = err -} - -// GetConduitDLQNackNodeID returns the value for key -// MetadataConduitDLQNackNodeID. If the value does not exist or is empty the -// function returns ErrMetadataFieldNotFound. -func (m Metadata) GetConduitDLQNackNodeID() (string, error) { - return m.getValue(MetadataConduitDLQNackNodeID) -} - -// SetConduitDLQNackNodeID sets the metadata value for key -// MetadataConduitDLQNackNodeID. -func (m Metadata) SetConduitDLQNackNodeID(id string) { - m[MetadataConduitDLQNackNodeID] = id -} - -// getValue returns the value for a specific key. If the value does not exist or -// is empty the function returns ErrMetadataFieldNotFound. -func (m Metadata) getValue(key string) (string, error) { - str := m[key] - if str == "" { - return "", fmt.Errorf("failed to get value for %q: %w", key, ErrMetadataFieldNotFound) - } - return str, nil -} diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/operation.go b/vendor/github.com/conduitio/conduit-commons/opencdc/operation.go deleted file mode 100644 index 202df5334..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/operation.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright © 2023 Meroxa, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:generate stringer -type=Operation -linecomment - -package opencdc - -import ( - "fmt" - "strconv" - "strings" -) - -const ( - OperationCreate Operation = iota + 1 // create - OperationUpdate // update - OperationDelete // delete - OperationSnapshot // snapshot -) - -// Operation defines what triggered the creation of a record. -type Operation int - -func (i Operation) MarshalText() ([]byte, error) { - return []byte(i.String()), nil -} - -func (i *Operation) UnmarshalText(b []byte) error { - if len(b) == 0 { - return nil // empty string, do nothing - } - - switch string(b) { - case OperationCreate.String(): - *i = OperationCreate - case OperationUpdate.String(): - *i = OperationUpdate - case OperationDelete.String(): - *i = OperationDelete - case OperationSnapshot.String(): - *i = OperationSnapshot - default: - // it's not a known operation, but we also allow Operation(int) - valIntRaw := strings.TrimSuffix(strings.TrimPrefix(string(b), "Operation("), ")") - valInt, err := strconv.Atoi(valIntRaw) - if err != nil { - return fmt.Errorf("operation %q: %w", b, ErrUnknownOperation) - } - *i = Operation(valInt) - } - - return nil -} diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/operation_string.go b/vendor/github.com/conduitio/conduit-commons/opencdc/operation_string.go deleted file mode 100644 index 24f0e9f8b..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/operation_string.go +++ /dev/null @@ -1,27 +0,0 @@ -// Code generated by "stringer -type=Operation -linecomment"; DO NOT EDIT. - -package opencdc - -import "strconv" - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - // Re-run the stringer command to generate them again. - var x [1]struct{} - _ = x[OperationCreate-1] - _ = x[OperationUpdate-2] - _ = x[OperationDelete-3] - _ = x[OperationSnapshot-4] -} - -const _Operation_name = "createupdatedeletesnapshot" - -var _Operation_index = [...]uint8{0, 6, 12, 18, 26} - -func (i Operation) String() string { - i -= 1 - if i < 0 || i >= Operation(len(_Operation_index)-1) { - return "Operation(" + strconv.FormatInt(int64(i+1), 10) + ")" - } - return _Operation_name[_Operation_index[i]:_Operation_index[i+1]] -} diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/position.go b/vendor/github.com/conduitio/conduit-commons/opencdc/position.go deleted file mode 100644 index 55d0bd0a3..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/position.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright © 2023 Meroxa, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package opencdc - -// Position is a unique identifier for a record being processed. -// It's a Source's responsibility to choose and assign record positions, -// as they will be used by the Source in subsequent pipeline runs. -type Position []byte - -// String is used when displaying the position in logs. -func (p Position) String() string { - if p != nil { - return string(p) - } - return "" -} diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/proto.go b/vendor/github.com/conduitio/conduit-commons/opencdc/proto.go deleted file mode 100644 index cc0d17417..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/proto.go +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright © 2023 Meroxa, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package opencdc - -import ( - "fmt" - - opencdcv1 "github.com/conduitio/conduit-commons/proto/opencdc/v1" - "google.golang.org/protobuf/types/known/structpb" -) - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - var cTypes [1]struct{} - _ = cTypes[int(OperationCreate)-int(opencdcv1.Operation_OPERATION_CREATE)] - _ = cTypes[int(OperationUpdate)-int(opencdcv1.Operation_OPERATION_UPDATE)] - _ = cTypes[int(OperationDelete)-int(opencdcv1.Operation_OPERATION_DELETE)] - _ = cTypes[int(OperationSnapshot)-int(opencdcv1.Operation_OPERATION_SNAPSHOT)] -} - -// -- From Proto To OpenCDC ---------------------------------------------------- - -// FromProto takes data from the supplied proto object and populates the -// receiver. If the proto object is nil, the receiver is set to its zero value. -// If the function returns an error, the receiver could be partially populated. -func (r *Record) FromProto(proto *opencdcv1.Record) error { - if proto == nil { - *r = Record{} - return nil - } - - var err error - r.Key, err = dataFromProto(proto.Key) - if err != nil { - return fmt.Errorf("error converting key: %w", err) - } - - if proto.Payload != nil { - err := r.Payload.FromProto(proto.Payload) - if err != nil { - return fmt.Errorf("error converting payload: %w", err) - } - } else { - r.Payload = Change{} - } - - r.Position = proto.Position - r.Metadata = proto.Metadata - r.Operation = Operation(proto.Operation) - return nil -} - -// FromProto takes data from the supplied proto object and populates the -// receiver. If the proto object is nil, the receiver is set to its zero value. -// If the function returns an error, the receiver could be partially populated. -func (c *Change) FromProto(proto *opencdcv1.Change) error { - if proto == nil { - *c = Change{} - return nil - } - - var err error - c.Before, err = dataFromProto(proto.Before) - if err != nil { - return fmt.Errorf("error converting before: %w", err) - } - - c.After, err = dataFromProto(proto.After) - if err != nil { - return fmt.Errorf("error converting after: %w", err) - } - - return nil -} - -func dataFromProto(proto *opencdcv1.Data) (Data, error) { - if proto == nil { - return nil, nil //nolint:nilnil // This is the expected behavior. - } - - switch v := proto.Data.(type) { - case *opencdcv1.Data_RawData: - return RawData(v.RawData), nil - case *opencdcv1.Data_StructuredData: - return StructuredData(v.StructuredData.AsMap()), nil - case nil: - return nil, nil //nolint:nilnil // This is the expected behavior. - default: - return nil, ErrInvalidProtoDataType - } -} - -// -- From OpenCDC To Proto ---------------------------------------------------- - -// ToProto takes data from the receiver and populates the supplied proto object. -// If the function returns an error, the proto object could be partially -// populated. -func (r Record) ToProto(proto *opencdcv1.Record) error { - if r.Key != nil { - if proto.Key == nil { - proto.Key = &opencdcv1.Data{} - } - err := r.Key.ToProto(proto.Key) - if err != nil { - return fmt.Errorf("error converting key: %w", err) - } - } else { - proto.Key = nil - } - - if proto.Payload == nil { - proto.Payload = &opencdcv1.Change{} - } - err := r.Payload.ToProto(proto.Payload) - if err != nil { - return fmt.Errorf("error converting payload: %w", err) - } - - proto.Position = r.Position - proto.Metadata = r.Metadata - proto.Operation = opencdcv1.Operation(r.Operation) - return nil -} - -// ToProto takes data from the receiver and populates the supplied proto object. -// If the function returns an error, the proto object could be partially -// populated. -func (c Change) ToProto(proto *opencdcv1.Change) error { - if c.Before != nil { - if proto.Before == nil { - proto.Before = &opencdcv1.Data{} - } - err := c.Before.ToProto(proto.Before) - if err != nil { - return fmt.Errorf("error converting before: %w", err) - } - } else { - proto.Before = nil - } - - if c.After != nil { - if proto.After == nil { - proto.After = &opencdcv1.Data{} - } - err := c.After.ToProto(proto.After) - if err != nil { - return fmt.Errorf("error converting after: %w", err) - } - } else { - proto.After = nil - } - - return nil -} - -// ToProto takes data from the receiver and populates the supplied proto object. -func (d RawData) ToProto(proto *opencdcv1.Data) error { - protoRawData, ok := proto.Data.(*opencdcv1.Data_RawData) - if !ok { - protoRawData = &opencdcv1.Data_RawData{} - proto.Data = protoRawData - } - protoRawData.RawData = d - return nil -} - -// ToProto takes data from the receiver and populates the supplied proto object. -func (d StructuredData) ToProto(proto *opencdcv1.Data) error { - protoStructuredData, ok := proto.Data.(*opencdcv1.Data_StructuredData) - if !ok { - protoStructuredData = &opencdcv1.Data_StructuredData{} - proto.Data = protoStructuredData - } - data, err := structpb.NewStruct(d) - if err != nil { - return fmt.Errorf("could not convert structured data to proto: %w", err) - } - protoStructuredData.StructuredData = data - return nil -} diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/record.go b/vendor/github.com/conduitio/conduit-commons/opencdc/record.go deleted file mode 100644 index cc7b8a053..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/record.go +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright © 2023 Meroxa, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package opencdc - -import ( - "bytes" - "fmt" - - "github.com/goccy/go-json" -) - -// Record represents a single data record produced by a source and/or consumed -// by a destination connector. -// Record should be used as a value, not a pointer, except when (de)serializing -// the record. Note that methods related to (de)serializing the record mutate -// the record and are thus not thread-safe (see SetSerializer, FromProto and -// UnmarshalJSON). -type Record struct { - // Position uniquely represents the record. - Position Position `json:"position"` - // Operation defines what triggered the creation of a record. There are four - // possibilities: create, update, delete or snapshot. The first three - // operations are encountered during normal CDC operation, while "snapshot" - // is meant to represent records during an initial load. Depending on the - // operation, the record will contain either the payload before the change, - // after the change, both or none (see field Payload). - Operation Operation `json:"operation"` - // Metadata contains additional information regarding the record. - Metadata Metadata `json:"metadata"` - - // Key represents a value that should identify the entity (e.g. database - // row). - Key Data `json:"key"` - // Payload holds the payload change (data before and after the operation - // occurred). - Payload Change `json:"payload"` - - serializer RecordSerializer -} - -// SetSerializer sets the serializer used to encode the record into bytes. If -// serializer is nil, the serializing behavior is reset to the default (JSON). -// This method mutates the receiver and is not thread-safe. -func (r *Record) SetSerializer(serializer RecordSerializer) { - r.serializer = serializer -} - -// Bytes returns the serialized representation of the Record. By default, this -// function returns a JSON representation. The serialization logic can be changed -// using SetSerializer. -func (r Record) Bytes() []byte { - if r.serializer != nil { - b, err := r.serializer.Serialize(r) - if err == nil { - return b - } - // serializer produced an error, fallback to default format - } - - b, err := json.Marshal(r) - if err != nil { - // Unlikely to happen, records travel from/to plugins through GRPC. - // If the content can be marshaled as protobuf it can be as JSON. - panic(fmt.Errorf("error while marshaling Record as JSON: %w", err)) - } - - return b -} - -func (r Record) Map() map[string]interface{} { - var genericMetadata map[string]interface{} - if r.Metadata != nil { - genericMetadata = make(map[string]interface{}, len(r.Metadata)) - for k, v := range r.Metadata { - genericMetadata[k] = v - } - } - - return map[string]any{ - "position": []byte(r.Position), - "operation": r.Operation.String(), - "metadata": genericMetadata, - "key": r.mapData(r.Key), - "payload": map[string]interface{}{ - "before": r.mapData(r.Payload.Before), - "after": r.mapData(r.Payload.After), - }, - } -} - -func (r Record) mapData(d Data) interface{} { - switch d := d.(type) { - case StructuredData: - return map[string]interface{}(d) - case RawData: - return []byte(d) - } - return nil -} - -func (r Record) Clone() Record { - var ( - metadata map[string]string - key Data - payloadBefore Data - payloadAfter Data - ) - - if r.Metadata != nil { - metadata = make(map[string]string, len(r.Metadata)) - for k, v := range r.Metadata { - metadata[k] = v - } - } - - if r.Key != nil { - key = r.Key.Clone() - } - if r.Payload.Before != nil { - payloadBefore = r.Payload.Before.Clone() - } - if r.Payload.After != nil { - payloadAfter = r.Payload.After.Clone() - } - - clone := Record{ - Position: bytes.Clone(r.Position), - Operation: r.Operation, - Metadata: metadata, - Key: key, - Payload: Change{ - Before: payloadBefore, - After: payloadAfter, - }, - } - return clone -} diff --git a/vendor/github.com/conduitio/conduit-commons/opencdc/serializer.go b/vendor/github.com/conduitio/conduit-commons/opencdc/serializer.go deleted file mode 100644 index cc9e5923e..000000000 --- a/vendor/github.com/conduitio/conduit-commons/opencdc/serializer.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright © 2023 Meroxa, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package opencdc - -// RecordSerializer is a type that can serialize a record to bytes. It's used in -// destination connectors to change the output structure and format. -type RecordSerializer interface { - Serialize(Record) ([]byte, error) -} diff --git a/vendor/github.com/conduitio/conduit-commons/proto/opencdc/v1/opencdc.pb.go b/vendor/github.com/conduitio/conduit-commons/proto/opencdc/v1/opencdc.pb.go deleted file mode 100644 index f42e37056..000000000 --- a/vendor/github.com/conduitio/conduit-commons/proto/opencdc/v1/opencdc.pb.go +++ /dev/null @@ -1,566 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.31.0 -// protoc (unknown) -// source: opencdc/v1/opencdc.proto - -package opencdcv1 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - descriptorpb "google.golang.org/protobuf/types/descriptorpb" - structpb "google.golang.org/protobuf/types/known/structpb" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Operation defines what triggered the creation of a record. -type Operation int32 - -const ( - Operation_OPERATION_UNSPECIFIED Operation = 0 - // Records with operation create contain data of a newly created entity. - Operation_OPERATION_CREATE Operation = 1 - // Records with operation update contain data of an updated entity. - Operation_OPERATION_UPDATE Operation = 2 - // Records with operation delete contain data of a deleted entity. - Operation_OPERATION_DELETE Operation = 3 - // Records with operation snapshot contain data of a previously existing - // entity, fetched as part of a snapshot. - Operation_OPERATION_SNAPSHOT Operation = 4 -) - -// Enum value maps for Operation. -var ( - Operation_name = map[int32]string{ - 0: "OPERATION_UNSPECIFIED", - 1: "OPERATION_CREATE", - 2: "OPERATION_UPDATE", - 3: "OPERATION_DELETE", - 4: "OPERATION_SNAPSHOT", - } - Operation_value = map[string]int32{ - "OPERATION_UNSPECIFIED": 0, - "OPERATION_CREATE": 1, - "OPERATION_UPDATE": 2, - "OPERATION_DELETE": 3, - "OPERATION_SNAPSHOT": 4, - } -) - -func (x Operation) Enum() *Operation { - p := new(Operation) - *p = x - return p -} - -func (x Operation) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Operation) Descriptor() protoreflect.EnumDescriptor { - return file_opencdc_v1_opencdc_proto_enumTypes[0].Descriptor() -} - -func (Operation) Type() protoreflect.EnumType { - return &file_opencdc_v1_opencdc_proto_enumTypes[0] -} - -func (x Operation) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Operation.Descriptor instead. -func (Operation) EnumDescriptor() ([]byte, []int) { - return file_opencdc_v1_opencdc_proto_rawDescGZIP(), []int{0} -} - -// Record contains data about a single change event related to a single entity. -type Record struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Position uniquely identifies the record. - Position []byte `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` - // Operation defines what triggered the creation of a record. There are four - // possibilities: create, update, delete or snapshot. The first three - // operations are encountered during normal CDC operation, while "snapshot" is - // meant to represent records during an initial load. Depending on the - // operation, the record will contain either the payload before the change, - // after the change, or both (see field payload). - Operation Operation `protobuf:"varint,2,opt,name=operation,proto3,enum=opencdc.v1.Operation" json:"operation,omitempty"` - // Metadata contains optional information related to the record. Although the - // map can contain arbitrary keys, the standard provides a set of standard - // metadata fields (see options prefixed with metadata_*). - Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // Key represents a value that should identify the entity (e.g. database row). - Key *Data `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"` - // Payload holds the payload change (data before and after the operation - // occurred). - Payload *Change `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"` -} - -func (x *Record) Reset() { - *x = Record{} - if protoimpl.UnsafeEnabled { - mi := &file_opencdc_v1_opencdc_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Record) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Record) ProtoMessage() {} - -func (x *Record) ProtoReflect() protoreflect.Message { - mi := &file_opencdc_v1_opencdc_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Record.ProtoReflect.Descriptor instead. -func (*Record) Descriptor() ([]byte, []int) { - return file_opencdc_v1_opencdc_proto_rawDescGZIP(), []int{0} -} - -func (x *Record) GetPosition() []byte { - if x != nil { - return x.Position - } - return nil -} - -func (x *Record) GetOperation() Operation { - if x != nil { - return x.Operation - } - return Operation_OPERATION_UNSPECIFIED -} - -func (x *Record) GetMetadata() map[string]string { - if x != nil { - return x.Metadata - } - return nil -} - -func (x *Record) GetKey() *Data { - if x != nil { - return x.Key - } - return nil -} - -func (x *Record) GetPayload() *Change { - if x != nil { - return x.Payload - } - return nil -} - -// Change represents the data before and after the operation occurred. -type Change struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Before contains the data before the operation occurred. This field is - // optional and should only be populated for operations "update" and "delete" - // (if the system supports fetching the data before the operation). - Before *Data `protobuf:"bytes,1,opt,name=before,proto3" json:"before,omitempty"` - // After contains the data after the operation occurred. This field should be - // populated for all operations except "delete". - After *Data `protobuf:"bytes,2,opt,name=after,proto3" json:"after,omitempty"` -} - -func (x *Change) Reset() { - *x = Change{} - if protoimpl.UnsafeEnabled { - mi := &file_opencdc_v1_opencdc_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Change) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Change) ProtoMessage() {} - -func (x *Change) ProtoReflect() protoreflect.Message { - mi := &file_opencdc_v1_opencdc_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Change.ProtoReflect.Descriptor instead. -func (*Change) Descriptor() ([]byte, []int) { - return file_opencdc_v1_opencdc_proto_rawDescGZIP(), []int{1} -} - -func (x *Change) GetBefore() *Data { - if x != nil { - return x.Before - } - return nil -} - -func (x *Change) GetAfter() *Data { - if x != nil { - return x.After - } - return nil -} - -// Data is used to represent the record key and payload. It can be either raw -// data (byte array) or structured data (struct). -type Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Data: - // - // *Data_RawData - // *Data_StructuredData - Data isData_Data `protobuf_oneof:"data"` -} - -func (x *Data) Reset() { - *x = Data{} - if protoimpl.UnsafeEnabled { - mi := &file_opencdc_v1_opencdc_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Data) ProtoMessage() {} - -func (x *Data) ProtoReflect() protoreflect.Message { - mi := &file_opencdc_v1_opencdc_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Data.ProtoReflect.Descriptor instead. -func (*Data) Descriptor() ([]byte, []int) { - return file_opencdc_v1_opencdc_proto_rawDescGZIP(), []int{2} -} - -func (m *Data) GetData() isData_Data { - if m != nil { - return m.Data - } - return nil -} - -func (x *Data) GetRawData() []byte { - if x, ok := x.GetData().(*Data_RawData); ok { - return x.RawData - } - return nil -} - -func (x *Data) GetStructuredData() *structpb.Struct { - if x, ok := x.GetData().(*Data_StructuredData); ok { - return x.StructuredData - } - return nil -} - -type isData_Data interface { - isData_Data() -} - -type Data_RawData struct { - // Raw data contains unstructured data in form of a byte array. - RawData []byte `protobuf:"bytes,1,opt,name=raw_data,json=rawData,proto3,oneof"` -} - -type Data_StructuredData struct { - // Structured data contains data in form of a struct with fields. - StructuredData *structpb.Struct `protobuf:"bytes,2,opt,name=structured_data,json=structuredData,proto3,oneof"` -} - -func (*Data_RawData) isData_Data() {} - -func (*Data_StructuredData) isData_Data() {} - -var file_opencdc_v1_opencdc_proto_extTypes = []protoimpl.ExtensionInfo{ - { - ExtendedType: (*descriptorpb.FileOptions)(nil), - ExtensionType: (*string)(nil), - Field: 9999, - Name: "opencdc.v1.opencdc_version", - Tag: "bytes,9999,opt,name=opencdc_version", - Filename: "opencdc/v1/opencdc.proto", - }, - { - ExtendedType: (*descriptorpb.FileOptions)(nil), - ExtensionType: (*string)(nil), - Field: 10000, - Name: "opencdc.v1.metadata_version", - Tag: "bytes,10000,opt,name=metadata_version", - Filename: "opencdc/v1/opencdc.proto", - }, - { - ExtendedType: (*descriptorpb.FileOptions)(nil), - ExtensionType: (*string)(nil), - Field: 10001, - Name: "opencdc.v1.metadata_created_at", - Tag: "bytes,10001,opt,name=metadata_created_at", - Filename: "opencdc/v1/opencdc.proto", - }, - { - ExtendedType: (*descriptorpb.FileOptions)(nil), - ExtensionType: (*string)(nil), - Field: 10002, - Name: "opencdc.v1.metadata_read_at", - Tag: "bytes,10002,opt,name=metadata_read_at", - Filename: "opencdc/v1/opencdc.proto", - }, -} - -// Extension fields to descriptorpb.FileOptions. -var ( - // optional string opencdc_version = 9999; - E_OpencdcVersion = &file_opencdc_v1_opencdc_proto_extTypes[0] - // optional string metadata_version = 10000; - E_MetadataVersion = &file_opencdc_v1_opencdc_proto_extTypes[1] - // optional string metadata_created_at = 10001; - E_MetadataCreatedAt = &file_opencdc_v1_opencdc_proto_extTypes[2] - // optional string metadata_read_at = 10002; - E_MetadataReadAt = &file_opencdc_v1_opencdc_proto_extTypes[3] -) - -var File_opencdc_v1_opencdc_proto protoreflect.FileDescriptor - -var file_opencdc_v1_opencdc_proto_rawDesc = []byte{ - 0x0a, 0x18, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x70, 0x65, - 0x6e, 0x63, 0x64, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6f, 0x70, 0x65, 0x6e, - 0x63, 0x64, 0x63, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa6, 0x02, 0x0a, 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, - 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x33, 0x0a, - 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x15, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, - 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2e, 0x76, - 0x31, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x12, 0x22, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, - 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2e, - 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, - 0x61, 0x64, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0x5a, 0x0a, 0x06, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x28, 0x0a, 0x06, 0x62, 0x65, 0x66, - 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6f, 0x70, 0x65, 0x6e, - 0x63, 0x64, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x06, 0x62, 0x65, 0x66, - 0x6f, 0x72, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2e, 0x76, 0x31, 0x2e, - 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x61, 0x66, 0x74, 0x65, 0x72, 0x22, 0x6f, 0x0a, 0x04, 0x44, - 0x61, 0x74, 0x61, 0x12, 0x1b, 0x0a, 0x08, 0x72, 0x61, 0x77, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x72, 0x61, 0x77, 0x44, 0x61, 0x74, 0x61, - 0x12, 0x42, 0x0a, 0x0f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x5f, 0x64, - 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, - 0x63, 0x74, 0x48, 0x00, 0x52, 0x0e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, - 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x2a, 0x80, 0x01, 0x0a, - 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x15, 0x4f, 0x50, - 0x45, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x49, - 0x4f, 0x4e, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x4f, - 0x50, 0x45, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, - 0x02, 0x12, 0x14, 0x0a, 0x10, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, - 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x03, 0x12, 0x16, 0x0a, 0x12, 0x4f, 0x50, 0x45, 0x52, 0x41, - 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x4e, 0x41, 0x50, 0x53, 0x48, 0x4f, 0x54, 0x10, 0x04, 0x3a, - 0x46, 0x0a, 0x0f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0x8f, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x48, 0x0a, 0x10, 0x6d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, - 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x90, 0x4e, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x3a, 0x4d, 0x0a, 0x13, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x91, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x6d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, - 0x3a, 0x47, 0x0a, 0x10, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x72, 0x65, 0x61, - 0x64, 0x5f, 0x61, 0x74, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x18, 0x92, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x52, 0x65, 0x61, 0x64, 0x41, 0x74, 0x42, 0xe8, 0x01, 0xfa, 0xf0, 0x04, 0x02, - 0x76, 0x31, 0x82, 0xf1, 0x04, 0x0f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2e, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x8a, 0xf1, 0x04, 0x11, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, - 0x2e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x92, 0xf1, 0x04, 0x0e, 0x6f, 0x70, - 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x41, 0x74, 0x0a, 0x0e, 0x63, 0x6f, - 0x6d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x4f, 0x70, - 0x65, 0x6e, 0x63, 0x64, 0x63, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3f, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x75, 0x69, 0x74, - 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x64, 0x75, 0x69, 0x74, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, - 0x6e, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, - 0x2f, 0x76, 0x31, 0x3b, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x76, 0x31, 0xa2, 0x02, 0x03, - 0x4f, 0x58, 0x58, 0xaa, 0x02, 0x0a, 0x4f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x2e, 0x56, 0x31, - 0xca, 0x02, 0x0a, 0x4f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x16, - 0x4f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0b, 0x4f, 0x70, 0x65, 0x6e, 0x63, 0x64, 0x63, - 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_opencdc_v1_opencdc_proto_rawDescOnce sync.Once - file_opencdc_v1_opencdc_proto_rawDescData = file_opencdc_v1_opencdc_proto_rawDesc -) - -func file_opencdc_v1_opencdc_proto_rawDescGZIP() []byte { - file_opencdc_v1_opencdc_proto_rawDescOnce.Do(func() { - file_opencdc_v1_opencdc_proto_rawDescData = protoimpl.X.CompressGZIP(file_opencdc_v1_opencdc_proto_rawDescData) - }) - return file_opencdc_v1_opencdc_proto_rawDescData -} - -var file_opencdc_v1_opencdc_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_opencdc_v1_opencdc_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_opencdc_v1_opencdc_proto_goTypes = []interface{}{ - (Operation)(0), // 0: opencdc.v1.Operation - (*Record)(nil), // 1: opencdc.v1.Record - (*Change)(nil), // 2: opencdc.v1.Change - (*Data)(nil), // 3: opencdc.v1.Data - nil, // 4: opencdc.v1.Record.MetadataEntry - (*structpb.Struct)(nil), // 5: google.protobuf.Struct - (*descriptorpb.FileOptions)(nil), // 6: google.protobuf.FileOptions -} -var file_opencdc_v1_opencdc_proto_depIdxs = []int32{ - 0, // 0: opencdc.v1.Record.operation:type_name -> opencdc.v1.Operation - 4, // 1: opencdc.v1.Record.metadata:type_name -> opencdc.v1.Record.MetadataEntry - 3, // 2: opencdc.v1.Record.key:type_name -> opencdc.v1.Data - 2, // 3: opencdc.v1.Record.payload:type_name -> opencdc.v1.Change - 3, // 4: opencdc.v1.Change.before:type_name -> opencdc.v1.Data - 3, // 5: opencdc.v1.Change.after:type_name -> opencdc.v1.Data - 5, // 6: opencdc.v1.Data.structured_data:type_name -> google.protobuf.Struct - 6, // 7: opencdc.v1.opencdc_version:extendee -> google.protobuf.FileOptions - 6, // 8: opencdc.v1.metadata_version:extendee -> google.protobuf.FileOptions - 6, // 9: opencdc.v1.metadata_created_at:extendee -> google.protobuf.FileOptions - 6, // 10: opencdc.v1.metadata_read_at:extendee -> google.protobuf.FileOptions - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 7, // [7:11] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name -} - -func init() { file_opencdc_v1_opencdc_proto_init() } -func file_opencdc_v1_opencdc_proto_init() { - if File_opencdc_v1_opencdc_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_opencdc_v1_opencdc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Record); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opencdc_v1_opencdc_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Change); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_opencdc_v1_opencdc_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Data); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_opencdc_v1_opencdc_proto_msgTypes[2].OneofWrappers = []interface{}{ - (*Data_RawData)(nil), - (*Data_StructuredData)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_opencdc_v1_opencdc_proto_rawDesc, - NumEnums: 1, - NumMessages: 4, - NumExtensions: 4, - NumServices: 0, - }, - GoTypes: file_opencdc_v1_opencdc_proto_goTypes, - DependencyIndexes: file_opencdc_v1_opencdc_proto_depIdxs, - EnumInfos: file_opencdc_v1_opencdc_proto_enumTypes, - MessageInfos: file_opencdc_v1_opencdc_proto_msgTypes, - ExtensionInfos: file_opencdc_v1_opencdc_proto_extTypes, - }.Build() - File_opencdc_v1_opencdc_proto = out.File - file_opencdc_v1_opencdc_proto_rawDesc = nil - file_opencdc_v1_opencdc_proto_goTypes = nil - file_opencdc_v1_opencdc_proto_depIdxs = nil -} diff --git a/vendor/github.com/conduitio/conduit-commons/proto/opencdc/v1/opencdc.proto b/vendor/github.com/conduitio/conduit-commons/proto/opencdc/v1/opencdc.proto deleted file mode 100644 index 4a1d7a356..000000000 --- a/vendor/github.com/conduitio/conduit-commons/proto/opencdc/v1/opencdc.proto +++ /dev/null @@ -1,95 +0,0 @@ -syntax = "proto3"; - -package opencdc.v1; - -import "google/protobuf/descriptor.proto"; -import "google/protobuf/struct.proto"; - -option go_package = "github.com/conduitio/conduit-commons/proto/opencdc/v1"; - -// CreatedAt can contain the time when the record was created in the 3rd party -// system. The expected format is a unix timestamp in nanoseconds. -option (metadata_created_at) = "opencdc.createdAt"; -// ReadAt can contain the time when the record was read from the 3rd party -// system. The expected format is a unix timestamp in nanoseconds. -option (metadata_read_at) = "opencdc.readAt"; -// Version contains the version of the OpenCDC format (e.g. "v1"). This field -// exists to ensure the OpenCDC format version can be easily identified in case -// the record gets marshaled into a different untyped format (e.g. JSON). -option (metadata_version) = "opencdc.version"; -// OpenCDC version is a constant that should be used as the value in the -// metadata field opencdc.version. It ensures the OpenCDC format version can be -// easily identified in case the record gets marshaled into a different untyped -// format (e.g. JSON). -option (opencdc_version) = "v1"; - -// We are (ab)using custom file options to define constants. -// See https://github.com/protocolbuffers/protobuf/issues/3520#issuecomment-323613839 -extend google.protobuf.FileOptions { - string opencdc_version = 9999; - - string metadata_version = 10000; - string metadata_created_at = 10001; - string metadata_read_at = 10002; -} - -// Operation defines what triggered the creation of a record. -enum Operation { - OPERATION_UNSPECIFIED = 0; - // Records with operation create contain data of a newly created entity. - OPERATION_CREATE = 1; - // Records with operation update contain data of an updated entity. - OPERATION_UPDATE = 2; - // Records with operation delete contain data of a deleted entity. - OPERATION_DELETE = 3; - // Records with operation snapshot contain data of a previously existing - // entity, fetched as part of a snapshot. - OPERATION_SNAPSHOT = 4; -} - -// Record contains data about a single change event related to a single entity. -message Record { - // Position uniquely identifies the record. - bytes position = 1; - - // Operation defines what triggered the creation of a record. There are four - // possibilities: create, update, delete or snapshot. The first three - // operations are encountered during normal CDC operation, while "snapshot" is - // meant to represent records during an initial load. Depending on the - // operation, the record will contain either the payload before the change, - // after the change, or both (see field payload). - Operation operation = 2; - - // Metadata contains optional information related to the record. Although the - // map can contain arbitrary keys, the standard provides a set of standard - // metadata fields (see options prefixed with metadata_*). - map metadata = 3; - - // Key represents a value that should identify the entity (e.g. database row). - Data key = 4; - // Payload holds the payload change (data before and after the operation - // occurred). - Change payload = 5; -} - -// Change represents the data before and after the operation occurred. -message Change { - // Before contains the data before the operation occurred. This field is - // optional and should only be populated for operations "update" and "delete" - // (if the system supports fetching the data before the operation). - Data before = 1; - // After contains the data after the operation occurred. This field should be - // populated for all operations except "delete". - Data after = 2; -} - -// Data is used to represent the record key and payload. It can be either raw -// data (byte array) or structured data (struct). -message Data { - oneof data { - // Raw data contains unstructured data in form of a byte array. - bytes raw_data = 1; - // Structured data contains data in form of a struct with fields. - google.protobuf.Struct structured_data = 2; - } -} diff --git a/vendor/github.com/emirpasic/gods/LICENSE b/vendor/github.com/emirpasic/gods/LICENSE deleted file mode 100644 index e5e449b6e..000000000 --- a/vendor/github.com/emirpasic/gods/LICENSE +++ /dev/null @@ -1,41 +0,0 @@ -Copyright (c) 2015, Emir Pasic -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -------------------------------------------------------------------------------- - -AVL Tree: - -Copyright (c) 2017 Benjamin Scher Purcell - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/vendor/github.com/emirpasic/gods/containers/containers.go b/vendor/github.com/emirpasic/gods/containers/containers.go deleted file mode 100644 index a512a3cba..000000000 --- a/vendor/github.com/emirpasic/gods/containers/containers.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package containers provides core interfaces and functions for data structures. -// -// Container is the base interface for all data structures to implement. -// -// Iterators provide stateful iterators. -// -// Enumerable provides Ruby inspired (each, select, map, find, any?, etc.) container functions. -// -// Serialization provides serializers (marshalers) and deserializers (unmarshalers). -package containers - -import "github.com/emirpasic/gods/utils" - -// Container is base interface that all data structures implement. -type Container interface { - Empty() bool - Size() int - Clear() - Values() []interface{} - String() string -} - -// GetSortedValues returns sorted container's elements with respect to the passed comparator. -// Does not affect the ordering of elements within the container. -func GetSortedValues(container Container, comparator utils.Comparator) []interface{} { - values := container.Values() - if len(values) < 2 { - return values - } - utils.Sort(values, comparator) - return values -} diff --git a/vendor/github.com/emirpasic/gods/containers/enumerable.go b/vendor/github.com/emirpasic/gods/containers/enumerable.go deleted file mode 100644 index 70660054a..000000000 --- a/vendor/github.com/emirpasic/gods/containers/enumerable.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package containers - -// EnumerableWithIndex provides functions for ordered containers whose values can be fetched by an index. -type EnumerableWithIndex interface { - // Each calls the given function once for each element, passing that element's index and value. - Each(func(index int, value interface{})) - - // Map invokes the given function once for each element and returns a - // container containing the values returned by the given function. - // Map(func(index int, value interface{}) interface{}) Container - - // Select returns a new container containing all elements for which the given function returns a true value. - // Select(func(index int, value interface{}) bool) Container - - // Any passes each element of the container to the given function and - // returns true if the function ever returns true for any element. - Any(func(index int, value interface{}) bool) bool - - // All passes each element of the container to the given function and - // returns true if the function returns true for all elements. - All(func(index int, value interface{}) bool) bool - - // Find passes each element of the container to the given function and returns - // the first (index,value) for which the function is true or -1,nil otherwise - // if no element matches the criteria. - Find(func(index int, value interface{}) bool) (int, interface{}) -} - -// EnumerableWithKey provides functions for ordered containers whose values whose elements are key/value pairs. -type EnumerableWithKey interface { - // Each calls the given function once for each element, passing that element's key and value. - Each(func(key interface{}, value interface{})) - - // Map invokes the given function once for each element and returns a container - // containing the values returned by the given function as key/value pairs. - // Map(func(key interface{}, value interface{}) (interface{}, interface{})) Container - - // Select returns a new container containing all elements for which the given function returns a true value. - // Select(func(key interface{}, value interface{}) bool) Container - - // Any passes each element of the container to the given function and - // returns true if the function ever returns true for any element. - Any(func(key interface{}, value interface{}) bool) bool - - // All passes each element of the container to the given function and - // returns true if the function returns true for all elements. - All(func(key interface{}, value interface{}) bool) bool - - // Find passes each element of the container to the given function and returns - // the first (key,value) for which the function is true or nil,nil otherwise if no element - // matches the criteria. - Find(func(key interface{}, value interface{}) bool) (interface{}, interface{}) -} diff --git a/vendor/github.com/emirpasic/gods/containers/iterator.go b/vendor/github.com/emirpasic/gods/containers/iterator.go deleted file mode 100644 index 73994ec82..000000000 --- a/vendor/github.com/emirpasic/gods/containers/iterator.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package containers - -// IteratorWithIndex is stateful iterator for ordered containers whose values can be fetched by an index. -type IteratorWithIndex interface { - // Next moves the iterator to the next element and returns true if there was a next element in the container. - // If Next() returns true, then next element's index and value can be retrieved by Index() and Value(). - // If Next() was called for the first time, then it will point the iterator to the first element if it exists. - // Modifies the state of the iterator. - Next() bool - - // Value returns the current element's value. - // Does not modify the state of the iterator. - Value() interface{} - - // Index returns the current element's index. - // Does not modify the state of the iterator. - Index() int - - // Begin resets the iterator to its initial state (one-before-first) - // Call Next() to fetch the first element if any. - Begin() - - // First moves the iterator to the first element and returns true if there was a first element in the container. - // If First() returns true, then first element's index and value can be retrieved by Index() and Value(). - // Modifies the state of the iterator. - First() bool - - // NextTo moves the iterator to the next element from current position that satisfies the condition given by the - // passed function, and returns true if there was a next element in the container. - // If NextTo() returns true, then next element's index and value can be retrieved by Index() and Value(). - // Modifies the state of the iterator. - NextTo(func(index int, value interface{}) bool) bool -} - -// IteratorWithKey is a stateful iterator for ordered containers whose elements are key value pairs. -type IteratorWithKey interface { - // Next moves the iterator to the next element and returns true if there was a next element in the container. - // If Next() returns true, then next element's key and value can be retrieved by Key() and Value(). - // If Next() was called for the first time, then it will point the iterator to the first element if it exists. - // Modifies the state of the iterator. - Next() bool - - // Value returns the current element's value. - // Does not modify the state of the iterator. - Value() interface{} - - // Key returns the current element's key. - // Does not modify the state of the iterator. - Key() interface{} - - // Begin resets the iterator to its initial state (one-before-first) - // Call Next() to fetch the first element if any. - Begin() - - // First moves the iterator to the first element and returns true if there was a first element in the container. - // If First() returns true, then first element's key and value can be retrieved by Key() and Value(). - // Modifies the state of the iterator. - First() bool - - // NextTo moves the iterator to the next element from current position that satisfies the condition given by the - // passed function, and returns true if there was a next element in the container. - // If NextTo() returns true, then next element's key and value can be retrieved by Key() and Value(). - // Modifies the state of the iterator. - NextTo(func(key interface{}, value interface{}) bool) bool -} - -// ReverseIteratorWithIndex is stateful iterator for ordered containers whose values can be fetched by an index. -// -// Essentially it is the same as IteratorWithIndex, but provides additional: -// -// Prev() function to enable traversal in reverse -// -// Last() function to move the iterator to the last element. -// -// End() function to move the iterator past the last element (one-past-the-end). -type ReverseIteratorWithIndex interface { - // Prev moves the iterator to the previous element and returns true if there was a previous element in the container. - // If Prev() returns true, then previous element's index and value can be retrieved by Index() and Value(). - // Modifies the state of the iterator. - Prev() bool - - // End moves the iterator past the last element (one-past-the-end). - // Call Prev() to fetch the last element if any. - End() - - // Last moves the iterator to the last element and returns true if there was a last element in the container. - // If Last() returns true, then last element's index and value can be retrieved by Index() and Value(). - // Modifies the state of the iterator. - Last() bool - - // PrevTo moves the iterator to the previous element from current position that satisfies the condition given by the - // passed function, and returns true if there was a next element in the container. - // If PrevTo() returns true, then next element's index and value can be retrieved by Index() and Value(). - // Modifies the state of the iterator. - PrevTo(func(index int, value interface{}) bool) bool - - IteratorWithIndex -} - -// ReverseIteratorWithKey is a stateful iterator for ordered containers whose elements are key value pairs. -// -// Essentially it is the same as IteratorWithKey, but provides additional: -// -// Prev() function to enable traversal in reverse -// -// Last() function to move the iterator to the last element. -type ReverseIteratorWithKey interface { - // Prev moves the iterator to the previous element and returns true if there was a previous element in the container. - // If Prev() returns true, then previous element's key and value can be retrieved by Key() and Value(). - // Modifies the state of the iterator. - Prev() bool - - // End moves the iterator past the last element (one-past-the-end). - // Call Prev() to fetch the last element if any. - End() - - // Last moves the iterator to the last element and returns true if there was a last element in the container. - // If Last() returns true, then last element's key and value can be retrieved by Key() and Value(). - // Modifies the state of the iterator. - Last() bool - - // PrevTo moves the iterator to the previous element from current position that satisfies the condition given by the - // passed function, and returns true if there was a next element in the container. - // If PrevTo() returns true, then next element's key and value can be retrieved by Key() and Value(). - // Modifies the state of the iterator. - PrevTo(func(key interface{}, value interface{}) bool) bool - - IteratorWithKey -} diff --git a/vendor/github.com/emirpasic/gods/containers/serialization.go b/vendor/github.com/emirpasic/gods/containers/serialization.go deleted file mode 100644 index fd9cbe23a..000000000 --- a/vendor/github.com/emirpasic/gods/containers/serialization.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package containers - -// JSONSerializer provides JSON serialization -type JSONSerializer interface { - // ToJSON outputs the JSON representation of containers's elements. - ToJSON() ([]byte, error) - // MarshalJSON @implements json.Marshaler - MarshalJSON() ([]byte, error) -} - -// JSONDeserializer provides JSON deserialization -type JSONDeserializer interface { - // FromJSON populates containers's elements from the input JSON representation. - FromJSON([]byte) error - // UnmarshalJSON @implements json.Unmarshaler - UnmarshalJSON([]byte) error -} diff --git a/vendor/github.com/emirpasic/gods/lists/lists.go b/vendor/github.com/emirpasic/gods/lists/lists.go deleted file mode 100644 index 55bd619e2..000000000 --- a/vendor/github.com/emirpasic/gods/lists/lists.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package lists provides an abstract List interface. -// -// In computer science, a list or sequence is an abstract data type that represents an ordered sequence of values, where the same value may occur more than once. An instance of a list is a computer representation of the mathematical concept of a finite sequence; the (potentially) infinite analog of a list is a stream. Lists are a basic example of containers, as they contain other values. If the same value occurs multiple times, each occurrence is considered a distinct item. -// -// Reference: https://en.wikipedia.org/wiki/List_%28abstract_data_type%29 -package lists - -import ( - "github.com/emirpasic/gods/containers" - "github.com/emirpasic/gods/utils" -) - -// List interface that all lists implement -type List interface { - Get(index int) (interface{}, bool) - Remove(index int) - Add(values ...interface{}) - Contains(values ...interface{}) bool - Sort(comparator utils.Comparator) - Swap(index1, index2 int) - Insert(index int, values ...interface{}) - Set(index int, value interface{}) - - containers.Container - // Empty() bool - // Size() int - // Clear() - // Values() []interface{} - // String() string -} diff --git a/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/enumerable.go b/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/enumerable.go deleted file mode 100644 index 6fdbcb8b3..000000000 --- a/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/enumerable.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package singlylinkedlist - -import "github.com/emirpasic/gods/containers" - -// Assert Enumerable implementation -var _ containers.EnumerableWithIndex = (*List)(nil) - -// Each calls the given function once for each element, passing that element's index and value. -func (list *List) Each(f func(index int, value interface{})) { - iterator := list.Iterator() - for iterator.Next() { - f(iterator.Index(), iterator.Value()) - } -} - -// Map invokes the given function once for each element and returns a -// container containing the values returned by the given function. -func (list *List) Map(f func(index int, value interface{}) interface{}) *List { - newList := &List{} - iterator := list.Iterator() - for iterator.Next() { - newList.Add(f(iterator.Index(), iterator.Value())) - } - return newList -} - -// Select returns a new container containing all elements for which the given function returns a true value. -func (list *List) Select(f func(index int, value interface{}) bool) *List { - newList := &List{} - iterator := list.Iterator() - for iterator.Next() { - if f(iterator.Index(), iterator.Value()) { - newList.Add(iterator.Value()) - } - } - return newList -} - -// Any passes each element of the container to the given function and -// returns true if the function ever returns true for any element. -func (list *List) Any(f func(index int, value interface{}) bool) bool { - iterator := list.Iterator() - for iterator.Next() { - if f(iterator.Index(), iterator.Value()) { - return true - } - } - return false -} - -// All passes each element of the container to the given function and -// returns true if the function returns true for all elements. -func (list *List) All(f func(index int, value interface{}) bool) bool { - iterator := list.Iterator() - for iterator.Next() { - if !f(iterator.Index(), iterator.Value()) { - return false - } - } - return true -} - -// Find passes each element of the container to the given function and returns -// the first (index,value) for which the function is true or -1,nil otherwise -// if no element matches the criteria. -func (list *List) Find(f func(index int, value interface{}) bool) (index int, value interface{}) { - iterator := list.Iterator() - for iterator.Next() { - if f(iterator.Index(), iterator.Value()) { - return iterator.Index(), iterator.Value() - } - } - return -1, nil -} diff --git a/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/iterator.go b/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/iterator.go deleted file mode 100644 index 4e7f1773b..000000000 --- a/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/iterator.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package singlylinkedlist - -import "github.com/emirpasic/gods/containers" - -// Assert Iterator implementation -var _ containers.IteratorWithIndex = (*Iterator)(nil) - -// Iterator holding the iterator's state -type Iterator struct { - list *List - index int - element *element -} - -// Iterator returns a stateful iterator whose values can be fetched by an index. -func (list *List) Iterator() Iterator { - return Iterator{list: list, index: -1, element: nil} -} - -// Next moves the iterator to the next element and returns true if there was a next element in the container. -// If Next() returns true, then next element's index and value can be retrieved by Index() and Value(). -// If Next() was called for the first time, then it will point the iterator to the first element if it exists. -// Modifies the state of the iterator. -func (iterator *Iterator) Next() bool { - if iterator.index < iterator.list.size { - iterator.index++ - } - if !iterator.list.withinRange(iterator.index) { - iterator.element = nil - return false - } - if iterator.index == 0 { - iterator.element = iterator.list.first - } else { - iterator.element = iterator.element.next - } - return true -} - -// Value returns the current element's value. -// Does not modify the state of the iterator. -func (iterator *Iterator) Value() interface{} { - return iterator.element.value -} - -// Index returns the current element's index. -// Does not modify the state of the iterator. -func (iterator *Iterator) Index() int { - return iterator.index -} - -// Begin resets the iterator to its initial state (one-before-first) -// Call Next() to fetch the first element if any. -func (iterator *Iterator) Begin() { - iterator.index = -1 - iterator.element = nil -} - -// First moves the iterator to the first element and returns true if there was a first element in the container. -// If First() returns true, then first element's index and value can be retrieved by Index() and Value(). -// Modifies the state of the iterator. -func (iterator *Iterator) First() bool { - iterator.Begin() - return iterator.Next() -} - -// NextTo moves the iterator to the next element from current position that satisfies the condition given by the -// passed function, and returns true if there was a next element in the container. -// If NextTo() returns true, then next element's index and value can be retrieved by Index() and Value(). -// Modifies the state of the iterator. -func (iterator *Iterator) NextTo(f func(index int, value interface{}) bool) bool { - for iterator.Next() { - index, value := iterator.Index(), iterator.Value() - if f(index, value) { - return true - } - } - return false -} diff --git a/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/serialization.go b/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/serialization.go deleted file mode 100644 index 588a316ce..000000000 --- a/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/serialization.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package singlylinkedlist - -import ( - "encoding/json" - "github.com/emirpasic/gods/containers" -) - -// Assert Serialization implementation -var _ containers.JSONSerializer = (*List)(nil) -var _ containers.JSONDeserializer = (*List)(nil) - -// ToJSON outputs the JSON representation of list's elements. -func (list *List) ToJSON() ([]byte, error) { - return json.Marshal(list.Values()) -} - -// FromJSON populates list's elements from the input JSON representation. -func (list *List) FromJSON(data []byte) error { - elements := []interface{}{} - err := json.Unmarshal(data, &elements) - if err == nil { - list.Clear() - list.Add(elements...) - } - return err -} - -// UnmarshalJSON @implements json.Unmarshaler -func (list *List) UnmarshalJSON(bytes []byte) error { - return list.FromJSON(bytes) -} - -// MarshalJSON @implements json.Marshaler -func (list *List) MarshalJSON() ([]byte, error) { - return list.ToJSON() -} diff --git a/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/singlylinkedlist.go b/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/singlylinkedlist.go deleted file mode 100644 index c3e2c675a..000000000 --- a/vendor/github.com/emirpasic/gods/lists/singlylinkedlist/singlylinkedlist.go +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package singlylinkedlist implements the singly-linked list. -// -// Structure is not thread safe. -// -// Reference: https://en.wikipedia.org/wiki/List_%28abstract_data_type%29 -package singlylinkedlist - -import ( - "fmt" - "strings" - - "github.com/emirpasic/gods/lists" - "github.com/emirpasic/gods/utils" -) - -// Assert List implementation -var _ lists.List = (*List)(nil) - -// List holds the elements, where each element points to the next element -type List struct { - first *element - last *element - size int -} - -type element struct { - value interface{} - next *element -} - -// New instantiates a new list and adds the passed values, if any, to the list -func New(values ...interface{}) *List { - list := &List{} - if len(values) > 0 { - list.Add(values...) - } - return list -} - -// Add appends a value (one or more) at the end of the list (same as Append()) -func (list *List) Add(values ...interface{}) { - for _, value := range values { - newElement := &element{value: value} - if list.size == 0 { - list.first = newElement - list.last = newElement - } else { - list.last.next = newElement - list.last = newElement - } - list.size++ - } -} - -// Append appends a value (one or more) at the end of the list (same as Add()) -func (list *List) Append(values ...interface{}) { - list.Add(values...) -} - -// Prepend prepends a values (or more) -func (list *List) Prepend(values ...interface{}) { - // in reverse to keep passed order i.e. ["c","d"] -> Prepend(["a","b"]) -> ["a","b","c",d"] - for v := len(values) - 1; v >= 0; v-- { - newElement := &element{value: values[v], next: list.first} - list.first = newElement - if list.size == 0 { - list.last = newElement - } - list.size++ - } -} - -// Get returns the element at index. -// Second return parameter is true if index is within bounds of the array and array is not empty, otherwise false. -func (list *List) Get(index int) (interface{}, bool) { - - if !list.withinRange(index) { - return nil, false - } - - element := list.first - for e := 0; e != index; e, element = e+1, element.next { - } - - return element.value, true -} - -// Remove removes the element at the given index from the list. -func (list *List) Remove(index int) { - - if !list.withinRange(index) { - return - } - - if list.size == 1 { - list.Clear() - return - } - - var beforeElement *element - element := list.first - for e := 0; e != index; e, element = e+1, element.next { - beforeElement = element - } - - if element == list.first { - list.first = element.next - } - if element == list.last { - list.last = beforeElement - } - if beforeElement != nil { - beforeElement.next = element.next - } - - element = nil - - list.size-- -} - -// Contains checks if values (one or more) are present in the set. -// All values have to be present in the set for the method to return true. -// Performance time complexity of n^2. -// Returns true if no arguments are passed at all, i.e. set is always super-set of empty set. -func (list *List) Contains(values ...interface{}) bool { - - if len(values) == 0 { - return true - } - if list.size == 0 { - return false - } - for _, value := range values { - found := false - for element := list.first; element != nil; element = element.next { - if element.value == value { - found = true - break - } - } - if !found { - return false - } - } - return true -} - -// Values returns all elements in the list. -func (list *List) Values() []interface{} { - values := make([]interface{}, list.size, list.size) - for e, element := 0, list.first; element != nil; e, element = e+1, element.next { - values[e] = element.value - } - return values -} - -//IndexOf returns index of provided element -func (list *List) IndexOf(value interface{}) int { - if list.size == 0 { - return -1 - } - for index, element := range list.Values() { - if element == value { - return index - } - } - return -1 -} - -// Empty returns true if list does not contain any elements. -func (list *List) Empty() bool { - return list.size == 0 -} - -// Size returns number of elements within the list. -func (list *List) Size() int { - return list.size -} - -// Clear removes all elements from the list. -func (list *List) Clear() { - list.size = 0 - list.first = nil - list.last = nil -} - -// Sort sort values (in-place) using. -func (list *List) Sort(comparator utils.Comparator) { - - if list.size < 2 { - return - } - - values := list.Values() - utils.Sort(values, comparator) - - list.Clear() - - list.Add(values...) - -} - -// Swap swaps values of two elements at the given indices. -func (list *List) Swap(i, j int) { - if list.withinRange(i) && list.withinRange(j) && i != j { - var element1, element2 *element - for e, currentElement := 0, list.first; element1 == nil || element2 == nil; e, currentElement = e+1, currentElement.next { - switch e { - case i: - element1 = currentElement - case j: - element2 = currentElement - } - } - element1.value, element2.value = element2.value, element1.value - } -} - -// Insert inserts values at specified index position shifting the value at that position (if any) and any subsequent elements to the right. -// Does not do anything if position is negative or bigger than list's size -// Note: position equal to list's size is valid, i.e. append. -func (list *List) Insert(index int, values ...interface{}) { - - if !list.withinRange(index) { - // Append - if index == list.size { - list.Add(values...) - } - return - } - - list.size += len(values) - - var beforeElement *element - foundElement := list.first - for e := 0; e != index; e, foundElement = e+1, foundElement.next { - beforeElement = foundElement - } - - if foundElement == list.first { - oldNextElement := list.first - for i, value := range values { - newElement := &element{value: value} - if i == 0 { - list.first = newElement - } else { - beforeElement.next = newElement - } - beforeElement = newElement - } - beforeElement.next = oldNextElement - } else { - oldNextElement := beforeElement.next - for _, value := range values { - newElement := &element{value: value} - beforeElement.next = newElement - beforeElement = newElement - } - beforeElement.next = oldNextElement - } -} - -// Set value at specified index -// Does not do anything if position is negative or bigger than list's size -// Note: position equal to list's size is valid, i.e. append. -func (list *List) Set(index int, value interface{}) { - - if !list.withinRange(index) { - // Append - if index == list.size { - list.Add(value) - } - return - } - - foundElement := list.first - for e := 0; e != index; { - e, foundElement = e+1, foundElement.next - } - foundElement.value = value -} - -// String returns a string representation of container -func (list *List) String() string { - str := "SinglyLinkedList\n" - values := []string{} - for element := list.first; element != nil; element = element.next { - values = append(values, fmt.Sprintf("%v", element.value)) - } - str += strings.Join(values, ", ") - return str -} - -// Check that the index is within bounds of the list -func (list *List) withinRange(index int) bool { - return index >= 0 && index < list.size -} diff --git a/vendor/github.com/emirpasic/gods/queues/linkedlistqueue/iterator.go b/vendor/github.com/emirpasic/gods/queues/linkedlistqueue/iterator.go deleted file mode 100644 index cf47b191b..000000000 --- a/vendor/github.com/emirpasic/gods/queues/linkedlistqueue/iterator.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package linkedlistqueue - -import "github.com/emirpasic/gods/containers" - -// Assert Iterator implementation -var _ containers.IteratorWithIndex = (*Iterator)(nil) - -// Iterator returns a stateful iterator whose values can be fetched by an index. -type Iterator struct { - queue *Queue - index int -} - -// Iterator returns a stateful iterator whose values can be fetched by an index. -func (queue *Queue) Iterator() Iterator { - return Iterator{queue: queue, index: -1} -} - -// Next moves the iterator to the next element and returns true if there was a next element in the container. -// If Next() returns true, then next element's index and value can be retrieved by Index() and Value(). -// If Next() was called for the first time, then it will point the iterator to the first element if it exists. -// Modifies the state of the iterator. -func (iterator *Iterator) Next() bool { - if iterator.index < iterator.queue.Size() { - iterator.index++ - } - return iterator.queue.withinRange(iterator.index) -} - -// Value returns the current element's value. -// Does not modify the state of the iterator. -func (iterator *Iterator) Value() interface{} { - value, _ := iterator.queue.list.Get(iterator.index) - return value -} - -// Index returns the current element's index. -// Does not modify the state of the iterator. -func (iterator *Iterator) Index() int { - return iterator.index -} - -// Begin resets the iterator to its initial state (one-before-first) -// Call Next() to fetch the first element if any. -func (iterator *Iterator) Begin() { - iterator.index = -1 -} - -// First moves the iterator to the first element and returns true if there was a first element in the container. -// If First() returns true, then first element's index and value can be retrieved by Index() and Value(). -// Modifies the state of the iterator. -func (iterator *Iterator) First() bool { - iterator.Begin() - return iterator.Next() -} - -// NextTo moves the iterator to the next element from current position that satisfies the condition given by the -// passed function, and returns true if there was a next element in the container. -// If NextTo() returns true, then next element's index and value can be retrieved by Index() and Value(). -// Modifies the state of the iterator. -func (iterator *Iterator) NextTo(f func(index int, value interface{}) bool) bool { - for iterator.Next() { - index, value := iterator.Index(), iterator.Value() - if f(index, value) { - return true - } - } - return false -} diff --git a/vendor/github.com/emirpasic/gods/queues/linkedlistqueue/linkedlistqueue.go b/vendor/github.com/emirpasic/gods/queues/linkedlistqueue/linkedlistqueue.go deleted file mode 100644 index fdb94636e..000000000 --- a/vendor/github.com/emirpasic/gods/queues/linkedlistqueue/linkedlistqueue.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2021, Aryan Ahadinia. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package linkedlistqueue implements a queue backed by a singly-linked list. -// -// Structure is not thread safe. -// -// Reference: https://en.wikipedia.org/wiki/Queue_(abstract_data_type) -package linkedlistqueue - -import ( - "fmt" - "strings" - - "github.com/emirpasic/gods/lists/singlylinkedlist" - "github.com/emirpasic/gods/queues" -) - -// Assert Queue implementation -var _ queues.Queue = (*Queue)(nil) - -// Queue holds elements in a singly-linked-list -type Queue struct { - list *singlylinkedlist.List -} - -// New instantiates a new empty queue -func New() *Queue { - return &Queue{list: &singlylinkedlist.List{}} -} - -// Enqueue adds a value to the end of the queue -func (queue *Queue) Enqueue(value interface{}) { - queue.list.Add(value) -} - -// Dequeue removes first element of the queue and returns it, or nil if queue is empty. -// Second return parameter is true, unless the queue was empty and there was nothing to dequeue. -func (queue *Queue) Dequeue() (value interface{}, ok bool) { - value, ok = queue.list.Get(0) - if ok { - queue.list.Remove(0) - } - return -} - -// Peek returns first element of the queue without removing it, or nil if queue is empty. -// Second return parameter is true, unless the queue was empty and there was nothing to peek. -func (queue *Queue) Peek() (value interface{}, ok bool) { - return queue.list.Get(0) -} - -// Empty returns true if queue does not contain any elements. -func (queue *Queue) Empty() bool { - return queue.list.Empty() -} - -// Size returns number of elements within the queue. -func (queue *Queue) Size() int { - return queue.list.Size() -} - -// Clear removes all elements from the queue. -func (queue *Queue) Clear() { - queue.list.Clear() -} - -// Values returns all elements in the queue (FIFO order). -func (queue *Queue) Values() []interface{} { - return queue.list.Values() -} - -// String returns a string representation of container -func (queue *Queue) String() string { - str := "LinkedListQueue\n" - values := []string{} - for _, value := range queue.list.Values() { - values = append(values, fmt.Sprintf("%v", value)) - } - str += strings.Join(values, ", ") - return str -} - -// Check that the index is within bounds of the list -func (queue *Queue) withinRange(index int) bool { - return index >= 0 && index < queue.list.Size() -} diff --git a/vendor/github.com/emirpasic/gods/queues/linkedlistqueue/serialization.go b/vendor/github.com/emirpasic/gods/queues/linkedlistqueue/serialization.go deleted file mode 100644 index 2b34c8e45..000000000 --- a/vendor/github.com/emirpasic/gods/queues/linkedlistqueue/serialization.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package linkedlistqueue - -import ( - "github.com/emirpasic/gods/containers" -) - -// Assert Serialization implementation -var _ containers.JSONSerializer = (*Queue)(nil) -var _ containers.JSONDeserializer = (*Queue)(nil) - -// ToJSON outputs the JSON representation of the queue. -func (queue *Queue) ToJSON() ([]byte, error) { - return queue.list.ToJSON() -} - -// FromJSON populates the queue from the input JSON representation. -func (queue *Queue) FromJSON(data []byte) error { - return queue.list.FromJSON(data) -} - -// UnmarshalJSON @implements json.Unmarshaler -func (queue *Queue) UnmarshalJSON(bytes []byte) error { - return queue.FromJSON(bytes) -} - -// MarshalJSON @implements json.Marshaler -func (queue *Queue) MarshalJSON() ([]byte, error) { - return queue.ToJSON() -} diff --git a/vendor/github.com/emirpasic/gods/queues/queues.go b/vendor/github.com/emirpasic/gods/queues/queues.go deleted file mode 100644 index 80239d485..000000000 --- a/vendor/github.com/emirpasic/gods/queues/queues.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2021, Aryan Ahadinia. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package queues provides an abstract Queue interface. -// -// In computer science, a queue is a collection of entities that are maintained in a sequence and can be modified by the addition of entities at one end of the sequence and the removal of entities from the other end of the sequence. By convention, the end of the sequence at which elements are added is called the back, tail, or rear of the queue, and the end at which elements are removed is called the head or front of the queue, analogously to the words used when people line up to wait for goods or services. -// The operation of adding an element to the rear of the queue is known as enqueue, and the operation of removing an element from the front is known as dequeue. Other operations may also be allowed, often including a peek or front operation that returns the value of the next element to be dequeued without remove it. -// -// Reference: https://en.wikipedia.org/wiki/Queue_(abstract_data_type) -package queues - -import "github.com/emirpasic/gods/containers" - -// Queue interface that all queues implement -type Queue interface { - Enqueue(value interface{}) - Dequeue() (value interface{}, ok bool) - Peek() (value interface{}, ok bool) - - containers.Container - // Empty() bool - // Size() int - // Clear() - // Values() []interface{} - // String() string -} diff --git a/vendor/github.com/emirpasic/gods/stacks/linkedliststack/iterator.go b/vendor/github.com/emirpasic/gods/stacks/linkedliststack/iterator.go deleted file mode 100644 index dea086b1c..000000000 --- a/vendor/github.com/emirpasic/gods/stacks/linkedliststack/iterator.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package linkedliststack - -import "github.com/emirpasic/gods/containers" - -// Assert Iterator implementation -var _ containers.IteratorWithIndex = (*Iterator)(nil) - -// Iterator returns a stateful iterator whose values can be fetched by an index. -type Iterator struct { - stack *Stack - index int -} - -// Iterator returns a stateful iterator whose values can be fetched by an index. -func (stack *Stack) Iterator() Iterator { - return Iterator{stack: stack, index: -1} -} - -// Next moves the iterator to the next element and returns true if there was a next element in the container. -// If Next() returns true, then next element's index and value can be retrieved by Index() and Value(). -// If Next() was called for the first time, then it will point the iterator to the first element if it exists. -// Modifies the state of the iterator. -func (iterator *Iterator) Next() bool { - if iterator.index < iterator.stack.Size() { - iterator.index++ - } - return iterator.stack.withinRange(iterator.index) -} - -// Value returns the current element's value. -// Does not modify the state of the iterator. -func (iterator *Iterator) Value() interface{} { - value, _ := iterator.stack.list.Get(iterator.index) // in reverse (LIFO) - return value -} - -// Index returns the current element's index. -// Does not modify the state of the iterator. -func (iterator *Iterator) Index() int { - return iterator.index -} - -// Begin resets the iterator to its initial state (one-before-first) -// Call Next() to fetch the first element if any. -func (iterator *Iterator) Begin() { - iterator.index = -1 -} - -// First moves the iterator to the first element and returns true if there was a first element in the container. -// If First() returns true, then first element's index and value can be retrieved by Index() and Value(). -// Modifies the state of the iterator. -func (iterator *Iterator) First() bool { - iterator.Begin() - return iterator.Next() -} - -// NextTo moves the iterator to the next element from current position that satisfies the condition given by the -// passed function, and returns true if there was a next element in the container. -// If NextTo() returns true, then next element's index and value can be retrieved by Index() and Value(). -// Modifies the state of the iterator. -func (iterator *Iterator) NextTo(f func(index int, value interface{}) bool) bool { - for iterator.Next() { - index, value := iterator.Index(), iterator.Value() - if f(index, value) { - return true - } - } - return false -} diff --git a/vendor/github.com/emirpasic/gods/stacks/linkedliststack/linkedliststack.go b/vendor/github.com/emirpasic/gods/stacks/linkedliststack/linkedliststack.go deleted file mode 100644 index ce69b2123..000000000 --- a/vendor/github.com/emirpasic/gods/stacks/linkedliststack/linkedliststack.go +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package linkedliststack implements a stack backed by a singly-linked list. -// -// Structure is not thread safe. -// -// Reference:https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29#Linked_list -package linkedliststack - -import ( - "fmt" - "github.com/emirpasic/gods/lists/singlylinkedlist" - "github.com/emirpasic/gods/stacks" - "strings" -) - -// Assert Stack implementation -var _ stacks.Stack = (*Stack)(nil) - -// Stack holds elements in a singly-linked-list -type Stack struct { - list *singlylinkedlist.List -} - -// New nnstantiates a new empty stack -func New() *Stack { - return &Stack{list: &singlylinkedlist.List{}} -} - -// Push adds a value onto the top of the stack -func (stack *Stack) Push(value interface{}) { - stack.list.Prepend(value) -} - -// Pop removes top element on stack and returns it, or nil if stack is empty. -// Second return parameter is true, unless the stack was empty and there was nothing to pop. -func (stack *Stack) Pop() (value interface{}, ok bool) { - value, ok = stack.list.Get(0) - stack.list.Remove(0) - return -} - -// Peek returns top element on the stack without removing it, or nil if stack is empty. -// Second return parameter is true, unless the stack was empty and there was nothing to peek. -func (stack *Stack) Peek() (value interface{}, ok bool) { - return stack.list.Get(0) -} - -// Empty returns true if stack does not contain any elements. -func (stack *Stack) Empty() bool { - return stack.list.Empty() -} - -// Size returns number of elements within the stack. -func (stack *Stack) Size() int { - return stack.list.Size() -} - -// Clear removes all elements from the stack. -func (stack *Stack) Clear() { - stack.list.Clear() -} - -// Values returns all elements in the stack (LIFO order). -func (stack *Stack) Values() []interface{} { - return stack.list.Values() -} - -// String returns a string representation of container -func (stack *Stack) String() string { - str := "LinkedListStack\n" - values := []string{} - for _, value := range stack.list.Values() { - values = append(values, fmt.Sprintf("%v", value)) - } - str += strings.Join(values, ", ") - return str -} - -// Check that the index is within bounds of the list -func (stack *Stack) withinRange(index int) bool { - return index >= 0 && index < stack.list.Size() -} diff --git a/vendor/github.com/emirpasic/gods/stacks/linkedliststack/serialization.go b/vendor/github.com/emirpasic/gods/stacks/linkedliststack/serialization.go deleted file mode 100644 index a82b768c0..000000000 --- a/vendor/github.com/emirpasic/gods/stacks/linkedliststack/serialization.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package linkedliststack - -import ( - "github.com/emirpasic/gods/containers" -) - -// Assert Serialization implementation -var _ containers.JSONSerializer = (*Stack)(nil) -var _ containers.JSONDeserializer = (*Stack)(nil) - -// ToJSON outputs the JSON representation of the stack. -func (stack *Stack) ToJSON() ([]byte, error) { - return stack.list.ToJSON() -} - -// FromJSON populates the stack from the input JSON representation. -func (stack *Stack) FromJSON(data []byte) error { - return stack.list.FromJSON(data) -} - -// UnmarshalJSON @implements json.Unmarshaler -func (stack *Stack) UnmarshalJSON(bytes []byte) error { - return stack.FromJSON(bytes) -} - -// MarshalJSON @implements json.Marshaler -func (stack *Stack) MarshalJSON() ([]byte, error) { - return stack.ToJSON() -} diff --git a/vendor/github.com/emirpasic/gods/stacks/stacks.go b/vendor/github.com/emirpasic/gods/stacks/stacks.go deleted file mode 100644 index e9ae56e17..000000000 --- a/vendor/github.com/emirpasic/gods/stacks/stacks.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package stacks provides an abstract Stack interface. -// -// In computer science, a stack is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the most recently added element that was not yet removed. The order in which elements come off a stack gives rise to its alternative name, LIFO (for last in, first out). Additionally, a peek operation may give access to the top without modifying the stack. -// -// Reference: https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29 -package stacks - -import "github.com/emirpasic/gods/containers" - -// Stack interface that all stacks implement -type Stack interface { - Push(value interface{}) - Pop() (value interface{}, ok bool) - Peek() (value interface{}, ok bool) - - containers.Container - // Empty() bool - // Size() int - // Clear() - // Values() []interface{} - // String() string -} diff --git a/vendor/github.com/emirpasic/gods/utils/comparator.go b/vendor/github.com/emirpasic/gods/utils/comparator.go deleted file mode 100644 index 6a9afbf34..000000000 --- a/vendor/github.com/emirpasic/gods/utils/comparator.go +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package utils - -import "time" - -// Comparator will make type assertion (see IntComparator for example), -// which will panic if a or b are not of the asserted type. -// -// Should return a number: -// negative , if a < b -// zero , if a == b -// positive , if a > b -type Comparator func(a, b interface{}) int - -// StringComparator provides a fast comparison on strings -func StringComparator(a, b interface{}) int { - s1 := a.(string) - s2 := b.(string) - min := len(s2) - if len(s1) < len(s2) { - min = len(s1) - } - diff := 0 - for i := 0; i < min && diff == 0; i++ { - diff = int(s1[i]) - int(s2[i]) - } - if diff == 0 { - diff = len(s1) - len(s2) - } - if diff < 0 { - return -1 - } - if diff > 0 { - return 1 - } - return 0 -} - -// IntComparator provides a basic comparison on int -func IntComparator(a, b interface{}) int { - aAsserted := a.(int) - bAsserted := b.(int) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// Int8Comparator provides a basic comparison on int8 -func Int8Comparator(a, b interface{}) int { - aAsserted := a.(int8) - bAsserted := b.(int8) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// Int16Comparator provides a basic comparison on int16 -func Int16Comparator(a, b interface{}) int { - aAsserted := a.(int16) - bAsserted := b.(int16) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// Int32Comparator provides a basic comparison on int32 -func Int32Comparator(a, b interface{}) int { - aAsserted := a.(int32) - bAsserted := b.(int32) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// Int64Comparator provides a basic comparison on int64 -func Int64Comparator(a, b interface{}) int { - aAsserted := a.(int64) - bAsserted := b.(int64) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// UIntComparator provides a basic comparison on uint -func UIntComparator(a, b interface{}) int { - aAsserted := a.(uint) - bAsserted := b.(uint) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// UInt8Comparator provides a basic comparison on uint8 -func UInt8Comparator(a, b interface{}) int { - aAsserted := a.(uint8) - bAsserted := b.(uint8) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// UInt16Comparator provides a basic comparison on uint16 -func UInt16Comparator(a, b interface{}) int { - aAsserted := a.(uint16) - bAsserted := b.(uint16) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// UInt32Comparator provides a basic comparison on uint32 -func UInt32Comparator(a, b interface{}) int { - aAsserted := a.(uint32) - bAsserted := b.(uint32) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// UInt64Comparator provides a basic comparison on uint64 -func UInt64Comparator(a, b interface{}) int { - aAsserted := a.(uint64) - bAsserted := b.(uint64) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// Float32Comparator provides a basic comparison on float32 -func Float32Comparator(a, b interface{}) int { - aAsserted := a.(float32) - bAsserted := b.(float32) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// Float64Comparator provides a basic comparison on float64 -func Float64Comparator(a, b interface{}) int { - aAsserted := a.(float64) - bAsserted := b.(float64) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// ByteComparator provides a basic comparison on byte -func ByteComparator(a, b interface{}) int { - aAsserted := a.(byte) - bAsserted := b.(byte) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// RuneComparator provides a basic comparison on rune -func RuneComparator(a, b interface{}) int { - aAsserted := a.(rune) - bAsserted := b.(rune) - switch { - case aAsserted > bAsserted: - return 1 - case aAsserted < bAsserted: - return -1 - default: - return 0 - } -} - -// TimeComparator provides a basic comparison on time.Time -func TimeComparator(a, b interface{}) int { - aAsserted := a.(time.Time) - bAsserted := b.(time.Time) - - switch { - case aAsserted.After(bAsserted): - return 1 - case aAsserted.Before(bAsserted): - return -1 - default: - return 0 - } -} diff --git a/vendor/github.com/emirpasic/gods/utils/sort.go b/vendor/github.com/emirpasic/gods/utils/sort.go deleted file mode 100644 index 79ced1f5d..000000000 --- a/vendor/github.com/emirpasic/gods/utils/sort.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package utils - -import "sort" - -// Sort sorts values (in-place) with respect to the given comparator. -// -// Uses Go's sort (hybrid of quicksort for large and then insertion sort for smaller slices). -func Sort(values []interface{}, comparator Comparator) { - sort.Sort(sortable{values, comparator}) -} - -type sortable struct { - values []interface{} - comparator Comparator -} - -func (s sortable) Len() int { - return len(s.values) -} -func (s sortable) Swap(i, j int) { - s.values[i], s.values[j] = s.values[j], s.values[i] -} -func (s sortable) Less(i, j int) bool { - return s.comparator(s.values[i], s.values[j]) < 0 -} diff --git a/vendor/github.com/emirpasic/gods/utils/utils.go b/vendor/github.com/emirpasic/gods/utils/utils.go deleted file mode 100644 index 262c62576..000000000 --- a/vendor/github.com/emirpasic/gods/utils/utils.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2015, Emir Pasic. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package utils provides common utility functions. -// -// Provided functionalities: -// - sorting -// - comparators -package utils - -import ( - "fmt" - "strconv" -) - -// ToString converts a value to string. -func ToString(value interface{}) string { - switch value := value.(type) { - case string: - return value - case int8: - return strconv.FormatInt(int64(value), 10) - case int16: - return strconv.FormatInt(int64(value), 10) - case int32: - return strconv.FormatInt(int64(value), 10) - case int64: - return strconv.FormatInt(value, 10) - case uint8: - return strconv.FormatUint(uint64(value), 10) - case uint16: - return strconv.FormatUint(uint64(value), 10) - case uint32: - return strconv.FormatUint(uint64(value), 10) - case uint64: - return strconv.FormatUint(value, 10) - case float32: - return strconv.FormatFloat(float64(value), 'g', -1, 64) - case float64: - return strconv.FormatFloat(value, 'g', -1, 64) - case bool: - return strconv.FormatBool(value) - default: - return fmt.Sprintf("%+v", value) - } -} diff --git a/vendor/github.com/envoyproxy/protoc-gen-validate/LICENSE b/vendor/github.com/envoyproxy/protoc-gen-validate/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vendor/github.com/envoyproxy/protoc-gen-validate/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/envoyproxy/protoc-gen-validate/validate/BUILD b/vendor/github.com/envoyproxy/protoc-gen-validate/validate/BUILD deleted file mode 100644 index a9d38c51b..000000000 --- a/vendor/github.com/envoyproxy/protoc-gen-validate/validate/BUILD +++ /dev/null @@ -1,74 +0,0 @@ -load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library") -load("@rules_java//java:defs.bzl", "java_proto_library") -load("@rules_proto//proto:defs.bzl", "proto_library") -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -package( - default_visibility = - ["//visibility:public"], -) - -proto_library( - name = "validate_proto", - srcs = ["validate.proto"], - deps = [ - "@com_google_protobuf//:descriptor_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:timestamp_proto", - ], -) - -cc_proto_library( - name = "validate_cc", - deps = [":validate_proto"], -) - -py_proto_library( - name = "validate_py", - srcs = ["validate.proto"], - deps = ["@com_google_protobuf//:protobuf_python"], -) - -go_proto_library( - name = "validate_go_proto", - importpath = "github.com/envoyproxy/protoc-gen-validate/validate", - proto = ":validate_proto", -) - -cc_library( - name = "cc_validate", - hdrs = ["validate.h"], -) - -go_library( - name = "validate_go", - embed = [":validate_go_proto"], - importpath = "github.com/envoyproxy/protoc-gen-validate/validate", -) - -java_proto_library( - name = "validate_java", - deps = [":validate_proto"], -) - -filegroup( - name = "validate_src", - srcs = ["validate.proto"], -) - -alias( - name = "go_default_library", - actual = ":validate", - deprecation = "Use :validate instead of :go_default_library. Details about the new naming convention: https://github.com/bazelbuild/bazel-gazelle/pull/863", - visibility = ["//visibility:public"], -) - -# this alias allows build files generated with Gazelle in other repositories -# to find validate as an external dependency -alias( - name = "validate", - actual = ":validate_go", - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.h b/vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.h deleted file mode 100644 index d6cf6c9d9..000000000 --- a/vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef _VALIDATE_H -#define _VALIDATE_H - -#include -#include -#include -#include -#include -#include -#include - -#if !defined(_WIN32) -#include -#else -#include -#include - -// uses macros to #define a ton of symbols, -// many of which interfere with our code here and down -// the line in various extensions. -#undef DELETE -#undef ERROR -#undef GetMessage -#undef interface -#undef TRUE -#undef min - -#endif - -#include "google/protobuf/message.h" - -namespace pgv { -using std::string; - -class UnimplementedException : public std::runtime_error { -public: - UnimplementedException() : std::runtime_error("not yet implemented") {} - UnimplementedException(const std::string& message) : std::runtime_error(message) {} - // Thrown by C++ validation code that is not yet implemented. -}; - -using ValidationMsg = std::string; - -class BaseValidator { -public: - /** - * Validate/check a generic message object with a registered validator for the concrete message - * type. - * @param m supplies the message to check. - * @param err supplies the place to return error information. - * @return true if the validation passes OR there is no registered validator for the concrete - * message type. false is returned if validation explicitly fails. - */ - static bool AbstractCheckMessage(const google::protobuf::Message& m, ValidationMsg* err) { - // Polymorphic lookup is used to see if there is a matching concrete validator. If so, call it. - // Otherwise return success. - auto it = abstractValidators().find(std::type_index(typeid(m))); - if (it == abstractValidators().end()) { - return true; - } - return it->second(m, err); - } - -protected: - // Used to implement AbstractCheckMessage() above. Every message that is linked into the binary - // will register itself by type_index, allowing for polymorphic lookup later. - static std::unordered_map>& - abstractValidators() { - static auto* validator_map = new std::unordered_map< - std::type_index, std::function>(); - return *validator_map; - } -}; - -template class Validator : public BaseValidator { -public: - Validator(std::function check) : check_(check) { - abstractValidators()[std::type_index(typeid(T))] = [this](const google::protobuf::Message& m, - ValidationMsg* err) -> bool { - return check_(dynamic_cast(m), err); - }; - } - -private: - std::function check_; -}; - -static inline std::string String(const ValidationMsg& msg) { return std::string(msg); } - -static inline bool IsPrefix(const string& maybe_prefix, const string& search_in) { - return search_in.compare(0, maybe_prefix.size(), maybe_prefix) == 0; -} - -static inline bool IsSuffix(const string& maybe_suffix, const string& search_in) { - return maybe_suffix.size() <= search_in.size() && - search_in.compare(search_in.size() - maybe_suffix.size(), maybe_suffix.size(), - maybe_suffix) == 0; -} - -static inline bool Contains(const string& search_in, const string& to_find) { - return search_in.find(to_find) != string::npos; -} - -static inline bool NotContains(const string& search_in, const string& to_find) { - return !Contains(search_in, to_find); -} - -static inline bool IsIpv4(const string& to_validate) { - struct sockaddr_in sa; - return !(inet_pton(AF_INET, to_validate.c_str(), &sa.sin_addr) < 1); -} - -static inline bool IsIpv6(const string& to_validate) { - struct sockaddr_in6 sa_six; - return !(inet_pton(AF_INET6, to_validate.c_str(), &sa_six.sin6_addr) < 1); -} - -static inline bool IsIp(const string& to_validate) { - return IsIpv4(to_validate) || IsIpv6(to_validate); -} - -static inline bool IsHostname(const string& to_validate) { - if (to_validate.length() > 253) { - return false; - } - - const std::regex dot_regex{"\\."}; - const auto iter_end = std::sregex_token_iterator(); - auto iter = std::sregex_token_iterator(to_validate.begin(), to_validate.end(), dot_regex, -1); - for (; iter != iter_end; ++iter) { - const std::string& part = *iter; - if (part.empty() || part.length() > 63) { - return false; - } - if (part.at(0) == '-') { - return false; - } - if (part.at(part.length() - 1) == '-') { - return false; - } - for (const auto& character : part) { - if ((character < 'A' || character > 'Z') && (character < 'a' || character > 'z') && - (character < '0' || character > '9') && character != '-') { - return false; - } - } - } - - return true; -} - -namespace { - -inline int OneCharLen(const char* src) { - return "\1\1\1\1\1\1\1\1\1\1\1\1\2\2\3\4"[(*src & 0xFF) >> 4]; -} - -inline int UTF8FirstLetterNumBytes(const char *utf8_str, int str_len) { - if (str_len == 0) - return 0; - return OneCharLen(utf8_str); -} - -inline size_t Utf8Len(const string& narrow_string) { - const char* str_char = narrow_string.c_str(); - ptrdiff_t byte_len = narrow_string.length(); - size_t unicode_len = 0; - int char_len = 1; - while (byte_len > 0 && char_len > 0) { - char_len = UTF8FirstLetterNumBytes(str_char, byte_len); - str_char += char_len; - byte_len -= char_len; - ++unicode_len; - } - return unicode_len; -} - -} // namespace - -} // namespace pgv - -#endif // _VALIDATE_H diff --git a/vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.pb.go b/vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.pb.go deleted file mode 100644 index a31b2e1a3..000000000 --- a/vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.pb.go +++ /dev/null @@ -1,4106 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.2 -// source: validate/validate.proto - -package validate - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - descriptorpb "google.golang.org/protobuf/types/descriptorpb" - durationpb "google.golang.org/protobuf/types/known/durationpb" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// WellKnownRegex contain some well-known patterns. -type KnownRegex int32 - -const ( - KnownRegex_UNKNOWN KnownRegex = 0 - // HTTP header name as defined by RFC 7230. - KnownRegex_HTTP_HEADER_NAME KnownRegex = 1 - // HTTP header value as defined by RFC 7230. - KnownRegex_HTTP_HEADER_VALUE KnownRegex = 2 -) - -// Enum value maps for KnownRegex. -var ( - KnownRegex_name = map[int32]string{ - 0: "UNKNOWN", - 1: "HTTP_HEADER_NAME", - 2: "HTTP_HEADER_VALUE", - } - KnownRegex_value = map[string]int32{ - "UNKNOWN": 0, - "HTTP_HEADER_NAME": 1, - "HTTP_HEADER_VALUE": 2, - } -) - -func (x KnownRegex) Enum() *KnownRegex { - p := new(KnownRegex) - *p = x - return p -} - -func (x KnownRegex) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (KnownRegex) Descriptor() protoreflect.EnumDescriptor { - return file_validate_validate_proto_enumTypes[0].Descriptor() -} - -func (KnownRegex) Type() protoreflect.EnumType { - return &file_validate_validate_proto_enumTypes[0] -} - -func (x KnownRegex) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Do not use. -func (x *KnownRegex) UnmarshalJSON(b []byte) error { - num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) - if err != nil { - return err - } - *x = KnownRegex(num) - return nil -} - -// Deprecated: Use KnownRegex.Descriptor instead. -func (KnownRegex) EnumDescriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{0} -} - -// FieldRules encapsulates the rules for each type of field. Depending on the -// field, the correct set should be used to ensure proper validations. -type FieldRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message *MessageRules `protobuf:"bytes,17,opt,name=message" json:"message,omitempty"` - // Types that are assignable to Type: - // - // *FieldRules_Float - // *FieldRules_Double - // *FieldRules_Int32 - // *FieldRules_Int64 - // *FieldRules_Uint32 - // *FieldRules_Uint64 - // *FieldRules_Sint32 - // *FieldRules_Sint64 - // *FieldRules_Fixed32 - // *FieldRules_Fixed64 - // *FieldRules_Sfixed32 - // *FieldRules_Sfixed64 - // *FieldRules_Bool - // *FieldRules_String_ - // *FieldRules_Bytes - // *FieldRules_Enum - // *FieldRules_Repeated - // *FieldRules_Map - // *FieldRules_Any - // *FieldRules_Duration - // *FieldRules_Timestamp - Type isFieldRules_Type `protobuf_oneof:"type"` -} - -func (x *FieldRules) Reset() { - *x = FieldRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FieldRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FieldRules) ProtoMessage() {} - -func (x *FieldRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FieldRules.ProtoReflect.Descriptor instead. -func (*FieldRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{0} -} - -func (x *FieldRules) GetMessage() *MessageRules { - if x != nil { - return x.Message - } - return nil -} - -func (m *FieldRules) GetType() isFieldRules_Type { - if m != nil { - return m.Type - } - return nil -} - -func (x *FieldRules) GetFloat() *FloatRules { - if x, ok := x.GetType().(*FieldRules_Float); ok { - return x.Float - } - return nil -} - -func (x *FieldRules) GetDouble() *DoubleRules { - if x, ok := x.GetType().(*FieldRules_Double); ok { - return x.Double - } - return nil -} - -func (x *FieldRules) GetInt32() *Int32Rules { - if x, ok := x.GetType().(*FieldRules_Int32); ok { - return x.Int32 - } - return nil -} - -func (x *FieldRules) GetInt64() *Int64Rules { - if x, ok := x.GetType().(*FieldRules_Int64); ok { - return x.Int64 - } - return nil -} - -func (x *FieldRules) GetUint32() *UInt32Rules { - if x, ok := x.GetType().(*FieldRules_Uint32); ok { - return x.Uint32 - } - return nil -} - -func (x *FieldRules) GetUint64() *UInt64Rules { - if x, ok := x.GetType().(*FieldRules_Uint64); ok { - return x.Uint64 - } - return nil -} - -func (x *FieldRules) GetSint32() *SInt32Rules { - if x, ok := x.GetType().(*FieldRules_Sint32); ok { - return x.Sint32 - } - return nil -} - -func (x *FieldRules) GetSint64() *SInt64Rules { - if x, ok := x.GetType().(*FieldRules_Sint64); ok { - return x.Sint64 - } - return nil -} - -func (x *FieldRules) GetFixed32() *Fixed32Rules { - if x, ok := x.GetType().(*FieldRules_Fixed32); ok { - return x.Fixed32 - } - return nil -} - -func (x *FieldRules) GetFixed64() *Fixed64Rules { - if x, ok := x.GetType().(*FieldRules_Fixed64); ok { - return x.Fixed64 - } - return nil -} - -func (x *FieldRules) GetSfixed32() *SFixed32Rules { - if x, ok := x.GetType().(*FieldRules_Sfixed32); ok { - return x.Sfixed32 - } - return nil -} - -func (x *FieldRules) GetSfixed64() *SFixed64Rules { - if x, ok := x.GetType().(*FieldRules_Sfixed64); ok { - return x.Sfixed64 - } - return nil -} - -func (x *FieldRules) GetBool() *BoolRules { - if x, ok := x.GetType().(*FieldRules_Bool); ok { - return x.Bool - } - return nil -} - -func (x *FieldRules) GetString_() *StringRules { - if x, ok := x.GetType().(*FieldRules_String_); ok { - return x.String_ - } - return nil -} - -func (x *FieldRules) GetBytes() *BytesRules { - if x, ok := x.GetType().(*FieldRules_Bytes); ok { - return x.Bytes - } - return nil -} - -func (x *FieldRules) GetEnum() *EnumRules { - if x, ok := x.GetType().(*FieldRules_Enum); ok { - return x.Enum - } - return nil -} - -func (x *FieldRules) GetRepeated() *RepeatedRules { - if x, ok := x.GetType().(*FieldRules_Repeated); ok { - return x.Repeated - } - return nil -} - -func (x *FieldRules) GetMap() *MapRules { - if x, ok := x.GetType().(*FieldRules_Map); ok { - return x.Map - } - return nil -} - -func (x *FieldRules) GetAny() *AnyRules { - if x, ok := x.GetType().(*FieldRules_Any); ok { - return x.Any - } - return nil -} - -func (x *FieldRules) GetDuration() *DurationRules { - if x, ok := x.GetType().(*FieldRules_Duration); ok { - return x.Duration - } - return nil -} - -func (x *FieldRules) GetTimestamp() *TimestampRules { - if x, ok := x.GetType().(*FieldRules_Timestamp); ok { - return x.Timestamp - } - return nil -} - -type isFieldRules_Type interface { - isFieldRules_Type() -} - -type FieldRules_Float struct { - // Scalar Field Types - Float *FloatRules `protobuf:"bytes,1,opt,name=float,oneof"` -} - -type FieldRules_Double struct { - Double *DoubleRules `protobuf:"bytes,2,opt,name=double,oneof"` -} - -type FieldRules_Int32 struct { - Int32 *Int32Rules `protobuf:"bytes,3,opt,name=int32,oneof"` -} - -type FieldRules_Int64 struct { - Int64 *Int64Rules `protobuf:"bytes,4,opt,name=int64,oneof"` -} - -type FieldRules_Uint32 struct { - Uint32 *UInt32Rules `protobuf:"bytes,5,opt,name=uint32,oneof"` -} - -type FieldRules_Uint64 struct { - Uint64 *UInt64Rules `protobuf:"bytes,6,opt,name=uint64,oneof"` -} - -type FieldRules_Sint32 struct { - Sint32 *SInt32Rules `protobuf:"bytes,7,opt,name=sint32,oneof"` -} - -type FieldRules_Sint64 struct { - Sint64 *SInt64Rules `protobuf:"bytes,8,opt,name=sint64,oneof"` -} - -type FieldRules_Fixed32 struct { - Fixed32 *Fixed32Rules `protobuf:"bytes,9,opt,name=fixed32,oneof"` -} - -type FieldRules_Fixed64 struct { - Fixed64 *Fixed64Rules `protobuf:"bytes,10,opt,name=fixed64,oneof"` -} - -type FieldRules_Sfixed32 struct { - Sfixed32 *SFixed32Rules `protobuf:"bytes,11,opt,name=sfixed32,oneof"` -} - -type FieldRules_Sfixed64 struct { - Sfixed64 *SFixed64Rules `protobuf:"bytes,12,opt,name=sfixed64,oneof"` -} - -type FieldRules_Bool struct { - Bool *BoolRules `protobuf:"bytes,13,opt,name=bool,oneof"` -} - -type FieldRules_String_ struct { - String_ *StringRules `protobuf:"bytes,14,opt,name=string,oneof"` -} - -type FieldRules_Bytes struct { - Bytes *BytesRules `protobuf:"bytes,15,opt,name=bytes,oneof"` -} - -type FieldRules_Enum struct { - // Complex Field Types - Enum *EnumRules `protobuf:"bytes,16,opt,name=enum,oneof"` -} - -type FieldRules_Repeated struct { - Repeated *RepeatedRules `protobuf:"bytes,18,opt,name=repeated,oneof"` -} - -type FieldRules_Map struct { - Map *MapRules `protobuf:"bytes,19,opt,name=map,oneof"` -} - -type FieldRules_Any struct { - // Well-Known Field Types - Any *AnyRules `protobuf:"bytes,20,opt,name=any,oneof"` -} - -type FieldRules_Duration struct { - Duration *DurationRules `protobuf:"bytes,21,opt,name=duration,oneof"` -} - -type FieldRules_Timestamp struct { - Timestamp *TimestampRules `protobuf:"bytes,22,opt,name=timestamp,oneof"` -} - -func (*FieldRules_Float) isFieldRules_Type() {} - -func (*FieldRules_Double) isFieldRules_Type() {} - -func (*FieldRules_Int32) isFieldRules_Type() {} - -func (*FieldRules_Int64) isFieldRules_Type() {} - -func (*FieldRules_Uint32) isFieldRules_Type() {} - -func (*FieldRules_Uint64) isFieldRules_Type() {} - -func (*FieldRules_Sint32) isFieldRules_Type() {} - -func (*FieldRules_Sint64) isFieldRules_Type() {} - -func (*FieldRules_Fixed32) isFieldRules_Type() {} - -func (*FieldRules_Fixed64) isFieldRules_Type() {} - -func (*FieldRules_Sfixed32) isFieldRules_Type() {} - -func (*FieldRules_Sfixed64) isFieldRules_Type() {} - -func (*FieldRules_Bool) isFieldRules_Type() {} - -func (*FieldRules_String_) isFieldRules_Type() {} - -func (*FieldRules_Bytes) isFieldRules_Type() {} - -func (*FieldRules_Enum) isFieldRules_Type() {} - -func (*FieldRules_Repeated) isFieldRules_Type() {} - -func (*FieldRules_Map) isFieldRules_Type() {} - -func (*FieldRules_Any) isFieldRules_Type() {} - -func (*FieldRules_Duration) isFieldRules_Type() {} - -func (*FieldRules_Timestamp) isFieldRules_Type() {} - -// FloatRules describes the constraints applied to `float` values -type FloatRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *float32 `protobuf:"fixed32,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *float32 `protobuf:"fixed32,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *float32 `protobuf:"fixed32,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *float32 `protobuf:"fixed32,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *float32 `protobuf:"fixed32,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []float32 `protobuf:"fixed32,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []float32 `protobuf:"fixed32,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *FloatRules) Reset() { - *x = FloatRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FloatRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FloatRules) ProtoMessage() {} - -func (x *FloatRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FloatRules.ProtoReflect.Descriptor instead. -func (*FloatRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{1} -} - -func (x *FloatRules) GetConst() float32 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *FloatRules) GetLt() float32 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *FloatRules) GetLte() float32 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *FloatRules) GetGt() float32 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *FloatRules) GetGte() float32 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *FloatRules) GetIn() []float32 { - if x != nil { - return x.In - } - return nil -} - -func (x *FloatRules) GetNotIn() []float32 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *FloatRules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// DoubleRules describes the constraints applied to `double` values -type DoubleRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *float64 `protobuf:"fixed64,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *float64 `protobuf:"fixed64,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *float64 `protobuf:"fixed64,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *float64 `protobuf:"fixed64,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *float64 `protobuf:"fixed64,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []float64 `protobuf:"fixed64,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []float64 `protobuf:"fixed64,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *DoubleRules) Reset() { - *x = DoubleRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoubleRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoubleRules) ProtoMessage() {} - -func (x *DoubleRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoubleRules.ProtoReflect.Descriptor instead. -func (*DoubleRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{2} -} - -func (x *DoubleRules) GetConst() float64 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *DoubleRules) GetLt() float64 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *DoubleRules) GetLte() float64 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *DoubleRules) GetGt() float64 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *DoubleRules) GetGte() float64 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *DoubleRules) GetIn() []float64 { - if x != nil { - return x.In - } - return nil -} - -func (x *DoubleRules) GetNotIn() []float64 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *DoubleRules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// Int32Rules describes the constraints applied to `int32` values -type Int32Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *int32 `protobuf:"varint,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *int32 `protobuf:"varint,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *int32 `protobuf:"varint,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *int32 `protobuf:"varint,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *int32 `protobuf:"varint,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []int32 `protobuf:"varint,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []int32 `protobuf:"varint,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *Int32Rules) Reset() { - *x = Int32Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Int32Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Int32Rules) ProtoMessage() {} - -func (x *Int32Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Int32Rules.ProtoReflect.Descriptor instead. -func (*Int32Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{3} -} - -func (x *Int32Rules) GetConst() int32 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *Int32Rules) GetLt() int32 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *Int32Rules) GetLte() int32 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *Int32Rules) GetGt() int32 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *Int32Rules) GetGte() int32 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *Int32Rules) GetIn() []int32 { - if x != nil { - return x.In - } - return nil -} - -func (x *Int32Rules) GetNotIn() []int32 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *Int32Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// Int64Rules describes the constraints applied to `int64` values -type Int64Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *int64 `protobuf:"varint,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *int64 `protobuf:"varint,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *int64 `protobuf:"varint,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *int64 `protobuf:"varint,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *int64 `protobuf:"varint,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []int64 `protobuf:"varint,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []int64 `protobuf:"varint,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *Int64Rules) Reset() { - *x = Int64Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Int64Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Int64Rules) ProtoMessage() {} - -func (x *Int64Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Int64Rules.ProtoReflect.Descriptor instead. -func (*Int64Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{4} -} - -func (x *Int64Rules) GetConst() int64 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *Int64Rules) GetLt() int64 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *Int64Rules) GetLte() int64 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *Int64Rules) GetGt() int64 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *Int64Rules) GetGte() int64 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *Int64Rules) GetIn() []int64 { - if x != nil { - return x.In - } - return nil -} - -func (x *Int64Rules) GetNotIn() []int64 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *Int64Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// UInt32Rules describes the constraints applied to `uint32` values -type UInt32Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *uint32 `protobuf:"varint,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *uint32 `protobuf:"varint,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *uint32 `protobuf:"varint,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *uint32 `protobuf:"varint,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *uint32 `protobuf:"varint,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []uint32 `protobuf:"varint,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []uint32 `protobuf:"varint,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *UInt32Rules) Reset() { - *x = UInt32Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UInt32Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UInt32Rules) ProtoMessage() {} - -func (x *UInt32Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UInt32Rules.ProtoReflect.Descriptor instead. -func (*UInt32Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{5} -} - -func (x *UInt32Rules) GetConst() uint32 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *UInt32Rules) GetLt() uint32 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *UInt32Rules) GetLte() uint32 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *UInt32Rules) GetGt() uint32 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *UInt32Rules) GetGte() uint32 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *UInt32Rules) GetIn() []uint32 { - if x != nil { - return x.In - } - return nil -} - -func (x *UInt32Rules) GetNotIn() []uint32 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *UInt32Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// UInt64Rules describes the constraints applied to `uint64` values -type UInt64Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *uint64 `protobuf:"varint,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *uint64 `protobuf:"varint,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *uint64 `protobuf:"varint,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *uint64 `protobuf:"varint,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *uint64 `protobuf:"varint,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []uint64 `protobuf:"varint,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []uint64 `protobuf:"varint,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *UInt64Rules) Reset() { - *x = UInt64Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UInt64Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UInt64Rules) ProtoMessage() {} - -func (x *UInt64Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UInt64Rules.ProtoReflect.Descriptor instead. -func (*UInt64Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{6} -} - -func (x *UInt64Rules) GetConst() uint64 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *UInt64Rules) GetLt() uint64 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *UInt64Rules) GetLte() uint64 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *UInt64Rules) GetGt() uint64 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *UInt64Rules) GetGte() uint64 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *UInt64Rules) GetIn() []uint64 { - if x != nil { - return x.In - } - return nil -} - -func (x *UInt64Rules) GetNotIn() []uint64 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *UInt64Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// SInt32Rules describes the constraints applied to `sint32` values -type SInt32Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *int32 `protobuf:"zigzag32,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *int32 `protobuf:"zigzag32,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *int32 `protobuf:"zigzag32,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *int32 `protobuf:"zigzag32,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *int32 `protobuf:"zigzag32,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []int32 `protobuf:"zigzag32,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []int32 `protobuf:"zigzag32,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *SInt32Rules) Reset() { - *x = SInt32Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SInt32Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SInt32Rules) ProtoMessage() {} - -func (x *SInt32Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SInt32Rules.ProtoReflect.Descriptor instead. -func (*SInt32Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{7} -} - -func (x *SInt32Rules) GetConst() int32 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *SInt32Rules) GetLt() int32 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *SInt32Rules) GetLte() int32 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *SInt32Rules) GetGt() int32 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *SInt32Rules) GetGte() int32 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *SInt32Rules) GetIn() []int32 { - if x != nil { - return x.In - } - return nil -} - -func (x *SInt32Rules) GetNotIn() []int32 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *SInt32Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// SInt64Rules describes the constraints applied to `sint64` values -type SInt64Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *int64 `protobuf:"zigzag64,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *int64 `protobuf:"zigzag64,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *int64 `protobuf:"zigzag64,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *int64 `protobuf:"zigzag64,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *int64 `protobuf:"zigzag64,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []int64 `protobuf:"zigzag64,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []int64 `protobuf:"zigzag64,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *SInt64Rules) Reset() { - *x = SInt64Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SInt64Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SInt64Rules) ProtoMessage() {} - -func (x *SInt64Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SInt64Rules.ProtoReflect.Descriptor instead. -func (*SInt64Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{8} -} - -func (x *SInt64Rules) GetConst() int64 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *SInt64Rules) GetLt() int64 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *SInt64Rules) GetLte() int64 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *SInt64Rules) GetGt() int64 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *SInt64Rules) GetGte() int64 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *SInt64Rules) GetIn() []int64 { - if x != nil { - return x.In - } - return nil -} - -func (x *SInt64Rules) GetNotIn() []int64 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *SInt64Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// Fixed32Rules describes the constraints applied to `fixed32` values -type Fixed32Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *uint32 `protobuf:"fixed32,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *uint32 `protobuf:"fixed32,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *uint32 `protobuf:"fixed32,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *uint32 `protobuf:"fixed32,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *uint32 `protobuf:"fixed32,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []uint32 `protobuf:"fixed32,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []uint32 `protobuf:"fixed32,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *Fixed32Rules) Reset() { - *x = Fixed32Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Fixed32Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Fixed32Rules) ProtoMessage() {} - -func (x *Fixed32Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Fixed32Rules.ProtoReflect.Descriptor instead. -func (*Fixed32Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{9} -} - -func (x *Fixed32Rules) GetConst() uint32 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *Fixed32Rules) GetLt() uint32 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *Fixed32Rules) GetLte() uint32 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *Fixed32Rules) GetGt() uint32 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *Fixed32Rules) GetGte() uint32 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *Fixed32Rules) GetIn() []uint32 { - if x != nil { - return x.In - } - return nil -} - -func (x *Fixed32Rules) GetNotIn() []uint32 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *Fixed32Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// Fixed64Rules describes the constraints applied to `fixed64` values -type Fixed64Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *uint64 `protobuf:"fixed64,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *uint64 `protobuf:"fixed64,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *uint64 `protobuf:"fixed64,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *uint64 `protobuf:"fixed64,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *uint64 `protobuf:"fixed64,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []uint64 `protobuf:"fixed64,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []uint64 `protobuf:"fixed64,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *Fixed64Rules) Reset() { - *x = Fixed64Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Fixed64Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Fixed64Rules) ProtoMessage() {} - -func (x *Fixed64Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Fixed64Rules.ProtoReflect.Descriptor instead. -func (*Fixed64Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{10} -} - -func (x *Fixed64Rules) GetConst() uint64 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *Fixed64Rules) GetLt() uint64 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *Fixed64Rules) GetLte() uint64 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *Fixed64Rules) GetGt() uint64 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *Fixed64Rules) GetGte() uint64 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *Fixed64Rules) GetIn() []uint64 { - if x != nil { - return x.In - } - return nil -} - -func (x *Fixed64Rules) GetNotIn() []uint64 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *Fixed64Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// SFixed32Rules describes the constraints applied to `sfixed32` values -type SFixed32Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *int32 `protobuf:"fixed32,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *int32 `protobuf:"fixed32,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *int32 `protobuf:"fixed32,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *int32 `protobuf:"fixed32,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *int32 `protobuf:"fixed32,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []int32 `protobuf:"fixed32,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []int32 `protobuf:"fixed32,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *SFixed32Rules) Reset() { - *x = SFixed32Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SFixed32Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SFixed32Rules) ProtoMessage() {} - -func (x *SFixed32Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SFixed32Rules.ProtoReflect.Descriptor instead. -func (*SFixed32Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{11} -} - -func (x *SFixed32Rules) GetConst() int32 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *SFixed32Rules) GetLt() int32 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *SFixed32Rules) GetLte() int32 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *SFixed32Rules) GetGt() int32 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *SFixed32Rules) GetGte() int32 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *SFixed32Rules) GetIn() []int32 { - if x != nil { - return x.In - } - return nil -} - -func (x *SFixed32Rules) GetNotIn() []int32 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *SFixed32Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// SFixed64Rules describes the constraints applied to `sfixed64` values -type SFixed64Rules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *int64 `protobuf:"fixed64,1,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *int64 `protobuf:"fixed64,2,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - Lte *int64 `protobuf:"fixed64,3,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - Gt *int64 `protobuf:"fixed64,4,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - Gte *int64 `protobuf:"fixed64,5,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []int64 `protobuf:"fixed64,6,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []int64 `protobuf:"fixed64,7,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,8,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *SFixed64Rules) Reset() { - *x = SFixed64Rules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SFixed64Rules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SFixed64Rules) ProtoMessage() {} - -func (x *SFixed64Rules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SFixed64Rules.ProtoReflect.Descriptor instead. -func (*SFixed64Rules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{12} -} - -func (x *SFixed64Rules) GetConst() int64 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *SFixed64Rules) GetLt() int64 { - if x != nil && x.Lt != nil { - return *x.Lt - } - return 0 -} - -func (x *SFixed64Rules) GetLte() int64 { - if x != nil && x.Lte != nil { - return *x.Lte - } - return 0 -} - -func (x *SFixed64Rules) GetGt() int64 { - if x != nil && x.Gt != nil { - return *x.Gt - } - return 0 -} - -func (x *SFixed64Rules) GetGte() int64 { - if x != nil && x.Gte != nil { - return *x.Gte - } - return 0 -} - -func (x *SFixed64Rules) GetIn() []int64 { - if x != nil { - return x.In - } - return nil -} - -func (x *SFixed64Rules) GetNotIn() []int64 { - if x != nil { - return x.NotIn - } - return nil -} - -func (x *SFixed64Rules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// BoolRules describes the constraints applied to `bool` values -type BoolRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *bool `protobuf:"varint,1,opt,name=const" json:"const,omitempty"` -} - -func (x *BoolRules) Reset() { - *x = BoolRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BoolRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BoolRules) ProtoMessage() {} - -func (x *BoolRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BoolRules.ProtoReflect.Descriptor instead. -func (*BoolRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{13} -} - -func (x *BoolRules) GetConst() bool { - if x != nil && x.Const != nil { - return *x.Const - } - return false -} - -// StringRules describe the constraints applied to `string` values -type StringRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *string `protobuf:"bytes,1,opt,name=const" json:"const,omitempty"` - // Len specifies that this field must be the specified number of - // characters (Unicode code points). Note that the number of - // characters may differ from the number of bytes in the string. - Len *uint64 `protobuf:"varint,19,opt,name=len" json:"len,omitempty"` - // MinLen specifies that this field must be the specified number of - // characters (Unicode code points) at a minimum. Note that the number of - // characters may differ from the number of bytes in the string. - MinLen *uint64 `protobuf:"varint,2,opt,name=min_len,json=minLen" json:"min_len,omitempty"` - // MaxLen specifies that this field must be the specified number of - // characters (Unicode code points) at a maximum. Note that the number of - // characters may differ from the number of bytes in the string. - MaxLen *uint64 `protobuf:"varint,3,opt,name=max_len,json=maxLen" json:"max_len,omitempty"` - // LenBytes specifies that this field must be the specified number of bytes - LenBytes *uint64 `protobuf:"varint,20,opt,name=len_bytes,json=lenBytes" json:"len_bytes,omitempty"` - // MinBytes specifies that this field must be the specified number of bytes - // at a minimum - MinBytes *uint64 `protobuf:"varint,4,opt,name=min_bytes,json=minBytes" json:"min_bytes,omitempty"` - // MaxBytes specifies that this field must be the specified number of bytes - // at a maximum - MaxBytes *uint64 `protobuf:"varint,5,opt,name=max_bytes,json=maxBytes" json:"max_bytes,omitempty"` - // Pattern specifes that this field must match against the specified - // regular expression (RE2 syntax). The included expression should elide - // any delimiters. - Pattern *string `protobuf:"bytes,6,opt,name=pattern" json:"pattern,omitempty"` - // Prefix specifies that this field must have the specified substring at - // the beginning of the string. - Prefix *string `protobuf:"bytes,7,opt,name=prefix" json:"prefix,omitempty"` - // Suffix specifies that this field must have the specified substring at - // the end of the string. - Suffix *string `protobuf:"bytes,8,opt,name=suffix" json:"suffix,omitempty"` - // Contains specifies that this field must have the specified substring - // anywhere in the string. - Contains *string `protobuf:"bytes,9,opt,name=contains" json:"contains,omitempty"` - // NotContains specifies that this field cannot have the specified substring - // anywhere in the string. - NotContains *string `protobuf:"bytes,23,opt,name=not_contains,json=notContains" json:"not_contains,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []string `protobuf:"bytes,10,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []string `protobuf:"bytes,11,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // WellKnown rules provide advanced constraints against common string - // patterns - // - // Types that are assignable to WellKnown: - // - // *StringRules_Email - // *StringRules_Hostname - // *StringRules_Ip - // *StringRules_Ipv4 - // *StringRules_Ipv6 - // *StringRules_Uri - // *StringRules_UriRef - // *StringRules_Address - // *StringRules_Uuid - // *StringRules_WellKnownRegex - WellKnown isStringRules_WellKnown `protobuf_oneof:"well_known"` - // This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable - // strict header validation. - // By default, this is true, and HTTP header validations are RFC-compliant. - // Setting to false will enable a looser validations that only disallows - // \r\n\0 characters, which can be used to bypass header matching rules. - Strict *bool `protobuf:"varint,25,opt,name=strict,def=1" json:"strict,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,26,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -// Default values for StringRules fields. -const ( - Default_StringRules_Strict = bool(true) -) - -func (x *StringRules) Reset() { - *x = StringRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *StringRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StringRules) ProtoMessage() {} - -func (x *StringRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StringRules.ProtoReflect.Descriptor instead. -func (*StringRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{14} -} - -func (x *StringRules) GetConst() string { - if x != nil && x.Const != nil { - return *x.Const - } - return "" -} - -func (x *StringRules) GetLen() uint64 { - if x != nil && x.Len != nil { - return *x.Len - } - return 0 -} - -func (x *StringRules) GetMinLen() uint64 { - if x != nil && x.MinLen != nil { - return *x.MinLen - } - return 0 -} - -func (x *StringRules) GetMaxLen() uint64 { - if x != nil && x.MaxLen != nil { - return *x.MaxLen - } - return 0 -} - -func (x *StringRules) GetLenBytes() uint64 { - if x != nil && x.LenBytes != nil { - return *x.LenBytes - } - return 0 -} - -func (x *StringRules) GetMinBytes() uint64 { - if x != nil && x.MinBytes != nil { - return *x.MinBytes - } - return 0 -} - -func (x *StringRules) GetMaxBytes() uint64 { - if x != nil && x.MaxBytes != nil { - return *x.MaxBytes - } - return 0 -} - -func (x *StringRules) GetPattern() string { - if x != nil && x.Pattern != nil { - return *x.Pattern - } - return "" -} - -func (x *StringRules) GetPrefix() string { - if x != nil && x.Prefix != nil { - return *x.Prefix - } - return "" -} - -func (x *StringRules) GetSuffix() string { - if x != nil && x.Suffix != nil { - return *x.Suffix - } - return "" -} - -func (x *StringRules) GetContains() string { - if x != nil && x.Contains != nil { - return *x.Contains - } - return "" -} - -func (x *StringRules) GetNotContains() string { - if x != nil && x.NotContains != nil { - return *x.NotContains - } - return "" -} - -func (x *StringRules) GetIn() []string { - if x != nil { - return x.In - } - return nil -} - -func (x *StringRules) GetNotIn() []string { - if x != nil { - return x.NotIn - } - return nil -} - -func (m *StringRules) GetWellKnown() isStringRules_WellKnown { - if m != nil { - return m.WellKnown - } - return nil -} - -func (x *StringRules) GetEmail() bool { - if x, ok := x.GetWellKnown().(*StringRules_Email); ok { - return x.Email - } - return false -} - -func (x *StringRules) GetHostname() bool { - if x, ok := x.GetWellKnown().(*StringRules_Hostname); ok { - return x.Hostname - } - return false -} - -func (x *StringRules) GetIp() bool { - if x, ok := x.GetWellKnown().(*StringRules_Ip); ok { - return x.Ip - } - return false -} - -func (x *StringRules) GetIpv4() bool { - if x, ok := x.GetWellKnown().(*StringRules_Ipv4); ok { - return x.Ipv4 - } - return false -} - -func (x *StringRules) GetIpv6() bool { - if x, ok := x.GetWellKnown().(*StringRules_Ipv6); ok { - return x.Ipv6 - } - return false -} - -func (x *StringRules) GetUri() bool { - if x, ok := x.GetWellKnown().(*StringRules_Uri); ok { - return x.Uri - } - return false -} - -func (x *StringRules) GetUriRef() bool { - if x, ok := x.GetWellKnown().(*StringRules_UriRef); ok { - return x.UriRef - } - return false -} - -func (x *StringRules) GetAddress() bool { - if x, ok := x.GetWellKnown().(*StringRules_Address); ok { - return x.Address - } - return false -} - -func (x *StringRules) GetUuid() bool { - if x, ok := x.GetWellKnown().(*StringRules_Uuid); ok { - return x.Uuid - } - return false -} - -func (x *StringRules) GetWellKnownRegex() KnownRegex { - if x, ok := x.GetWellKnown().(*StringRules_WellKnownRegex); ok { - return x.WellKnownRegex - } - return KnownRegex_UNKNOWN -} - -func (x *StringRules) GetStrict() bool { - if x != nil && x.Strict != nil { - return *x.Strict - } - return Default_StringRules_Strict -} - -func (x *StringRules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -type isStringRules_WellKnown interface { - isStringRules_WellKnown() -} - -type StringRules_Email struct { - // Email specifies that the field must be a valid email address as - // defined by RFC 5322 - Email bool `protobuf:"varint,12,opt,name=email,oneof"` -} - -type StringRules_Hostname struct { - // Hostname specifies that the field must be a valid hostname as - // defined by RFC 1034. This constraint does not support - // internationalized domain names (IDNs). - Hostname bool `protobuf:"varint,13,opt,name=hostname,oneof"` -} - -type StringRules_Ip struct { - // Ip specifies that the field must be a valid IP (v4 or v6) address. - // Valid IPv6 addresses should not include surrounding square brackets. - Ip bool `protobuf:"varint,14,opt,name=ip,oneof"` -} - -type StringRules_Ipv4 struct { - // Ipv4 specifies that the field must be a valid IPv4 address. - Ipv4 bool `protobuf:"varint,15,opt,name=ipv4,oneof"` -} - -type StringRules_Ipv6 struct { - // Ipv6 specifies that the field must be a valid IPv6 address. Valid - // IPv6 addresses should not include surrounding square brackets. - Ipv6 bool `protobuf:"varint,16,opt,name=ipv6,oneof"` -} - -type StringRules_Uri struct { - // Uri specifies that the field must be a valid, absolute URI as defined - // by RFC 3986 - Uri bool `protobuf:"varint,17,opt,name=uri,oneof"` -} - -type StringRules_UriRef struct { - // UriRef specifies that the field must be a valid URI as defined by RFC - // 3986 and may be relative or absolute. - UriRef bool `protobuf:"varint,18,opt,name=uri_ref,json=uriRef,oneof"` -} - -type StringRules_Address struct { - // Address specifies that the field must be either a valid hostname as - // defined by RFC 1034 (which does not support internationalized domain - // names or IDNs), or it can be a valid IP (v4 or v6). - Address bool `protobuf:"varint,21,opt,name=address,oneof"` -} - -type StringRules_Uuid struct { - // Uuid specifies that the field must be a valid UUID as defined by - // RFC 4122 - Uuid bool `protobuf:"varint,22,opt,name=uuid,oneof"` -} - -type StringRules_WellKnownRegex struct { - // WellKnownRegex specifies a common well known pattern defined as a regex. - WellKnownRegex KnownRegex `protobuf:"varint,24,opt,name=well_known_regex,json=wellKnownRegex,enum=validate.KnownRegex,oneof"` -} - -func (*StringRules_Email) isStringRules_WellKnown() {} - -func (*StringRules_Hostname) isStringRules_WellKnown() {} - -func (*StringRules_Ip) isStringRules_WellKnown() {} - -func (*StringRules_Ipv4) isStringRules_WellKnown() {} - -func (*StringRules_Ipv6) isStringRules_WellKnown() {} - -func (*StringRules_Uri) isStringRules_WellKnown() {} - -func (*StringRules_UriRef) isStringRules_WellKnown() {} - -func (*StringRules_Address) isStringRules_WellKnown() {} - -func (*StringRules_Uuid) isStringRules_WellKnown() {} - -func (*StringRules_WellKnownRegex) isStringRules_WellKnown() {} - -// BytesRules describe the constraints applied to `bytes` values -type BytesRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const []byte `protobuf:"bytes,1,opt,name=const" json:"const,omitempty"` - // Len specifies that this field must be the specified number of bytes - Len *uint64 `protobuf:"varint,13,opt,name=len" json:"len,omitempty"` - // MinLen specifies that this field must be the specified number of bytes - // at a minimum - MinLen *uint64 `protobuf:"varint,2,opt,name=min_len,json=minLen" json:"min_len,omitempty"` - // MaxLen specifies that this field must be the specified number of bytes - // at a maximum - MaxLen *uint64 `protobuf:"varint,3,opt,name=max_len,json=maxLen" json:"max_len,omitempty"` - // Pattern specifes that this field must match against the specified - // regular expression (RE2 syntax). The included expression should elide - // any delimiters. - Pattern *string `protobuf:"bytes,4,opt,name=pattern" json:"pattern,omitempty"` - // Prefix specifies that this field must have the specified bytes at the - // beginning of the string. - Prefix []byte `protobuf:"bytes,5,opt,name=prefix" json:"prefix,omitempty"` - // Suffix specifies that this field must have the specified bytes at the - // end of the string. - Suffix []byte `protobuf:"bytes,6,opt,name=suffix" json:"suffix,omitempty"` - // Contains specifies that this field must have the specified bytes - // anywhere in the string. - Contains []byte `protobuf:"bytes,7,opt,name=contains" json:"contains,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In [][]byte `protobuf:"bytes,8,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn [][]byte `protobuf:"bytes,9,rep,name=not_in,json=notIn" json:"not_in,omitempty"` - // WellKnown rules provide advanced constraints against common byte - // patterns - // - // Types that are assignable to WellKnown: - // - // *BytesRules_Ip - // *BytesRules_Ipv4 - // *BytesRules_Ipv6 - WellKnown isBytesRules_WellKnown `protobuf_oneof:"well_known"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,14,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *BytesRules) Reset() { - *x = BytesRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BytesRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BytesRules) ProtoMessage() {} - -func (x *BytesRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[15] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BytesRules.ProtoReflect.Descriptor instead. -func (*BytesRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{15} -} - -func (x *BytesRules) GetConst() []byte { - if x != nil { - return x.Const - } - return nil -} - -func (x *BytesRules) GetLen() uint64 { - if x != nil && x.Len != nil { - return *x.Len - } - return 0 -} - -func (x *BytesRules) GetMinLen() uint64 { - if x != nil && x.MinLen != nil { - return *x.MinLen - } - return 0 -} - -func (x *BytesRules) GetMaxLen() uint64 { - if x != nil && x.MaxLen != nil { - return *x.MaxLen - } - return 0 -} - -func (x *BytesRules) GetPattern() string { - if x != nil && x.Pattern != nil { - return *x.Pattern - } - return "" -} - -func (x *BytesRules) GetPrefix() []byte { - if x != nil { - return x.Prefix - } - return nil -} - -func (x *BytesRules) GetSuffix() []byte { - if x != nil { - return x.Suffix - } - return nil -} - -func (x *BytesRules) GetContains() []byte { - if x != nil { - return x.Contains - } - return nil -} - -func (x *BytesRules) GetIn() [][]byte { - if x != nil { - return x.In - } - return nil -} - -func (x *BytesRules) GetNotIn() [][]byte { - if x != nil { - return x.NotIn - } - return nil -} - -func (m *BytesRules) GetWellKnown() isBytesRules_WellKnown { - if m != nil { - return m.WellKnown - } - return nil -} - -func (x *BytesRules) GetIp() bool { - if x, ok := x.GetWellKnown().(*BytesRules_Ip); ok { - return x.Ip - } - return false -} - -func (x *BytesRules) GetIpv4() bool { - if x, ok := x.GetWellKnown().(*BytesRules_Ipv4); ok { - return x.Ipv4 - } - return false -} - -func (x *BytesRules) GetIpv6() bool { - if x, ok := x.GetWellKnown().(*BytesRules_Ipv6); ok { - return x.Ipv6 - } - return false -} - -func (x *BytesRules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -type isBytesRules_WellKnown interface { - isBytesRules_WellKnown() -} - -type BytesRules_Ip struct { - // Ip specifies that the field must be a valid IP (v4 or v6) address in - // byte format - Ip bool `protobuf:"varint,10,opt,name=ip,oneof"` -} - -type BytesRules_Ipv4 struct { - // Ipv4 specifies that the field must be a valid IPv4 address in byte - // format - Ipv4 bool `protobuf:"varint,11,opt,name=ipv4,oneof"` -} - -type BytesRules_Ipv6 struct { - // Ipv6 specifies that the field must be a valid IPv6 address in byte - // format - Ipv6 bool `protobuf:"varint,12,opt,name=ipv6,oneof"` -} - -func (*BytesRules_Ip) isBytesRules_WellKnown() {} - -func (*BytesRules_Ipv4) isBytesRules_WellKnown() {} - -func (*BytesRules_Ipv6) isBytesRules_WellKnown() {} - -// EnumRules describe the constraints applied to enum values -type EnumRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Const specifies that this field must be exactly the specified value - Const *int32 `protobuf:"varint,1,opt,name=const" json:"const,omitempty"` - // DefinedOnly specifies that this field must be only one of the defined - // values for this enum, failing on any undefined value. - DefinedOnly *bool `protobuf:"varint,2,opt,name=defined_only,json=definedOnly" json:"defined_only,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []int32 `protobuf:"varint,3,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []int32 `protobuf:"varint,4,rep,name=not_in,json=notIn" json:"not_in,omitempty"` -} - -func (x *EnumRules) Reset() { - *x = EnumRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *EnumRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EnumRules) ProtoMessage() {} - -func (x *EnumRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[16] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use EnumRules.ProtoReflect.Descriptor instead. -func (*EnumRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{16} -} - -func (x *EnumRules) GetConst() int32 { - if x != nil && x.Const != nil { - return *x.Const - } - return 0 -} - -func (x *EnumRules) GetDefinedOnly() bool { - if x != nil && x.DefinedOnly != nil { - return *x.DefinedOnly - } - return false -} - -func (x *EnumRules) GetIn() []int32 { - if x != nil { - return x.In - } - return nil -} - -func (x *EnumRules) GetNotIn() []int32 { - if x != nil { - return x.NotIn - } - return nil -} - -// MessageRules describe the constraints applied to embedded message values. -// For message-type fields, validation is performed recursively. -type MessageRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Skip specifies that the validation rules of this field should not be - // evaluated - Skip *bool `protobuf:"varint,1,opt,name=skip" json:"skip,omitempty"` - // Required specifies that this field must be set - Required *bool `protobuf:"varint,2,opt,name=required" json:"required,omitempty"` -} - -func (x *MessageRules) Reset() { - *x = MessageRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MessageRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MessageRules) ProtoMessage() {} - -func (x *MessageRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[17] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use MessageRules.ProtoReflect.Descriptor instead. -func (*MessageRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{17} -} - -func (x *MessageRules) GetSkip() bool { - if x != nil && x.Skip != nil { - return *x.Skip - } - return false -} - -func (x *MessageRules) GetRequired() bool { - if x != nil && x.Required != nil { - return *x.Required - } - return false -} - -// RepeatedRules describe the constraints applied to `repeated` values -type RepeatedRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // MinItems specifies that this field must have the specified number of - // items at a minimum - MinItems *uint64 `protobuf:"varint,1,opt,name=min_items,json=minItems" json:"min_items,omitempty"` - // MaxItems specifies that this field must have the specified number of - // items at a maximum - MaxItems *uint64 `protobuf:"varint,2,opt,name=max_items,json=maxItems" json:"max_items,omitempty"` - // Unique specifies that all elements in this field must be unique. This - // contraint is only applicable to scalar and enum types (messages are not - // supported). - Unique *bool `protobuf:"varint,3,opt,name=unique" json:"unique,omitempty"` - // Items specifies the contraints to be applied to each item in the field. - // Repeated message fields will still execute validation against each item - // unless skip is specified here. - Items *FieldRules `protobuf:"bytes,4,opt,name=items" json:"items,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,5,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *RepeatedRules) Reset() { - *x = RepeatedRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RepeatedRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RepeatedRules) ProtoMessage() {} - -func (x *RepeatedRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[18] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RepeatedRules.ProtoReflect.Descriptor instead. -func (*RepeatedRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{18} -} - -func (x *RepeatedRules) GetMinItems() uint64 { - if x != nil && x.MinItems != nil { - return *x.MinItems - } - return 0 -} - -func (x *RepeatedRules) GetMaxItems() uint64 { - if x != nil && x.MaxItems != nil { - return *x.MaxItems - } - return 0 -} - -func (x *RepeatedRules) GetUnique() bool { - if x != nil && x.Unique != nil { - return *x.Unique - } - return false -} - -func (x *RepeatedRules) GetItems() *FieldRules { - if x != nil { - return x.Items - } - return nil -} - -func (x *RepeatedRules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// MapRules describe the constraints applied to `map` values -type MapRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // MinPairs specifies that this field must have the specified number of - // KVs at a minimum - MinPairs *uint64 `protobuf:"varint,1,opt,name=min_pairs,json=minPairs" json:"min_pairs,omitempty"` - // MaxPairs specifies that this field must have the specified number of - // KVs at a maximum - MaxPairs *uint64 `protobuf:"varint,2,opt,name=max_pairs,json=maxPairs" json:"max_pairs,omitempty"` - // NoSparse specifies values in this field cannot be unset. This only - // applies to map's with message value types. - NoSparse *bool `protobuf:"varint,3,opt,name=no_sparse,json=noSparse" json:"no_sparse,omitempty"` - // Keys specifies the constraints to be applied to each key in the field. - Keys *FieldRules `protobuf:"bytes,4,opt,name=keys" json:"keys,omitempty"` - // Values specifies the constraints to be applied to the value of each key - // in the field. Message values will still have their validations evaluated - // unless skip is specified here. - Values *FieldRules `protobuf:"bytes,5,opt,name=values" json:"values,omitempty"` - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - IgnoreEmpty *bool `protobuf:"varint,6,opt,name=ignore_empty,json=ignoreEmpty" json:"ignore_empty,omitempty"` -} - -func (x *MapRules) Reset() { - *x = MapRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MapRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MapRules) ProtoMessage() {} - -func (x *MapRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[19] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use MapRules.ProtoReflect.Descriptor instead. -func (*MapRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{19} -} - -func (x *MapRules) GetMinPairs() uint64 { - if x != nil && x.MinPairs != nil { - return *x.MinPairs - } - return 0 -} - -func (x *MapRules) GetMaxPairs() uint64 { - if x != nil && x.MaxPairs != nil { - return *x.MaxPairs - } - return 0 -} - -func (x *MapRules) GetNoSparse() bool { - if x != nil && x.NoSparse != nil { - return *x.NoSparse - } - return false -} - -func (x *MapRules) GetKeys() *FieldRules { - if x != nil { - return x.Keys - } - return nil -} - -func (x *MapRules) GetValues() *FieldRules { - if x != nil { - return x.Values - } - return nil -} - -func (x *MapRules) GetIgnoreEmpty() bool { - if x != nil && x.IgnoreEmpty != nil { - return *x.IgnoreEmpty - } - return false -} - -// AnyRules describe constraints applied exclusively to the -// `google.protobuf.Any` well-known type -type AnyRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required specifies that this field must be set - Required *bool `protobuf:"varint,1,opt,name=required" json:"required,omitempty"` - // In specifies that this field's `type_url` must be equal to one of the - // specified values. - In []string `protobuf:"bytes,2,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field's `type_url` must not be equal to any of - // the specified values. - NotIn []string `protobuf:"bytes,3,rep,name=not_in,json=notIn" json:"not_in,omitempty"` -} - -func (x *AnyRules) Reset() { - *x = AnyRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AnyRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AnyRules) ProtoMessage() {} - -func (x *AnyRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[20] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AnyRules.ProtoReflect.Descriptor instead. -func (*AnyRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{20} -} - -func (x *AnyRules) GetRequired() bool { - if x != nil && x.Required != nil { - return *x.Required - } - return false -} - -func (x *AnyRules) GetIn() []string { - if x != nil { - return x.In - } - return nil -} - -func (x *AnyRules) GetNotIn() []string { - if x != nil { - return x.NotIn - } - return nil -} - -// DurationRules describe the constraints applied exclusively to the -// `google.protobuf.Duration` well-known type -type DurationRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required specifies that this field must be set - Required *bool `protobuf:"varint,1,opt,name=required" json:"required,omitempty"` - // Const specifies that this field must be exactly the specified value - Const *durationpb.Duration `protobuf:"bytes,2,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *durationpb.Duration `protobuf:"bytes,3,opt,name=lt" json:"lt,omitempty"` - // Lt specifies that this field must be less than the specified value, - // inclusive - Lte *durationpb.Duration `protobuf:"bytes,4,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive - Gt *durationpb.Duration `protobuf:"bytes,5,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than the specified value, - // inclusive - Gte *durationpb.Duration `protobuf:"bytes,6,opt,name=gte" json:"gte,omitempty"` - // In specifies that this field must be equal to one of the specified - // values - In []*durationpb.Duration `protobuf:"bytes,7,rep,name=in" json:"in,omitempty"` - // NotIn specifies that this field cannot be equal to one of the specified - // values - NotIn []*durationpb.Duration `protobuf:"bytes,8,rep,name=not_in,json=notIn" json:"not_in,omitempty"` -} - -func (x *DurationRules) Reset() { - *x = DurationRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DurationRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DurationRules) ProtoMessage() {} - -func (x *DurationRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[21] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DurationRules.ProtoReflect.Descriptor instead. -func (*DurationRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{21} -} - -func (x *DurationRules) GetRequired() bool { - if x != nil && x.Required != nil { - return *x.Required - } - return false -} - -func (x *DurationRules) GetConst() *durationpb.Duration { - if x != nil { - return x.Const - } - return nil -} - -func (x *DurationRules) GetLt() *durationpb.Duration { - if x != nil { - return x.Lt - } - return nil -} - -func (x *DurationRules) GetLte() *durationpb.Duration { - if x != nil { - return x.Lte - } - return nil -} - -func (x *DurationRules) GetGt() *durationpb.Duration { - if x != nil { - return x.Gt - } - return nil -} - -func (x *DurationRules) GetGte() *durationpb.Duration { - if x != nil { - return x.Gte - } - return nil -} - -func (x *DurationRules) GetIn() []*durationpb.Duration { - if x != nil { - return x.In - } - return nil -} - -func (x *DurationRules) GetNotIn() []*durationpb.Duration { - if x != nil { - return x.NotIn - } - return nil -} - -// TimestampRules describe the constraints applied exclusively to the -// `google.protobuf.Timestamp` well-known type -type TimestampRules struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Required specifies that this field must be set - Required *bool `protobuf:"varint,1,opt,name=required" json:"required,omitempty"` - // Const specifies that this field must be exactly the specified value - Const *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=const" json:"const,omitempty"` - // Lt specifies that this field must be less than the specified value, - // exclusive - Lt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=lt" json:"lt,omitempty"` - // Lte specifies that this field must be less than the specified value, - // inclusive - Lte *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=lte" json:"lte,omitempty"` - // Gt specifies that this field must be greater than the specified value, - // exclusive - Gt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=gt" json:"gt,omitempty"` - // Gte specifies that this field must be greater than the specified value, - // inclusive - Gte *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=gte" json:"gte,omitempty"` - // LtNow specifies that this must be less than the current time. LtNow - // can only be used with the Within rule. - LtNow *bool `protobuf:"varint,7,opt,name=lt_now,json=ltNow" json:"lt_now,omitempty"` - // GtNow specifies that this must be greater than the current time. GtNow - // can only be used with the Within rule. - GtNow *bool `protobuf:"varint,8,opt,name=gt_now,json=gtNow" json:"gt_now,omitempty"` - // Within specifies that this field must be within this duration of the - // current time. This constraint can be used alone or with the LtNow and - // GtNow rules. - Within *durationpb.Duration `protobuf:"bytes,9,opt,name=within" json:"within,omitempty"` -} - -func (x *TimestampRules) Reset() { - *x = TimestampRules{} - if protoimpl.UnsafeEnabled { - mi := &file_validate_validate_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TimestampRules) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TimestampRules) ProtoMessage() {} - -func (x *TimestampRules) ProtoReflect() protoreflect.Message { - mi := &file_validate_validate_proto_msgTypes[22] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TimestampRules.ProtoReflect.Descriptor instead. -func (*TimestampRules) Descriptor() ([]byte, []int) { - return file_validate_validate_proto_rawDescGZIP(), []int{22} -} - -func (x *TimestampRules) GetRequired() bool { - if x != nil && x.Required != nil { - return *x.Required - } - return false -} - -func (x *TimestampRules) GetConst() *timestamppb.Timestamp { - if x != nil { - return x.Const - } - return nil -} - -func (x *TimestampRules) GetLt() *timestamppb.Timestamp { - if x != nil { - return x.Lt - } - return nil -} - -func (x *TimestampRules) GetLte() *timestamppb.Timestamp { - if x != nil { - return x.Lte - } - return nil -} - -func (x *TimestampRules) GetGt() *timestamppb.Timestamp { - if x != nil { - return x.Gt - } - return nil -} - -func (x *TimestampRules) GetGte() *timestamppb.Timestamp { - if x != nil { - return x.Gte - } - return nil -} - -func (x *TimestampRules) GetLtNow() bool { - if x != nil && x.LtNow != nil { - return *x.LtNow - } - return false -} - -func (x *TimestampRules) GetGtNow() bool { - if x != nil && x.GtNow != nil { - return *x.GtNow - } - return false -} - -func (x *TimestampRules) GetWithin() *durationpb.Duration { - if x != nil { - return x.Within - } - return nil -} - -var file_validate_validate_proto_extTypes = []protoimpl.ExtensionInfo{ - { - ExtendedType: (*descriptorpb.MessageOptions)(nil), - ExtensionType: (*bool)(nil), - Field: 1071, - Name: "validate.disabled", - Tag: "varint,1071,opt,name=disabled", - Filename: "validate/validate.proto", - }, - { - ExtendedType: (*descriptorpb.MessageOptions)(nil), - ExtensionType: (*bool)(nil), - Field: 1072, - Name: "validate.ignored", - Tag: "varint,1072,opt,name=ignored", - Filename: "validate/validate.proto", - }, - { - ExtendedType: (*descriptorpb.OneofOptions)(nil), - ExtensionType: (*bool)(nil), - Field: 1071, - Name: "validate.required", - Tag: "varint,1071,opt,name=required", - Filename: "validate/validate.proto", - }, - { - ExtendedType: (*descriptorpb.FieldOptions)(nil), - ExtensionType: (*FieldRules)(nil), - Field: 1071, - Name: "validate.rules", - Tag: "bytes,1071,opt,name=rules", - Filename: "validate/validate.proto", - }, -} - -// Extension fields to descriptorpb.MessageOptions. -var ( - // Disabled nullifies any validation rules for this message, including any - // message fields associated with it that do support validation. - // - // optional bool disabled = 1071; - E_Disabled = &file_validate_validate_proto_extTypes[0] - // Ignore skips generation of validation methods for this message. - // - // optional bool ignored = 1072; - E_Ignored = &file_validate_validate_proto_extTypes[1] -) - -// Extension fields to descriptorpb.OneofOptions. -var ( - // Required ensures that exactly one the field options in a oneof is set; - // validation fails if no fields in the oneof are set. - // - // optional bool required = 1071; - E_Required = &file_validate_validate_proto_extTypes[2] -) - -// Extension fields to descriptorpb.FieldOptions. -var ( - // Rules specify the validations to be performed on this field. By default, - // no validation is performed against a field. - // - // optional validate.FieldRules rules = 1071; - E_Rules = &file_validate_validate_proto_extTypes[3] -) - -var File_validate_validate_proto protoreflect.FileDescriptor - -var file_validate_validate_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc8, 0x08, 0x0a, 0x0a, 0x46, 0x69, 0x65, 0x6c, 0x64, - 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x66, 0x6c, 0x6f, 0x61, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x05, - 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x2f, 0x0a, 0x06, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x06, - 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x05, 0x69, - 0x6e, 0x74, 0x33, 0x32, 0x12, 0x2c, 0x0a, 0x05, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x49, - 0x6e, 0x74, 0x36, 0x34, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x74, - 0x36, 0x34, 0x12, 0x2f, 0x0a, 0x06, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x55, 0x49, - 0x6e, 0x74, 0x33, 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x06, 0x75, 0x69, 0x6e, - 0x74, 0x33, 0x32, 0x12, 0x2f, 0x0a, 0x06, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x55, - 0x49, 0x6e, 0x74, 0x36, 0x34, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x06, 0x75, 0x69, - 0x6e, 0x74, 0x36, 0x34, 0x12, 0x2f, 0x0a, 0x06, 0x73, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, - 0x53, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x06, 0x73, - 0x69, 0x6e, 0x74, 0x33, 0x32, 0x12, 0x2f, 0x0a, 0x06, 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2e, 0x53, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x06, - 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x12, 0x32, 0x0a, 0x07, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, - 0x32, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x2e, 0x46, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, - 0x00, 0x52, 0x07, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x12, 0x32, 0x0a, 0x07, 0x66, 0x69, - 0x78, 0x65, 0x64, 0x36, 0x34, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x46, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x52, 0x75, - 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x07, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x12, 0x35, - 0x0a, 0x08, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x17, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x46, 0x69, 0x78, - 0x65, 0x64, 0x33, 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x08, 0x73, 0x66, 0x69, - 0x78, 0x65, 0x64, 0x33, 0x32, 0x12, 0x35, 0x0a, 0x08, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, - 0x34, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x2e, 0x53, 0x46, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x48, 0x00, 0x52, 0x08, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x12, 0x29, 0x0a, 0x04, - 0x62, 0x6f, 0x6f, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, - 0x00, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6c, 0x12, 0x2f, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, - 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x2c, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, - 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x2e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, - 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x04, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x10, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, - 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x04, 0x65, 0x6e, 0x75, - 0x6d, 0x12, 0x35, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x12, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x52, - 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x08, - 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x26, 0x0a, 0x03, 0x6d, 0x61, 0x70, 0x18, - 0x13, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2e, 0x4d, 0x61, 0x70, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x03, 0x6d, 0x61, 0x70, - 0x12, 0x26, 0x0a, 0x03, 0x61, 0x6e, 0x79, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x75, 0x6c, 0x65, - 0x73, 0x48, 0x00, 0x52, 0x03, 0x61, 0x6e, 0x79, 0x12, 0x35, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x75, - 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x16, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x48, 0x00, 0x52, 0x09, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x22, 0xb0, 0x01, 0x0a, 0x0a, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x02, 0x52, - 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x02, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x02, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x02, 0x52, 0x02, 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x02, 0x52, 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, - 0x18, 0x06, 0x20, 0x03, 0x28, 0x02, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, - 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x02, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, - 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, - 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x52, - 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x01, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, - 0x67, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x02, 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, - 0x67, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x01, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, - 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x01, 0x52, 0x05, - 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, - 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, - 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0xb0, 0x01, 0x0a, 0x0a, 0x49, 0x6e, 0x74, - 0x33, 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x0e, 0x0a, - 0x02, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x10, 0x0a, - 0x03, 0x6c, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, - 0x0e, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x67, 0x74, 0x12, - 0x10, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x67, 0x74, - 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x05, 0x52, 0x02, 0x69, - 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, - 0x05, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, - 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, - 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0xb0, 0x01, 0x0a, 0x0a, - 0x49, 0x6e, 0x74, 0x36, 0x34, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, - 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, - 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x6c, 0x74, - 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6c, - 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, - 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x03, - 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, - 0x20, 0x03, 0x28, 0x03, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, - 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0xb1, - 0x01, 0x0a, 0x0b, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, - 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x63, - 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x02, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x02, 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x06, - 0x20, 0x03, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x5f, - 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x12, - 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x52, 0x75, 0x6c, - 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x74, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x74, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x04, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, - 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x04, 0x52, 0x05, 0x6e, 0x6f, - 0x74, 0x49, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, - 0x70, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, - 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x53, 0x49, 0x6e, 0x74, 0x33, - 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x11, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, - 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x11, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, - 0x6c, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x11, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x0e, - 0x0a, 0x02, 0x67, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x11, 0x52, 0x02, 0x67, 0x74, 0x12, 0x10, - 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x11, 0x52, 0x03, 0x67, 0x74, 0x65, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x11, 0x52, 0x02, 0x69, 0x6e, - 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x11, - 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, - 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, - 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x53, - 0x49, 0x6e, 0x74, 0x36, 0x34, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, - 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x12, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, - 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x12, 0x52, 0x02, 0x6c, 0x74, - 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x12, 0x52, 0x03, 0x6c, - 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x12, 0x52, 0x02, - 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x12, 0x52, - 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x12, - 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, - 0x20, 0x03, 0x28, 0x12, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, - 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0xb2, - 0x01, 0x0a, 0x0c, 0x46, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, - 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x07, 0x52, 0x05, - 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x07, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x07, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x07, 0x52, 0x02, 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x07, 0x52, 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, - 0x06, 0x20, 0x03, 0x28, 0x07, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x74, - 0x5f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x07, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, - 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x22, 0xb2, 0x01, 0x0a, 0x0c, 0x46, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x52, - 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x06, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x06, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x06, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, - 0x67, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x06, 0x52, 0x02, 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, - 0x67, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x06, 0x52, 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x06, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, - 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x06, 0x52, 0x05, - 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, - 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, - 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0xb3, 0x01, 0x0a, 0x0d, 0x53, 0x46, 0x69, - 0x78, 0x65, 0x64, 0x33, 0x32, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, - 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0f, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, - 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0f, 0x52, 0x02, 0x6c, 0x74, - 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0f, 0x52, 0x03, 0x6c, - 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0f, 0x52, 0x02, - 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0f, 0x52, - 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0f, - 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, - 0x20, 0x03, 0x28, 0x0f, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, - 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0xb3, - 0x01, 0x0a, 0x0d, 0x53, 0x46, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x10, 0x52, - 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x10, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x74, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x10, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x10, 0x52, 0x02, 0x67, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x10, 0x52, 0x03, 0x67, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, - 0x18, 0x06, 0x20, 0x03, 0x28, 0x10, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, - 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x10, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, - 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, - 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x22, 0x21, 0x0a, 0x09, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x75, 0x6c, 0x65, - 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x22, 0xd4, 0x05, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x69, - 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x10, 0x0a, - 0x03, 0x6c, 0x65, 0x6e, 0x18, 0x13, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x6c, 0x65, 0x6e, 0x12, - 0x17, 0x0a, 0x07, 0x6d, 0x69, 0x6e, 0x5f, 0x6c, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x06, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x5f, - 0x6c, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6d, 0x61, 0x78, 0x4c, 0x65, - 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x65, 0x6e, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x14, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6c, 0x65, 0x6e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, - 0x0a, 0x09, 0x6d, 0x69, 0x6e, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x08, 0x6d, 0x69, 0x6e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6d, - 0x61, 0x78, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, - 0x6d, 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, - 0x65, 0x72, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, - 0x72, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75, - 0x66, 0x66, 0x69, 0x78, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x75, 0x66, 0x66, - 0x69, 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x12, 0x21, - 0x0a, 0x0c, 0x6e, 0x6f, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x17, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x6f, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, - 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x0b, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x12, 0x16, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, - 0x6c, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, - 0x12, 0x1c, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x01, - 0x28, 0x08, 0x48, 0x00, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, - 0x0a, 0x02, 0x69, 0x70, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x02, 0x69, 0x70, - 0x12, 0x14, 0x0a, 0x04, 0x69, 0x70, 0x76, 0x34, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, - 0x52, 0x04, 0x69, 0x70, 0x76, 0x34, 0x12, 0x14, 0x0a, 0x04, 0x69, 0x70, 0x76, 0x36, 0x18, 0x10, - 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x04, 0x69, 0x70, 0x76, 0x36, 0x12, 0x12, 0x0a, 0x03, - 0x75, 0x72, 0x69, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x03, 0x75, 0x72, 0x69, - 0x12, 0x19, 0x0a, 0x07, 0x75, 0x72, 0x69, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x12, 0x20, 0x01, 0x28, - 0x08, 0x48, 0x00, 0x52, 0x06, 0x75, 0x72, 0x69, 0x52, 0x65, 0x66, 0x12, 0x1a, 0x0a, 0x07, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, - 0x16, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x40, 0x0a, - 0x10, 0x77, 0x65, 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x72, 0x65, 0x67, 0x65, - 0x78, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x2e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x67, 0x65, 0x78, 0x48, 0x00, 0x52, - 0x0e, 0x77, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x67, 0x65, 0x78, 0x12, - 0x1c, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x18, 0x19, 0x20, 0x01, 0x28, 0x08, 0x3a, - 0x04, 0x74, 0x72, 0x75, 0x65, 0x52, 0x06, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x12, 0x21, 0x0a, - 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x1a, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x42, 0x0c, 0x0a, 0x0a, 0x77, 0x65, 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x22, 0xe2, - 0x02, 0x0a, 0x0a, 0x42, 0x79, 0x74, 0x65, 0x73, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x14, 0x0a, - 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x63, 0x6f, - 0x6e, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x65, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x03, 0x6c, 0x65, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x69, 0x6e, 0x5f, 0x6c, 0x65, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x12, 0x17, - 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x5f, 0x6c, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x06, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, - 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, - 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75, 0x66, - 0x66, 0x69, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x75, 0x66, 0x66, 0x69, - 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x6e, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, - 0x06, 0x6e, 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x05, 0x6e, - 0x6f, 0x74, 0x49, 0x6e, 0x12, 0x10, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, - 0x48, 0x00, 0x52, 0x02, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x04, 0x69, 0x70, 0x76, 0x34, 0x18, 0x0b, - 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x04, 0x69, 0x70, 0x76, 0x34, 0x12, 0x14, 0x0a, 0x04, - 0x69, 0x70, 0x76, 0x36, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x04, 0x69, 0x70, - 0x76, 0x36, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, - 0x74, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x0c, 0x0a, 0x0a, 0x77, 0x65, 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, - 0x6f, 0x77, 0x6e, 0x22, 0x6b, 0x0a, 0x09, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, - 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x64, 0x65, - 0x66, 0x69, 0x6e, 0x65, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x05, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x74, - 0x5f, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, - 0x22, 0x3e, 0x0a, 0x0c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6b, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, - 0x73, 0x6b, 0x69, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, - 0x22, 0xb0, 0x01, 0x0a, 0x0d, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x75, 0x6c, - 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x69, 0x6e, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x69, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, - 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x16, 0x0a, 0x06, - 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x75, 0x6e, - 0x69, 0x71, 0x75, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x46, - 0x69, 0x65, 0x6c, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, - 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x22, 0xdc, 0x01, 0x0a, 0x08, 0x4d, 0x61, 0x70, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x69, 0x6e, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x69, 0x6e, 0x50, 0x61, 0x69, 0x72, 0x73, 0x12, 0x1b, 0x0a, - 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x08, 0x6d, 0x61, 0x78, 0x50, 0x61, 0x69, 0x72, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, - 0x5f, 0x73, 0x70, 0x61, 0x72, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6e, - 0x6f, 0x53, 0x70, 0x61, 0x72, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x04, 0x6b, 0x65, 0x79, - 0x73, 0x12, 0x2c, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x46, 0x69, 0x65, - 0x6c, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, - 0x21, 0x0a, 0x0c, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x22, 0x4d, 0x0a, 0x08, 0x41, 0x6e, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x1a, - 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x6e, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, - 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, - 0x6e, 0x22, 0xe9, 0x02, 0x0a, 0x0d, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x75, - 0x6c, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, - 0x2f, 0x0a, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, - 0x12, 0x29, 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x2b, 0x0a, 0x03, 0x6c, - 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x29, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x02, 0x67, 0x74, 0x12, 0x2b, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x03, 0x67, 0x74, 0x65, - 0x12, 0x29, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x30, 0x0a, 0x06, 0x6e, - 0x6f, 0x74, 0x5f, 0x69, 0x6e, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x49, 0x6e, 0x22, 0xf3, 0x02, - 0x0a, 0x0e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x30, 0x0a, 0x05, - 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x05, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x12, 0x2a, - 0x0a, 0x02, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x02, 0x6c, 0x74, 0x12, 0x2c, 0x0a, 0x03, 0x6c, 0x74, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x03, 0x6c, 0x74, 0x65, 0x12, 0x2a, 0x0a, 0x02, 0x67, 0x74, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x52, 0x02, 0x67, 0x74, 0x12, 0x2c, 0x0a, 0x03, 0x67, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x03, 0x67, - 0x74, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x6c, 0x74, 0x5f, 0x6e, 0x6f, 0x77, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x05, 0x6c, 0x74, 0x4e, 0x6f, 0x77, 0x12, 0x15, 0x0a, 0x06, 0x67, 0x74, 0x5f, - 0x6e, 0x6f, 0x77, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x67, 0x74, 0x4e, 0x6f, 0x77, - 0x12, 0x31, 0x0a, 0x06, 0x77, 0x69, 0x74, 0x68, 0x69, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x77, 0x69, 0x74, - 0x68, 0x69, 0x6e, 0x2a, 0x46, 0x0a, 0x0a, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x52, 0x65, 0x67, 0x65, - 0x78, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x14, - 0x0a, 0x10, 0x48, 0x54, 0x54, 0x50, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x5f, 0x4e, 0x41, - 0x4d, 0x45, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x48, 0x54, 0x54, 0x50, 0x5f, 0x48, 0x45, 0x41, - 0x44, 0x45, 0x52, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x02, 0x3a, 0x3c, 0x0a, 0x08, 0x64, - 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xaf, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x3a, 0x3a, 0x0a, 0x07, 0x69, 0x67, 0x6e, - 0x6f, 0x72, 0x65, 0x64, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb0, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x67, - 0x6e, 0x6f, 0x72, 0x65, 0x64, 0x3a, 0x3a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, - 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0xaf, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, - 0x64, 0x3a, 0x4a, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, - 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xaf, 0x08, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x14, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, - 0x64, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x42, 0x50, 0x0a, - 0x1a, 0x69, 0x6f, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x70, - 0x67, 0x76, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5a, 0x32, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, -} - -var ( - file_validate_validate_proto_rawDescOnce sync.Once - file_validate_validate_proto_rawDescData = file_validate_validate_proto_rawDesc -) - -func file_validate_validate_proto_rawDescGZIP() []byte { - file_validate_validate_proto_rawDescOnce.Do(func() { - file_validate_validate_proto_rawDescData = protoimpl.X.CompressGZIP(file_validate_validate_proto_rawDescData) - }) - return file_validate_validate_proto_rawDescData -} - -var file_validate_validate_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_validate_validate_proto_msgTypes = make([]protoimpl.MessageInfo, 23) -var file_validate_validate_proto_goTypes = []interface{}{ - (KnownRegex)(0), // 0: validate.KnownRegex - (*FieldRules)(nil), // 1: validate.FieldRules - (*FloatRules)(nil), // 2: validate.FloatRules - (*DoubleRules)(nil), // 3: validate.DoubleRules - (*Int32Rules)(nil), // 4: validate.Int32Rules - (*Int64Rules)(nil), // 5: validate.Int64Rules - (*UInt32Rules)(nil), // 6: validate.UInt32Rules - (*UInt64Rules)(nil), // 7: validate.UInt64Rules - (*SInt32Rules)(nil), // 8: validate.SInt32Rules - (*SInt64Rules)(nil), // 9: validate.SInt64Rules - (*Fixed32Rules)(nil), // 10: validate.Fixed32Rules - (*Fixed64Rules)(nil), // 11: validate.Fixed64Rules - (*SFixed32Rules)(nil), // 12: validate.SFixed32Rules - (*SFixed64Rules)(nil), // 13: validate.SFixed64Rules - (*BoolRules)(nil), // 14: validate.BoolRules - (*StringRules)(nil), // 15: validate.StringRules - (*BytesRules)(nil), // 16: validate.BytesRules - (*EnumRules)(nil), // 17: validate.EnumRules - (*MessageRules)(nil), // 18: validate.MessageRules - (*RepeatedRules)(nil), // 19: validate.RepeatedRules - (*MapRules)(nil), // 20: validate.MapRules - (*AnyRules)(nil), // 21: validate.AnyRules - (*DurationRules)(nil), // 22: validate.DurationRules - (*TimestampRules)(nil), // 23: validate.TimestampRules - (*durationpb.Duration)(nil), // 24: google.protobuf.Duration - (*timestamppb.Timestamp)(nil), // 25: google.protobuf.Timestamp - (*descriptorpb.MessageOptions)(nil), // 26: google.protobuf.MessageOptions - (*descriptorpb.OneofOptions)(nil), // 27: google.protobuf.OneofOptions - (*descriptorpb.FieldOptions)(nil), // 28: google.protobuf.FieldOptions -} -var file_validate_validate_proto_depIdxs = []int32{ - 18, // 0: validate.FieldRules.message:type_name -> validate.MessageRules - 2, // 1: validate.FieldRules.float:type_name -> validate.FloatRules - 3, // 2: validate.FieldRules.double:type_name -> validate.DoubleRules - 4, // 3: validate.FieldRules.int32:type_name -> validate.Int32Rules - 5, // 4: validate.FieldRules.int64:type_name -> validate.Int64Rules - 6, // 5: validate.FieldRules.uint32:type_name -> validate.UInt32Rules - 7, // 6: validate.FieldRules.uint64:type_name -> validate.UInt64Rules - 8, // 7: validate.FieldRules.sint32:type_name -> validate.SInt32Rules - 9, // 8: validate.FieldRules.sint64:type_name -> validate.SInt64Rules - 10, // 9: validate.FieldRules.fixed32:type_name -> validate.Fixed32Rules - 11, // 10: validate.FieldRules.fixed64:type_name -> validate.Fixed64Rules - 12, // 11: validate.FieldRules.sfixed32:type_name -> validate.SFixed32Rules - 13, // 12: validate.FieldRules.sfixed64:type_name -> validate.SFixed64Rules - 14, // 13: validate.FieldRules.bool:type_name -> validate.BoolRules - 15, // 14: validate.FieldRules.string:type_name -> validate.StringRules - 16, // 15: validate.FieldRules.bytes:type_name -> validate.BytesRules - 17, // 16: validate.FieldRules.enum:type_name -> validate.EnumRules - 19, // 17: validate.FieldRules.repeated:type_name -> validate.RepeatedRules - 20, // 18: validate.FieldRules.map:type_name -> validate.MapRules - 21, // 19: validate.FieldRules.any:type_name -> validate.AnyRules - 22, // 20: validate.FieldRules.duration:type_name -> validate.DurationRules - 23, // 21: validate.FieldRules.timestamp:type_name -> validate.TimestampRules - 0, // 22: validate.StringRules.well_known_regex:type_name -> validate.KnownRegex - 1, // 23: validate.RepeatedRules.items:type_name -> validate.FieldRules - 1, // 24: validate.MapRules.keys:type_name -> validate.FieldRules - 1, // 25: validate.MapRules.values:type_name -> validate.FieldRules - 24, // 26: validate.DurationRules.const:type_name -> google.protobuf.Duration - 24, // 27: validate.DurationRules.lt:type_name -> google.protobuf.Duration - 24, // 28: validate.DurationRules.lte:type_name -> google.protobuf.Duration - 24, // 29: validate.DurationRules.gt:type_name -> google.protobuf.Duration - 24, // 30: validate.DurationRules.gte:type_name -> google.protobuf.Duration - 24, // 31: validate.DurationRules.in:type_name -> google.protobuf.Duration - 24, // 32: validate.DurationRules.not_in:type_name -> google.protobuf.Duration - 25, // 33: validate.TimestampRules.const:type_name -> google.protobuf.Timestamp - 25, // 34: validate.TimestampRules.lt:type_name -> google.protobuf.Timestamp - 25, // 35: validate.TimestampRules.lte:type_name -> google.protobuf.Timestamp - 25, // 36: validate.TimestampRules.gt:type_name -> google.protobuf.Timestamp - 25, // 37: validate.TimestampRules.gte:type_name -> google.protobuf.Timestamp - 24, // 38: validate.TimestampRules.within:type_name -> google.protobuf.Duration - 26, // 39: validate.disabled:extendee -> google.protobuf.MessageOptions - 26, // 40: validate.ignored:extendee -> google.protobuf.MessageOptions - 27, // 41: validate.required:extendee -> google.protobuf.OneofOptions - 28, // 42: validate.rules:extendee -> google.protobuf.FieldOptions - 1, // 43: validate.rules:type_name -> validate.FieldRules - 44, // [44:44] is the sub-list for method output_type - 44, // [44:44] is the sub-list for method input_type - 43, // [43:44] is the sub-list for extension type_name - 39, // [39:43] is the sub-list for extension extendee - 0, // [0:39] is the sub-list for field type_name -} - -func init() { file_validate_validate_proto_init() } -func file_validate_validate_proto_init() { - if File_validate_validate_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_validate_validate_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FieldRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FloatRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoubleRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Int32Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Int64Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UInt32Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UInt64Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SInt32Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SInt64Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Fixed32Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Fixed64Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SFixed32Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SFixed64Rules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BoolRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StringRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BytesRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EnumRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MessageRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RepeatedRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MapRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AnyRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DurationRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validate_validate_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TimestampRules); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_validate_validate_proto_msgTypes[0].OneofWrappers = []interface{}{ - (*FieldRules_Float)(nil), - (*FieldRules_Double)(nil), - (*FieldRules_Int32)(nil), - (*FieldRules_Int64)(nil), - (*FieldRules_Uint32)(nil), - (*FieldRules_Uint64)(nil), - (*FieldRules_Sint32)(nil), - (*FieldRules_Sint64)(nil), - (*FieldRules_Fixed32)(nil), - (*FieldRules_Fixed64)(nil), - (*FieldRules_Sfixed32)(nil), - (*FieldRules_Sfixed64)(nil), - (*FieldRules_Bool)(nil), - (*FieldRules_String_)(nil), - (*FieldRules_Bytes)(nil), - (*FieldRules_Enum)(nil), - (*FieldRules_Repeated)(nil), - (*FieldRules_Map)(nil), - (*FieldRules_Any)(nil), - (*FieldRules_Duration)(nil), - (*FieldRules_Timestamp)(nil), - } - file_validate_validate_proto_msgTypes[14].OneofWrappers = []interface{}{ - (*StringRules_Email)(nil), - (*StringRules_Hostname)(nil), - (*StringRules_Ip)(nil), - (*StringRules_Ipv4)(nil), - (*StringRules_Ipv6)(nil), - (*StringRules_Uri)(nil), - (*StringRules_UriRef)(nil), - (*StringRules_Address)(nil), - (*StringRules_Uuid)(nil), - (*StringRules_WellKnownRegex)(nil), - } - file_validate_validate_proto_msgTypes[15].OneofWrappers = []interface{}{ - (*BytesRules_Ip)(nil), - (*BytesRules_Ipv4)(nil), - (*BytesRules_Ipv6)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_validate_validate_proto_rawDesc, - NumEnums: 1, - NumMessages: 23, - NumExtensions: 4, - NumServices: 0, - }, - GoTypes: file_validate_validate_proto_goTypes, - DependencyIndexes: file_validate_validate_proto_depIdxs, - EnumInfos: file_validate_validate_proto_enumTypes, - MessageInfos: file_validate_validate_proto_msgTypes, - ExtensionInfos: file_validate_validate_proto_extTypes, - }.Build() - File_validate_validate_proto = out.File - file_validate_validate_proto_rawDesc = nil - file_validate_validate_proto_goTypes = nil - file_validate_validate_proto_depIdxs = nil -} diff --git a/vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.proto b/vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.proto deleted file mode 100644 index 705d382aa..000000000 --- a/vendor/github.com/envoyproxy/protoc-gen-validate/validate/validate.proto +++ /dev/null @@ -1,862 +0,0 @@ -syntax = "proto2"; -package validate; - -option go_package = "github.com/envoyproxy/protoc-gen-validate/validate"; -option java_package = "io.envoyproxy.pgv.validate"; - -import "google/protobuf/descriptor.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -// Validation rules applied at the message level -extend google.protobuf.MessageOptions { - // Disabled nullifies any validation rules for this message, including any - // message fields associated with it that do support validation. - optional bool disabled = 1071; - // Ignore skips generation of validation methods for this message. - optional bool ignored = 1072; -} - -// Validation rules applied at the oneof level -extend google.protobuf.OneofOptions { - // Required ensures that exactly one the field options in a oneof is set; - // validation fails if no fields in the oneof are set. - optional bool required = 1071; -} - -// Validation rules applied at the field level -extend google.protobuf.FieldOptions { - // Rules specify the validations to be performed on this field. By default, - // no validation is performed against a field. - optional FieldRules rules = 1071; -} - -// FieldRules encapsulates the rules for each type of field. Depending on the -// field, the correct set should be used to ensure proper validations. -message FieldRules { - optional MessageRules message = 17; - oneof type { - // Scalar Field Types - FloatRules float = 1; - DoubleRules double = 2; - Int32Rules int32 = 3; - Int64Rules int64 = 4; - UInt32Rules uint32 = 5; - UInt64Rules uint64 = 6; - SInt32Rules sint32 = 7; - SInt64Rules sint64 = 8; - Fixed32Rules fixed32 = 9; - Fixed64Rules fixed64 = 10; - SFixed32Rules sfixed32 = 11; - SFixed64Rules sfixed64 = 12; - BoolRules bool = 13; - StringRules string = 14; - BytesRules bytes = 15; - - // Complex Field Types - EnumRules enum = 16; - RepeatedRules repeated = 18; - MapRules map = 19; - - // Well-Known Field Types - AnyRules any = 20; - DurationRules duration = 21; - TimestampRules timestamp = 22; - } -} - -// FloatRules describes the constraints applied to `float` values -message FloatRules { - // Const specifies that this field must be exactly the specified value - optional float const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional float lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional float lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional float gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional float gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated float in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated float not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// DoubleRules describes the constraints applied to `double` values -message DoubleRules { - // Const specifies that this field must be exactly the specified value - optional double const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional double lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional double lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional double gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional double gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated double in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated double not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Int32Rules describes the constraints applied to `int32` values -message Int32Rules { - // Const specifies that this field must be exactly the specified value - optional int32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional int32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional int32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional int32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional int32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated int32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated int32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Int64Rules describes the constraints applied to `int64` values -message Int64Rules { - // Const specifies that this field must be exactly the specified value - optional int64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional int64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional int64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional int64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional int64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated int64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated int64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// UInt32Rules describes the constraints applied to `uint32` values -message UInt32Rules { - // Const specifies that this field must be exactly the specified value - optional uint32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional uint32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional uint32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional uint32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional uint32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated uint32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated uint32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// UInt64Rules describes the constraints applied to `uint64` values -message UInt64Rules { - // Const specifies that this field must be exactly the specified value - optional uint64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional uint64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional uint64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional uint64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional uint64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated uint64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated uint64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SInt32Rules describes the constraints applied to `sint32` values -message SInt32Rules { - // Const specifies that this field must be exactly the specified value - optional sint32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sint32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sint32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sint32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sint32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sint32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sint32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SInt64Rules describes the constraints applied to `sint64` values -message SInt64Rules { - // Const specifies that this field must be exactly the specified value - optional sint64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sint64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sint64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sint64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sint64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sint64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sint64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Fixed32Rules describes the constraints applied to `fixed32` values -message Fixed32Rules { - // Const specifies that this field must be exactly the specified value - optional fixed32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional fixed32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional fixed32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional fixed32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional fixed32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated fixed32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated fixed32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Fixed64Rules describes the constraints applied to `fixed64` values -message Fixed64Rules { - // Const specifies that this field must be exactly the specified value - optional fixed64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional fixed64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional fixed64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional fixed64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional fixed64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated fixed64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated fixed64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SFixed32Rules describes the constraints applied to `sfixed32` values -message SFixed32Rules { - // Const specifies that this field must be exactly the specified value - optional sfixed32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sfixed32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sfixed32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sfixed32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sfixed32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sfixed32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sfixed32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SFixed64Rules describes the constraints applied to `sfixed64` values -message SFixed64Rules { - // Const specifies that this field must be exactly the specified value - optional sfixed64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sfixed64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sfixed64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sfixed64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sfixed64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sfixed64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sfixed64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// BoolRules describes the constraints applied to `bool` values -message BoolRules { - // Const specifies that this field must be exactly the specified value - optional bool const = 1; -} - -// StringRules describe the constraints applied to `string` values -message StringRules { - // Const specifies that this field must be exactly the specified value - optional string const = 1; - - // Len specifies that this field must be the specified number of - // characters (Unicode code points). Note that the number of - // characters may differ from the number of bytes in the string. - optional uint64 len = 19; - - // MinLen specifies that this field must be the specified number of - // characters (Unicode code points) at a minimum. Note that the number of - // characters may differ from the number of bytes in the string. - optional uint64 min_len = 2; - - // MaxLen specifies that this field must be the specified number of - // characters (Unicode code points) at a maximum. Note that the number of - // characters may differ from the number of bytes in the string. - optional uint64 max_len = 3; - - // LenBytes specifies that this field must be the specified number of bytes - optional uint64 len_bytes = 20; - - // MinBytes specifies that this field must be the specified number of bytes - // at a minimum - optional uint64 min_bytes = 4; - - // MaxBytes specifies that this field must be the specified number of bytes - // at a maximum - optional uint64 max_bytes = 5; - - // Pattern specifes that this field must match against the specified - // regular expression (RE2 syntax). The included expression should elide - // any delimiters. - optional string pattern = 6; - - // Prefix specifies that this field must have the specified substring at - // the beginning of the string. - optional string prefix = 7; - - // Suffix specifies that this field must have the specified substring at - // the end of the string. - optional string suffix = 8; - - // Contains specifies that this field must have the specified substring - // anywhere in the string. - optional string contains = 9; - - // NotContains specifies that this field cannot have the specified substring - // anywhere in the string. - optional string not_contains = 23; - - // In specifies that this field must be equal to one of the specified - // values - repeated string in = 10; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated string not_in = 11; - - // WellKnown rules provide advanced constraints against common string - // patterns - oneof well_known { - // Email specifies that the field must be a valid email address as - // defined by RFC 5322 - bool email = 12; - - // Hostname specifies that the field must be a valid hostname as - // defined by RFC 1034. This constraint does not support - // internationalized domain names (IDNs). - bool hostname = 13; - - // Ip specifies that the field must be a valid IP (v4 or v6) address. - // Valid IPv6 addresses should not include surrounding square brackets. - bool ip = 14; - - // Ipv4 specifies that the field must be a valid IPv4 address. - bool ipv4 = 15; - - // Ipv6 specifies that the field must be a valid IPv6 address. Valid - // IPv6 addresses should not include surrounding square brackets. - bool ipv6 = 16; - - // Uri specifies that the field must be a valid, absolute URI as defined - // by RFC 3986 - bool uri = 17; - - // UriRef specifies that the field must be a valid URI as defined by RFC - // 3986 and may be relative or absolute. - bool uri_ref = 18; - - // Address specifies that the field must be either a valid hostname as - // defined by RFC 1034 (which does not support internationalized domain - // names or IDNs), or it can be a valid IP (v4 or v6). - bool address = 21; - - // Uuid specifies that the field must be a valid UUID as defined by - // RFC 4122 - bool uuid = 22; - - // WellKnownRegex specifies a common well known pattern defined as a regex. - KnownRegex well_known_regex = 24; - } - - // This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable - // strict header validation. - // By default, this is true, and HTTP header validations are RFC-compliant. - // Setting to false will enable a looser validations that only disallows - // \r\n\0 characters, which can be used to bypass header matching rules. - optional bool strict = 25 [default = true]; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 26; -} - -// WellKnownRegex contain some well-known patterns. -enum KnownRegex { - UNKNOWN = 0; - - // HTTP header name as defined by RFC 7230. - HTTP_HEADER_NAME = 1; - - // HTTP header value as defined by RFC 7230. - HTTP_HEADER_VALUE = 2; -} - -// BytesRules describe the constraints applied to `bytes` values -message BytesRules { - // Const specifies that this field must be exactly the specified value - optional bytes const = 1; - - // Len specifies that this field must be the specified number of bytes - optional uint64 len = 13; - - // MinLen specifies that this field must be the specified number of bytes - // at a minimum - optional uint64 min_len = 2; - - // MaxLen specifies that this field must be the specified number of bytes - // at a maximum - optional uint64 max_len = 3; - - // Pattern specifes that this field must match against the specified - // regular expression (RE2 syntax). The included expression should elide - // any delimiters. - optional string pattern = 4; - - // Prefix specifies that this field must have the specified bytes at the - // beginning of the string. - optional bytes prefix = 5; - - // Suffix specifies that this field must have the specified bytes at the - // end of the string. - optional bytes suffix = 6; - - // Contains specifies that this field must have the specified bytes - // anywhere in the string. - optional bytes contains = 7; - - // In specifies that this field must be equal to one of the specified - // values - repeated bytes in = 8; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated bytes not_in = 9; - - // WellKnown rules provide advanced constraints against common byte - // patterns - oneof well_known { - // Ip specifies that the field must be a valid IP (v4 or v6) address in - // byte format - bool ip = 10; - - // Ipv4 specifies that the field must be a valid IPv4 address in byte - // format - bool ipv4 = 11; - - // Ipv6 specifies that the field must be a valid IPv6 address in byte - // format - bool ipv6 = 12; - } - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 14; -} - -// EnumRules describe the constraints applied to enum values -message EnumRules { - // Const specifies that this field must be exactly the specified value - optional int32 const = 1; - - // DefinedOnly specifies that this field must be only one of the defined - // values for this enum, failing on any undefined value. - optional bool defined_only = 2; - - // In specifies that this field must be equal to one of the specified - // values - repeated int32 in = 3; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated int32 not_in = 4; -} - -// MessageRules describe the constraints applied to embedded message values. -// For message-type fields, validation is performed recursively. -message MessageRules { - // Skip specifies that the validation rules of this field should not be - // evaluated - optional bool skip = 1; - - // Required specifies that this field must be set - optional bool required = 2; -} - -// RepeatedRules describe the constraints applied to `repeated` values -message RepeatedRules { - // MinItems specifies that this field must have the specified number of - // items at a minimum - optional uint64 min_items = 1; - - // MaxItems specifies that this field must have the specified number of - // items at a maximum - optional uint64 max_items = 2; - - // Unique specifies that all elements in this field must be unique. This - // contraint is only applicable to scalar and enum types (messages are not - // supported). - optional bool unique = 3; - - // Items specifies the contraints to be applied to each item in the field. - // Repeated message fields will still execute validation against each item - // unless skip is specified here. - optional FieldRules items = 4; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 5; -} - -// MapRules describe the constraints applied to `map` values -message MapRules { - // MinPairs specifies that this field must have the specified number of - // KVs at a minimum - optional uint64 min_pairs = 1; - - // MaxPairs specifies that this field must have the specified number of - // KVs at a maximum - optional uint64 max_pairs = 2; - - // NoSparse specifies values in this field cannot be unset. This only - // applies to map's with message value types. - optional bool no_sparse = 3; - - // Keys specifies the constraints to be applied to each key in the field. - optional FieldRules keys = 4; - - // Values specifies the constraints to be applied to the value of each key - // in the field. Message values will still have their validations evaluated - // unless skip is specified here. - optional FieldRules values = 5; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 6; -} - -// AnyRules describe constraints applied exclusively to the -// `google.protobuf.Any` well-known type -message AnyRules { - // Required specifies that this field must be set - optional bool required = 1; - - // In specifies that this field's `type_url` must be equal to one of the - // specified values. - repeated string in = 2; - - // NotIn specifies that this field's `type_url` must not be equal to any of - // the specified values. - repeated string not_in = 3; -} - -// DurationRules describe the constraints applied exclusively to the -// `google.protobuf.Duration` well-known type -message DurationRules { - // Required specifies that this field must be set - optional bool required = 1; - - // Const specifies that this field must be exactly the specified value - optional google.protobuf.Duration const = 2; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional google.protobuf.Duration lt = 3; - - // Lt specifies that this field must be less than the specified value, - // inclusive - optional google.protobuf.Duration lte = 4; - - // Gt specifies that this field must be greater than the specified value, - // exclusive - optional google.protobuf.Duration gt = 5; - - // Gte specifies that this field must be greater than the specified value, - // inclusive - optional google.protobuf.Duration gte = 6; - - // In specifies that this field must be equal to one of the specified - // values - repeated google.protobuf.Duration in = 7; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated google.protobuf.Duration not_in = 8; -} - -// TimestampRules describe the constraints applied exclusively to the -// `google.protobuf.Timestamp` well-known type -message TimestampRules { - // Required specifies that this field must be set - optional bool required = 1; - - // Const specifies that this field must be exactly the specified value - optional google.protobuf.Timestamp const = 2; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional google.protobuf.Timestamp lt = 3; - - // Lte specifies that this field must be less than the specified value, - // inclusive - optional google.protobuf.Timestamp lte = 4; - - // Gt specifies that this field must be greater than the specified value, - // exclusive - optional google.protobuf.Timestamp gt = 5; - - // Gte specifies that this field must be greater than the specified value, - // inclusive - optional google.protobuf.Timestamp gte = 6; - - // LtNow specifies that this must be less than the current time. LtNow - // can only be used with the Within rule. - optional bool lt_now = 7; - - // GtNow specifies that this must be greater than the current time. GtNow - // can only be used with the Within rule. - optional bool gt_now = 8; - - // Within specifies that this field must be within this duration of the - // current time. This constraint can be used alone or with the LtNow and - // GtNow rules. - optional google.protobuf.Duration within = 9; -} diff --git a/vendor/github.com/goccy/go-json/.codecov.yml b/vendor/github.com/goccy/go-json/.codecov.yml deleted file mode 100644 index e98134570..000000000 --- a/vendor/github.com/goccy/go-json/.codecov.yml +++ /dev/null @@ -1,32 +0,0 @@ -codecov: - require_ci_to_pass: yes - -coverage: - precision: 2 - round: down - range: "70...100" - - status: - project: - default: - target: 70% - threshold: 2% - patch: off - changes: no - -parsers: - gcov: - branch_detection: - conditional: yes - loop: yes - method: no - macro: no - -comment: - layout: "header,diff" - behavior: default - require_changes: no - -ignore: - - internal/encoder/vm_color - - internal/encoder/vm_color_indent diff --git a/vendor/github.com/goccy/go-json/.gitignore b/vendor/github.com/goccy/go-json/.gitignore deleted file mode 100644 index 378283829..000000000 --- a/vendor/github.com/goccy/go-json/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -cover.html -cover.out diff --git a/vendor/github.com/goccy/go-json/.golangci.yml b/vendor/github.com/goccy/go-json/.golangci.yml deleted file mode 100644 index 57ae5a528..000000000 --- a/vendor/github.com/goccy/go-json/.golangci.yml +++ /dev/null @@ -1,83 +0,0 @@ -run: - skip-files: - - encode_optype.go - - ".*_test\\.go$" - -linters-settings: - govet: - enable-all: true - disable: - - shadow - -linters: - enable-all: true - disable: - - dogsled - - dupl - - exhaustive - - exhaustivestruct - - errorlint - - forbidigo - - funlen - - gci - - gochecknoglobals - - gochecknoinits - - gocognit - - gocritic - - gocyclo - - godot - - godox - - goerr113 - - gofumpt - - gomnd - - gosec - - ifshort - - lll - - makezero - - nakedret - - nestif - - nlreturn - - paralleltest - - testpackage - - thelper - - wrapcheck - - interfacer - - lll - - nakedret - - nestif - - nlreturn - - testpackage - - wsl - - varnamelen - - nilnil - - ireturn - - govet - - forcetypeassert - - cyclop - - containedctx - - revive - -issues: - exclude-rules: - # not needed - - path: /*.go - text: "ST1003: should not use underscores in package names" - linters: - - stylecheck - - path: /*.go - text: "don't use an underscore in package name" - linters: - - golint - - path: rtype.go - linters: - - golint - - stylecheck - - path: error.go - linters: - - staticcheck - - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-issues-per-linter: 0 - - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. - max-same-issues: 0 diff --git a/vendor/github.com/goccy/go-json/CHANGELOG.md b/vendor/github.com/goccy/go-json/CHANGELOG.md deleted file mode 100644 index d09bb89c3..000000000 --- a/vendor/github.com/goccy/go-json/CHANGELOG.md +++ /dev/null @@ -1,425 +0,0 @@ -# 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 ) -* Fix encoding of not empty interface type ( #284 ) -* Fix encoding of empty struct interface type ( #286 ) - -# v0.7.7 - 2021/08/25 - -* Fix invalid utf8 on stream decoder ( #279 ) -* Fix buffer length bug on string stream decoder ( #280 ) - -Thank you @orisano !! - -# v0.7.6 - 2021/08/13 - -* Fix nil slice assignment ( #276 ) -* Improve error message ( #277 ) - -# v0.7.5 - 2021/08/12 - -* Fix encoding of embedded struct with tags ( #265 ) -* Fix encoding of embedded struct that isn't first field ( #272 ) -* Fix decoding of binary type with escaped char ( #273 ) - -# v0.7.4 - 2021/07/06 - -* Fix encoding of indirect layout structure ( #264 ) - -# v0.7.3 - 2021/06/29 - -* Fix encoding of pointer type in empty interface ( #262 ) - -# v0.7.2 - 2021/06/26 - -### Fix decoder - -* Add decoder for func type to fix decoding of nil function value ( #257 ) -* Fix stream decoding of []byte type ( #258 ) - -### Performance - -* Improve decoding performance of map[string]interface{} type ( use `mapassign_faststr` ) ( #256 ) -* Improve encoding performance of empty interface type ( remove recursive calling of `vm.Run` ) ( #259 ) - -### Benchmark - -* Add bytedance/sonic as benchmark target ( #254 ) - -# v0.7.1 - 2021/06/18 - -### Fix decoder - -* Fix error when unmarshal empty array ( #253 ) - -# v0.7.0 - 2021/06/12 - -### Support context for MarshalJSON and UnmarshalJSON ( #248 ) - -* json.MarshalContext(context.Context, interface{}, ...json.EncodeOption) ([]byte, error) -* json.NewEncoder(io.Writer).EncodeContext(context.Context, interface{}, ...json.EncodeOption) error -* json.UnmarshalContext(context.Context, []byte, interface{}, ...json.DecodeOption) error -* json.NewDecoder(io.Reader).DecodeContext(context.Context, interface{}) error - -```go -type MarshalerContext interface { - MarshalJSON(context.Context) ([]byte, error) -} - -type UnmarshalerContext interface { - UnmarshalJSON(context.Context, []byte) error -} -``` - -### Add DecodeFieldPriorityFirstWin option ( #242 ) - -In the default behavior, go-json, like encoding/json, will reflect the result of the last evaluation when a field with the same name exists. I've added new options to allow you to change this behavior. `json.DecodeFieldPriorityFirstWin` option reflects the result of the first evaluation if a field with the same name exists. This behavior has a performance advantage as it allows the subsequent strings to be skipped if all fields have been evaluated. - -### Fix encoder - -* Fix indent number contains recursive type ( #249 ) -* Fix encoding of using empty interface as map key ( #244 ) - -### Fix decoder - -* Fix decoding fields containing escaped characters ( #237 ) - -### Refactor - -* Move some tests to subdirectory ( #243 ) -* Refactor package layout for decoder ( #238 ) - -# v0.6.1 - 2021/06/02 - -### Fix encoder - -* Fix value of totalLength for encoding ( #236 ) - -# v0.6.0 - 2021/06/01 - -### Support Colorize option for encoding (#233) - -```go -b, err := json.MarshalWithOption(v, json.Colorize(json.DefaultColorScheme)) -if err != nil { - ... -} -fmt.Println(string(b)) // print colored json -``` - -### Refactor - -* Fix opcode layout - Adjust memory layout of the opcode to 128 bytes in a 64-bit environment ( #230 ) -* Refactor encode option ( #231 ) -* Refactor escape string ( #232 ) - -# v0.5.1 - 2021/5/20 - -### Optimization - -* Add type addrShift to enable bigger encoder/decoder cache ( #213 ) - -### Fix decoder - -* Keep original reference of slice element ( #229 ) - -### Refactor - -* Refactor Debug mode for encoding ( #226 ) -* Generate VM sources for encoding ( #227 ) -* Refactor validator for null/true/false for decoding ( #221 ) - -# v0.5.0 - 2021/5/9 - -### Supports using omitempty and string tags at the same time ( #216 ) - -### Fix decoder - -* Fix stream decoder for unicode char ( #215 ) -* Fix decoding of slice element ( #219 ) -* Fix calculating of buffer length for stream decoder ( #220 ) - -### Refactor - -* replace skipWhiteSpace goto by loop ( #212 ) - -# v0.4.14 - 2021/5/4 - -### Benchmark - -* Add valyala/fastjson to benchmark ( #193 ) -* Add benchmark task for CI ( #211 ) - -### Fix decoder - -* Fix decoding of slice with unmarshal json type ( #198 ) -* Fix decoding of null value for interface type that does not implement Unmarshaler ( #205 ) -* Fix decoding of null value to []byte by json.Unmarshal ( #206 ) -* Fix decoding of backslash char at the end of string ( #207 ) -* Fix stream decoder for null/true/false value ( #208 ) -* Fix stream decoder for slow reader ( #211 ) - -### Performance - -* If cap of slice is enough, reuse slice data for compatibility with encoding/json ( #200 ) - -# v0.4.13 - 2021/4/20 - -### Fix json.Compact and json.Indent - -* Support validation the input buffer for json.Compact and json.Indent ( #189 ) -* Optimize json.Compact and json.Indent ( improve memory footprint ) ( #190 ) - -# v0.4.12 - 2021/4/15 - -### Fix encoder - -* Fix unnecessary indent for empty slice type ( #181 ) -* Fix encoding of omitempty feature for the slice or interface type ( #183 ) -* Fix encoding custom types zero values with omitempty when marshaller exists ( #187 ) - -### Fix decoder - -* Fix decoder for invalid top level value ( #184 ) -* Fix decoder for invalid number value ( #185 ) - -# v0.4.11 - 2021/4/3 - -* Improve decoder performance for interface type - -# v0.4.10 - 2021/4/2 - -### Fix encoder - -* Fixed a bug when encoding slice and map containing recursive structures -* Fixed a logic to determine if indirect reference - -# v0.4.9 - 2021/3/29 - -### Add debug mode - -If you use `json.MarshalWithOption(v, json.Debug())` and `panic` occurred in `go-json`, produces debug information to console. - -### Support a new feature to compatible with encoding/json - -- invalid UTF-8 is coerced to valid UTF-8 ( without performance down ) - -### Fix encoder - -- Fixed handling of MarshalJSON of function type - -### Fix decoding of slice of pointer type - -If there is a pointer value, go-json will use it. (This behavior is necessary to achieve the ability to prioritize pre-filled values). However, since slices are reused internally, there was a bug that referred to the previous pointer value. Therefore, it is not necessary to refer to the pointer value in advance for the slice element, so we explicitly initialize slice element by `nil`. - -# v0.4.8 - 2021/3/21 - -### Reduce memory usage at compile time - -* go-json have used about 2GB of memory at compile time, but now it can compile with about less than 550MB. - -### Fix any encoder's bug - -* Add many test cases for encoder -* Fix composite type ( slice/array/map ) -* Fix pointer types -* Fix encoding of MarshalJSON or MarshalText or json.Number type - -### Refactor encoder - -* Change package layout for reducing memory usage at compile -* Remove anonymous and only operation -* Remove root property from encodeCompileContext and opcode - -### Fix CI - -* Add Go 1.16 -* Remove Go 1.13 -* Fix `make cover` task - -### Number/Delim/Token/RawMessage use the types defined in encoding/json by type alias - -# v0.4.7 - 2021/02/22 - -### Fix decoder - -* Fix decoding of deep recursive structure -* Fix decoding of embedded unexported pointer field -* Fix invalid test case -* Fix decoding of invalid value -* Fix decoding of prefilled value -* Fix not being able to return UnmarshalTypeError when it should be returned -* Fix decoding of null value -* Fix decoding of type of null string -* Use pre allocated pointer if exists it at decoding - -### Reduce memory usage at compile - -* Integrate int/int8/int16/int32/int64 and uint/uint8/uint16/uint32/uint64 operation to reduce memory usage at compile - -### Remove unnecessary optype diff --git a/vendor/github.com/goccy/go-json/LICENSE b/vendor/github.com/goccy/go-json/LICENSE deleted file mode 100644 index 6449c8bff..000000000 --- a/vendor/github.com/goccy/go-json/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Masaaki Goshima - -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/goccy/go-json/Makefile b/vendor/github.com/goccy/go-json/Makefile deleted file mode 100644 index 5bbfc4c9a..000000000 --- a/vendor/github.com/goccy/go-json/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -PKG := github.com/goccy/go-json - -BIN_DIR := $(CURDIR)/bin -PKGS := $(shell go list ./... | grep -v internal/cmd|grep -v test) -COVER_PKGS := $(foreach pkg,$(PKGS),$(subst $(PKG),.,$(pkg))) - -COMMA := , -EMPTY := -SPACE := $(EMPTY) $(EMPTY) -COVERPKG_OPT := $(subst $(SPACE),$(COMMA),$(COVER_PKGS)) - -$(BIN_DIR): - @mkdir -p $(BIN_DIR) - -.PHONY: cover -cover: - go test -coverpkg=$(COVERPKG_OPT) -coverprofile=cover.out ./... - -.PHONY: cover-html -cover-html: cover - go tool cover -html=cover.out - -.PHONY: lint -lint: golangci-lint - $(BIN_DIR)/golangci-lint run - -golangci-lint: | $(BIN_DIR) - @{ \ - set -e; \ - 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.48.0; \ - rm -rf $$GOLANGCI_LINT_TMP_DIR; \ - } - -.PHONY: generate -generate: - go generate ./internal/... diff --git a/vendor/github.com/goccy/go-json/README.md b/vendor/github.com/goccy/go-json/README.md deleted file mode 100644 index 7bacc54f9..000000000 --- a/vendor/github.com/goccy/go-json/README.md +++ /dev/null @@ -1,529 +0,0 @@ -# go-json - -![Go](https://github.com/goccy/go-json/workflows/Go/badge.svg) -[![GoDoc](https://godoc.org/github.com/goccy/go-json?status.svg)](https://pkg.go.dev/github.com/goccy/go-json?tab=doc) -[![codecov](https://codecov.io/gh/goccy/go-json/branch/master/graph/badge.svg)](https://codecov.io/gh/goccy/go-json) - -Fast JSON encoder/decoder compatible with encoding/json for Go - - - -# Roadmap - -``` -* version ( expected release date ) - -* v0.9.0 - | - | while maintaining compatibility with encoding/json, we will add convenient APIs - | - v -* v1.0.0 -``` - -We are accepting requests for features that will be implemented between v0.9.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). - -# Features - -- Drop-in replacement of `encoding/json` -- Fast ( See [Benchmark section](https://github.com/goccy/go-json#benchmarks) ) -- 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 - -``` -go get github.com/goccy/go-json -``` - -# How to use - -Replace import statement from `encoding/json` to `github.com/goccy/go-json` - -``` --import "encoding/json" -+import "github.com/goccy/go-json" -``` - -# JSON library comparison - -| name | encoder | decoder | compatible with `encoding/json` | -| :----: | :------: | :-----: | :-----------------------------: | -| encoding/json | yes | yes | N/A | -| [json-iterator/go](https://github.com/json-iterator/go) | yes | yes | partial | -| [easyjson](https://github.com/mailru/easyjson) | yes | yes | no | -| [gojay](https://github.com/francoispqt/gojay) | yes | yes | no | -| [segmentio/encoding/json](https://github.com/segmentio/encoding/tree/master/json) | yes | yes | partial | -| [jettison](https://github.com/wI2L/jettison) | yes | no | no | -| [simdjson-go](https://github.com/minio/simdjson-go) | no | yes | no | -| goccy/go-json | yes | yes | yes | - -- `json-iterator/go` isn't compatible with `encoding/json` in many ways (e.g. https://github.com/json-iterator/go/issues/229 ), but it hasn't been supported for a long time. -- `segmentio/encoding/json` is well supported for encoders, but some are not supported for decoder APIs such as `Token` ( streaming decode ) - -## Other libraries - -- [jingo](https://github.com/bet365/jingo) - -I tried the benchmark but it didn't work. -Also, it seems to panic when it receives an unexpected value because there is no error handling... - -- [ffjson](https://github.com/pquerna/ffjson) - -Benchmarking gave very slow results. -It seems that it is assumed that the user will use the buffer pool properly. -Also, development seems to have already stopped - -# Benchmarks - -``` -$ cd benchmarks -$ go test -bench . -``` - -## Encode - - - - -## Decode - - - - - - -# Fuzzing - -[go-json-fuzz](https://github.com/goccy/go-json-fuzz) is the repository for fuzzing tests. -If you run the test in this repository and find a bug, please commit to corpus to go-json-fuzz and report the issue to [go-json](https://github.com/goccy/go-json/issues). - -# How it works - -`go-json` is very fast in both encoding and decoding compared to other libraries. -It's easier to implement by using automatic code generation for performance or by using a dedicated interface, but `go-json` dares to stick to compatibility with `encoding/json` and is the simple interface. Despite this, we are developing with the aim of being the fastest library. - -Here, we explain the various speed-up techniques implemented by `go-json`. - -## Basic technique - -The techniques listed here are the ones used by most of the libraries listed above. - -### Buffer reuse - -Since the only value required for the result of `json.Marshal(interface{}) ([]byte, error)` is `[]byte`, the only value that must be allocated during encoding is the return value `[]byte` . - -Also, as the number of allocations increases, the performance will be affected, so the number of allocations should be kept as low as possible when creating `[]byte`. - -Therefore, there is a technique to reduce the number of times a new buffer must be allocated by reusing the buffer used for the previous encoding by using `sync.Pool`. - -Finally, you allocate a buffer that is as long as the resulting buffer and copy the contents into it, you only need to allocate the buffer once in theory. - -```go -type buffer struct { - data []byte -} - -var bufPool = sync.Pool{ - New: func() interface{} { - return &buffer{data: make([]byte, 0, 1024)} - }, -} - -buf := bufPool.Get().(*buffer) -data := encode(buf.data) // reuse buf.data - -newBuf := make([]byte, len(data)) -copy(newBuf, buf) - -buf.data = data -bufPool.Put(buf) -``` - -### Elimination of reflection - -As you know, the reflection operation is very slow. - -Therefore, using the fact that the address position where the type information is stored is fixed for each binary ( we call this `typeptr` ), -we can use the address in the type information to call a pre-built optimized process. - -For example, you can get the address to the type information from `interface{}` as follows and you can use that information to call a process that does not have reflection. - -To process without reflection, pass a pointer (`unsafe.Pointer`) to the value is stored. - -```go - -type emptyInterface struct { - typ unsafe.Pointer - ptr unsafe.Pointer -} - -var typeToEncoder = map[uintptr]func(unsafe.Pointer)([]byte, error){} - -func Marshal(v interface{}) ([]byte, error) { - iface := (*emptyInterface)(unsafe.Pointer(&v) - typeptr := uintptr(iface.typ) - if enc, exists := typeToEncoder[typeptr]; exists { - return enc(iface.ptr) - } - ... -} -``` - -※ In reality, `typeToEncoder` can be referenced by multiple goroutines, so exclusive control is required. - -## Unique speed-up technique - -## Encoder - -### Do not escape arguments of `Marshal` - -`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. -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. -For this reason, to date `reflect.Type` is the same as `*reflect.rtype`. - -Therefore, by directly handling `*reflect.rtype`, which is an implementation of `reflect.Type`, it is possible to avoid escaping because it changes from `interface` to using `struct`. - -The technique for working with `*reflect.rtype` directly from `go-json` is implemented at [rtype.go](https://github.com/goccy/go-json/blob/master/internal/runtime/rtype.go) - -Also, the same technique is cut out as a library ( https://github.com/goccy/go-reflect ) - -Initially this feature was the default behavior of `go-json`. -But after careful testing, I found that I passed a large value to `json.Marshal()` and if the argument could not be assigned to the stack, it could not be properly escaped to the heap (a bug in the Go compiler). - -Therefore, this feature will be provided as an **optional** until this issue is resolved. - -To use it, add `NoEscape` like `MarshalNoEscape()` - -### Encoding using opcode sequence - -I explained that you can use `typeptr` to call a pre-built process from type information. - -In other libraries, this dedicated process is processed by making it an function calling like anonymous function, but function calls are inherently slow processes and should be avoided as much as possible. - -Therefore, `go-json` adopted the Instruction-based execution processing system, which is also used to implement virtual machines for programming language. - -If it is the first type to encode, create the opcode ( instruction ) sequence required for encoding. -From the second time onward, use `typeptr` to get the cached pre-built opcode sequence and encode it based on it. An example of the opcode sequence is shown below. - -```go -json.Marshal(struct{ - X int `json:"x"` - Y string `json:"y"` -}{X: 1, Y: "hello"}) -``` - -When encoding a structure like the one above, create a sequence of opcodes like this: - -``` -- opStructFieldHead ( `{` ) -- opStructFieldInt ( `"x": 1,` ) -- opStructFieldString ( `"y": "hello"` ) -- opStructEnd ( `}` ) -- opEnd -``` - -※ When processing each operation, write the letters on the right. - -In addition, each opcode is managed by the following structure ( -Pseudo code ). - -```go -type opType int -const ( - opStructFieldHead opType = iota - opStructFieldInt - opStructFieldStirng - opStructEnd - opEnd -) -type opcode struct { - op opType - key []byte - next *opcode -} -``` - -The process of encoding using the opcode sequence is roughly implemented as follows. - -```go -func encode(code *opcode, b []byte, p unsafe.Pointer) ([]byte, error) { - for { - switch code.op { - case opStructFieldHead: - b = append(b, '{') - code = code.next - case opStructFieldInt: - b = append(b, code.key...) - b = appendInt((*int)(unsafe.Pointer(uintptr(p)+code.offset))) - code = code.next - case opStructFieldString: - b = append(b, code.key...) - b = appendString((*string)(unsafe.Pointer(uintptr(p)+code.offset))) - code = code.next - case opStructEnd: - b = append(b, '}') - code = code.next - case opEnd: - goto END - } - } -END: - return b, nil -} -``` - -In this way, the huge `switch-case` is used to encode by manipulating the linked list opcodes to avoid unnecessary function calls. - -### Opcode sequence optimization - -One of the advantages of encoding using the opcode sequence is the ease of optimization. -The opcode sequence mentioned above is actually converted into the following optimized operations and used. - -``` -- opStructFieldHeadInt ( `{"x": 1,` ) -- opStructEndString ( `"y": "hello"}` ) -- opEnd -``` - -It has been reduced from 5 opcodes to 3 opcodes ! -Reducing the number of opcodees means reducing the number of branches with `switch-case`. -In other words, the closer the number of operations is to 1, the faster the processing can be performed. - -In `go-json`, optimization to reduce the number of opcodes itself like the above and it speeds up by preparing opcodes with optimized paths. - -### Change recursive call from CALL to JMP - -Recursive processing is required during encoding if the type is defined recursively as follows: - -```go -type T struct { - X int - U *U -} - -type U struct { - T *T -} - -b, err := json.Marshal(&T{ - X: 1, - U: &U{ - T: &T{ - X: 2, - }, - }, -}) -fmt.Println(string(b)) // {"X":1,"U":{"T":{"X":2,"U":null}}} -``` - -In `go-json`, recursive processing is processed by the operation type of ` opStructFieldRecursive`. - -In this operation, after acquiring the opcode sequence used for recursive processing, the function is **not** called recursively as it is, but the necessary values ​​are saved by itself and implemented by moving to the next operation. - -The technique of implementing recursive processing with the `JMP` operation while avoiding the `CALL` operation is a famous technique for implementing a high-speed virtual machine. - -For more details, please refer to [the article](https://engineering.mercari.com/blog/entry/1599563768-081104c850) ( but Japanese only ). - -### Dispatch by typeptr from map to slice - -When retrieving the data cached from the type information by `typeptr`, we usually use map. -Map requires exclusive control, so use `sync.Map` for a naive implementation. - -However, this is slow, so it's a good idea to use the `atomic` package for exclusive control as implemented by `segmentio/encoding/json` ( https://github.com/segmentio/encoding/blob/master/json/codec.go#L41-L55 ). - -This implementation slows down the set instead of speeding up the get, but it works well because of the nature of the library, it encodes much more for the same type. - -However, as a result of profiling, I noticed that `runtime.mapaccess2` accounts for a significant percentage of the execution time. So I thought if I could change the lookup from map to slice. - -There is an API named `typelinks` defined in the `runtime` package that the `reflect` package uses internally. -This allows you to get all the type information defined in the binary at runtime. - -The fact that all type information can be acquired means that by constructing slices in advance with the acquired total number of type information, it is possible to look up with the value of `typeptr` without worrying about out-of-range access. - -However, if there is too much type information, it will use a lot of memory, so by default we will only use this optimization if the slice size fits within **2Mib** . - -If this approach is not available, it will fall back to the `atomic` based process described above. - -If you want to know more, please refer to the implementation [here](https://github.com/goccy/go-json/blob/master/internal/runtime/type.go#L36-L100) - -## Decoder - -### Dispatch by typeptr from map to slice - -Like the encoder, the decoder also uses typeptr to call the dedicated process. - -### Faster termination character inspection using NUL character - -In order to decode, you have to traverse the input buffer character by position. -At that time, if you check whether the buffer has reached the end, it will be very slow. - -`buf` : `[]byte` type variable. holds the string passed to the decoder -`cursor` : `int64` type variable. holds the current read position - -```go -buflen := len(buf) -for ; cursor < buflen; cursor++ { // compare cursor and buflen at all times, it is so slow. - switch buf[cursor] { - case ' ', '\n', '\r', '\t': - } -} -``` - -Therefore, by adding the `NUL` (`\000`) character to the end of the read buffer as shown below, it is possible to check the termination character at the same time as other characters. - -```go -for { - switch buf[cursor] { - case ' ', '\n', '\r', '\t': - case '\000': - return nil - } - cursor++ -} -``` - -### Use Boundary Check Elimination - -Due to the `NUL` character optimization, the Go compiler does a boundary check every time, even though `buf[cursor]` does not cause out-of-range access. - -Therefore, `go-json` eliminates boundary check by fetching characters for hotspot by pointer operation. For example, the following code. - -```go -func char(ptr unsafe.Pointer, offset int64) byte { - return *(*byte)(unsafe.Pointer(uintptr(ptr) + uintptr(offset))) -} - -p := (*sliceHeader)(&unsafe.Pointer(buf)).data -for { - switch char(p, cursor) { - case ' ', '\n', '\r', '\t': - case '\000': - return nil - } - cursor++ -} -``` - -### Checking the existence of fields of struct using Bitmaps - -I found by the profiling result, in the struct decode, lookup process for field was taking a long time. - -For example, consider decoding a string like `{"a":1,"b":2,"c":3}` into the following structure: - -```go -type T struct { - A int `json:"a"` - B int `json:"b"` - C int `json:"c"` -} -``` - -At this time, it was found that it takes a lot of time to acquire the decoding process corresponding to the field from the field name as shown below during the decoding process. - -```go -fieldName := decodeKey(buf, cursor) // "a" or "b" or "c" -decoder, exists := fieldToDecoderMap[fieldName] // so slow -if exists { - decoder(buf, cursor) -} else { - skipValue(buf, cursor) -} -``` - -To improve this process, `json-iterator/go` is optimized so that it can be branched by switch-case when the number of fields in the structure is 10 or less (switch-case is faster than map). However, there is a risk of hash collision because the value hashed by the FNV algorithm is used for conditional branching. Also, `gojay` processes this part at high speed by letting the library user yourself write `switch-case`. - - -`go-json` considers and implements a new approach that is different from these. I call this **bitmap field optimization**. - -The range of values ​​per character can be represented by `[256]byte`. Also, if the number of fields in the structure is 8 or less, `int8` type can represent the state of each field. -In other words, it has the following structure. - -- Base ( 8bit ): `00000000` -- Key "a": `00000001` ( assign key "a" to the first bit ) -- Key "b": `00000010` ( assign key "b" to the second bit ) -- Key "c": `00000100` ( assign key "c" to the third bit ) - -Bitmap structure is the following - -``` - | key index(0) | ------------------------- - 0 | 00000000 | - 1 | 00000000 | -~~ | | -97 (a) | 00000001 | -98 (b) | 00000010 | -99 (c) | 00000100 | -~~ | | -255 | 00000000 | -``` - -You can think of this as a Bitmap with a height of `256` and a width of the maximum string length in the field name. -In other words, it can be represented by the following type . - -```go -[maxFieldKeyLength][256]int8 -``` - -When decoding a field character, check whether the corresponding character exists by referring to the pre-built bitmap like the following. - -```go -var curBit int8 = math.MaxInt8 // 11111111 - -c := char(buf, cursor) -bit := bitmap[keyIdx][c] -curBit &= bit -if curBit == 0 { - // not found field -} -``` - -If `curBit` is not `0` until the end of the field string, then the string is -You may have hit one of the fields. -But the possibility is that if the decoded string is shorter than the field string, you will get a false hit. - -- input: `{"a":1}` -```go -type T struct { - X int `json:"abc"` -} -``` -※ Since `a` is shorter than `abc`, it can decode to the end of the field character without `curBit` being 0. - -Rest assured. In this case, it doesn't matter because you can tell if you hit by comparing the string length of `a` with the string length of `abc`. - -Finally, calculate the position of the bit where `1` is set and get the corresponding value, and you're done. - -Using this technique, field lookups are possible with only bitwise operations and access to slices. - -`go-json` uses a similar technique for fields with 9 or more and 16 or less fields. At this time, Bitmap is constructed as `[maxKeyLen][256]int16` type. - -Currently, this optimization is not performed when the maximum length of the field name is long (specifically, 64 bytes or more) in addition to the limitation of the number of fields from the viewpoint of saving memory usage. - -### Others - -I have done a lot of other optimizations. I will find time to write about them. If you have any questions about what's written here or other optimizations, please visit the `#go-json` channel on `gophers.slack.com` . - -## Reference - -Regarding the story of go-json, there are the following articles in Japanese only. - -- https://speakerdeck.com/goccy/zui-su-falsejsonraiburariwoqiu-mete -- https://engineering.mercari.com/blog/entry/1599563768-081104c850/ - -# Looking for Sponsors - -I'm looking for sponsors this library. This library is being developed as a personal project in my spare time. If you want a quick response or problem resolution when using this library in your project, please register as a [sponsor](https://github.com/sponsors/goccy). I will cooperate as much as possible. Of course, this library is developed as an MIT license, so you can use it freely for free. - -# License - -MIT diff --git a/vendor/github.com/goccy/go-json/color.go b/vendor/github.com/goccy/go-json/color.go deleted file mode 100644 index e80b22b48..000000000 --- a/vendor/github.com/goccy/go-json/color.go +++ /dev/null @@ -1,68 +0,0 @@ -package json - -import ( - "fmt" - - "github.com/goccy/go-json/internal/encoder" -) - -type ( - ColorFormat = encoder.ColorFormat - ColorScheme = encoder.ColorScheme -) - -const escape = "\x1b" - -type colorAttr int - -//nolint:deadcode,varcheck -const ( - fgBlackColor colorAttr = iota + 30 - fgRedColor - fgGreenColor - fgYellowColor - fgBlueColor - fgMagentaColor - fgCyanColor - fgWhiteColor -) - -//nolint:deadcode,varcheck -const ( - fgHiBlackColor colorAttr = iota + 90 - fgHiRedColor - fgHiGreenColor - fgHiYellowColor - fgHiBlueColor - fgHiMagentaColor - fgHiCyanColor - fgHiWhiteColor -) - -func createColorFormat(attr colorAttr) ColorFormat { - return ColorFormat{ - Header: wrapColor(attr), - Footer: resetColor(), - } -} - -func wrapColor(attr colorAttr) string { - return fmt.Sprintf("%s[%dm", escape, attr) -} - -func resetColor() string { - return wrapColor(colorAttr(0)) -} - -var ( - DefaultColorScheme = &ColorScheme{ - Int: createColorFormat(fgHiMagentaColor), - Uint: createColorFormat(fgHiMagentaColor), - Float: createColorFormat(fgHiMagentaColor), - Bool: createColorFormat(fgHiYellowColor), - String: createColorFormat(fgHiGreenColor), - Binary: createColorFormat(fgHiRedColor), - ObjectKey: createColorFormat(fgHiCyanColor), - Null: createColorFormat(fgBlueColor), - } -) diff --git a/vendor/github.com/goccy/go-json/decode.go b/vendor/github.com/goccy/go-json/decode.go deleted file mode 100644 index 74c6ac3bc..000000000 --- a/vendor/github.com/goccy/go-json/decode.go +++ /dev/null @@ -1,263 +0,0 @@ -package json - -import ( - "context" - "fmt" - "io" - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/decoder" - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type Decoder struct { - s *decoder.Stream -} - -const ( - nul = '\000' -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -func unmarshal(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - src := make([]byte, len(data)+1) // append nul byte to the end - copy(src, data) - - header := (*emptyInterface)(unsafe.Pointer(&v)) - - if err := validateType(header.typ, uintptr(header.ptr)); err != nil { - return err - } - dec, err := decoder.CompileToGetDecoder(header.typ) - if err != nil { - return err - } - ctx := decoder.TakeRuntimeContext() - ctx.Buf = src - ctx.Option.Flags = 0 - for _, optFunc := range optFuncs { - optFunc(ctx.Option) - } - cursor, err := dec.Decode(ctx, 0, 0, header.ptr) - if err != nil { - decoder.ReleaseRuntimeContext(ctx) - return err - } - decoder.ReleaseRuntimeContext(ctx) - return validateEndBuf(src, cursor) -} - -func unmarshalContext(ctx context.Context, data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - src := make([]byte, len(data)+1) // append nul byte to the end - copy(src, data) - - header := (*emptyInterface)(unsafe.Pointer(&v)) - - if err := validateType(header.typ, uintptr(header.ptr)); err != nil { - return err - } - dec, err := decoder.CompileToGetDecoder(header.typ) - if err != nil { - return err - } - rctx := decoder.TakeRuntimeContext() - rctx.Buf = src - rctx.Option.Flags = 0 - rctx.Option.Flags |= decoder.ContextOption - rctx.Option.Context = ctx - for _, optFunc := range optFuncs { - optFunc(rctx.Option) - } - cursor, err := dec.Decode(rctx, 0, 0, header.ptr) - if err != nil { - decoder.ReleaseRuntimeContext(rctx) - return err - } - decoder.ReleaseRuntimeContext(rctx) - 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) - - header := (*emptyInterface)(unsafe.Pointer(&v)) - - if err := validateType(header.typ, uintptr(header.ptr)); err != nil { - return err - } - dec, err := decoder.CompileToGetDecoder(header.typ) - if err != nil { - return err - } - - ctx := decoder.TakeRuntimeContext() - ctx.Buf = src - ctx.Option.Flags = 0 - for _, optFunc := range optFuncs { - optFunc(ctx.Option) - } - cursor, err := dec.Decode(ctx, 0, 0, noescape(header.ptr)) - if err != nil { - decoder.ReleaseRuntimeContext(ctx) - return err - } - decoder.ReleaseRuntimeContext(ctx) - return validateEndBuf(src, cursor) -} - -func validateEndBuf(src []byte, cursor int64) error { - for { - switch src[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case nul: - return nil - } - return errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after top-level value", src[cursor]), - cursor+1, - ) - } -} - -//nolint:staticcheck -//go:nosplit -func noescape(p unsafe.Pointer) unsafe.Pointer { - x := uintptr(p) - return unsafe.Pointer(x ^ 0) -} - -func validateType(typ *runtime.Type, p uintptr) error { - if typ == nil || typ.Kind() != reflect.Ptr || p == 0 { - return &InvalidUnmarshalError{Type: runtime.RType2Type(typ)} - } - return nil -} - -// NewDecoder returns a new decoder that reads from r. -// -// The decoder introduces its own buffering and may -// read data from r beyond the JSON values requested. -func NewDecoder(r io.Reader) *Decoder { - s := decoder.NewStream(r) - return &Decoder{ - s: s, - } -} - -// Buffered returns a reader of the data remaining in the Decoder's -// buffer. The reader is valid until the next call to Decode. -func (d *Decoder) Buffered() io.Reader { - return d.s.Buffered() -} - -// Decode reads the next JSON-encoded value from its -// input and stores it in the value pointed to by v. -// -// See the documentation for Unmarshal for details about -// the conversion of JSON into a Go value. -func (d *Decoder) Decode(v interface{}) error { - return d.DecodeWithOption(v) -} - -// DecodeContext reads the next JSON-encoded value from its -// input and stores it in the value pointed to by v with context.Context. -func (d *Decoder) DecodeContext(ctx context.Context, v interface{}) error { - d.s.Option.Flags |= decoder.ContextOption - d.s.Option.Context = ctx - return d.DecodeWithOption(v) -} - -func (d *Decoder) DecodeWithOption(v interface{}, optFuncs ...DecodeOptionFunc) error { - header := (*emptyInterface)(unsafe.Pointer(&v)) - typ := header.typ - ptr := uintptr(header.ptr) - typeptr := uintptr(unsafe.Pointer(typ)) - // noescape trick for header.typ ( reflect.*rtype ) - copiedType := *(**runtime.Type)(unsafe.Pointer(&typeptr)) - - if err := validateType(copiedType, ptr); err != nil { - return err - } - - dec, err := decoder.CompileToGetDecoder(typ) - if err != nil { - return err - } - if err := d.s.PrepareForDecode(); err != nil { - return err - } - s := d.s - for _, optFunc := range optFuncs { - optFunc(s.Option) - } - if err := dec.DecodeStream(s, 0, header.ptr); err != nil { - return err - } - s.Reset() - return nil -} - -func (d *Decoder) More() bool { - return d.s.More() -} - -func (d *Decoder) Token() (Token, error) { - return d.s.Token() -} - -// 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 (d *Decoder) DisallowUnknownFields() { - d.s.DisallowUnknownFields = true -} - -func (d *Decoder) InputOffset() int64 { - return d.s.TotalOffset() -} - -// UseNumber causes the Decoder to unmarshal a number into an interface{} as a -// Number instead of as a float64. -func (d *Decoder) UseNumber() { - d.s.UseNumber = true -} diff --git a/vendor/github.com/goccy/go-json/docker-compose.yml b/vendor/github.com/goccy/go-json/docker-compose.yml deleted file mode 100644 index db40c79ad..000000000 --- a/vendor/github.com/goccy/go-json/docker-compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: '2' -services: - go-json: - image: golang:1.18 - volumes: - - '.:/go/src/go-json' - deploy: - resources: - limits: - memory: 620M - working_dir: /go/src/go-json - command: | - sh -c "go test -c . && ls go-json.test" diff --git a/vendor/github.com/goccy/go-json/encode.go b/vendor/github.com/goccy/go-json/encode.go deleted file mode 100644 index 4bd899f38..000000000 --- a/vendor/github.com/goccy/go-json/encode.go +++ /dev/null @@ -1,326 +0,0 @@ -package json - -import ( - "context" - "io" - "os" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/encoder/vm" - "github.com/goccy/go-json/internal/encoder/vm_color" - "github.com/goccy/go-json/internal/encoder/vm_color_indent" - "github.com/goccy/go-json/internal/encoder/vm_indent" -) - -// An Encoder writes JSON values to an output stream. -type Encoder struct { - w io.Writer - enabledIndent bool - enabledHTMLEscape bool - prefix string - indentStr string -} - -// NewEncoder returns a new encoder that writes to w. -func NewEncoder(w io.Writer) *Encoder { - return &Encoder{w: w, enabledHTMLEscape: true} -} - -// Encode writes the JSON encoding of v to the stream, followed by a newline character. -// -// See the documentation for Marshal for details about the conversion of Go values to JSON. -func (e *Encoder) Encode(v interface{}) error { - return e.EncodeWithOption(v) -} - -// EncodeWithOption call Encode with EncodeOption. -func (e *Encoder) EncodeWithOption(v interface{}, optFuncs ...EncodeOptionFunc) error { - ctx := encoder.TakeRuntimeContext() - ctx.Option.Flag = 0 - - err := e.encodeWithOption(ctx, v, optFuncs...) - - encoder.ReleaseRuntimeContext(ctx) - return err -} - -// EncodeContext call Encode with context.Context and EncodeOption. -func (e *Encoder) EncodeContext(ctx context.Context, v interface{}, optFuncs ...EncodeOptionFunc) error { - rctx := encoder.TakeRuntimeContext() - rctx.Option.Flag = 0 - rctx.Option.Flag |= encoder.ContextOption - rctx.Option.Context = ctx - - err := e.encodeWithOption(rctx, v, optFuncs...) - - encoder.ReleaseRuntimeContext(rctx) - return err -} - -func (e *Encoder) encodeWithOption(ctx *encoder.RuntimeContext, v interface{}, optFuncs ...EncodeOptionFunc) error { - 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) - } - var ( - buf []byte - err error - ) - if e.enabledIndent { - buf, err = encodeIndent(ctx, v, e.prefix, e.indentStr) - } else { - buf, err = encode(ctx, v) - } - if err != nil { - return err - } - if e.enabledIndent { - buf = buf[:len(buf)-2] - } else { - buf = buf[:len(buf)-1] - } - buf = append(buf, '\n') - if _, err := e.w.Write(buf); err != nil { - return err - } - return nil -} - -// SetEscapeHTML specifies whether problematic HTML characters should be escaped inside JSON quoted strings. -// The default behavior is to escape &, <, and > to \u0026, \u003c, and \u003e to avoid certain safety problems that can arise when embedding JSON in HTML. -// -// In non-HTML settings where the escaping interferes with the readability of the output, SetEscapeHTML(false) disables this behavior. -func (e *Encoder) SetEscapeHTML(on bool) { - e.enabledHTMLEscape = on -} - -// SetIndent instructs the encoder to format each subsequent encoded value as if indented by the package-level function Indent(dst, src, prefix, indent). -// Calling SetIndent("", "") disables indentation. -func (e *Encoder) SetIndent(prefix, indent string) { - if prefix == "" && indent == "" { - e.enabledIndent = false - return - } - e.prefix = prefix - e.indentStr = indent - e.enabledIndent = true -} - -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.Context = ctx - for _, optFunc := range optFuncs { - optFunc(rctx.Option) - } - - buf, err := encode(rctx, v) - if err != nil { - encoder.ReleaseRuntimeContext(rctx) - return nil, err - } - - // this line exists to escape call of `runtime.makeslicecopy` . - // if use `make([]byte, len(buf)-1)` and `copy(copied, buf)`, - // dst buffer size and src buffer size are differrent. - // in this case, compiler uses `runtime.makeslicecopy`, but it is slow. - buf = buf[:len(buf)-1] - copied := make([]byte, len(buf)) - copy(copied, buf) - - encoder.ReleaseRuntimeContext(rctx) - return copied, nil -} - -func marshal(v interface{}, optFuncs ...EncodeOptionFunc) ([]byte, error) { - ctx := encoder.TakeRuntimeContext() - - ctx.Option.Flag = 0 - ctx.Option.Flag |= (encoder.HTMLEscapeOption | encoder.NormalizeUTF8Option) - for _, optFunc := range optFuncs { - optFunc(ctx.Option) - } - - buf, err := encode(ctx, v) - if err != nil { - encoder.ReleaseRuntimeContext(ctx) - return nil, err - } - - // this line exists to escape call of `runtime.makeslicecopy` . - // if use `make([]byte, len(buf)-1)` and `copy(copied, buf)`, - // dst buffer size and src buffer size are differrent. - // in this case, compiler uses `runtime.makeslicecopy`, but it is slow. - buf = buf[:len(buf)-1] - copied := make([]byte, len(buf)) - copy(copied, buf) - - encoder.ReleaseRuntimeContext(ctx) - return copied, nil -} - -func marshalNoEscape(v interface{}) ([]byte, error) { - ctx := encoder.TakeRuntimeContext() - - ctx.Option.Flag = 0 - ctx.Option.Flag |= (encoder.HTMLEscapeOption | encoder.NormalizeUTF8Option) - - buf, err := encodeNoEscape(ctx, v) - if err != nil { - encoder.ReleaseRuntimeContext(ctx) - return nil, err - } - - // this line exists to escape call of `runtime.makeslicecopy` . - // if use `make([]byte, len(buf)-1)` and `copy(copied, buf)`, - // dst buffer size and src buffer size are differrent. - // in this case, compiler uses `runtime.makeslicecopy`, but it is slow. - buf = buf[:len(buf)-1] - copied := make([]byte, len(buf)) - copy(copied, buf) - - encoder.ReleaseRuntimeContext(ctx) - return copied, nil -} - -func marshalIndent(v interface{}, prefix, indent string, optFuncs ...EncodeOptionFunc) ([]byte, error) { - ctx := encoder.TakeRuntimeContext() - - ctx.Option.Flag = 0 - ctx.Option.Flag |= (encoder.HTMLEscapeOption | encoder.NormalizeUTF8Option | encoder.IndentOption) - for _, optFunc := range optFuncs { - optFunc(ctx.Option) - } - - buf, err := encodeIndent(ctx, v, prefix, indent) - if err != nil { - encoder.ReleaseRuntimeContext(ctx) - return nil, err - } - - buf = buf[:len(buf)-2] - copied := make([]byte, len(buf)) - copy(copied, buf) - - encoder.ReleaseRuntimeContext(ctx) - return copied, nil -} - -func encode(ctx *encoder.RuntimeContext, v interface{}) ([]byte, error) { - b := ctx.Buf[:0] - if v == nil { - b = encoder.AppendNull(ctx, b) - b = encoder.AppendComma(ctx, b) - return b, nil - } - header := (*emptyInterface)(unsafe.Pointer(&v)) - typ := header.typ - - typeptr := uintptr(unsafe.Pointer(typ)) - codeSet, err := encoder.CompileToGetCodeSet(ctx, typeptr) - if err != nil { - return nil, err - } - - p := uintptr(header.ptr) - ctx.Init(p, codeSet.CodeLength) - ctx.KeepRefs = append(ctx.KeepRefs, header.ptr) - - buf, err := encodeRunCode(ctx, b, codeSet) - if err != nil { - return nil, err - } - ctx.Buf = buf - return buf, nil -} - -func encodeNoEscape(ctx *encoder.RuntimeContext, v interface{}) ([]byte, error) { - b := ctx.Buf[:0] - if v == nil { - b = encoder.AppendNull(ctx, b) - b = encoder.AppendComma(ctx, b) - return b, nil - } - header := (*emptyInterface)(unsafe.Pointer(&v)) - typ := header.typ - - typeptr := uintptr(unsafe.Pointer(typ)) - codeSet, err := encoder.CompileToGetCodeSet(ctx, typeptr) - if err != nil { - return nil, err - } - - p := uintptr(header.ptr) - ctx.Init(p, codeSet.CodeLength) - buf, err := encodeRunCode(ctx, b, codeSet) - if err != nil { - return nil, err - } - - ctx.Buf = buf - return buf, nil -} - -func encodeIndent(ctx *encoder.RuntimeContext, v interface{}, prefix, indent string) ([]byte, error) { - b := ctx.Buf[:0] - if v == nil { - b = encoder.AppendNull(ctx, b) - b = encoder.AppendCommaIndent(ctx, b) - return b, nil - } - header := (*emptyInterface)(unsafe.Pointer(&v)) - typ := header.typ - - typeptr := uintptr(unsafe.Pointer(typ)) - codeSet, err := encoder.CompileToGetCodeSet(ctx, typeptr) - if err != nil { - return nil, err - } - - p := uintptr(header.ptr) - ctx.Init(p, codeSet.CodeLength) - buf, err := encodeRunIndentCode(ctx, b, codeSet, prefix, indent) - - ctx.KeepRefs = append(ctx.KeepRefs, header.ptr) - - if err != nil { - return nil, err - } - - ctx.Buf = buf - return buf, nil -} - -func encodeRunCode(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - if (ctx.Option.Flag & encoder.DebugOption) != 0 { - if (ctx.Option.Flag & encoder.ColorizeOption) != 0 { - return vm_color.DebugRun(ctx, b, codeSet) - } - return vm.DebugRun(ctx, b, codeSet) - } - if (ctx.Option.Flag & encoder.ColorizeOption) != 0 { - return vm_color.Run(ctx, b, codeSet) - } - return vm.Run(ctx, b, codeSet) -} - -func encodeRunIndentCode(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, prefix, indent string) ([]byte, error) { - ctx.Prefix = []byte(prefix) - ctx.IndentStr = []byte(indent) - if (ctx.Option.Flag & encoder.DebugOption) != 0 { - if (ctx.Option.Flag & encoder.ColorizeOption) != 0 { - return vm_color_indent.DebugRun(ctx, b, codeSet) - } - return vm_indent.DebugRun(ctx, b, codeSet) - } - if (ctx.Option.Flag & encoder.ColorizeOption) != 0 { - return vm_color_indent.Run(ctx, b, codeSet) - } - return vm_indent.Run(ctx, b, codeSet) -} diff --git a/vendor/github.com/goccy/go-json/error.go b/vendor/github.com/goccy/go-json/error.go deleted file mode 100644 index 5b2dcee50..000000000 --- a/vendor/github.com/goccy/go-json/error.go +++ /dev/null @@ -1,41 +0,0 @@ -package json - -import ( - "github.com/goccy/go-json/internal/errors" -) - -// Before Go 1.2, an InvalidUTF8Error was returned by Marshal when -// attempting to encode a string value with invalid UTF-8 sequences. -// As of Go 1.2, Marshal instead coerces the string to valid UTF-8 by -// replacing invalid bytes with the Unicode replacement rune U+FFFD. -// -// Deprecated: No longer used; kept for compatibility. -type InvalidUTF8Error = errors.InvalidUTF8Error - -// An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. -// (The argument to Unmarshal must be a non-nil pointer.) -type InvalidUnmarshalError = errors.InvalidUnmarshalError - -// A MarshalerError represents an error from calling a MarshalJSON or MarshalText method. -type MarshalerError = errors.MarshalerError - -// A SyntaxError is a description of a JSON syntax error. -type SyntaxError = errors.SyntaxError - -// An UnmarshalFieldError describes a JSON object key that -// led to an unexported (and therefore unwritable) struct field. -// -// Deprecated: No longer used; kept for compatibility. -type UnmarshalFieldError = errors.UnmarshalFieldError - -// An UnmarshalTypeError describes a JSON value that was -// not appropriate for a value of a specific Go type. -type UnmarshalTypeError = errors.UnmarshalTypeError - -// An UnsupportedTypeError is returned by Marshal when attempting -// to encode an unsupported value type. -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 deleted file mode 100644 index b6876cf0d..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go +++ /dev/null @@ -1,41 +0,0 @@ -package decoder - -import ( - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -type anonymousFieldDecoder struct { - structType *runtime.Type - offset uintptr - dec Decoder -} - -func newAnonymousFieldDecoder(structType *runtime.Type, offset uintptr, dec Decoder) *anonymousFieldDecoder { - return &anonymousFieldDecoder{ - structType: structType, - offset: offset, - dec: dec, - } -} - -func (d *anonymousFieldDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - if *(*unsafe.Pointer)(p) == nil { - *(*unsafe.Pointer)(p) = unsafe_New(d.structType) - } - p = *(*unsafe.Pointer)(p) - return d.dec.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+d.offset)) -} - -func (d *anonymousFieldDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - if *(*unsafe.Pointer)(p) == nil { - *(*unsafe.Pointer)(p) = unsafe_New(d.structType) - } - 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 deleted file mode 100644 index 4b23ed43f..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/array.go +++ /dev/null @@ -1,176 +0,0 @@ -package decoder - -import ( - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type arrayDecoder struct { - elemType *runtime.Type - size uintptr - valueDecoder Decoder - alen int - structName string - fieldName string - zeroValue unsafe.Pointer -} - -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)) - return &arrayDecoder{ - valueDecoder: dec, - elemType: elemType, - size: elemType.Size(), - alen: alen, - structName: structName, - fieldName: fieldName, - zeroValue: zeroValue, - } -} - -func (d *arrayDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - case 'n': - if err := nullBytes(s); err != nil { - return err - } - return nil - case '[': - idx := 0 - s.cursor++ - if s.skipWhiteSpace() == ']' { - for idx < d.alen { - *(*unsafe.Pointer)(unsafe.Pointer(uintptr(p) + uintptr(idx)*d.size)) = d.zeroValue - idx++ - } - s.cursor++ - return nil - } - for { - if idx < d.alen { - if err := d.valueDecoder.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+uintptr(idx)*d.size)); err != nil { - return err - } - } else { - if err := s.skipValue(depth); err != nil { - return err - } - } - idx++ - switch s.skipWhiteSpace() { - case ']': - for idx < d.alen { - *(*unsafe.Pointer)(unsafe.Pointer(uintptr(p) + uintptr(idx)*d.size)) = d.zeroValue - idx++ - } - s.cursor++ - return nil - case ',': - s.cursor++ - continue - case nul: - if s.read() { - s.cursor++ - continue - } - goto ERROR - default: - goto ERROR - } - } - case nul: - if s.read() { - continue - } - goto ERROR - default: - goto ERROR - } - s.cursor++ - } -ERROR: - return errors.ErrUnexpectedEndOfJSON("array", s.totalOffset()) -} - -func (d *arrayDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - case '[': - idx := 0 - cursor++ - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == ']' { - for idx < d.alen { - *(*unsafe.Pointer)(unsafe.Pointer(uintptr(p) + uintptr(idx)*d.size)) = d.zeroValue - idx++ - } - cursor++ - return cursor, nil - } - for { - if idx < d.alen { - c, err := d.valueDecoder.Decode(ctx, cursor, depth, unsafe.Pointer(uintptr(p)+uintptr(idx)*d.size)) - if err != nil { - return 0, err - } - cursor = c - } else { - c, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - cursor = c - } - idx++ - cursor = skipWhiteSpace(buf, cursor) - switch buf[cursor] { - case ']': - for idx < d.alen { - *(*unsafe.Pointer)(unsafe.Pointer(uintptr(p) + uintptr(idx)*d.size)) = d.zeroValue - idx++ - } - cursor++ - return cursor, nil - case ',': - cursor++ - continue - default: - return 0, errors.ErrInvalidCharacter(buf[cursor], "array", cursor) - } - } - default: - return 0, errors.ErrUnexpectedEndOfJSON("array", cursor) - } - } -} - -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 c53e6ad9f..000000000 --- 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 deleted file mode 100644 index ba6cf5bc4..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/bool.go +++ /dev/null @@ -1,83 +0,0 @@ -package decoder - -import ( - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type boolDecoder struct { - structName string - fieldName string -} - -func newBoolDecoder(structName, fieldName string) *boolDecoder { - return &boolDecoder{structName: structName, fieldName: fieldName} -} - -func (d *boolDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - c := s.skipWhiteSpace() - for { - switch c { - case 't': - if err := trueBytes(s); err != nil { - return err - } - **(**bool)(unsafe.Pointer(&p)) = true - return nil - case 'f': - if err := falseBytes(s); err != nil { - return err - } - **(**bool)(unsafe.Pointer(&p)) = false - return nil - case 'n': - if err := nullBytes(s); err != nil { - return err - } - return nil - case nul: - if s.read() { - c = s.char() - continue - } - goto ERROR - } - break - } -ERROR: - return errors.ErrUnexpectedEndOfJSON("bool", s.totalOffset()) -} - -func (d *boolDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - switch buf[cursor] { - case 't': - if err := validateTrue(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**bool)(unsafe.Pointer(&p)) = true - return cursor, nil - case 'f': - if err := validateFalse(buf, cursor); err != nil { - return 0, err - } - cursor += 5 - **(**bool)(unsafe.Pointer(&p)) = false - return cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - } - 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 deleted file mode 100644 index 939bf4327..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/bytes.go +++ /dev/null @@ -1,118 +0,0 @@ -package decoder - -import ( - "encoding/base64" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type bytesDecoder struct { - typ *runtime.Type - sliceDecoder Decoder - stringDecoder *stringDecoder - structName string - fieldName string -} - -func byteUnmarshalerSliceDecoder(typ *runtime.Type, structName string, fieldName string) Decoder { - var unmarshalDecoder Decoder - switch { - case runtime.PtrTo(typ).Implements(unmarshalJSONType): - 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) - } - return newSliceDecoder(unmarshalDecoder, typ, 1, structName, fieldName) -} - -func newBytesDecoder(typ *runtime.Type, structName string, fieldName string) *bytesDecoder { - return &bytesDecoder{ - typ: typ, - sliceDecoder: byteUnmarshalerSliceDecoder(typ, structName, fieldName), - stringDecoder: newStringDecoder(structName, fieldName), - structName: structName, - fieldName: fieldName, - } -} - -func (d *bytesDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamBinary(s, depth, p) - if err != nil { - return err - } - if bytes == nil { - s.reset() - return nil - } - decodedLen := base64.StdEncoding.DecodedLen(len(bytes)) - buf := make([]byte, decodedLen) - n, err := base64.StdEncoding.Decode(buf, bytes) - if err != nil { - return err - } - *(*[]byte)(p) = buf[:n] - s.reset() - return nil -} - -func (d *bytesDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeBinary(ctx, cursor, depth, p) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - decodedLen := base64.StdEncoding.DecodedLen(len(bytes)) - b := make([]byte, decodedLen) - n, err := base64.StdEncoding.Decode(b, bytes) - if err != nil { - return 0, err - } - *(*[]byte)(p) = b[:n] - 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 == '[' { - if d.sliceDecoder == nil { - return nil, &errors.UnmarshalTypeError{ - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - } - err := d.sliceDecoder.DecodeStream(s, depth, p) - return nil, err - } - return d.stringDecoder.decodeStreamByte(s) -} - -func (d *bytesDecoder) decodeBinary(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) ([]byte, int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == '[' { - if d.sliceDecoder == nil { - return nil, 0, &errors.UnmarshalTypeError{ - Type: runtime.RType2Type(d.typ), - Offset: cursor, - } - } - c, err := d.sliceDecoder.Decode(ctx, cursor, depth, p) - if err != nil { - return nil, 0, err - } - return nil, c, nil - } - return d.stringDecoder.decodeByte(buf, cursor) -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/compile.go b/vendor/github.com/goccy/go-json/internal/decoder/compile.go deleted file mode 100644 index fab643764..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/compile.go +++ /dev/null @@ -1,487 +0,0 @@ -package decoder - -import ( - "encoding/json" - "fmt" - "reflect" - "strings" - "sync/atomic" - "unicode" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -var ( - jsonNumberType = reflect.TypeOf(json.Number("")) - typeAddr *runtime.TypeAddr - cachedDecoderMap unsafe.Pointer // map[uintptr]decoder - cachedDecoder []Decoder -) - -func init() { - typeAddr = runtime.AnalyzeTypeAddr() - if typeAddr == nil { - typeAddr = &runtime.TypeAddr{} - } - cachedDecoder = make([]Decoder, typeAddr.AddrRange>>typeAddr.AddrShift+1) -} - -func loadDecoderMap() map[uintptr]Decoder { - p := atomic.LoadPointer(&cachedDecoderMap) - return *(*map[uintptr]Decoder)(unsafe.Pointer(&p)) -} - -func storeDecoder(typ uintptr, dec Decoder, m map[uintptr]Decoder) { - newDecoderMap := make(map[uintptr]Decoder, len(m)+1) - newDecoderMap[typ] = dec - - for k, v := range m { - newDecoderMap[k] = v - } - - atomic.StorePointer(&cachedDecoderMap, *(*unsafe.Pointer)(unsafe.Pointer(&newDecoderMap))) -} - -func compileToGetDecoderSlowPath(typeptr uintptr, typ *runtime.Type) (Decoder, error) { - decoderMap := loadDecoderMap() - if dec, exists := decoderMap[typeptr]; exists { - return dec, nil - } - - dec, err := compileHead(typ, map[uintptr]Decoder{}) - if err != nil { - return nil, err - } - storeDecoder(typeptr, dec, decoderMap) - return dec, nil -} - -func compileHead(typ *runtime.Type, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - switch { - case implementsUnmarshalJSONType(runtime.PtrTo(typ)): - return newUnmarshalJSONDecoder(runtime.PtrTo(typ), "", ""), nil - case runtime.PtrTo(typ).Implements(unmarshalTextType): - return newUnmarshalTextDecoder(runtime.PtrTo(typ), "", ""), nil - } - return compile(typ.Elem(), "", "", structTypeToDecoder) -} - -func compile(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - switch { - case implementsUnmarshalJSONType(runtime.PtrTo(typ)): - return newUnmarshalJSONDecoder(runtime.PtrTo(typ), structName, fieldName), nil - case runtime.PtrTo(typ).Implements(unmarshalTextType): - return newUnmarshalTextDecoder(runtime.PtrTo(typ), structName, fieldName), nil - } - - switch typ.Kind() { - case reflect.Ptr: - return compilePtr(typ, structName, fieldName, structTypeToDecoder) - case reflect.Struct: - return compileStruct(typ, structName, fieldName, structTypeToDecoder) - case reflect.Slice: - elem := typ.Elem() - if elem.Kind() == reflect.Uint8 { - return compileBytes(elem, structName, fieldName) - } - return compileSlice(typ, structName, fieldName, structTypeToDecoder) - case reflect.Array: - return compileArray(typ, structName, fieldName, structTypeToDecoder) - case reflect.Map: - return compileMap(typ, structName, fieldName, structTypeToDecoder) - case reflect.Interface: - return compileInterface(typ, structName, fieldName) - case reflect.Uintptr: - return compileUint(typ, structName, fieldName) - case reflect.Int: - return compileInt(typ, structName, fieldName) - case reflect.Int8: - return compileInt8(typ, structName, fieldName) - case reflect.Int16: - return compileInt16(typ, structName, fieldName) - case reflect.Int32: - return compileInt32(typ, structName, fieldName) - case reflect.Int64: - return compileInt64(typ, structName, fieldName) - case reflect.Uint: - return compileUint(typ, structName, fieldName) - case reflect.Uint8: - return compileUint8(typ, structName, fieldName) - case reflect.Uint16: - return compileUint16(typ, structName, fieldName) - case reflect.Uint32: - return compileUint32(typ, structName, fieldName) - case reflect.Uint64: - return compileUint64(typ, structName, fieldName) - case reflect.String: - return compileString(typ, structName, fieldName) - case reflect.Bool: - return compileBool(structName, fieldName) - case reflect.Float32: - return compileFloat32(structName, fieldName) - case reflect.Float64: - return compileFloat64(structName, fieldName) - case reflect.Func: - return compileFunc(typ, structName, fieldName) - } - return newInvalidDecoder(typ, structName, fieldName), nil -} - -func isStringTagSupportedType(typ *runtime.Type) bool { - switch { - case implementsUnmarshalJSONType(runtime.PtrTo(typ)): - return false - case runtime.PtrTo(typ).Implements(unmarshalTextType): - return false - } - switch typ.Kind() { - case reflect.Map: - return false - case reflect.Slice: - return false - case reflect.Array: - return false - case reflect.Struct: - return false - case reflect.Interface: - return false - } - return true -} - -func compileMapKey(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - 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 - } - for { - switch t := dec.(type) { - case *stringDecoder, *interfaceDecoder: - return dec, nil - case *boolDecoder, *intDecoder, *uintDecoder, *numberDecoder: - return newWrappedStringDecoder(typ, dec, structName, fieldName), nil - case *ptrDecoder: - dec = t.dec - default: - return newInvalidDecoder(typ, structName, fieldName), nil - } - } -} - -func compilePtr(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - dec, err := compile(typ.Elem(), structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - return newPtrDecoder(dec, typ.Elem(), structName, fieldName), nil -} - -func compileInt(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int)(p) = int(v) - }), nil -} - -func compileInt8(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int8)(p) = int8(v) - }), nil -} - -func compileInt16(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int16)(p) = int16(v) - }), nil -} - -func compileInt32(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int32)(p) = int32(v) - }), nil -} - -func compileInt64(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int64)(p) = v - }), nil -} - -func compileUint(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint)(p) = uint(v) - }), nil -} - -func compileUint8(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint8)(p) = uint8(v) - }), nil -} - -func compileUint16(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint16)(p) = uint16(v) - }), nil -} - -func compileUint32(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint32)(p) = uint32(v) - }), nil -} - -func compileUint64(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint64)(p) = v - }), nil -} - -func compileFloat32(structName, fieldName string) (Decoder, error) { - return newFloatDecoder(structName, fieldName, func(p unsafe.Pointer, v float64) { - *(*float32)(p) = float32(v) - }), nil -} - -func compileFloat64(structName, fieldName string) (Decoder, error) { - return newFloatDecoder(structName, fieldName, func(p unsafe.Pointer, v float64) { - *(*float64)(p) = v - }), nil -} - -func compileString(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - if typ == runtime.Type2RType(jsonNumberType) { - return newNumberDecoder(structName, fieldName, func(p unsafe.Pointer, v json.Number) { - *(*json.Number)(p) = v - }), nil - } - return newStringDecoder(structName, fieldName), nil -} - -func compileBool(structName, fieldName string) (Decoder, error) { - return newBoolDecoder(structName, fieldName), nil -} - -func compileBytes(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newBytesDecoder(typ, structName, fieldName), nil -} - -func compileSlice(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - elem := typ.Elem() - decoder, err := compile(elem, structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - return newSliceDecoder(decoder, elem, elem.Size(), structName, fieldName), nil -} - -func compileArray(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - elem := typ.Elem() - decoder, err := compile(elem, structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - return newArrayDecoder(decoder, elem, typ.Len(), structName, fieldName), nil -} - -func compileMap(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - keyDec, err := compileMapKey(typ.Key(), structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - valueDec, err := compile(typ.Elem(), structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - return newMapDecoder(typ, typ.Key(), keyDec, typ.Elem(), valueDec, structName, fieldName), nil -} - -func compileInterface(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newInterfaceDecoder(typ, structName, fieldName), nil -} - -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) { - continue - } - tags = append(tags, runtime.StructTagFromField(field)) - } - return tags -} - -func compileStruct(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - fieldNum := typ.NumField() - fieldMap := map[string]*structFieldSet{} - typeptr := uintptr(unsafe.Pointer(typ)) - if dec, exists := structTypeToDecoder[typeptr]; exists { - return dec, nil - } - 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) { - continue - } - isUnexportedField := unicode.IsLower([]rune(field.Name)[0]) - tag := runtime.StructTagFromField(field) - dec, err := compile(runtime.Type2RType(field.Type), structName, field.Name, structTypeToDecoder) - if err != nil { - return nil, err - } - if field.Anonymous && !tag.IsTaggedKey { - if stDec, ok := dec.(*structDecoder); ok { - if runtime.Type2RType(field.Type) == typ { - // 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) - } - } else if pdec, ok := dec.(*ptrDecoder); ok { - contentDec := pdec.contentDecoder() - if pdec.typ == typ { - // recursive definition - continue - } - var fieldSetErr error - if isUnexportedField { - fieldSetErr = fmt.Errorf( - "json: cannot set embedded pointer to unexported struct: %v", - field.Type.Elem(), - ) - } - if dec, ok := contentDec.(*structDecoder); ok { - for k, v := range dec.fieldMap { - if tags.ExistsKey(k) { - 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, - } - 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)) { - dec = newWrappedStringDecoder(runtime.Type2RType(field.Type), dec, structName, field.Name) - } - var key string - if tag.Key != "" { - key = tag.Key - } else { - key = field.Name - } - fieldSet := &structFieldSet{ - dec: dec, - offset: field.Offset, - isTaggedKey: tag.IsTaggedKey, - 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 - } - } - delete(structTypeToDecoder, typeptr) - structDec.tryOptimize() - 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 deleted file mode 100644 index eb7e2b134..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go +++ /dev/null @@ -1,29 +0,0 @@ -//go:build !race -// +build !race - -package decoder - -import ( - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -func CompileToGetDecoder(typ *runtime.Type) (Decoder, error) { - typeptr := uintptr(unsafe.Pointer(typ)) - if typeptr > typeAddr.MaxTypeAddr { - return compileToGetDecoderSlowPath(typeptr, typ) - } - - index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift - if dec := cachedDecoder[index]; dec != nil { - return dec, nil - } - - dec, err := compileHead(typ, map[uintptr]Decoder{}) - if err != nil { - return nil, err - } - cachedDecoder[index] = dec - return dec, nil -} 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 deleted file mode 100644 index 49cdda4a1..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/compile_race.go +++ /dev/null @@ -1,37 +0,0 @@ -//go:build race -// +build race - -package decoder - -import ( - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -var decMu sync.RWMutex - -func CompileToGetDecoder(typ *runtime.Type) (Decoder, error) { - typeptr := uintptr(unsafe.Pointer(typ)) - if typeptr > typeAddr.MaxTypeAddr { - return compileToGetDecoderSlowPath(typeptr, typ) - } - - index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift - decMu.RLock() - if dec := cachedDecoder[index]; dec != nil { - decMu.RUnlock() - return dec, nil - } - decMu.RUnlock() - - dec, err := compileHead(typ, map[uintptr]Decoder{}) - if err != nil { - return nil, err - } - decMu.Lock() - cachedDecoder[index] = dec - decMu.Unlock() - return dec, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/context.go b/vendor/github.com/goccy/go-json/internal/decoder/context.go deleted file mode 100644 index cb2ffdafd..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/context.go +++ /dev/null @@ -1,254 +0,0 @@ -package decoder - -import ( - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type RuntimeContext struct { - Buf []byte - Option *Option -} - -var ( - runtimeContextPool = sync.Pool{ - New: func() interface{} { - return &RuntimeContext{ - Option: &Option{}, - } - }, - } -) - -func TakeRuntimeContext() *RuntimeContext { - return runtimeContextPool.Get().(*RuntimeContext) -} - -func ReleaseRuntimeContext(ctx *RuntimeContext) { - runtimeContextPool.Put(ctx) -} - -var ( - isWhiteSpace = [256]bool{} -) - -func init() { - isWhiteSpace[' '] = true - isWhiteSpace['\n'] = true - isWhiteSpace['\t'] = true - isWhiteSpace['\r'] = true -} - -func char(ptr unsafe.Pointer, offset int64) byte { - return *(*byte)(unsafe.Pointer(uintptr(ptr) + uintptr(offset))) -} - -func skipWhiteSpace(buf []byte, cursor int64) int64 { - for isWhiteSpace[buf[cursor]] { - cursor++ - } - return cursor -} - -func skipObject(buf []byte, cursor, depth int64) (int64, error) { - braceCount := 1 - for { - switch buf[cursor] { - case '{': - braceCount++ - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - case '}': - depth-- - braceCount-- - if braceCount == 0 { - return cursor + 1, nil - } - case '[': - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - case ']': - depth-- - case '"': - for { - cursor++ - switch buf[cursor] { - case '\\': - cursor++ - if buf[cursor] == nul { - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - goto SWITCH_OUT - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("object of object", cursor) - } - SWITCH_OUT: - cursor++ - } -} - -func skipArray(buf []byte, cursor, depth int64) (int64, error) { - bracketCount := 1 - for { - switch buf[cursor] { - case '[': - bracketCount++ - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - case ']': - bracketCount-- - depth-- - if bracketCount == 0 { - return cursor + 1, nil - } - case '{': - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - case '}': - depth-- - case '"': - for { - cursor++ - switch buf[cursor] { - case '\\': - cursor++ - if buf[cursor] == nul { - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - goto SWITCH_OUT - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("array of object", cursor) - } - SWITCH_OUT: - cursor++ - } -} - -func skipValue(buf []byte, cursor, depth int64) (int64, error) { - for { - switch buf[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case '{': - return skipObject(buf, cursor+1, depth+1) - case '[': - return skipArray(buf, cursor+1, depth+1) - case '"': - for { - cursor++ - switch buf[cursor] { - case '\\': - cursor++ - if buf[cursor] == nul { - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - return cursor + 1, nil - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - for { - cursor++ - if floatTable[buf[cursor]] { - continue - } - break - } - return cursor, nil - case 't': - if err := validateTrue(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - case 'f': - if err := validateFalse(buf, cursor); err != nil { - return 0, err - } - cursor += 5 - return cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - default: - return cursor, errors.ErrUnexpectedEndOfJSON("null", cursor) - } - } -} - -func validateTrue(buf []byte, cursor int64) error { - if cursor+3 >= int64(len(buf)) { - return errors.ErrUnexpectedEndOfJSON("true", cursor) - } - if buf[cursor+1] != 'r' { - return errors.ErrInvalidCharacter(buf[cursor+1], "true", cursor) - } - if buf[cursor+2] != 'u' { - return errors.ErrInvalidCharacter(buf[cursor+2], "true", cursor) - } - if buf[cursor+3] != 'e' { - return errors.ErrInvalidCharacter(buf[cursor+3], "true", cursor) - } - return nil -} - -func validateFalse(buf []byte, cursor int64) error { - if cursor+4 >= int64(len(buf)) { - return errors.ErrUnexpectedEndOfJSON("false", cursor) - } - if buf[cursor+1] != 'a' { - return errors.ErrInvalidCharacter(buf[cursor+1], "false", cursor) - } - if buf[cursor+2] != 'l' { - return errors.ErrInvalidCharacter(buf[cursor+2], "false", cursor) - } - if buf[cursor+3] != 's' { - return errors.ErrInvalidCharacter(buf[cursor+3], "false", cursor) - } - if buf[cursor+4] != 'e' { - return errors.ErrInvalidCharacter(buf[cursor+4], "false", cursor) - } - return nil -} - -func validateNull(buf []byte, cursor int64) error { - if cursor+3 >= int64(len(buf)) { - return errors.ErrUnexpectedEndOfJSON("null", cursor) - } - if buf[cursor+1] != 'u' { - return errors.ErrInvalidCharacter(buf[cursor+1], "null", cursor) - } - if buf[cursor+2] != 'l' { - return errors.ErrInvalidCharacter(buf[cursor+2], "null", cursor) - } - if buf[cursor+3] != 'l' { - return errors.ErrInvalidCharacter(buf[cursor+3], "null", cursor) - } - return nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/float.go b/vendor/github.com/goccy/go-json/internal/decoder/float.go deleted file mode 100644 index 9b2eb8b35..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/float.go +++ /dev/null @@ -1,170 +0,0 @@ -package decoder - -import ( - "strconv" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type floatDecoder struct { - op func(unsafe.Pointer, float64) - structName string - fieldName string -} - -func newFloatDecoder(structName, fieldName string, op func(unsafe.Pointer, float64)) *floatDecoder { - return &floatDecoder{op: op, structName: structName, fieldName: fieldName} -} - -var ( - floatTable = [256]bool{ - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - '.': true, - 'e': true, - 'E': true, - '+': true, - '-': true, - } - - validEndNumberChar = [256]bool{ - nul: true, - ' ': true, - '\t': true, - '\r': true, - '\n': true, - ',': true, - ':': true, - '}': true, - ']': true, - } -) - -func floatBytes(s *Stream) []byte { - start := s.cursor - for { - s.cursor++ - if floatTable[s.char()] { - continue - } else if s.char() == nul { - if s.read() { - s.cursor-- // for retry current character - continue - } - } - break - } - return s.buf[start:s.cursor] -} - -func (d *floatDecoder) decodeStreamByte(s *Stream) ([]byte, error) { - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return floatBytes(s), nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - goto ERROR - default: - goto ERROR - } - } -ERROR: - return nil, errors.ErrUnexpectedEndOfJSON("float", s.totalOffset()) -} - -func (d *floatDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := cursor - cursor++ - for floatTable[buf[cursor]] { - cursor++ - } - num := buf[start:cursor] - return num, cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - default: - return nil, 0, errors.ErrUnexpectedEndOfJSON("float", cursor) - } - } -} - -func (d *floatDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - return nil - } - str := *(*string)(unsafe.Pointer(&bytes)) - f64, err := strconv.ParseFloat(str, 64) - if err != nil { - return errors.ErrSyntax(err.Error(), s.totalOffset()) - } - d.op(p, f64) - return nil -} - -func (d *floatDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - bytes, c, err := d.decodeByte(buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - if !validEndNumberChar[buf[cursor]] { - return 0, errors.ErrUnexpectedEndOfJSON("float", cursor) - } - s := *(*string)(unsafe.Pointer(&bytes)) - f64, err := strconv.ParseFloat(s, 64) - if err != nil { - return 0, errors.ErrSyntax(err.Error(), cursor) - } - 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 deleted file mode 100644 index 4cc12ca81..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/func.go +++ /dev/null @@ -1,146 +0,0 @@ -package decoder - -import ( - "bytes" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type funcDecoder struct { - typ *runtime.Type - structName string - fieldName string -} - -func newFuncDecoder(typ *runtime.Type, structName, fieldName string) *funcDecoder { - fnDecoder := &funcDecoder{typ, structName, fieldName} - return fnDecoder -} - -func (d *funcDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - s.skipWhiteSpace() - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - if len(src) > 0 { - switch src[0] { - case '"': - return &errors.UnmarshalTypeError{ - Value: "string", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '[': - return &errors.UnmarshalTypeError{ - Value: "array", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '{': - return &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return &errors.UnmarshalTypeError{ - Value: "number", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case 'n': - if err := nullBytes(s); err != nil { - return err - } - *(*unsafe.Pointer)(p) = nil - return nil - case 't': - if err := trueBytes(s); err == nil { - return &errors.UnmarshalTypeError{ - Value: "boolean", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - } - case 'f': - if err := falseBytes(s); err == nil { - return &errors.UnmarshalTypeError{ - Value: "boolean", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - } - } - } - return errors.ErrInvalidBeginningOfValue(s.buf[s.cursor], s.totalOffset()) -} - -func (d *funcDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - if len(src) > 0 { - switch src[0] { - case '"': - return 0, &errors.UnmarshalTypeError{ - Value: "string", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '[': - return 0, &errors.UnmarshalTypeError{ - Value: "array", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '{': - return 0, &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return 0, &errors.UnmarshalTypeError{ - Value: "number", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case 'n': - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return end, nil - } - case 't': - if err := validateTrue(buf, start); err == nil { - return 0, &errors.UnmarshalTypeError{ - Value: "boolean", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - } - case 'f': - if err := validateFalse(buf, start); err == nil { - return 0, &errors.UnmarshalTypeError{ - Value: "boolean", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - } - } - } - 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 deleted file mode 100644 index 1a7f08199..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/int.go +++ /dev/null @@ -1,246 +0,0 @@ -package decoder - -import ( - "fmt" - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type intDecoder struct { - typ *runtime.Type - kind reflect.Kind - op func(unsafe.Pointer, int64) - structName string - fieldName string -} - -func newIntDecoder(typ *runtime.Type, structName, fieldName string, op func(unsafe.Pointer, int64)) *intDecoder { - return &intDecoder{ - typ: typ, - kind: typ.Kind(), - op: op, - structName: structName, - fieldName: fieldName, - } -} - -func (d *intDecoder) typeError(buf []byte, offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: fmt.Sprintf("number %s", string(buf)), - Type: runtime.RType2Type(d.typ), - Struct: d.structName, - Field: d.fieldName, - Offset: offset, - } -} - -var ( - pow10i64 = [...]int64{ - 1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, - } - pow10i64Len = len(pow10i64) -) - -func (d *intDecoder) parseInt(b []byte) (int64, error) { - isNegative := false - if b[0] == '-' { - b = b[1:] - isNegative = true - } - maxDigit := len(b) - if maxDigit > pow10i64Len { - return 0, fmt.Errorf("invalid length of number") - } - sum := int64(0) - for i := 0; i < maxDigit; i++ { - c := int64(b[i]) - 48 - digitValue := pow10i64[maxDigit-i-1] - sum += c * digitValue - } - if isNegative { - return -1 * sum, nil - } - return sum, nil -} - -var ( - numTable = [256]bool{ - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - } -) - -var ( - numZeroBuf = []byte{'0'} -) - -func (d *intDecoder) decodeStreamByte(s *Stream) ([]byte, error) { - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '-': - start := s.cursor - for { - s.cursor++ - if numTable[s.char()] { - continue - } else if s.char() == nul { - if s.read() { - s.cursor-- // for retry current character - continue - } - } - break - } - num := s.buf[start:s.cursor] - if len(num) < 2 { - goto ERROR - } - return num, nil - case '0': - s.cursor++ - return numZeroBuf, nil - case '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := s.cursor - for { - s.cursor++ - if numTable[s.char()] { - continue - } else if s.char() == nul { - if s.read() { - s.cursor-- // for retry current character - continue - } - } - break - } - num := s.buf[start:s.cursor] - return num, nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - goto ERROR - default: - return nil, d.typeError([]byte{s.char()}, s.totalOffset()) - } - } -ERROR: - return nil, errors.ErrUnexpectedEndOfJSON("number(integer)", s.totalOffset()) -} - -func (d *intDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - b := (*sliceHeader)(unsafe.Pointer(&buf)).data - for { - switch char(b, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case '0': - cursor++ - return numZeroBuf, cursor, nil - case '-', '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := cursor - cursor++ - for numTable[char(b, cursor)] { - cursor++ - } - num := buf[start:cursor] - return num, cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - default: - return nil, 0, d.typeError([]byte{char(b, cursor)}, cursor) - } - } -} - -func (d *intDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - return nil - } - i64, err := d.parseInt(bytes) - if err != nil { - return d.typeError(bytes, s.totalOffset()) - } - switch d.kind { - case reflect.Int8: - 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 { - return d.typeError(bytes, s.totalOffset()) - } - case reflect.Int32: - if i64 < -1*(1<<31) || (1<<31) <= i64 { - return d.typeError(bytes, s.totalOffset()) - } - } - d.op(p, i64) - s.reset() - return nil -} - -func (d *intDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - - i64, err := d.parseInt(bytes) - if err != nil { - return 0, d.typeError(bytes, cursor) - } - switch d.kind { - case reflect.Int8: - 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 { - return 0, d.typeError(bytes, cursor) - } - case reflect.Int32: - 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 deleted file mode 100644 index 45c69ab8c..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/interface.go +++ /dev/null @@ -1,528 +0,0 @@ -package decoder - -import ( - "bytes" - "encoding" - "encoding/json" - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type interfaceDecoder struct { - typ *runtime.Type - structName string - fieldName string - sliceDecoder *sliceDecoder - mapDecoder *mapDecoder - floatDecoder *floatDecoder - numberDecoder *numberDecoder - stringDecoder *stringDecoder -} - -func newEmptyInterfaceDecoder(structName, fieldName string) *interfaceDecoder { - ifaceDecoder := &interfaceDecoder{ - typ: emptyInterfaceType, - structName: structName, - fieldName: fieldName, - floatDecoder: newFloatDecoder(structName, fieldName, func(p unsafe.Pointer, v float64) { - *(*interface{})(p) = v - }), - numberDecoder: newNumberDecoder(structName, fieldName, func(p unsafe.Pointer, v json.Number) { - *(*interface{})(p) = v - }), - stringDecoder: newStringDecoder(structName, fieldName), - } - ifaceDecoder.sliceDecoder = newSliceDecoder( - ifaceDecoder, - emptyInterfaceType, - emptyInterfaceType.Size(), - structName, fieldName, - ) - ifaceDecoder.mapDecoder = newMapDecoder( - interfaceMapType, - stringType, - ifaceDecoder.stringDecoder, - interfaceMapType.Elem(), - ifaceDecoder, - structName, - fieldName, - ) - return ifaceDecoder -} - -func newInterfaceDecoder(typ *runtime.Type, structName, fieldName string) *interfaceDecoder { - emptyIfaceDecoder := newEmptyInterfaceDecoder(structName, fieldName) - stringDecoder := newStringDecoder(structName, fieldName) - return &interfaceDecoder{ - typ: typ, - structName: structName, - fieldName: fieldName, - sliceDecoder: newSliceDecoder( - emptyIfaceDecoder, - emptyInterfaceType, - emptyInterfaceType.Size(), - structName, fieldName, - ), - mapDecoder: newMapDecoder( - interfaceMapType, - stringType, - stringDecoder, - interfaceMapType.Elem(), - emptyIfaceDecoder, - structName, - fieldName, - ), - floatDecoder: newFloatDecoder(structName, fieldName, func(p unsafe.Pointer, v float64) { - *(*interface{})(p) = v - }), - numberDecoder: newNumberDecoder(structName, fieldName, func(p unsafe.Pointer, v json.Number) { - *(*interface{})(p) = v - }), - stringDecoder: stringDecoder, - } -} - -func (d *interfaceDecoder) numDecoder(s *Stream) Decoder { - if s.UseNumber { - return d.numberDecoder - } - return d.floatDecoder -} - -var ( - emptyInterfaceType = runtime.Type2RType(reflect.TypeOf((*interface{})(nil)).Elem()) - EmptyInterfaceType = emptyInterfaceType - interfaceMapType = runtime.Type2RType( - reflect.TypeOf((*map[string]interface{})(nil)).Elem(), - ) - stringType = runtime.Type2RType( - reflect.TypeOf(""), - ) -) - -func decodeStreamUnmarshaler(s *Stream, depth int64, unmarshaler json.Unmarshaler) error { - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalJSON(dst); err != nil { - return err - } - return nil -} - -func decodeStreamUnmarshalerContext(s *Stream, depth int64, unmarshaler unmarshalerContext) error { - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalJSON(s.Option.Context, dst); err != nil { - return err - } - return nil -} - -func decodeUnmarshaler(buf []byte, cursor, depth int64, unmarshaler json.Unmarshaler) (int64, error) { - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalJSON(dst); err != nil { - return 0, err - } - return end, nil -} - -func decodeUnmarshalerContext(ctx *RuntimeContext, buf []byte, cursor, depth int64, unmarshaler unmarshalerContext) (int64, error) { - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalJSON(ctx.Option.Context, dst); err != nil { - return 0, err - } - return end, nil -} - -func decodeStreamTextUnmarshaler(s *Stream, depth int64, unmarshaler encoding.TextUnmarshaler, p unsafe.Pointer) error { - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return nil - } - - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalText(dst); err != nil { - return err - } - return nil -} - -func decodeTextUnmarshaler(buf []byte, cursor, depth int64, unmarshaler encoding.TextUnmarshaler, p unsafe.Pointer) (int64, error) { - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return end, nil - } - if s, ok := unquoteBytes(src); ok { - src = s - } - if err := unmarshaler.UnmarshalText(src); err != nil { - return 0, err - } - return end, nil -} - -func (d *interfaceDecoder) decodeStreamEmptyInterface(s *Stream, depth int64, p unsafe.Pointer) error { - c := s.skipWhiteSpace() - for { - switch c { - case '{': - var v map[string]interface{} - ptr := unsafe.Pointer(&v) - if err := d.mapDecoder.DecodeStream(s, depth, ptr); err != nil { - return err - } - *(*interface{})(p) = v - return nil - case '[': - var v []interface{} - ptr := unsafe.Pointer(&v) - if err := d.sliceDecoder.DecodeStream(s, depth, ptr); err != nil { - return err - } - *(*interface{})(p) = v - return nil - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return d.numDecoder(s).DecodeStream(s, depth, p) - case '"': - s.cursor++ - start := s.cursor - for { - switch s.char() { - case '\\': - if _, err := decodeEscapeString(s, nil); err != nil { - return err - } - case '"': - literal := s.buf[start:s.cursor] - s.cursor++ - *(*interface{})(p) = string(literal) - return nil - case nul: - if s.read() { - continue - } - return errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - s.cursor++ - } - case 't': - if err := trueBytes(s); err != nil { - return err - } - **(**interface{})(unsafe.Pointer(&p)) = true - return nil - case 'f': - if err := falseBytes(s); err != nil { - return err - } - **(**interface{})(unsafe.Pointer(&p)) = false - return nil - case 'n': - if err := nullBytes(s); err != nil { - return err - } - *(*interface{})(p) = nil - return nil - case nul: - if s.read() { - c = s.char() - continue - } - } - break - } - return errors.ErrInvalidBeginningOfValue(c, s.totalOffset()) -} - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -func (d *interfaceDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - runtimeInterfaceValue := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: p, - })) - rv := reflect.ValueOf(runtimeInterfaceValue) - if rv.NumMethod() > 0 && rv.CanInterface() { - if u, ok := rv.Interface().(unmarshalerContext); ok { - return decodeStreamUnmarshalerContext(s, depth, u) - } - if u, ok := rv.Interface().(json.Unmarshaler); ok { - return decodeStreamUnmarshaler(s, depth, u) - } - if u, ok := rv.Interface().(encoding.TextUnmarshaler); ok { - return decodeStreamTextUnmarshaler(s, depth, u, p) - } - if s.skipWhiteSpace() == 'n' { - if err := nullBytes(s); err != nil { - return err - } - *(*interface{})(p) = nil - return nil - } - return d.errUnmarshalType(rv.Type(), s.totalOffset()) - } - iface := rv.Interface() - ifaceHeader := (*emptyInterface)(unsafe.Pointer(&iface)) - typ := ifaceHeader.typ - if ifaceHeader.ptr == nil || d.typ == typ || typ == nil { - // concrete type is empty interface - return d.decodeStreamEmptyInterface(s, depth, p) - } - if typ.Kind() == reflect.Ptr && typ.Elem() == d.typ || typ.Kind() != reflect.Ptr { - return d.decodeStreamEmptyInterface(s, depth, p) - } - if s.skipWhiteSpace() == 'n' { - if err := nullBytes(s); err != nil { - return err - } - *(*interface{})(p) = nil - return nil - } - decoder, err := CompileToGetDecoder(typ) - if err != nil { - return err - } - return decoder.DecodeStream(s, depth, ifaceHeader.ptr) -} - -func (d *interfaceDecoder) errUnmarshalType(typ reflect.Type, offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: typ.String(), - Type: typ, - Offset: offset, - Struct: d.structName, - Field: d.fieldName, - } -} - -func (d *interfaceDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - runtimeInterfaceValue := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: p, - })) - rv := reflect.ValueOf(runtimeInterfaceValue) - if rv.NumMethod() > 0 && rv.CanInterface() { - if u, ok := rv.Interface().(unmarshalerContext); ok { - return decodeUnmarshalerContext(ctx, buf, cursor, depth, u) - } - if u, ok := rv.Interface().(json.Unmarshaler); ok { - return decodeUnmarshaler(buf, cursor, depth, u) - } - if u, ok := rv.Interface().(encoding.TextUnmarshaler); ok { - return decodeTextUnmarshaler(buf, cursor, depth, u, p) - } - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == 'n' { - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**interface{})(unsafe.Pointer(&p)) = nil - return cursor, nil - } - return 0, d.errUnmarshalType(rv.Type(), cursor) - } - - iface := rv.Interface() - ifaceHeader := (*emptyInterface)(unsafe.Pointer(&iface)) - typ := ifaceHeader.typ - if ifaceHeader.ptr == nil || d.typ == typ || typ == nil { - // concrete type is empty interface - return d.decodeEmptyInterface(ctx, cursor, depth, p) - } - if typ.Kind() == reflect.Ptr && typ.Elem() == d.typ || typ.Kind() != reflect.Ptr { - return d.decodeEmptyInterface(ctx, cursor, depth, p) - } - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == 'n' { - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**interface{})(unsafe.Pointer(&p)) = nil - return cursor, nil - } - decoder, err := CompileToGetDecoder(typ) - if err != nil { - return 0, err - } - return decoder.Decode(ctx, cursor, depth, ifaceHeader.ptr) -} - -func (d *interfaceDecoder) decodeEmptyInterface(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - switch buf[cursor] { - case '{': - var v map[string]interface{} - ptr := unsafe.Pointer(&v) - cursor, err := d.mapDecoder.Decode(ctx, cursor, depth, ptr) - if err != nil { - return 0, err - } - **(**interface{})(unsafe.Pointer(&p)) = v - return cursor, nil - case '[': - var v []interface{} - ptr := unsafe.Pointer(&v) - cursor, err := d.sliceDecoder.Decode(ctx, cursor, depth, ptr) - if err != nil { - return 0, err - } - **(**interface{})(unsafe.Pointer(&p)) = v - return cursor, nil - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return d.floatDecoder.Decode(ctx, cursor, depth, p) - case '"': - var v string - ptr := unsafe.Pointer(&v) - cursor, err := d.stringDecoder.Decode(ctx, cursor, depth, ptr) - if err != nil { - return 0, err - } - **(**interface{})(unsafe.Pointer(&p)) = v - return cursor, nil - case 't': - if err := validateTrue(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**interface{})(unsafe.Pointer(&p)) = true - return cursor, nil - case 'f': - if err := validateFalse(buf, cursor); err != nil { - return 0, err - } - cursor += 5 - **(**interface{})(unsafe.Pointer(&p)) = false - return cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**interface{})(unsafe.Pointer(&p)) = nil - return cursor, nil - } - 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 4c9721b09..000000000 --- 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 deleted file mode 100644 index 07a9caea6..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/map.go +++ /dev/null @@ -1,280 +0,0 @@ -package decoder - -import ( - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type mapDecoder struct { - mapType *runtime.Type - keyType *runtime.Type - valueType *runtime.Type - canUseAssignFaststrType bool - keyDecoder Decoder - valueDecoder Decoder - structName string - fieldName string -} - -func newMapDecoder(mapType *runtime.Type, keyType *runtime.Type, keyDec Decoder, valueType *runtime.Type, valueDec Decoder, structName, fieldName string) *mapDecoder { - return &mapDecoder{ - mapType: mapType, - keyDecoder: keyDec, - keyType: keyType, - canUseAssignFaststrType: canUseAssignFaststrType(keyType, valueType), - valueType: valueType, - valueDecoder: valueDec, - structName: structName, - fieldName: fieldName, - } -} - -const ( - mapMaxElemSize = 128 -) - -// See detail: https://github.com/goccy/go-json/pull/283 -func canUseAssignFaststrType(key *runtime.Type, value *runtime.Type) bool { - indirectElem := value.Size() > mapMaxElemSize - if indirectElem { - return false - } - return key.Kind() == reflect.String -} - -//go:linkname makemap reflect.makemap -func makemap(*runtime.Type, int) unsafe.Pointer - -//nolint:golint -//go:linkname mapassign_faststr runtime.mapassign_faststr -//go:noescape -func mapassign_faststr(t *runtime.Type, m unsafe.Pointer, s string) unsafe.Pointer - -//go:linkname mapassign reflect.mapassign -//go:noescape -func mapassign(t *runtime.Type, m unsafe.Pointer, k, v unsafe.Pointer) - -func (d *mapDecoder) mapassign(t *runtime.Type, m, k, v unsafe.Pointer) { - if d.canUseAssignFaststrType { - mapV := mapassign_faststr(t, m, *(*string)(k)) - typedmemmove(d.valueType, mapV, v) - } else { - mapassign(t, m, k, v) - } -} - -func (d *mapDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - - switch s.skipWhiteSpace() { - case 'n': - if err := nullBytes(s); err != nil { - return err - } - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = nil - return nil - case '{': - default: - return errors.ErrExpected("{ character for map value", s.totalOffset()) - } - mapValue := *(*unsafe.Pointer)(p) - if mapValue == nil { - mapValue = makemap(d.mapType, 0) - } - s.cursor++ - if s.skipWhiteSpace() == '}' { - *(*unsafe.Pointer)(p) = mapValue - s.cursor++ - return nil - } - for { - k := unsafe_New(d.keyType) - if err := d.keyDecoder.DecodeStream(s, depth, k); err != nil { - return err - } - s.skipWhiteSpace() - if !s.equalChar(':') { - return errors.ErrExpected("colon after object key", s.totalOffset()) - } - s.cursor++ - v := unsafe_New(d.valueType) - if err := d.valueDecoder.DecodeStream(s, depth, v); err != nil { - return err - } - d.mapassign(d.mapType, mapValue, k, v) - s.skipWhiteSpace() - if s.equalChar('}') { - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = mapValue - s.cursor++ - return nil - } - if !s.equalChar(',') { - return errors.ErrExpected("comma after object value", s.totalOffset()) - } - s.cursor++ - } -} - -func (d *mapDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - - cursor = skipWhiteSpace(buf, cursor) - buflen := int64(len(buf)) - if buflen < 2 { - return 0, errors.ErrExpected("{} for map", cursor) - } - switch buf[cursor] { - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = nil - return cursor, nil - case '{': - default: - return 0, errors.ErrExpected("{ character for map value", cursor) - } - cursor++ - cursor = skipWhiteSpace(buf, cursor) - mapValue := *(*unsafe.Pointer)(p) - if mapValue == nil { - mapValue = makemap(d.mapType, 0) - } - if buf[cursor] == '}' { - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = mapValue - cursor++ - return cursor, nil - } - for { - k := unsafe_New(d.keyType) - keyCursor, err := d.keyDecoder.Decode(ctx, cursor, depth, k) - if err != nil { - return 0, err - } - cursor = skipWhiteSpace(buf, keyCursor) - if buf[cursor] != ':' { - return 0, errors.ErrExpected("colon after object key", cursor) - } - cursor++ - v := unsafe_New(d.valueType) - valueCursor, err := d.valueDecoder.Decode(ctx, cursor, depth, v) - if err != nil { - return 0, err - } - d.mapassign(d.mapType, mapValue, k, v) - cursor = skipWhiteSpace(buf, valueCursor) - if buf[cursor] == '}' { - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = mapValue - cursor++ - return cursor, nil - } - if buf[cursor] != ',' { - return 0, errors.ErrExpected("comma after object value", cursor) - } - 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 deleted file mode 100644 index 10e5435e6..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/number.go +++ /dev/null @@ -1,123 +0,0 @@ -package decoder - -import ( - "encoding/json" - "strconv" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type numberDecoder struct { - stringDecoder *stringDecoder - op func(unsafe.Pointer, json.Number) - structName string - fieldName string -} - -func newNumberDecoder(structName, fieldName string, op func(unsafe.Pointer, json.Number)) *numberDecoder { - return &numberDecoder{ - stringDecoder: newStringDecoder(structName, fieldName), - op: op, - structName: structName, - fieldName: fieldName, - } -} - -func (d *numberDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&bytes)), 64); err != nil { - return errors.ErrSyntax(err.Error(), s.totalOffset()) - } - d.op(p, json.Number(string(bytes))) - s.reset() - return nil -} - -func (d *numberDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&bytes)), 64); err != nil { - return 0, errors.ErrSyntax(err.Error(), c) - } - cursor = c - s := *(*string)(unsafe.Pointer(&bytes)) - d.op(p, json.Number(s)) - 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 { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return floatBytes(s), nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case '"': - return d.stringDecoder.decodeStreamByte(s) - case nul: - if s.read() { - continue - } - goto ERROR - default: - goto ERROR - } - } -ERROR: - if s.cursor == start { - return nil, errors.ErrInvalidBeginningOfValue(s.char(), s.totalOffset()) - } - return nil, errors.ErrUnexpectedEndOfJSON("json.Number", s.totalOffset()) -} - -func (d *numberDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := cursor - cursor++ - for floatTable[buf[cursor]] { - cursor++ - } - num := buf[start:cursor] - return num, cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - case '"': - return d.stringDecoder.decodeByte(buf, cursor) - default: - return nil, 0, errors.ErrUnexpectedEndOfJSON("json.Number", cursor) - } - } -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/option.go b/vendor/github.com/goccy/go-json/internal/decoder/option.go deleted file mode 100644 index 502f772eb..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/option.go +++ /dev/null @@ -1,17 +0,0 @@ -package decoder - -import "context" - -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 a15ff69e3..000000000 --- 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 deleted file mode 100644 index de12e105c..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/ptr.go +++ /dev/null @@ -1,96 +0,0 @@ -package decoder - -import ( - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -type ptrDecoder struct { - dec Decoder - typ *runtime.Type - structName string - fieldName string -} - -func newPtrDecoder(dec Decoder, typ *runtime.Type, structName, fieldName string) *ptrDecoder { - return &ptrDecoder{ - dec: dec, - typ: typ, - structName: structName, - fieldName: fieldName, - } -} - -func (d *ptrDecoder) contentDecoder() Decoder { - dec, ok := d.dec.(*ptrDecoder) - if !ok { - return d.dec - } - return dec.contentDecoder() -} - -//nolint:golint -//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() - } - if s.char() == 'n' { - if err := nullBytes(s); err != nil { - return err - } - *(*unsafe.Pointer)(p) = nil - return nil - } - var newptr unsafe.Pointer - if *(*unsafe.Pointer)(p) == nil { - newptr = unsafe_New(d.typ) - *(*unsafe.Pointer)(p) = newptr - } else { - newptr = *(*unsafe.Pointer)(p) - } - if err := d.dec.DecodeStream(s, depth, newptr); err != nil { - return err - } - return nil -} - -func (d *ptrDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == 'n' { - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - if p != nil { - *(*unsafe.Pointer)(p) = nil - } - cursor += 4 - return cursor, nil - } - var newptr unsafe.Pointer - if *(*unsafe.Pointer)(p) == nil { - newptr = unsafe_New(d.typ) - *(*unsafe.Pointer)(p) = newptr - } else { - newptr = *(*unsafe.Pointer)(p) - } - c, err := d.dec.Decode(ctx, cursor, depth, newptr) - if err != 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 deleted file mode 100644 index 30a23e4b5..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/slice.go +++ /dev/null @@ -1,380 +0,0 @@ -package decoder - -import ( - "reflect" - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -var ( - sliceType = runtime.Type2RType( - reflect.TypeOf((*sliceHeader)(nil)).Elem(), - ) - nilSlice = unsafe.Pointer(&sliceHeader{}) -) - -type sliceDecoder struct { - elemType *runtime.Type - isElemPointerType bool - valueDecoder Decoder - size uintptr - arrayPool sync.Pool - structName string - fieldName string -} - -// If use reflect.SliceHeader, data type is uintptr. -// In this case, Go compiler cannot trace reference created by newArray(). -// So, define using unsafe.Pointer as data type -type sliceHeader struct { - data unsafe.Pointer - len int - cap int -} - -const ( - defaultSliceCapacity = 2 -) - -func newSliceDecoder(dec Decoder, elemType *runtime.Type, size uintptr, structName, fieldName string) *sliceDecoder { - return &sliceDecoder{ - valueDecoder: dec, - elemType: elemType, - isElemPointerType: elemType.Kind() == reflect.Ptr || elemType.Kind() == reflect.Map, - size: size, - arrayPool: sync.Pool{ - New: func() interface{} { - return &sliceHeader{ - data: newArray(elemType, defaultSliceCapacity), - len: 0, - cap: defaultSliceCapacity, - } - }, - }, - structName: structName, - fieldName: fieldName, - } -} - -func (d *sliceDecoder) newSlice(src *sliceHeader) *sliceHeader { - slice := d.arrayPool.Get().(*sliceHeader) - if src.len > 0 { - // copy original elem - if slice.cap < src.cap { - data := newArray(d.elemType, src.cap) - slice = &sliceHeader{data: data, len: src.len, cap: src.cap} - } else { - slice.len = src.len - } - copySlice(d.elemType, *slice, *src) - } else { - slice.len = 0 - } - return slice -} - -func (d *sliceDecoder) releaseSlice(p *sliceHeader) { - d.arrayPool.Put(p) -} - -//go:linkname copySlice reflect.typedslicecopy -func copySlice(elemType *runtime.Type, dst, src sliceHeader) int - -//go:linkname newArray reflect.unsafe_NewArray -func newArray(*runtime.Type, int) unsafe.Pointer - -//go:linkname typedmemmove reflect.typedmemmove -func typedmemmove(t *runtime.Type, dst, src unsafe.Pointer) - -func (d *sliceDecoder) errNumber(offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: "number", - Type: reflect.SliceOf(runtime.RType2Type(d.elemType)), - Struct: d.structName, - Field: d.fieldName, - Offset: offset, - } -} - -func (d *sliceDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case 'n': - if err := nullBytes(s); err != nil { - return err - } - typedmemmove(sliceType, p, nilSlice) - return nil - case '[': - s.cursor++ - if s.skipWhiteSpace() == ']' { - dst := (*sliceHeader)(p) - if dst.data == nil { - dst.data = newArray(d.elemType, 0) - } else { - dst.len = 0 - } - s.cursor++ - return nil - } - idx := 0 - slice := d.newSlice((*sliceHeader)(p)) - srcLen := slice.len - capacity := slice.cap - data := slice.data - for { - if capacity <= idx { - src := sliceHeader{data: data, len: idx, cap: capacity} - capacity *= 2 - data = newArray(d.elemType, capacity) - dst := sliceHeader{data: data, len: idx, cap: capacity} - copySlice(d.elemType, dst, src) - } - ep := unsafe.Pointer(uintptr(data) + uintptr(idx)*d.size) - - // if srcLen is greater than idx, keep the original reference - if srcLen <= idx { - if d.isElemPointerType { - **(**unsafe.Pointer)(unsafe.Pointer(&ep)) = nil // initialize elem pointer - } else { - // assign new element to the slice - typedmemmove(d.elemType, ep, unsafe_New(d.elemType)) - } - } - - if err := d.valueDecoder.DecodeStream(s, depth, ep); err != nil { - return err - } - s.skipWhiteSpace() - RETRY: - switch s.char() { - case ']': - slice.cap = capacity - slice.len = idx + 1 - slice.data = data - dst := (*sliceHeader)(p) - dst.len = idx + 1 - if dst.len > dst.cap { - dst.data = newArray(d.elemType, dst.len) - dst.cap = dst.len - } - copySlice(d.elemType, *dst, *slice) - d.releaseSlice(slice) - s.cursor++ - return nil - case ',': - idx++ - case nul: - if s.read() { - goto RETRY - } - slice.cap = capacity - slice.data = data - d.releaseSlice(slice) - goto ERROR - default: - slice.cap = capacity - slice.data = data - d.releaseSlice(slice) - goto ERROR - } - s.cursor++ - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return d.errNumber(s.totalOffset()) - case nul: - if s.read() { - continue - } - goto ERROR - default: - goto ERROR - } - } -ERROR: - return errors.ErrUnexpectedEndOfJSON("slice", s.totalOffset()) -} - -func (d *sliceDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - typedmemmove(sliceType, p, nilSlice) - return cursor, nil - case '[': - cursor++ - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == ']' { - dst := (*sliceHeader)(p) - if dst.data == nil { - dst.data = newArray(d.elemType, 0) - } else { - dst.len = 0 - } - cursor++ - return cursor, nil - } - idx := 0 - slice := d.newSlice((*sliceHeader)(p)) - srcLen := slice.len - capacity := slice.cap - data := slice.data - for { - if capacity <= idx { - src := sliceHeader{data: data, len: idx, cap: capacity} - capacity *= 2 - data = newArray(d.elemType, capacity) - dst := sliceHeader{data: data, len: idx, cap: capacity} - copySlice(d.elemType, dst, src) - } - ep := unsafe.Pointer(uintptr(data) + uintptr(idx)*d.size) - // if srcLen is greater than idx, keep the original reference - if srcLen <= idx { - if d.isElemPointerType { - **(**unsafe.Pointer)(unsafe.Pointer(&ep)) = nil // initialize elem pointer - } else { - // assign new element to the slice - typedmemmove(d.elemType, ep, unsafe_New(d.elemType)) - } - } - c, err := d.valueDecoder.Decode(ctx, cursor, depth, ep) - if err != nil { - return 0, err - } - cursor = c - cursor = skipWhiteSpace(buf, cursor) - switch buf[cursor] { - case ']': - slice.cap = capacity - slice.len = idx + 1 - slice.data = data - dst := (*sliceHeader)(p) - dst.len = idx + 1 - if dst.len > dst.cap { - dst.data = newArray(d.elemType, dst.len) - dst.cap = dst.len - } - copySlice(d.elemType, *dst, *slice) - d.releaseSlice(slice) - cursor++ - return cursor, nil - case ',': - idx++ - default: - slice.cap = capacity - slice.data = data - d.releaseSlice(slice) - return 0, errors.ErrInvalidCharacter(buf[cursor], "slice", cursor) - } - cursor++ - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return 0, d.errNumber(cursor) - default: - return 0, errors.ErrUnexpectedEndOfJSON("slice", cursor) - } - } -} - -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 deleted file mode 100644 index a383f7259..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/stream.go +++ /dev/null @@ -1,556 +0,0 @@ -package decoder - -import ( - "bytes" - "encoding/json" - "io" - "strconv" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -const ( - initBufSize = 512 -) - -type Stream struct { - buf []byte - bufSize int64 - length int64 - r io.Reader - offset int64 - cursor int64 - filledBuffer bool - allRead bool - UseNumber bool - DisallowUnknownFields bool - Option *Option -} - -func NewStream(r io.Reader) *Stream { - return &Stream{ - r: r, - bufSize: initBufSize, - buf: make([]byte, initBufSize), - Option: &Option{}, - } -} - -func (s *Stream) TotalOffset() int64 { - return s.totalOffset() -} - -func (s *Stream) Buffered() io.Reader { - buflen := int64(len(s.buf)) - for i := s.cursor; i < buflen; i++ { - if s.buf[i] == nul { - return bytes.NewReader(s.buf[s.cursor:i]) - } - } - return bytes.NewReader(s.buf[s.cursor:]) -} - -func (s *Stream) PrepareForDecode() error { - for { - switch s.char() { - case ' ', '\t', '\r', '\n': - s.cursor++ - continue - case ',', ':': - s.cursor++ - return nil - case nul: - if s.read() { - continue - } - return io.EOF - } - break - } - return nil -} - -func (s *Stream) totalOffset() int64 { - return s.offset + s.cursor -} - -func (s *Stream) char() byte { - return s.buf[s.cursor] -} - -func (s *Stream) equalChar(c byte) bool { - cur := s.buf[s.cursor] - if cur == nul { - s.read() - cur = s.buf[s.cursor] - } - return cur == c -} - -func (s *Stream) stat() ([]byte, int64, unsafe.Pointer) { - return s.buf, s.cursor, (*sliceHeader)(unsafe.Pointer(&s.buf)).data -} - -func (s *Stream) bufptr() unsafe.Pointer { - return (*sliceHeader)(unsafe.Pointer(&s.buf)).data -} - -func (s *Stream) statForRetry() ([]byte, int64, unsafe.Pointer) { - s.cursor-- // for retry ( because caller progress cursor position in each loop ) - return s.buf, s.cursor, (*sliceHeader)(unsafe.Pointer(&s.buf)).data -} - -func (s *Stream) Reset() { - s.reset() - s.bufSize = int64(len(s.buf)) -} - -func (s *Stream) More() bool { - for { - switch s.char() { - case ' ', '\n', '\r', '\t': - s.cursor++ - continue - case '}', ']': - return false - case nul: - if s.read() { - continue - } - return false - } - break - } - return true -} - -func (s *Stream) Token() (interface{}, error) { - for { - c := s.char() - switch c { - case ' ', '\n', '\r', '\t': - s.cursor++ - case '{', '[', ']', '}': - s.cursor++ - return json.Delim(c), nil - case ',', ':': - 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) - if err != nil { - return nil, err - } - return f64, nil - case '"': - bytes, err := stringBytes(s) - if err != nil { - return nil, err - } - return string(bytes), nil - case 't': - if err := trueBytes(s); err != nil { - return nil, err - } - return true, nil - case 'f': - if err := falseBytes(s); err != nil { - return nil, err - } - return false, nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - goto END - default: - return nil, errors.ErrInvalidCharacter(s.char(), "token", s.totalOffset()) - } - } -END: - return nil, io.EOF -} - -func (s *Stream) reset() { - s.offset += s.cursor - s.buf = s.buf[s.cursor:] - s.length -= s.cursor - s.cursor = 0 -} - -func (s *Stream) readBuf() []byte { - if s.filledBuffer { - s.bufSize *= 2 - remainBuf := s.buf - s.buf = make([]byte, s.bufSize) - copy(s.buf, remainBuf) - } - remainLen := s.length - s.cursor - remainNotNulCharNum := int64(0) - for i := int64(0); i < remainLen; i++ { - if s.buf[s.cursor+i] == nul { - break - } - remainNotNulCharNum++ - } - s.length = s.cursor + remainNotNulCharNum - return s.buf[s.cursor+remainNotNulCharNum:] -} - -func (s *Stream) read() bool { - if s.allRead { - return false - } - buf := s.readBuf() - last := len(buf) - 1 - buf[last] = nul - n, err := s.r.Read(buf[:last]) - s.length += int64(n) - if n == last { - s.filledBuffer = true - } else { - s.filledBuffer = false - } - if err == io.EOF { - s.allRead = true - } else if err != nil { - return false - } - return true -} - -func (s *Stream) skipWhiteSpace() byte { - p := s.bufptr() -LOOP: - c := char(p, s.cursor) - switch c { - case ' ', '\n', '\t', '\r': - s.cursor++ - goto LOOP - case nul: - if s.read() { - p = s.bufptr() - goto LOOP - } - } - return c -} - -func (s *Stream) skipObject(depth int64) error { - braceCount := 1 - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case '{': - braceCount++ - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - case '}': - braceCount-- - depth-- - if braceCount == 0 { - s.cursor = cursor + 1 - return nil - } - case '[': - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - case ']': - depth-- - case '"': - for { - cursor++ - switch char(p, cursor) { - case '\\': - cursor++ - if char(p, cursor) == nul { - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - goto SWITCH_OUT - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.statForRetry() - continue - } - return errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return errors.ErrUnexpectedEndOfJSON("object of object", cursor) - } - SWITCH_OUT: - cursor++ - } -} - -func (s *Stream) skipArray(depth int64) error { - bracketCount := 1 - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case '[': - bracketCount++ - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - case ']': - bracketCount-- - depth-- - if bracketCount == 0 { - s.cursor = cursor + 1 - return nil - } - case '{': - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - case '}': - depth-- - case '"': - for { - cursor++ - switch char(p, cursor) { - case '\\': - cursor++ - if char(p, cursor) == nul { - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - goto SWITCH_OUT - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.statForRetry() - continue - } - return errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return errors.ErrUnexpectedEndOfJSON("array of object", cursor) - } - SWITCH_OUT: - cursor++ - } -} - -func (s *Stream) skipValue(depth int64) error { - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return errors.ErrUnexpectedEndOfJSON("value of object", s.totalOffset()) - case '{': - s.cursor = cursor + 1 - return s.skipObject(depth + 1) - case '[': - s.cursor = cursor + 1 - return s.skipArray(depth + 1) - case '"': - for { - cursor++ - switch char(p, cursor) { - case '\\': - cursor++ - if char(p, cursor) == nul { - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return errors.ErrUnexpectedEndOfJSON("value of string", s.totalOffset()) - } - case '"': - s.cursor = cursor + 1 - return nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.statForRetry() - continue - } - return errors.ErrUnexpectedEndOfJSON("value of string", s.totalOffset()) - } - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - for { - cursor++ - c := char(p, cursor) - if floatTable[c] { - continue - } else if c == nul { - if s.read() { - _, cursor, p = s.stat() - continue - } - } - s.cursor = cursor - return nil - } - case 't': - s.cursor = cursor - if err := trueBytes(s); err != nil { - return err - } - return nil - case 'f': - s.cursor = cursor - if err := falseBytes(s); err != nil { - return err - } - return nil - case 'n': - s.cursor = cursor - if err := nullBytes(s); err != nil { - return err - } - return nil - } - cursor++ - } -} - -func nullBytes(s *Stream) error { - // current cursor's character is 'n' - s.cursor++ - if s.char() != 'u' { - if err := retryReadNull(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'l' { - if err := retryReadNull(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'l' { - if err := retryReadNull(s); err != nil { - return err - } - } - s.cursor++ - return nil -} - -func retryReadNull(s *Stream) error { - if s.char() == nul && s.read() { - return nil - } - return errors.ErrInvalidCharacter(s.char(), "null", s.totalOffset()) -} - -func trueBytes(s *Stream) error { - // current cursor's character is 't' - s.cursor++ - if s.char() != 'r' { - if err := retryReadTrue(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'u' { - if err := retryReadTrue(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'e' { - if err := retryReadTrue(s); err != nil { - return err - } - } - s.cursor++ - return nil -} - -func retryReadTrue(s *Stream) error { - if s.char() == nul && s.read() { - return nil - } - return errors.ErrInvalidCharacter(s.char(), "bool(true)", s.totalOffset()) -} - -func falseBytes(s *Stream) error { - // current cursor's character is 'f' - s.cursor++ - if s.char() != 'a' { - if err := retryReadFalse(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'l' { - if err := retryReadFalse(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 's' { - if err := retryReadFalse(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'e' { - if err := retryReadFalse(s); err != nil { - return err - } - } - s.cursor++ - return nil -} - -func retryReadFalse(s *Stream) error { - if s.char() == nul && s.read() { - return nil - } - return errors.ErrInvalidCharacter(s.char(), "bool(false)", s.totalOffset()) -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/string.go b/vendor/github.com/goccy/go-json/internal/decoder/string.go deleted file mode 100644 index 32602c908..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/string.go +++ /dev/null @@ -1,452 +0,0 @@ -package decoder - -import ( - "bytes" - "fmt" - "reflect" - "unicode" - "unicode/utf16" - "unicode/utf8" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type stringDecoder struct { - structName string - fieldName string -} - -func newStringDecoder(structName, fieldName string) *stringDecoder { - return &stringDecoder{ - structName: structName, - fieldName: fieldName, - } -} - -func (d *stringDecoder) errUnmarshalType(typeName string, offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: typeName, - Type: reflect.TypeOf(""), - Offset: offset, - Struct: d.structName, - Field: d.fieldName, - } -} - -func (d *stringDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - return nil - } - **(**string)(unsafe.Pointer(&p)) = *(*string)(unsafe.Pointer(&bytes)) - s.reset() - return nil -} - -func (d *stringDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - **(**string)(unsafe.Pointer(&p)) = *(*string)(unsafe.Pointer(&bytes)) - 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, - '1': 1, - '2': 2, - '3': 3, - '4': 4, - '5': 5, - '6': 6, - '7': 7, - '8': 8, - '9': 9, - 'A': 10, - 'B': 11, - 'C': 12, - 'D': 13, - 'E': 14, - 'F': 15, - 'a': 10, - 'b': 11, - 'c': 12, - 'd': 13, - 'e': 14, - 'f': 15, - } -) - -func unicodeToRune(code []byte) rune { - var r rune - for i := 0; i < len(code); i++ { - r = r*16 + rune(hexToInt[code[i]]) - } - 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()) - } - - 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.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]) - if r := utf16.DecodeRune(r, r2); r != unicode.ReplacementChar { - return r, surrogateOffset, p, nil - } - } - return r, defaultOffset, p, nil -} - -func decodeUnicode(s *Stream, p unsafe.Pointer) (unsafe.Pointer, error) { - const backSlashAndULen = 2 // length of \u - - r, offset, pp, err := decodeUnicodeRune(s, p) - if err != nil { - return nil, err - } - unicode := []byte(string(r)) - unicodeLen := int64(len(unicode)) - s.buf = append(append(s.buf[:s.cursor-1], unicode...), s.buf[s.cursor+offset:]...) - unicodeOrgLen := offset - 1 - s.length = s.length - (backSlashAndULen + (unicodeOrgLen - unicodeLen)) - s.cursor = s.cursor - backSlashAndULen + unicodeLen - return pp, nil -} - -func decodeEscapeString(s *Stream, p unsafe.Pointer) (unsafe.Pointer, error) { - s.cursor++ -RETRY: - switch s.buf[s.cursor] { - case '"': - s.buf[s.cursor] = '"' - case '\\': - s.buf[s.cursor] = '\\' - case '/': - s.buf[s.cursor] = '/' - case 'b': - s.buf[s.cursor] = '\b' - case 'f': - s.buf[s.cursor] = '\f' - case 'n': - s.buf[s.cursor] = '\n' - case 'r': - s.buf[s.cursor] = '\r' - case 't': - s.buf[s.cursor] = '\t' - case 'u': - return decodeUnicode(s, p) - case nul: - 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()) - } - s.buf = append(s.buf[:s.cursor-1], s.buf[s.cursor:]...) - s.length-- - s.cursor-- - p = s.bufptr() - return p, nil -} - -var ( - runeErrBytes = []byte(string(utf8.RuneError)) - runeErrBytesLen = int64(len(runeErrBytes)) -) - -func stringBytes(s *Stream) ([]byte, error) { - _, cursor, p := s.stat() - cursor++ // skip double quote char - start := cursor - for { - switch char(p, cursor) { - case '\\': - s.cursor = cursor - pp, err := decodeEscapeString(s, p) - if err != nil { - return nil, err - } - p = pp - cursor = s.cursor - case '"': - literal := s.buf[start:cursor] - cursor++ - s.cursor = cursor - return literal, nil - case - // 0x00 is nul, 0x5c is '\\', 0x22 is '"' . - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, // 0x00-0x0F - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, // 0x10-0x1F - 0x20, 0x21 /*0x22,*/, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, // 0x20-0x2F - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, // 0x30-0x3F - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, // 0x40-0x4F - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B /*0x5C,*/, 0x5D, 0x5E, 0x5F, // 0x50-0x5F - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, // 0x60-0x6F - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F: // 0x70-0x7F - // character is ASCII. skip to next char - case - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, // 0x80-0x8F - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, // 0x90-0x9F - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, // 0xA0-0xAF - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, // 0xB0-0xBF - 0xC0, 0xC1, // 0xC0-0xC1 - 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF: // 0xF5-0xFE - // character is invalid - s.buf = append(append(append([]byte{}, s.buf[:cursor]...), runeErrBytes...), s.buf[cursor+1:]...) - _, _, p = s.stat() - cursor += runeErrBytesLen - s.length += runeErrBytesLen - continue - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - goto ERROR - case 0xEF: - // RuneError is {0xEF, 0xBF, 0xBD} - if s.buf[cursor+1] == 0xBF && s.buf[cursor+2] == 0xBD { - // found RuneError: skip - cursor += 2 - break - } - fallthrough - default: - // multi bytes character - if !utf8.FullRune(s.buf[cursor : len(s.buf)-1]) { - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - goto ERROR - } - r, size := utf8.DecodeRune(s.buf[cursor:]) - if r == utf8.RuneError { - s.buf = append(append(append([]byte{}, s.buf[:cursor]...), runeErrBytes...), s.buf[cursor+1:]...) - cursor += runeErrBytesLen - s.length += runeErrBytesLen - _, _, p = s.stat() - } else { - cursor += int64(size) - } - continue - } - cursor++ - } -ERROR: - return nil, errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) -} - -func (d *stringDecoder) decodeStreamByte(s *Stream) ([]byte, error) { - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '[': - return nil, d.errUnmarshalType("array", s.totalOffset()) - case '{': - return nil, d.errUnmarshalType("object", s.totalOffset()) - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return nil, d.errUnmarshalType("number", s.totalOffset()) - case '"': - return stringBytes(s) - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - } - break - } - return nil, errors.ErrInvalidBeginningOfValue(s.char(), s.totalOffset()) -} - -func (d *stringDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - case '[': - return nil, 0, d.errUnmarshalType("array", cursor) - case '{': - return nil, 0, d.errUnmarshalType("object", cursor) - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return nil, 0, d.errUnmarshalType("number", cursor) - case '"': - 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 '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 - 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: - return nil, 0, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - cursor++ - } - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - default: - return nil, 0, errors.ErrInvalidBeginningOfValue(buf[cursor], cursor) - } - } -} - -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 deleted file mode 100644 index 313da153b..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/struct.go +++ /dev/null @@ -1,845 +0,0 @@ -package decoder - -import ( - "fmt" - "math" - "math/bits" - "sort" - "strings" - "unicode" - "unicode/utf16" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type structFieldSet struct { - dec Decoder - offset uintptr - isTaggedKey bool - fieldIdx int - key string - keyLen int64 - err error -} - -type structDecoder struct { - fieldMap map[string]*structFieldSet - fieldUniqueNameNum int - stringDecoder *stringDecoder - structName string - fieldName string - isTriedOptimize bool - keyBitmapUint8 [][256]uint8 - keyBitmapUint16 [][256]uint16 - sortedFieldSets []*structFieldSet - keyDecoder func(*structDecoder, []byte, int64) (int64, *structFieldSet, error) - keyStreamDecoder func(*structDecoder, *Stream) (*structFieldSet, string, error) -} - -var ( - largeToSmallTable [256]byte -) - -func init() { - for i := 0; i < 256; i++ { - c := i - if 'A' <= c && c <= 'Z' { - c += 'a' - 'A' - } - largeToSmallTable[i] = byte(c) - } -} - -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, - stringDecoder: newStringDecoder(structName, fieldName), - structName: structName, - fieldName: fieldName, - keyDecoder: decodeKey, - keyStreamDecoder: decodeKeyStream, - } -} - -const ( - allowOptimizeMaxKeyLen = 64 - allowOptimizeMaxFieldLen = 16 -) - -func (d *structDecoder) tryOptimize() { - fieldUniqueNameMap := map[string]int{} - fieldIdx := -1 - for k, v := range d.fieldMap { - lower := strings.ToLower(k) - idx, exists := fieldUniqueNameMap[lower] - if exists { - v.fieldIdx = idx - } else { - fieldIdx++ - v.fieldIdx = fieldIdx - } - fieldUniqueNameMap[lower] = fieldIdx - } - d.fieldUniqueNameNum = len(fieldUniqueNameMap) - - if d.isTriedOptimize { - return - } - fieldMap := map[string]*structFieldSet{} - conflicted := map[string]struct{}{} - 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 - return - } - conflicted[key] = struct{}{} - } - if field, exists := fieldMap[key]; exists { - if field != v { - d.isTriedOptimize = true - return - } - } - fieldMap[key] = v - } - - if len(fieldMap) > allowOptimizeMaxFieldLen { - d.isTriedOptimize = true - return - } - - var maxKeyLen int - sortedKeys := []string{} - for key := range fieldMap { - keyLen := len(key) - if keyLen > allowOptimizeMaxKeyLen { - d.isTriedOptimize = true - return - } - if maxKeyLen < keyLen { - maxKeyLen = keyLen - } - sortedKeys = append(sortedKeys, key) - } - sort.Strings(sortedKeys) - - // By allocating one extra capacity than `maxKeyLen`, - // it is possible to avoid the process of comparing the index of the key with the length of the bitmap each time. - bitmapLen := maxKeyLen + 1 - if len(sortedKeys) <= 8 { - keyBitmap := make([][256]uint8, bitmapLen) - for i, key := range sortedKeys { - for j := 0; j < len(key); j++ { - c := key[j] - keyBitmap[j][c] |= (1 << uint(i)) - } - d.sortedFieldSets = append(d.sortedFieldSets, fieldMap[key]) - } - d.keyBitmapUint8 = keyBitmap - d.keyDecoder = decodeKeyByBitmapUint8 - d.keyStreamDecoder = decodeKeyByBitmapUint8Stream - } else { - keyBitmap := make([][256]uint16, bitmapLen) - for i, key := range sortedKeys { - for j := 0; j < len(key); j++ { - c := key[j] - keyBitmap[j][c] |= (1 << uint(i)) - } - d.sortedFieldSets = append(d.sortedFieldSets, fieldMap[key]) - } - d.keyBitmapUint16 = keyBitmap - d.keyDecoder = decodeKeyByBitmapUint16 - d.keyStreamDecoder = decodeKeyByBitmapUint16Stream - } -} - -// decode from '\uXXXX' -func decodeKeyCharByUnicodeRune(buf []byte, cursor int64) ([]byte, int64, error) { - 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 - } - 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, nil -} - -func decodeKeyCharByEscapedChar(buf []byte, cursor int64) ([]byte, int64, error) { - c := buf[cursor] - cursor++ - switch c { - case '"': - return []byte{'"'}, cursor, nil - case '\\': - return []byte{'\\'}, cursor, nil - case '/': - return []byte{'/'}, cursor, nil - case 'b': - return []byte{'\b'}, cursor, nil - case 'f': - return []byte{'\f'}, cursor, nil - case 'n': - return []byte{'\n'}, cursor, nil - case 'r': - return []byte{'\r'}, cursor, nil - case 't': - return []byte{'\t'}, cursor, nil - case 'u': - return decodeKeyCharByUnicodeRune(buf, cursor) - } - return nil, cursor, nil -} - -func decodeKeyByBitmapUint8(d *structDecoder, buf []byte, cursor int64) (int64, *structFieldSet, error) { - var ( - curBit uint8 = math.MaxUint8 - ) - b := (*sliceHeader)(unsafe.Pointer(&buf)).data - for { - switch char(b, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - case '"': - cursor++ - c := char(b, cursor) - switch c { - case '"': - cursor++ - return cursor, nil, nil - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - keyIdx := 0 - bitmap := d.keyBitmapUint8 - start := cursor - for { - c := char(b, cursor) - switch c { - case '"': - fieldSetIndex := bits.TrailingZeros8(curBit) - field := d.sortedFieldSets[fieldSetIndex] - keyLen := cursor - start - cursor++ - if keyLen < field.keyLen { - // early match - return cursor, nil, nil - } - return cursor, field, nil - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - case '\\': - cursor++ - chars, nextCursor, err := decodeKeyCharByEscapedChar(buf, cursor) - if err != nil { - return 0, nil, err - } - for _, c := range chars { - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - return decodeKeyNotFound(b, cursor) - } - keyIdx++ - } - cursor = nextCursor - default: - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - return decodeKeyNotFound(b, cursor) - } - keyIdx++ - } - cursor++ - } - default: - return cursor, nil, errors.ErrInvalidBeginningOfValue(char(b, cursor), cursor) - } - } -} - -func decodeKeyByBitmapUint16(d *structDecoder, buf []byte, cursor int64) (int64, *structFieldSet, error) { - var ( - curBit uint16 = math.MaxUint16 - ) - b := (*sliceHeader)(unsafe.Pointer(&buf)).data - for { - switch char(b, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - case '"': - cursor++ - c := char(b, cursor) - switch c { - case '"': - cursor++ - return cursor, nil, nil - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - keyIdx := 0 - bitmap := d.keyBitmapUint16 - start := cursor - for { - c := char(b, cursor) - switch c { - case '"': - fieldSetIndex := bits.TrailingZeros16(curBit) - field := d.sortedFieldSets[fieldSetIndex] - keyLen := cursor - start - cursor++ - if keyLen < field.keyLen { - // early match - return cursor, nil, nil - } - return cursor, field, nil - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - case '\\': - cursor++ - chars, nextCursor, err := decodeKeyCharByEscapedChar(buf, cursor) - if err != nil { - return 0, nil, err - } - for _, c := range chars { - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - return decodeKeyNotFound(b, cursor) - } - keyIdx++ - } - cursor = nextCursor - default: - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - return decodeKeyNotFound(b, cursor) - } - keyIdx++ - } - cursor++ - } - default: - return cursor, nil, errors.ErrInvalidBeginningOfValue(char(b, cursor), cursor) - } - } -} - -func decodeKeyNotFound(b unsafe.Pointer, cursor int64) (int64, *structFieldSet, error) { - for { - cursor++ - switch char(b, cursor) { - case '"': - cursor++ - return cursor, nil, nil - case '\\': - cursor++ - if char(b, cursor) == nul { - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - } -} - -func decodeKey(d *structDecoder, buf []byte, cursor int64) (int64, *structFieldSet, error) { - key, c, err := d.stringDecoder.decodeByte(buf, cursor) - if err != nil { - return 0, nil, err - } - cursor = c - k := *(*string)(unsafe.Pointer(&key)) - field, exists := d.fieldMap[k] - if !exists { - return cursor, nil, nil - } - return cursor, field, nil -} - -func decodeKeyByBitmapUint8Stream(d *structDecoder, s *Stream) (*structFieldSet, string, error) { - var ( - curBit uint8 = math.MaxUint8 - ) - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return nil, "", errors.ErrInvalidBeginningOfValue(char(p, cursor), s.totalOffset()) - case '"': - cursor++ - FIRST_CHAR: - start := cursor - switch char(p, cursor) { - case '"': - cursor++ - s.cursor = cursor - return nil, "", nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - goto FIRST_CHAR - } - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - keyIdx := 0 - bitmap := d.keyBitmapUint8 - for { - c := char(p, cursor) - switch c { - case '"': - fieldSetIndex := bits.TrailingZeros8(curBit) - field := d.sortedFieldSets[fieldSetIndex] - keyLen := cursor - start - cursor++ - s.cursor = cursor - if keyLen < field.keyLen { - // early match - return nil, field.key, nil - } - return field, field.key, nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - case '\\': - s.cursor = cursor + 1 // skip '\' char - chars, err := decodeKeyCharByEscapeCharStream(s) - if err != nil { - return nil, "", err - } - cursor = s.cursor - for _, c := range chars { - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - s.cursor = cursor - return decodeKeyNotFoundStream(s, start) - } - keyIdx++ - } - default: - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - s.cursor = cursor - return decodeKeyNotFoundStream(s, start) - } - keyIdx++ - } - cursor++ - } - default: - return nil, "", errors.ErrInvalidBeginningOfValue(char(p, cursor), s.totalOffset()) - } - } -} - -func decodeKeyByBitmapUint16Stream(d *structDecoder, s *Stream) (*structFieldSet, string, error) { - var ( - curBit uint16 = math.MaxUint16 - ) - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return nil, "", errors.ErrInvalidBeginningOfValue(char(p, cursor), s.totalOffset()) - case '"': - cursor++ - FIRST_CHAR: - start := cursor - switch char(p, cursor) { - case '"': - cursor++ - s.cursor = cursor - return nil, "", nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - goto FIRST_CHAR - } - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - keyIdx := 0 - bitmap := d.keyBitmapUint16 - for { - c := char(p, cursor) - switch c { - case '"': - fieldSetIndex := bits.TrailingZeros16(curBit) - field := d.sortedFieldSets[fieldSetIndex] - keyLen := cursor - start - cursor++ - s.cursor = cursor - if keyLen < field.keyLen { - // early match - return nil, field.key, nil - } - return field, field.key, nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - case '\\': - s.cursor = cursor + 1 // skip '\' char - chars, err := decodeKeyCharByEscapeCharStream(s) - if err != nil { - return nil, "", err - } - cursor = s.cursor - for _, c := range chars { - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - s.cursor = cursor - return decodeKeyNotFoundStream(s, start) - } - keyIdx++ - } - default: - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - s.cursor = cursor - return decodeKeyNotFoundStream(s, start) - } - keyIdx++ - } - cursor++ - } - default: - return nil, "", errors.ErrInvalidBeginningOfValue(char(p, cursor), s.totalOffset()) - } - } -} - -// decode from '\uXXXX' -func decodeKeyCharByUnicodeRuneStream(s *Stream) ([]byte, error) { - const defaultOffset = 4 - const surrogateOffset = 6 - - if s.cursor+defaultOffset >= s.length { - if !s.read() { - return nil, errors.ErrInvalidCharacter(s.char(), "escaped unicode char", s.totalOffset()) - } - } - - r := unicodeToRune(s.buf[s.cursor : s.cursor+defaultOffset]) - if utf16.IsSurrogate(r) { - s.cursor += defaultOffset - if s.cursor+surrogateOffset >= s.length { - s.read() - } - if s.cursor+surrogateOffset >= s.length || s.buf[s.cursor] != '\\' || s.buf[s.cursor+1] != 'u' { - s.cursor += defaultOffset - 1 - return []byte(string(unicode.ReplacementChar)), nil - } - r2 := unicodeToRune(s.buf[s.cursor+defaultOffset+2 : s.cursor+surrogateOffset]) - if r := utf16.DecodeRune(r, r2); r != unicode.ReplacementChar { - s.cursor += defaultOffset - 1 - return []byte(string(r)), nil - } - } - s.cursor += defaultOffset - 1 - return []byte(string(r)), nil -} - -func decodeKeyCharByEscapeCharStream(s *Stream) ([]byte, error) { - c := s.buf[s.cursor] - s.cursor++ -RETRY: - switch c { - case '"': - return []byte{'"'}, nil - case '\\': - return []byte{'\\'}, nil - case '/': - return []byte{'/'}, nil - case 'b': - return []byte{'\b'}, nil - case 'f': - return []byte{'\f'}, nil - case 'n': - return []byte{'\n'}, nil - case 'r': - return []byte{'\r'}, nil - case 't': - return []byte{'\t'}, nil - case 'u': - return decodeKeyCharByUnicodeRuneStream(s) - case nul: - if !s.read() { - return nil, errors.ErrInvalidCharacter(s.char(), "escaped char", s.totalOffset()) - } - goto RETRY - default: - return nil, errors.ErrUnexpectedEndOfJSON("struct field", s.totalOffset()) - } -} - -func decodeKeyNotFoundStream(s *Stream, start int64) (*structFieldSet, string, error) { - buf, cursor, p := s.stat() - for { - cursor++ - switch char(p, cursor) { - case '"': - b := buf[start:cursor] - key := *(*string)(unsafe.Pointer(&b)) - cursor++ - s.cursor = cursor - return nil, key, nil - case '\\': - cursor++ - if char(p, cursor) == nul { - s.cursor = cursor - if !s.read() { - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - buf, cursor, p = s.statForRetry() - } - case nul: - s.cursor = cursor - if !s.read() { - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - buf, cursor, p = s.statForRetry() - } - } -} - -func decodeKeyStream(d *structDecoder, s *Stream) (*structFieldSet, string, error) { - key, err := d.stringDecoder.decodeStreamByte(s) - if err != nil { - return nil, "", err - } - k := *(*string)(unsafe.Pointer(&key)) - return d.fieldMap[k], k, nil -} - -func (d *structDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - - c := s.skipWhiteSpace() - switch c { - case 'n': - if err := nullBytes(s); err != nil { - return err - } - return nil - default: - if s.char() != '{' { - return errors.ErrInvalidBeginningOfValue(s.char(), s.totalOffset()) - } - } - s.cursor++ - if s.skipWhiteSpace() == '}' { - s.cursor++ - return nil - } - var ( - seenFields map[int]struct{} - seenFieldNum int - ) - firstWin := (s.Option.Flags & FirstWinOption) != 0 - if firstWin { - seenFields = make(map[int]struct{}, d.fieldUniqueNameNum) - } - for { - s.reset() - field, key, err := d.keyStreamDecoder(d, s) - if err != nil { - return err - } - if s.skipWhiteSpace() != ':' { - return errors.ErrExpected("colon after object key", s.totalOffset()) - } - s.cursor++ - if field != nil { - if field.err != nil { - return field.err - } - if firstWin { - if _, exists := seenFields[field.fieldIdx]; exists { - if err := s.skipValue(depth); err != nil { - return err - } - } else { - if err := field.dec.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+field.offset)); err != nil { - return err - } - seenFieldNum++ - if d.fieldUniqueNameNum <= seenFieldNum { - return s.skipObject(depth) - } - seenFields[field.fieldIdx] = struct{}{} - } - } else { - if err := field.dec.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+field.offset)); err != nil { - return err - } - } - } else if s.DisallowUnknownFields { - return fmt.Errorf("json: unknown field %q", key) - } else { - if err := s.skipValue(depth); err != nil { - return err - } - } - c := s.skipWhiteSpace() - if c == '}' { - s.cursor++ - return nil - } - if c != ',' { - return errors.ErrExpected("comma after object element", s.totalOffset()) - } - s.cursor++ - } -} - -func (d *structDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - buflen := int64(len(buf)) - cursor = skipWhiteSpace(buf, cursor) - b := (*sliceHeader)(unsafe.Pointer(&buf)).data - switch char(b, cursor) { - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - case '{': - default: - return 0, errors.ErrInvalidBeginningOfValue(char(b, cursor), cursor) - } - cursor++ - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == '}' { - cursor++ - return cursor, nil - } - var ( - seenFields map[int]struct{} - seenFieldNum int - ) - firstWin := (ctx.Option.Flags & FirstWinOption) != 0 - if firstWin { - seenFields = make(map[int]struct{}, d.fieldUniqueNameNum) - } - for { - c, field, err := d.keyDecoder(d, buf, cursor) - if err != nil { - return 0, err - } - cursor = skipWhiteSpace(buf, c) - if char(b, cursor) != ':' { - return 0, errors.ErrExpected("colon after object key", cursor) - } - cursor++ - if cursor >= buflen { - return 0, errors.ErrExpected("object value after colon", cursor) - } - if field != nil { - if field.err != nil { - return 0, field.err - } - if firstWin { - if _, exists := seenFields[field.fieldIdx]; exists { - c, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - cursor = c - } else { - c, err := field.dec.Decode(ctx, cursor, depth, unsafe.Pointer(uintptr(p)+field.offset)) - if err != nil { - return 0, err - } - cursor = c - seenFieldNum++ - if d.fieldUniqueNameNum <= seenFieldNum { - return skipObject(buf, cursor, depth) - } - seenFields[field.fieldIdx] = struct{}{} - } - } else { - c, err := field.dec.Decode(ctx, cursor, depth, unsafe.Pointer(uintptr(p)+field.offset)) - if err != nil { - return 0, err - } - cursor = c - } - } else { - c, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - cursor = c - } - cursor = skipWhiteSpace(buf, cursor) - if char(b, cursor) == '}' { - cursor++ - return cursor, nil - } - if char(b, cursor) != ',' { - return 0, errors.ErrExpected("comma after object element", cursor) - } - 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 deleted file mode 100644 index beaf3ab86..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/type.go +++ /dev/null @@ -1,30 +0,0 @@ -package decoder - -import ( - "context" - "encoding" - "encoding/json" - "reflect" - "unsafe" -) - -type Decoder interface { - Decode(*RuntimeContext, int64, int64, unsafe.Pointer) (int64, error) - DecodePath(*RuntimeContext, int64, int64) ([][]byte, int64, error) - DecodeStream(*Stream, int64, unsafe.Pointer) error -} - -const ( - nul = '\000' - maxDecodeNestingDepth = 10000 -) - -type unmarshalerContext interface { - UnmarshalJSON(context.Context, []byte) error -} - -var ( - unmarshalJSONType = reflect.TypeOf((*json.Unmarshaler)(nil)).Elem() - unmarshalJSONContextType = reflect.TypeOf((*unmarshalerContext)(nil)).Elem() - unmarshalTextType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() -) diff --git a/vendor/github.com/goccy/go-json/internal/decoder/uint.go b/vendor/github.com/goccy/go-json/internal/decoder/uint.go deleted file mode 100644 index 4131731b8..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/uint.go +++ /dev/null @@ -1,194 +0,0 @@ -package decoder - -import ( - "fmt" - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type uintDecoder struct { - typ *runtime.Type - kind reflect.Kind - op func(unsafe.Pointer, uint64) - structName string - fieldName string -} - -func newUintDecoder(typ *runtime.Type, structName, fieldName string, op func(unsafe.Pointer, uint64)) *uintDecoder { - return &uintDecoder{ - typ: typ, - kind: typ.Kind(), - op: op, - structName: structName, - fieldName: fieldName, - } -} - -func (d *uintDecoder) typeError(buf []byte, offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: fmt.Sprintf("number %s", string(buf)), - Type: runtime.RType2Type(d.typ), - Offset: offset, - } -} - -var ( - pow10u64 = [...]uint64{ - 1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - } - pow10u64Len = len(pow10u64) -) - -func (d *uintDecoder) parseUint(b []byte) (uint64, error) { - maxDigit := len(b) - if maxDigit > pow10u64Len { - return 0, fmt.Errorf("invalid length of number") - } - sum := uint64(0) - for i := 0; i < maxDigit; i++ { - c := uint64(b[i]) - 48 - digitValue := pow10u64[maxDigit-i-1] - sum += c * digitValue - } - return sum, nil -} - -func (d *uintDecoder) decodeStreamByte(s *Stream) ([]byte, error) { - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '0': - s.cursor++ - return numZeroBuf, nil - case '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := s.cursor - for { - s.cursor++ - if numTable[s.char()] { - continue - } else if s.char() == nul { - if s.read() { - s.cursor-- // for retry current character - continue - } - } - break - } - num := s.buf[start:s.cursor] - return num, nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - default: - return nil, d.typeError([]byte{s.char()}, s.totalOffset()) - } - break - } - return nil, errors.ErrUnexpectedEndOfJSON("number(unsigned integer)", s.totalOffset()) -} - -func (d *uintDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case '0': - cursor++ - return numZeroBuf, cursor, nil - case '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := cursor - cursor++ - for numTable[buf[cursor]] { - cursor++ - } - num := buf[start:cursor] - return num, cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - default: - return nil, 0, d.typeError([]byte{buf[cursor]}, cursor) - } - } -} - -func (d *uintDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - return nil - } - u64, err := d.parseUint(bytes) - if err != nil { - return d.typeError(bytes, s.totalOffset()) - } - switch d.kind { - case reflect.Uint8: - if (1 << 8) <= u64 { - return d.typeError(bytes, s.totalOffset()) - } - case reflect.Uint16: - if (1 << 16) <= u64 { - return d.typeError(bytes, s.totalOffset()) - } - case reflect.Uint32: - if (1 << 32) <= u64 { - return d.typeError(bytes, s.totalOffset()) - } - } - d.op(p, u64) - return nil -} - -func (d *uintDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - u64, err := d.parseUint(bytes) - if err != nil { - return 0, d.typeError(bytes, cursor) - } - switch d.kind { - case reflect.Uint8: - if (1 << 8) <= u64 { - return 0, d.typeError(bytes, cursor) - } - case reflect.Uint16: - if (1 << 16) <= u64 { - return 0, d.typeError(bytes, cursor) - } - case reflect.Uint32: - if (1 << 32) <= u64 { - return 0, d.typeError(bytes, cursor) - } - } - 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 deleted file mode 100644 index 4cd6dbd57..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go +++ /dev/null @@ -1,104 +0,0 @@ -package decoder - -import ( - "context" - "encoding/json" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type unmarshalJSONDecoder struct { - typ *runtime.Type - structName string - fieldName string -} - -func newUnmarshalJSONDecoder(typ *runtime.Type, structName, fieldName string) *unmarshalJSONDecoder { - return &unmarshalJSONDecoder{ - typ: typ, - structName: structName, - fieldName: fieldName, - } -} - -func (d *unmarshalJSONDecoder) annotateError(cursor int64, err error) { - switch e := err.(type) { - case *errors.UnmarshalTypeError: - e.Struct = d.structName - e.Field = d.fieldName - case *errors.SyntaxError: - e.Offset = cursor - } -} - -func (d *unmarshalJSONDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - s.skipWhiteSpace() - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - dst := make([]byte, len(src)) - copy(dst, src) - - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - 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 { - d.annotateError(s.cursor, err) - return err - } - case json.Unmarshaler: - if err := v.UnmarshalJSON(dst); err != nil { - d.annotateError(s.cursor, err) - return err - } - } - return nil -} - -func (d *unmarshalJSONDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - dst := make([]byte, len(src)) - copy(dst, src) - - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: p, - })) - if (ctx.Option.Flags & ContextOption) != 0 { - if err := v.(unmarshalerContext).UnmarshalJSON(ctx.Option.Context, dst); err != nil { - d.annotateError(cursor, err) - return 0, err - } - } else { - if err := v.(json.Unmarshaler).UnmarshalJSON(dst); err != nil { - d.annotateError(cursor, err) - return 0, err - } - } - 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 deleted file mode 100644 index 6d37993f0..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go +++ /dev/null @@ -1,285 +0,0 @@ -package decoder - -import ( - "bytes" - "encoding" - "fmt" - "unicode" - "unicode/utf16" - "unicode/utf8" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type unmarshalTextDecoder struct { - typ *runtime.Type - structName string - fieldName string -} - -func newUnmarshalTextDecoder(typ *runtime.Type, structName, fieldName string) *unmarshalTextDecoder { - return &unmarshalTextDecoder{ - typ: typ, - structName: structName, - fieldName: fieldName, - } -} - -func (d *unmarshalTextDecoder) annotateError(cursor int64, err error) { - switch e := err.(type) { - case *errors.UnmarshalTypeError: - e.Struct = d.structName - e.Field = d.fieldName - case *errors.SyntaxError: - e.Offset = cursor - } -} - -var ( - nullbytes = []byte(`null`) -) - -func (d *unmarshalTextDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - s.skipWhiteSpace() - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - if len(src) > 0 { - switch src[0] { - case '[': - return &errors.UnmarshalTypeError{ - Value: "array", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '{': - return &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return &errors.UnmarshalTypeError{ - Value: "number", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case 'n': - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return nil - } - } - } - dst := make([]byte, len(src)) - copy(dst, src) - - if b, ok := unquoteBytes(dst); ok { - dst = b - } - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: p, - })) - if err := v.(encoding.TextUnmarshaler).UnmarshalText(dst); err != nil { - d.annotateError(s.cursor, err) - return err - } - return nil -} - -func (d *unmarshalTextDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - if len(src) > 0 { - switch src[0] { - case '[': - return 0, &errors.UnmarshalTypeError{ - Value: "array", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '{': - return 0, &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return 0, &errors.UnmarshalTypeError{ - Value: "number", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case 'n': - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return end, nil - } - } - } - - if s, ok := unquoteBytes(src); ok { - src = s - } - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) - if err := v.(encoding.TextUnmarshaler).UnmarshalText(src); err != nil { - d.annotateError(cursor, err) - return 0, err - } - 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) { - length := len(s) - if length < 2 || s[0] != '"' || s[length-1] != '"' { - return - } - s = s[1 : length-1] - length -= 2 - - // Check for unusual characters. If there are none, - // then no unquoting is needed, so return a slice of the - // original bytes. - r := 0 - for r < length { - c := s[r] - if c == '\\' || c == '"' || c < ' ' { - break - } - if c < utf8.RuneSelf { - r++ - continue - } - rr, size := utf8.DecodeRune(s[r:]) - if rr == utf8.RuneError && size == 1 { - break - } - r += size - } - if r == length { - return s, true - } - - b := make([]byte, length+2*utf8.UTFMax) - w := copy(b, s[0:r]) - for r < length { - // Out of room? Can only happen if s is full of - // malformed UTF-8 and we're replacing each - // byte with RuneError. - if w >= len(b)-2*utf8.UTFMax { - nb := make([]byte, (len(b)+utf8.UTFMax)*2) - copy(nb, b[0:w]) - b = nb - } - switch c := s[r]; { - case c == '\\': - r++ - if r >= length { - return - } - switch s[r] { - default: - return - case '"', '\\', '/', '\'': - b[w] = s[r] - r++ - w++ - case 'b': - b[w] = '\b' - r++ - w++ - case 'f': - b[w] = '\f' - r++ - w++ - case 'n': - b[w] = '\n' - r++ - w++ - case 'r': - b[w] = '\r' - r++ - w++ - case 't': - b[w] = '\t' - r++ - w++ - case 'u': - r-- - rr := getu4(s[r:]) - if rr < 0 { - return - } - r += 6 - if utf16.IsSurrogate(rr) { - rr1 := getu4(s[r:]) - if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar { - // A valid pair; consume. - r += 6 - w += utf8.EncodeRune(b[w:], dec) - break - } - // Invalid surrogate; fall back to replacement rune. - rr = unicode.ReplacementChar - } - w += utf8.EncodeRune(b[w:], rr) - } - - // Quote, control characters are invalid. - case c == '"', c < ' ': - return - - // ASCII - case c < utf8.RuneSelf: - b[w] = c - r++ - w++ - - // Coerce to well-formed UTF-8. - default: - rr, size := utf8.DecodeRune(s[r:]) - r += size - w += utf8.EncodeRune(b[w:], rr) - } - } - return b[0:w], true -} - -func getu4(s []byte) rune { - if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { - return -1 - } - var r rune - for _, c := range s[2:6] { - switch { - case '0' <= c && c <= '9': - c = c - '0' - case 'a' <= c && c <= 'f': - c = c - 'a' + 10 - case 'A' <= c && c <= 'F': - c = c - 'A' + 10 - default: - return -1 - } - r = r*16 + rune(c) - } - return r -} 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 deleted file mode 100644 index 0c4e2e6ea..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go +++ /dev/null @@ -1,73 +0,0 @@ -package decoder - -import ( - "fmt" - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -type wrappedStringDecoder struct { - typ *runtime.Type - dec Decoder - stringDecoder *stringDecoder - structName string - fieldName string - isPtrType bool -} - -func newWrappedStringDecoder(typ *runtime.Type, dec Decoder, structName, fieldName string) *wrappedStringDecoder { - return &wrappedStringDecoder{ - typ: typ, - dec: dec, - stringDecoder: newStringDecoder(structName, fieldName), - structName: structName, - fieldName: fieldName, - isPtrType: typ.Kind() == reflect.Ptr, - } -} - -func (d *wrappedStringDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.stringDecoder.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - if d.isPtrType { - *(*unsafe.Pointer)(p) = nil - } - return nil - } - b := make([]byte, len(bytes)+1) - copy(b, bytes) - if _, err := d.dec.Decode(&RuntimeContext{Buf: b}, 0, depth, p); err != nil { - return err - } - return nil -} - -func (d *wrappedStringDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.stringDecoder.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - if d.isPtrType { - *(*unsafe.Pointer)(p) = nil - } - return c, nil - } - bytes = append(bytes, nul) - oldBuf := ctx.Buf - ctx.Buf = bytes - if _, err := d.dec.Decode(ctx, 0, depth, p); err != nil { - return 0, err - } - 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 5b08faefc..000000000 --- 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 deleted file mode 100644 index 0eb9545d8..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/compact.go +++ /dev/null @@ -1,286 +0,0 @@ -package encoder - -import ( - "bytes" - "fmt" - "strconv" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -var ( - isWhiteSpace = [256]bool{ - ' ': true, - '\n': true, - '\t': true, - '\r': true, - } - isHTMLEscapeChar = [256]bool{ - '<': true, - '>': true, - '&': true, - } - nul = byte('\000') -) - -func Compact(buf *bytes.Buffer, src []byte, escape bool) error { - if len(src) == 0 { - return errors.ErrUnexpectedEndOfJSON("", 0) - } - buf.Grow(len(src)) - dst := buf.Bytes() - - ctx := TakeRuntimeContext() - ctxBuf := ctx.Buf[:0] - ctxBuf = append(append(ctxBuf, src...), nul) - ctx.Buf = ctxBuf - - if err := compactAndWrite(buf, dst, ctxBuf, escape); err != nil { - ReleaseRuntimeContext(ctx) - return err - } - ReleaseRuntimeContext(ctx) - return nil -} - -func compactAndWrite(buf *bytes.Buffer, dst []byte, src []byte, escape bool) error { - dst, err := compact(dst, src, escape) - if err != nil { - return err - } - if _, err := buf.Write(dst); err != nil { - return err - } - return nil -} - -func compact(dst, src []byte, escape bool) ([]byte, error) { - buf, cursor, err := compactValue(dst, src, 0, escape) - if err != nil { - return nil, err - } - if err := validateEndBuf(src, cursor); err != nil { - return nil, err - } - return buf, nil -} - -func validateEndBuf(src []byte, cursor int64) error { - for { - switch src[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case nul: - return nil - } - return errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after top-level value", src[cursor]), - cursor+1, - ) - } -} - -func skipWhiteSpace(buf []byte, cursor int64) int64 { -LOOP: - if isWhiteSpace[buf[cursor]] { - cursor++ - goto LOOP - } - return cursor -} - -func compactValue(dst, src []byte, cursor int64, escape bool) ([]byte, int64, error) { - for { - switch src[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case '{': - return compactObject(dst, src, cursor, escape) - case '}': - return nil, 0, errors.ErrSyntax("unexpected character '}'", cursor) - case '[': - return compactArray(dst, src, cursor, escape) - case ']': - return nil, 0, errors.ErrSyntax("unexpected character ']'", cursor) - case '"': - return compactString(dst, src, cursor, escape) - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return compactNumber(dst, src, cursor) - case 't': - return compactTrue(dst, src, cursor) - case 'f': - return compactFalse(dst, src, cursor) - case 'n': - return compactNull(dst, src, cursor) - default: - return nil, 0, errors.ErrSyntax(fmt.Sprintf("unexpected character '%c'", src[cursor]), cursor) - } - } -} - -func compactObject(dst, src []byte, cursor int64, escape bool) ([]byte, int64, error) { - if src[cursor] == '{' { - dst = append(dst, '{') - } else { - return nil, 0, errors.ErrExpected("expected { character for object value", cursor) - } - cursor = skipWhiteSpace(src, cursor+1) - if src[cursor] == '}' { - dst = append(dst, '}') - return dst, cursor + 1, nil - } - var err error - for { - cursor = skipWhiteSpace(src, cursor) - dst, cursor, err = compactString(dst, src, cursor, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - if src[cursor] != ':' { - return nil, 0, errors.ErrExpected("colon after object key", cursor) - } - dst = append(dst, ':') - dst, cursor, err = compactValue(dst, src, cursor+1, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - switch src[cursor] { - case '}': - dst = append(dst, '}') - cursor++ - return dst, cursor, nil - case ',': - dst = append(dst, ',') - default: - return nil, 0, errors.ErrExpected("comma after object value", cursor) - } - cursor++ - } -} - -func compactArray(dst, src []byte, cursor int64, escape bool) ([]byte, int64, error) { - if src[cursor] == '[' { - dst = append(dst, '[') - } else { - return nil, 0, errors.ErrExpected("expected [ character for array value", cursor) - } - cursor = skipWhiteSpace(src, cursor+1) - if src[cursor] == ']' { - dst = append(dst, ']') - return dst, cursor + 1, nil - } - var err error - for { - dst, cursor, err = compactValue(dst, src, cursor, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - switch src[cursor] { - case ']': - dst = append(dst, ']') - cursor++ - return dst, cursor, nil - case ',': - dst = append(dst, ',') - default: - return nil, 0, errors.ErrExpected("comma after array value", cursor) - } - cursor++ - } -} - -func compactString(dst, src []byte, cursor int64, escape bool) ([]byte, int64, error) { - if src[cursor] != '"' { - return nil, 0, errors.ErrInvalidCharacter(src[cursor], "string", cursor) - } - start := cursor - for { - cursor++ - c := src[cursor] - if escape { - if isHTMLEscapeChar[c] { - dst = append(dst, src[start:cursor]...) - dst = append(dst, `\u00`...) - dst = append(dst, hex[c>>4], hex[c&0xF]) - start = cursor + 1 - } else if c == 0xE2 && cursor+2 < int64(len(src)) && src[cursor+1] == 0x80 && src[cursor+2]&^1 == 0xA8 { - dst = append(dst, src[start:cursor]...) - dst = append(dst, `\u202`...) - dst = append(dst, hex[src[cursor+2]&0xF]) - cursor += 2 - start = cursor + 3 - } - } - switch c { - case '\\': - cursor++ - if src[cursor] == nul { - return nil, 0, errors.ErrUnexpectedEndOfJSON("string", int64(len(src))) - } - case '"': - cursor++ - return append(dst, src[start:cursor]...), cursor, nil - case nul: - return nil, 0, errors.ErrUnexpectedEndOfJSON("string", int64(len(src))) - } - } -} - -func compactNumber(dst, src []byte, cursor int64) ([]byte, int64, error) { - start := cursor - for { - cursor++ - if floatTable[src[cursor]] { - continue - } - break - } - num := src[start:cursor] - if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&num)), 64); err != nil { - return nil, 0, err - } - dst = append(dst, num...) - return dst, cursor, nil -} - -func compactTrue(dst, src []byte, cursor int64) ([]byte, int64, error) { - if cursor+3 >= int64(len(src)) { - return nil, 0, errors.ErrUnexpectedEndOfJSON("true", cursor) - } - if !bytes.Equal(src[cursor:cursor+4], []byte(`true`)) { - return nil, 0, errors.ErrInvalidCharacter(src[cursor], "true", cursor) - } - dst = append(dst, "true"...) - cursor += 4 - return dst, cursor, nil -} - -func compactFalse(dst, src []byte, cursor int64) ([]byte, int64, error) { - if cursor+4 >= int64(len(src)) { - return nil, 0, errors.ErrUnexpectedEndOfJSON("false", cursor) - } - if !bytes.Equal(src[cursor:cursor+5], []byte(`false`)) { - return nil, 0, errors.ErrInvalidCharacter(src[cursor], "false", cursor) - } - dst = append(dst, "false"...) - cursor += 5 - return dst, cursor, nil -} - -func compactNull(dst, src []byte, cursor int64) ([]byte, int64, error) { - if cursor+3 >= int64(len(src)) { - return nil, 0, errors.ErrUnexpectedEndOfJSON("null", cursor) - } - if !bytes.Equal(src[cursor:cursor+4], []byte(`null`)) { - return nil, 0, errors.ErrInvalidCharacter(src[cursor], "null", cursor) - } - dst = append(dst, "null"...) - cursor += 4 - return dst, cursor, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compiler.go b/vendor/github.com/goccy/go-json/internal/encoder/compiler.go deleted file mode 100644 index 3ae39ba8c..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/compiler.go +++ /dev/null @@ -1,935 +0,0 @@ -package encoder - -import ( - "context" - "encoding" - "encoding/json" - "reflect" - "sync/atomic" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type marshalerContext interface { - MarshalJSON(context.Context) ([]byte, error) -} - -var ( - marshalJSONType = reflect.TypeOf((*json.Marshaler)(nil)).Elem() - marshalJSONContextType = reflect.TypeOf((*marshalerContext)(nil)).Elem() - marshalTextType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() - jsonNumberType = reflect.TypeOf(json.Number("")) - cachedOpcodeSets []*OpcodeSet - cachedOpcodeMap unsafe.Pointer // map[uintptr]*OpcodeSet - typeAddr *runtime.TypeAddr -) - -func init() { - typeAddr = runtime.AnalyzeTypeAddr() - if typeAddr == nil { - typeAddr = &runtime.TypeAddr{} - } - cachedOpcodeSets = make([]*OpcodeSet, typeAddr.AddrRange>>typeAddr.AddrShift+1) -} - -func loadOpcodeMap() map[uintptr]*OpcodeSet { - p := atomic.LoadPointer(&cachedOpcodeMap) - return *(*map[uintptr]*OpcodeSet)(unsafe.Pointer(&p)) -} - -func storeOpcodeSet(typ uintptr, set *OpcodeSet, m map[uintptr]*OpcodeSet) { - newOpcodeMap := make(map[uintptr]*OpcodeSet, len(m)+1) - newOpcodeMap[typ] = set - - for k, v := range m { - newOpcodeMap[k] = v - } - - atomic.StorePointer(&cachedOpcodeMap, *(*unsafe.Pointer)(unsafe.Pointer(&newOpcodeMap))) -} - -func compileToGetCodeSetSlowPath(typeptr uintptr) (*OpcodeSet, error) { - opcodeMap := loadOpcodeMap() - 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) - 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 { - 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) - setTotalLengthToInterfaceOp(escapeKeyCode) - interfaceNoescapeKeyCode := copyToInterfaceOpcode(noescapeKeyCode) - interfaceEscapeKeyCode := copyToInterfaceOpcode(escapeKeyCode) - codeLength := noescapeKeyCode.TotalLength() - return &OpcodeSet{ - Type: typ, - NoescapeKeyCode: noescapeKeyCode, - EscapeKeyCode: escapeKeyCode, - InterfaceNoescapeKeyCode: interfaceNoescapeKeyCode, - InterfaceEscapeKeyCode: interfaceEscapeKeyCode, - CodeLength: codeLength, - EndCode: ToEndCode(interfaceNoescapeKeyCode), - Code: code, - QueryCache: map[string]*OpcodeSet{}, - }, nil -} - -func (c *Compiler) typeToCode(typ *runtime.Type) (Code, error) { - switch { - case c.implementsMarshalJSON(typ): - return c.marshalJSONCode(typ) - case c.implementsMarshalText(typ): - return c.marshalTextCode(typ) - } - - isPtr := false - orgType := typ - if typ.Kind() == reflect.Ptr { - typ = typ.Elem() - isPtr = true - } - switch { - case c.implementsMarshalJSON(typ): - return c.marshalJSONCode(orgType) - case c.implementsMarshalText(typ): - return c.marshalTextCode(orgType) - } - switch typ.Kind() { - 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, isPtr) - } - } - return c.sliceCode(typ) - case reflect.Map: - if isPtr { - return c.ptrCode(runtime.PtrTo(typ)) - } - return c.mapCode(typ) - case reflect.Struct: - return c.structCode(typ, isPtr) - case reflect.Int: - return c.intCode(typ, isPtr) - case reflect.Int8: - return c.int8Code(typ, isPtr) - case reflect.Int16: - return c.int16Code(typ, isPtr) - case reflect.Int32: - return c.int32Code(typ, isPtr) - case reflect.Int64: - return c.int64Code(typ, isPtr) - case reflect.Uint, reflect.Uintptr: - return c.uintCode(typ, isPtr) - case reflect.Uint8: - return c.uint8Code(typ, isPtr) - case reflect.Uint16: - return c.uint16Code(typ, isPtr) - case reflect.Uint32: - return c.uint32Code(typ, isPtr) - case reflect.Uint64: - return c.uint64Code(typ, isPtr) - case reflect.Float32: - return c.float32Code(typ, isPtr) - case reflect.Float64: - return c.float64Code(typ, isPtr) - case reflect.String: - return c.stringCode(typ, isPtr) - case reflect.Bool: - return c.boolCode(typ, isPtr) - case reflect.Interface: - return c.interfaceCode(typ, isPtr) - 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.isPtrMarshalJSONType(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) - 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) 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) - } - continue - } - } - if _, exists := duplicatedFieldMap[field]; exists { - 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++ - } - } - 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 - } - 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) { - return false - } - if typ.Kind() != reflect.Ptr { - return true - } - // type kind is reflect.Ptr - if !c.implementsMarshalJSONType(typ.Elem()) { - return true - } - // needs to dereference - return false -} - -func (c *Compiler) implementsMarshalText(typ *runtime.Type) bool { - if !typ.Implements(marshalTextType) { - return false - } - if typ.Kind() != reflect.Ptr { - return true - } - // type kind is reflect.Ptr - if !typ.Elem().Implements(marshalTextType) { - return true - } - // needs to dereference - return false -} - -func (c *Compiler) isNilableType(typ *runtime.Type) bool { - if !runtime.IfaceIndir(typ) { - return true - } - switch typ.Kind() { - case reflect.Ptr: - return true - case reflect.Map: - return true - case reflect.Func: - return true - default: - return false - } -} - -func (c *Compiler) 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 (c *Compiler) 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 deleted file mode 100644 index 20c93cbf7..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build !race -// +build !race - -package encoder - -func CompileToGetCodeSet(ctx *RuntimeContext, typeptr uintptr) (*OpcodeSet, error) { - if typeptr > typeAddr.MaxTypeAddr || typeptr < typeAddr.BaseTypeAddr { - codeSet, err := compileToGetCodeSetSlowPath(typeptr) - if err != nil { - return nil, err - } - return getFilteredCodeSetIfNeeded(ctx, codeSet) - } - 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 - } - codeSet, err := newCompiler().compile(typeptr) - if err != nil { - return nil, err - } - filtered, err := getFilteredCodeSetIfNeeded(ctx, codeSet) - if err != nil { - return nil, err - } - cachedOpcodeSets[index] = codeSet - return filtered, 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 deleted file mode 100644 index 13ba23fdf..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build race -// +build race - -package encoder - -import ( - "sync" -) - -var setsMu sync.RWMutex - -func CompileToGetCodeSet(ctx *RuntimeContext, typeptr uintptr) (*OpcodeSet, error) { - if typeptr > typeAddr.MaxTypeAddr || typeptr < typeAddr.BaseTypeAddr { - codeSet, err := compileToGetCodeSetSlowPath(typeptr) - if err != nil { - return nil, err - } - return getFilteredCodeSetIfNeeded(ctx, codeSet) - } - 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 - } - setsMu.RUnlock() - - codeSet, err := newCompiler().compile(typeptr) - if err != nil { - return nil, err - } - filtered, err := getFilteredCodeSetIfNeeded(ctx, codeSet) - if err != nil { - return nil, err - } - setsMu.Lock() - cachedOpcodeSets[index] = codeSet - setsMu.Unlock() - return filtered, 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 deleted file mode 100644 index 3833d0c86..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/context.go +++ /dev/null @@ -1,105 +0,0 @@ -package encoder - -import ( - "context" - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -type compileContext struct { - opcodeIndex uint32 - ptrIndex int - indent uint32 - escapeKey bool - structTypeToCodes map[uintptr]Opcodes - recursiveCodes *Opcodes -} - -func (c *compileContext) incIndent() { - c.indent++ -} - -func (c *compileContext) decIndent() { - c.indent-- -} - -func (c *compileContext) incIndex() { - c.incOpcodeIndex() - c.incPtrIndex() -} - -func (c *compileContext) decIndex() { - c.decOpcodeIndex() - c.decPtrIndex() -} - -func (c *compileContext) incOpcodeIndex() { - c.opcodeIndex++ -} - -func (c *compileContext) decOpcodeIndex() { - c.opcodeIndex-- -} - -func (c *compileContext) incPtrIndex() { - c.ptrIndex++ -} - -func (c *compileContext) decPtrIndex() { - c.ptrIndex-- -} - -const ( - bufSize = 1024 -) - -var ( - runtimeContextPool = sync.Pool{ - New: func() interface{} { - return &RuntimeContext{ - Buf: make([]byte, 0, bufSize), - Ptrs: make([]uintptr, 128), - KeepRefs: make([]unsafe.Pointer, 0, 8), - Option: &Option{}, - } - }, - } -) - -type RuntimeContext struct { - Context context.Context - Buf []byte - MarshalBuf []byte - Ptrs []uintptr - KeepRefs []unsafe.Pointer - SeenPtr []uintptr - BaseIndent uint32 - Prefix []byte - IndentStr []byte - Option *Option -} - -func (c *RuntimeContext) Init(p uintptr, codelen int) { - if len(c.Ptrs) < codelen { - c.Ptrs = make([]uintptr, codelen) - } - c.Ptrs[0] = p - c.KeepRefs = c.KeepRefs[:0] - c.SeenPtr = c.SeenPtr[:0] - c.BaseIndent = 0 -} - -func (c *RuntimeContext) Ptr() uintptr { - header := (*runtime.SliceHeader)(unsafe.Pointer(&c.Ptrs)) - return uintptr(header.Data) -} - -func TakeRuntimeContext() *RuntimeContext { - return runtimeContextPool.Get().(*RuntimeContext) -} - -func ReleaseRuntimeContext(ctx *RuntimeContext) { - runtimeContextPool.Put(ctx) -} 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 35c959d48..000000000 --- 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 deleted file mode 100644 index 14eb6a0d6..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/encoder.go +++ /dev/null @@ -1,596 +0,0 @@ -package encoder - -import ( - "bytes" - "encoding" - "encoding/base64" - "encoding/json" - "fmt" - "math" - "reflect" - "strconv" - "strings" - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -func (t OpType) IsMultipleOpHead() bool { - switch t { - case OpStructHead: - return true - case OpStructHeadSlice: - return true - case OpStructHeadArray: - return true - case OpStructHeadMap: - return true - case OpStructHeadStruct: - return true - case OpStructHeadOmitEmpty: - return true - case OpStructHeadOmitEmptySlice: - return true - case OpStructHeadOmitEmptyArray: - return true - case OpStructHeadOmitEmptyMap: - return true - case OpStructHeadOmitEmptyStruct: - return true - case OpStructHeadSlicePtr: - return true - case OpStructHeadOmitEmptySlicePtr: - return true - case OpStructHeadArrayPtr: - return true - case OpStructHeadOmitEmptyArrayPtr: - return true - case OpStructHeadMapPtr: - return true - case OpStructHeadOmitEmptyMapPtr: - return true - } - return false -} - -func (t OpType) IsMultipleOpField() bool { - switch t { - case OpStructField: - return true - case OpStructFieldSlice: - return true - case OpStructFieldArray: - return true - case OpStructFieldMap: - return true - case OpStructFieldStruct: - return true - case OpStructFieldOmitEmpty: - return true - case OpStructFieldOmitEmptySlice: - return true - case OpStructFieldOmitEmptyArray: - return true - case OpStructFieldOmitEmptyMap: - return true - case OpStructFieldOmitEmptyStruct: - return true - case OpStructFieldSlicePtr: - return true - case OpStructFieldOmitEmptySlicePtr: - return true - case OpStructFieldArrayPtr: - return true - case OpStructFieldOmitEmptyArrayPtr: - return true - case OpStructFieldMapPtr: - return true - case OpStructFieldOmitEmptyMapPtr: - return true - } - return false -} - -type OpcodeSet struct { - Type *runtime.Type - NoescapeKeyCode *Opcode - EscapeKeyCode *Opcode - InterfaceNoescapeKeyCode *Opcode - 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 { - Code *Opcode - Linked bool // whether recursive code already have linked - CurLen uintptr - NextLen uintptr -} - -const StartDetectingCyclesAfter = 1000 - -func Load(base uintptr, idx uintptr) uintptr { - addr := base + idx - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func Store(base uintptr, idx uintptr, p uintptr) { - addr := base + idx - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func LoadNPtr(base uintptr, idx uintptr, ptrNum int) uintptr { - addr := base + idx - p := **(**uintptr)(unsafe.Pointer(&addr)) - if p == 0 { - return 0 - } - return PtrToPtr(p) - /* - for i := 0; i < ptrNum; i++ { - if p == 0 { - return p - } - p = PtrToPtr(p) - } - return p - */ -} - -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)) } -func PtrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func PtrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func PtrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func PtrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func PtrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func PtrToNPtr(p uintptr, ptrNum int) uintptr { - for i := 0; i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = PtrToPtr(p) - } - return p -} - -func PtrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func PtrToInterface(code *Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func ErrUnsupportedValue(code *Opcode, ptr uintptr) *errors.UnsupportedValueError { - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&ptr)), - })) - return &errors.UnsupportedValueError{ - Value: reflect.ValueOf(v), - Str: fmt.Sprintf("encountered a cycle via %s", code.Type), - } -} - -func ErrUnsupportedFloat(v float64) *errors.UnsupportedValueError { - return &errors.UnsupportedValueError{ - Value: reflect.ValueOf(v), - Str: strconv.FormatFloat(v, 'g', -1, 64), - } -} - -func ErrMarshalerWithCode(code *Opcode, err error) *errors.MarshalerError { - return &errors.MarshalerError{ - Type: runtime.RType2Type(code.Type), - Err: err, - } -} - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type MapItem struct { - Key []byte - Value []byte -} - -type Mapslice struct { - Items []MapItem -} - -func (m *Mapslice) Len() int { - return len(m.Items) -} - -func (m *Mapslice) Less(i, j int) bool { - return bytes.Compare(m.Items[i].Key, m.Items[j].Key) < 0 -} - -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 - Slice *Mapslice - Buf []byte - Len int - Iter mapIter -} - -var mapContextPool = sync.Pool{ - New: func() interface{} { - return &MapContext{ - Slice: &Mapslice{}, - } - }, -} - -func NewMapContext(mapLen int, unorderedMap bool) *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] - } - } - ctx.Buf = ctx.Buf[:0] - ctx.Iter = mapIter{} - ctx.Idx = 0 - ctx.Len = mapLen - return ctx -} - -func ReleaseMapContext(c *MapContext) { - mapContextPool.Put(c) -} - -//go:linkname MapIterInit runtime.mapiterinit -//go:noescape -func MapIterInit(mapType *runtime.Type, m unsafe.Pointer, it *mapIter) - -//go:linkname MapIterKey reflect.mapiterkey -//go:noescape -func MapIterKey(it *mapIter) unsafe.Pointer - -//go:linkname MapIterNext reflect.mapiternext -//go:noescape -func MapIterNext(it *mapIter) - -//go:linkname MapLen reflect.maplen -//go:noescape -func MapLen(m unsafe.Pointer) int - -func AppendByteSlice(_ *RuntimeContext, b []byte, src []byte) []byte { - if src == nil { - return append(b, `null`...) - } - encodedLen := base64.StdEncoding.EncodedLen(len(src)) - b = append(b, '"') - pos := len(b) - remainLen := cap(b[pos:]) - var buf []byte - if remainLen > encodedLen { - buf = b[pos : pos+encodedLen] - } else { - buf = make([]byte, encodedLen) - } - base64.StdEncoding.Encode(buf, src) - return append(append(b, buf...), '"') -} - -func AppendFloat32(_ *RuntimeContext, b []byte, v float32) []byte { - f64 := float64(v) - abs := math.Abs(f64) - fmt := byte('f') - // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right. - if abs != 0 { - f32 := float32(abs) - if f32 < 1e-6 || f32 >= 1e21 { - fmt = 'e' - } - } - return strconv.AppendFloat(b, f64, fmt, -1, 32) -} - -func AppendFloat64(_ *RuntimeContext, b []byte, v float64) []byte { - abs := math.Abs(v) - 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' - } - } - return strconv.AppendFloat(b, v, fmt, -1, 64) -} - -func AppendBool(_ *RuntimeContext, b []byte, v bool) []byte { - if v { - return append(b, "true"...) - } - return append(b, "false"...) -} - -var ( - floatTable = [256]bool{ - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - '.': true, - 'e': true, - 'E': true, - '+': true, - '-': true, - } -) - -func AppendNumber(_ *RuntimeContext, b []byte, n json.Number) ([]byte, error) { - if len(n) == 0 { - return append(b, '0'), nil - } - for i := 0; i < len(n); i++ { - if !floatTable[n[i]] { - return nil, fmt.Errorf("json: invalid number literal %q", n) - } - } - b = append(b, n...) - return b, nil -} - -func AppendMarshalJSON(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if (code.Flags & AddrForMarshalerFlags) != 0 { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - var bb []byte - if (code.Flags & MarshalerContextFlags) != 0 { - marshaler, ok := v.(marshalerContext) - 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) - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - bb = b - } else { - marshaler, ok := v.(json.Marshaler) - if !ok { - return AppendNull(ctx, b), nil - } - b, err := marshaler.MarshalJSON() - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - bb = b - } - marshalBuf := ctx.MarshalBuf[:0] - marshalBuf = append(append(marshalBuf, bb...), nul) - compactedBuf, err := compact(b, marshalBuf, (ctx.Option.Flag&HTMLEscapeOption) != 0) - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - ctx.MarshalBuf = marshalBuf - return compactedBuf, nil -} - -func AppendMarshalJSONIndent(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if (code.Flags & AddrForMarshalerFlags) != 0 { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - var bb []byte - if (code.Flags & MarshalerContextFlags) != 0 { - marshaler, ok := v.(marshalerContext) - if !ok { - return AppendNull(ctx, b), nil - } - b, err := marshaler.MarshalJSON(ctx.Option.Context) - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - bb = b - } else { - marshaler, ok := v.(json.Marshaler) - if !ok { - return AppendNull(ctx, b), nil - } - b, err := marshaler.MarshalJSON() - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - bb = b - } - marshalBuf := ctx.MarshalBuf[:0] - marshalBuf = append(append(marshalBuf, bb...), nul) - indentedBuf, err := doIndent( - b, - marshalBuf, - string(ctx.Prefix)+strings.Repeat(string(ctx.IndentStr), int(ctx.BaseIndent+code.Indent)), - string(ctx.IndentStr), - (ctx.Option.Flag&HTMLEscapeOption) != 0, - ) - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - ctx.MarshalBuf = marshalBuf - return indentedBuf, nil -} - -func AppendMarshalText(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if (code.Flags & AddrForMarshalerFlags) != 0 { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - marshaler, ok := v.(encoding.TextMarshaler) - if !ok { - return AppendNull(ctx, b), nil - } - bytes, err := marshaler.MarshalText() - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - return AppendString(ctx, b, *(*string)(unsafe.Pointer(&bytes))), nil -} - -func AppendMarshalTextIndent(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if (code.Flags & AddrForMarshalerFlags) != 0 { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - marshaler, ok := v.(encoding.TextMarshaler) - if !ok { - return AppendNull(ctx, b), nil - } - bytes, err := marshaler.MarshalText() - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - return AppendString(ctx, b, *(*string)(unsafe.Pointer(&bytes))), nil -} - -func AppendNull(_ *RuntimeContext, b []byte) []byte { - return append(b, "null"...) -} - -func AppendComma(_ *RuntimeContext, b []byte) []byte { - return append(b, ',') -} - -func AppendCommaIndent(_ *RuntimeContext, b []byte) []byte { - return append(b, ',', '\n') -} - -func AppendStructEnd(_ *RuntimeContext, b []byte) []byte { - return append(b, '}', ',') -} - -func AppendStructEndIndent(ctx *RuntimeContext, code *Opcode, b []byte) []byte { - b = append(b, '\n') - b = append(b, ctx.Prefix...) - indentNum := ctx.BaseIndent + code.Indent - 1 - for i := uint32(0); i < indentNum; i++ { - b = append(b, ctx.IndentStr...) - } - return append(b, '}', ',', '\n') -} - -func AppendIndent(ctx *RuntimeContext, b []byte, indent uint32) []byte { - b = append(b, ctx.Prefix...) - indentNum := ctx.BaseIndent + indent - for i := uint32(0); i < indentNum; i++ { - b = append(b, ctx.IndentStr...) - } - return b -} - -func IsNilForMarshaler(v interface{}) bool { - rv := reflect.ValueOf(v) - switch rv.Kind() { - case reflect.Bool: - return !rv.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return rv.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return rv.Uint() == 0 - case reflect.Float32, reflect.Float64: - return math.Float64bits(rv.Float()) == 0 - case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Func: - 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/indent.go b/vendor/github.com/goccy/go-json/internal/encoder/indent.go deleted file mode 100644 index dfe04b5e3..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/indent.go +++ /dev/null @@ -1,211 +0,0 @@ -package encoder - -import ( - "bytes" - "fmt" - - "github.com/goccy/go-json/internal/errors" -) - -func takeIndentSrcRuntimeContext(src []byte) (*RuntimeContext, []byte) { - ctx := TakeRuntimeContext() - buf := ctx.Buf[:0] - buf = append(append(buf, src...), nul) - ctx.Buf = buf - return ctx, buf -} - -func Indent(buf *bytes.Buffer, src []byte, prefix, indentStr string) error { - if len(src) == 0 { - return errors.ErrUnexpectedEndOfJSON("", 0) - } - - srcCtx, srcBuf := takeIndentSrcRuntimeContext(src) - dstCtx := TakeRuntimeContext() - dst := dstCtx.Buf[:0] - - dst, err := indentAndWrite(buf, dst, srcBuf, prefix, indentStr) - if err != nil { - ReleaseRuntimeContext(srcCtx) - ReleaseRuntimeContext(dstCtx) - return err - } - dstCtx.Buf = dst - ReleaseRuntimeContext(srcCtx) - ReleaseRuntimeContext(dstCtx) - return nil -} - -func indentAndWrite(buf *bytes.Buffer, dst []byte, src []byte, prefix, indentStr string) ([]byte, error) { - dst, err := doIndent(dst, src, prefix, indentStr, false) - if err != nil { - return nil, err - } - if _, err := buf.Write(dst); err != nil { - return nil, err - } - return dst, nil -} - -func doIndent(dst, src []byte, prefix, indentStr string, escape bool) ([]byte, error) { - buf, cursor, err := indentValue(dst, src, 0, 0, []byte(prefix), []byte(indentStr), escape) - if err != nil { - return nil, err - } - if err := validateEndBuf(src, cursor); err != nil { - return nil, err - } - return buf, nil -} - -func indentValue( - dst []byte, - src []byte, - indentNum int, - cursor int64, - prefix []byte, - indentBytes []byte, - escape bool) ([]byte, int64, error) { - for { - switch src[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case '{': - return indentObject(dst, src, indentNum, cursor, prefix, indentBytes, escape) - case '}': - return nil, 0, errors.ErrSyntax("unexpected character '}'", cursor) - case '[': - return indentArray(dst, src, indentNum, cursor, prefix, indentBytes, escape) - case ']': - return nil, 0, errors.ErrSyntax("unexpected character ']'", cursor) - case '"': - return compactString(dst, src, cursor, escape) - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return compactNumber(dst, src, cursor) - case 't': - return compactTrue(dst, src, cursor) - case 'f': - return compactFalse(dst, src, cursor) - case 'n': - return compactNull(dst, src, cursor) - default: - return nil, 0, errors.ErrSyntax(fmt.Sprintf("unexpected character '%c'", src[cursor]), cursor) - } - } -} - -func indentObject( - dst []byte, - src []byte, - indentNum int, - cursor int64, - prefix []byte, - indentBytes []byte, - escape bool) ([]byte, int64, error) { - if src[cursor] == '{' { - dst = append(dst, '{') - } else { - return nil, 0, errors.ErrExpected("expected { character for object value", cursor) - } - cursor = skipWhiteSpace(src, cursor+1) - if src[cursor] == '}' { - dst = append(dst, '}') - return dst, cursor + 1, nil - } - indentNum++ - var err error - for { - dst = append(append(dst, '\n'), prefix...) - for i := 0; i < indentNum; i++ { - dst = append(dst, indentBytes...) - } - cursor = skipWhiteSpace(src, cursor) - dst, cursor, err = compactString(dst, src, cursor, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - if src[cursor] != ':' { - return nil, 0, errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after object key", src[cursor]), - cursor+1, - ) - } - dst = append(dst, ':', ' ') - dst, cursor, err = indentValue(dst, src, indentNum, cursor+1, prefix, indentBytes, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - switch src[cursor] { - case '}': - dst = append(append(dst, '\n'), prefix...) - for i := 0; i < indentNum-1; i++ { - dst = append(dst, indentBytes...) - } - dst = append(dst, '}') - cursor++ - return dst, cursor, nil - case ',': - dst = append(dst, ',') - default: - return nil, 0, errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after object key:value pair", src[cursor]), - cursor+1, - ) - } - cursor++ - } -} - -func indentArray( - dst []byte, - src []byte, - indentNum int, - cursor int64, - prefix []byte, - indentBytes []byte, - escape bool) ([]byte, int64, error) { - if src[cursor] == '[' { - dst = append(dst, '[') - } else { - return nil, 0, errors.ErrExpected("expected [ character for array value", cursor) - } - cursor = skipWhiteSpace(src, cursor+1) - if src[cursor] == ']' { - dst = append(dst, ']') - return dst, cursor + 1, nil - } - indentNum++ - var err error - for { - dst = append(append(dst, '\n'), prefix...) - for i := 0; i < indentNum; i++ { - dst = append(dst, indentBytes...) - } - dst, cursor, err = indentValue(dst, src, indentNum, cursor, prefix, indentBytes, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - switch src[cursor] { - case ']': - dst = append(append(dst, '\n'), prefix...) - for i := 0; i < indentNum-1; i++ { - dst = append(dst, indentBytes...) - } - dst = append(dst, ']') - cursor++ - return dst, cursor, nil - case ',': - dst = append(dst, ',') - default: - return nil, 0, errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after array value", src[cursor]), - cursor+1, - ) - } - cursor++ - } -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/int.go b/vendor/github.com/goccy/go-json/internal/encoder/int.go deleted file mode 100644 index 85f079609..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/int.go +++ /dev/null @@ -1,152 +0,0 @@ -package encoder - -import ( - "unsafe" -) - -var endianness int - -func init() { - var b [2]byte - *(*uint16)(unsafe.Pointer(&b)) = uint16(0xABCD) - - switch b[0] { - case 0xCD: - endianness = 0 // LE - case 0xAB: - endianness = 1 // BE - default: - panic("could not determine endianness") - } -} - -// "00010203...96979899" cast to []uint16 -var intLELookup = [100]uint16{ - 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730, 0x3830, 0x3930, - 0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731, 0x3831, 0x3931, - 0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, 0x3732, 0x3832, 0x3932, - 0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, 0x3633, 0x3733, 0x3833, 0x3933, - 0x3034, 0x3134, 0x3234, 0x3334, 0x3434, 0x3534, 0x3634, 0x3734, 0x3834, 0x3934, - 0x3035, 0x3135, 0x3235, 0x3335, 0x3435, 0x3535, 0x3635, 0x3735, 0x3835, 0x3935, - 0x3036, 0x3136, 0x3236, 0x3336, 0x3436, 0x3536, 0x3636, 0x3736, 0x3836, 0x3936, - 0x3037, 0x3137, 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737, 0x3837, 0x3937, - 0x3038, 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738, 0x3838, 0x3938, - 0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739, 0x3839, 0x3939, -} - -var intBELookup = [100]uint16{ - 0x3030, 0x3031, 0x3032, 0x3033, 0x3034, 0x3035, 0x3036, 0x3037, 0x3038, 0x3039, - 0x3130, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138, 0x3139, - 0x3230, 0x3231, 0x3232, 0x3233, 0x3234, 0x3235, 0x3236, 0x3237, 0x3238, 0x3239, - 0x3330, 0x3331, 0x3332, 0x3333, 0x3334, 0x3335, 0x3336, 0x3337, 0x3338, 0x3339, - 0x3430, 0x3431, 0x3432, 0x3433, 0x3434, 0x3435, 0x3436, 0x3437, 0x3438, 0x3439, - 0x3530, 0x3531, 0x3532, 0x3533, 0x3534, 0x3535, 0x3536, 0x3537, 0x3538, 0x3539, - 0x3630, 0x3631, 0x3632, 0x3633, 0x3634, 0x3635, 0x3636, 0x3637, 0x3638, 0x3639, - 0x3730, 0x3731, 0x3732, 0x3733, 0x3734, 0x3735, 0x3736, 0x3737, 0x3738, 0x3739, - 0x3830, 0x3831, 0x3832, 0x3833, 0x3834, 0x3835, 0x3836, 0x3837, 0x3838, 0x3839, - 0x3930, 0x3931, 0x3932, 0x3933, 0x3934, 0x3935, 0x3936, 0x3937, 0x3938, 0x3939, -} - -var intLookup = [2]*[100]uint16{&intLELookup, &intBELookup} - -func numMask(numBitSize uint8) uint64 { - return 1<>(code.NumBitSize-1))&1 == 1 - if !negative { - if n < 10 { - return append(out, byte(n+'0')) - } else if n < 100 { - u := intLELookup[n] - return append(out, byte(u), byte(u>>8)) - } - } else { - n = -n & mask - } - - lookup := intLookup[endianness] - - var b [22]byte - u := (*[11]uint16)(unsafe.Pointer(&b)) - i := 11 - - for n >= 100 { - j := n % 100 - n /= 100 - i-- - u[i] = lookup[j] - } - - i-- - u[i] = lookup[n] - - i *= 2 // convert to byte index - if n < 10 { - i++ // remove leading zero - } - if negative { - i-- - b[i] = '-' - } - - 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)) - } - mask := numMask(code.NumBitSize) - n := u64 & mask - if n < 10 { - return append(out, byte(n+'0')) - } else if n < 100 { - u := intLELookup[n] - return append(out, byte(u), byte(u>>8)) - } - - lookup := intLookup[endianness] - - var b [22]byte - u := (*[11]uint16)(unsafe.Pointer(&b)) - i := 11 - - for n >= 100 { - j := n % 100 - n /= 100 - i-- - u[i] = lookup[j] - } - - i-- - u[i] = lookup[n] - - i *= 2 // convert to byte index - if n < 10 { - i++ // remove leading zero - } - return append(out, b[i:]...) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/map112.go b/vendor/github.com/goccy/go-json/internal/encoder/map112.go deleted file mode 100644 index e96ffadf7..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/map112.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build !go1.13 -// +build !go1.13 - -package encoder - -import "unsafe" - -//go:linkname MapIterValue reflect.mapitervalue -func MapIterValue(it *mapIter) 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 deleted file mode 100644 index 9b69dcc36..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/map113.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build go1.13 -// +build go1.13 - -package encoder - -import "unsafe" - -//go:linkname MapIterValue reflect.mapiterelem -func MapIterValue(it *mapIter) 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 deleted file mode 100644 index df22f5542..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/opcode.go +++ /dev/null @@ -1,752 +0,0 @@ -package encoder - -import ( - "bytes" - "fmt" - "sort" - "strings" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -type OpFlags uint16 - -const ( - AnonymousHeadFlags OpFlags = 1 << 0 - AnonymousKeyFlags OpFlags = 1 << 1 - IndirectFlags OpFlags = 1 << 2 - IsTaggedKeyFlags OpFlags = 1 << 3 - NilCheckFlags OpFlags = 1 << 4 - AddrForMarshalerFlags OpFlags = 1 << 5 - IsNextOpPtrTypeFlags OpFlags = 1 << 6 - IsNilableTypeFlags OpFlags = 1 << 7 - MarshalerContextFlags OpFlags = 1 << 8 - NonEmptyInterfaceFlags OpFlags = 1 << 9 -) - -type Opcode struct { - Op OpType // operation type - Idx uint32 // offset to access ptr - Next *Opcode // next opcode - End *Opcode // array/slice/struct/map end - NextField *Opcode // next struct field - Key string // struct field key - Offset uint32 // offset size from struct header - PtrNum uint8 // pointer number: e.g. double pointer is 2. - NumBitSize uint8 - Flags OpFlags - - Type *runtime.Type // go type - 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 - 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.Size, - } { - if max < value { - max = value - } - } - return max -} - -func (c *Opcode) ToHeaderType(isString bool) OpType { - switch c.Op { - case OpInt: - if isString { - return OpStructHeadIntString - } - return OpStructHeadInt - case OpIntPtr: - if isString { - return OpStructHeadIntPtrString - } - return OpStructHeadIntPtr - case OpUint: - if isString { - return OpStructHeadUintString - } - return OpStructHeadUint - case OpUintPtr: - if isString { - return OpStructHeadUintPtrString - } - return OpStructHeadUintPtr - case OpFloat32: - if isString { - return OpStructHeadFloat32String - } - return OpStructHeadFloat32 - case OpFloat32Ptr: - if isString { - return OpStructHeadFloat32PtrString - } - return OpStructHeadFloat32Ptr - case OpFloat64: - if isString { - return OpStructHeadFloat64String - } - return OpStructHeadFloat64 - case OpFloat64Ptr: - if isString { - return OpStructHeadFloat64PtrString - } - return OpStructHeadFloat64Ptr - case OpString: - if isString { - return OpStructHeadStringString - } - return OpStructHeadString - case OpStringPtr: - if isString { - return OpStructHeadStringPtrString - } - return OpStructHeadStringPtr - case OpNumber: - if isString { - return OpStructHeadNumberString - } - return OpStructHeadNumber - case OpNumberPtr: - if isString { - return OpStructHeadNumberPtrString - } - return OpStructHeadNumberPtr - case OpBool: - if isString { - return OpStructHeadBoolString - } - return OpStructHeadBool - case OpBoolPtr: - if isString { - return OpStructHeadBoolPtrString - } - return OpStructHeadBoolPtr - case OpBytes: - return OpStructHeadBytes - case OpBytesPtr: - return OpStructHeadBytesPtr - case OpMap: - return OpStructHeadMap - case OpMapPtr: - c.Op = OpMap - return OpStructHeadMapPtr - case OpArray: - return OpStructHeadArray - case OpArrayPtr: - c.Op = OpArray - return OpStructHeadArrayPtr - case OpSlice: - return OpStructHeadSlice - case OpSlicePtr: - c.Op = OpSlice - return OpStructHeadSlicePtr - case OpMarshalJSON: - return OpStructHeadMarshalJSON - case OpMarshalJSONPtr: - return OpStructHeadMarshalJSONPtr - case OpMarshalText: - return OpStructHeadMarshalText - case OpMarshalTextPtr: - return OpStructHeadMarshalTextPtr - } - return OpStructHead -} - -func (c *Opcode) ToFieldType(isString bool) OpType { - switch c.Op { - case OpInt: - if isString { - return OpStructFieldIntString - } - return OpStructFieldInt - case OpIntPtr: - if isString { - return OpStructFieldIntPtrString - } - return OpStructFieldIntPtr - case OpUint: - if isString { - return OpStructFieldUintString - } - return OpStructFieldUint - case OpUintPtr: - if isString { - return OpStructFieldUintPtrString - } - return OpStructFieldUintPtr - case OpFloat32: - if isString { - return OpStructFieldFloat32String - } - return OpStructFieldFloat32 - case OpFloat32Ptr: - if isString { - return OpStructFieldFloat32PtrString - } - return OpStructFieldFloat32Ptr - case OpFloat64: - if isString { - return OpStructFieldFloat64String - } - return OpStructFieldFloat64 - case OpFloat64Ptr: - if isString { - return OpStructFieldFloat64PtrString - } - return OpStructFieldFloat64Ptr - case OpString: - if isString { - return OpStructFieldStringString - } - return OpStructFieldString - case OpStringPtr: - if isString { - return OpStructFieldStringPtrString - } - return OpStructFieldStringPtr - case OpNumber: - if isString { - return OpStructFieldNumberString - } - return OpStructFieldNumber - case OpNumberPtr: - if isString { - return OpStructFieldNumberPtrString - } - return OpStructFieldNumberPtr - case OpBool: - if isString { - return OpStructFieldBoolString - } - return OpStructFieldBool - case OpBoolPtr: - if isString { - return OpStructFieldBoolPtrString - } - return OpStructFieldBoolPtr - case OpBytes: - return OpStructFieldBytes - case OpBytesPtr: - return OpStructFieldBytesPtr - case OpMap: - return OpStructFieldMap - case OpMapPtr: - c.Op = OpMap - return OpStructFieldMapPtr - case OpArray: - return OpStructFieldArray - case OpArrayPtr: - c.Op = OpArray - return OpStructFieldArrayPtr - case OpSlice: - return OpStructFieldSlice - case OpSlicePtr: - c.Op = OpSlice - return OpStructFieldSlicePtr - case OpMarshalJSON: - return OpStructFieldMarshalJSON - case OpMarshalJSONPtr: - return OpStructFieldMarshalJSONPtr - case OpMarshalText: - return OpStructFieldMarshalText - case OpMarshalTextPtr: - return OpStructFieldMarshalTextPtr - } - return OpStructField -} - -func newOpCode(ctx *compileContext, typ *runtime.Type, op OpType) *Opcode { - return newOpCodeWithNext(ctx, typ, op, newEndOp(ctx, typ)) -} - -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 -} - -func setTotalLengthToInterfaceOp(code *Opcode) { - for c := code; !c.IsEnd(); { - if c.Op == OpInterface || c.Op == OpInterfacePtr { - c.Length = uint32(code.TotalLength()) - } - c = c.IterNext() - } -} - -func ToEndCode(code *Opcode) *Opcode { - c := code - for !c.IsEnd() { - c = c.IterNext() - } - return c -} - -func copyToInterfaceOpcode(code *Opcode) *Opcode { - copied := copyOpcode(code) - c := copied - c = ToEndCode(c) - c.Idx += uintptrSize - c.ElemIdx = c.Idx + uintptrSize - c.Length = c.Idx + 2*uintptrSize - c.Op = OpInterfaceEnd - return copied -} - -func newOpCodeWithNext(ctx *compileContext, typ *runtime.Type, op OpType, next *Opcode) *Opcode { - return &Opcode{ - Op: op, - Idx: opcodeOffset(ctx.ptrIndex), - Next: next, - Type: typ, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - } -} - -func newEndOp(ctx *compileContext, typ *runtime.Type) *Opcode { - return newOpCodeWithNext(ctx, typ, OpEnd, nil) -} - -func (c *Opcode) TotalLength() int { - var idx int - code := c - for !code.IsEnd() { - maxIdx := int(code.MaxIdx() / uintptrSize) - if idx < maxIdx { - idx = maxIdx - } - if code.Op == OpRecursiveEnd { - break - } - code = code.IterNext() - } - maxIdx := int(code.MaxIdx() / uintptrSize) - if idx < maxIdx { - idx = maxIdx - } - return idx + 1 -} - -func (c *Opcode) dumpHead(code *Opcode) string { - var length uint32 - if code.Op.CodeType() == CodeArrayHead { - length = code.Length - } else { - length = code.Length / uintptrSize - } - return fmt.Sprintf( - `[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.ElemIdx/uintptrSize, - length, - ) -} - -func (c *Opcode) dumpMapHead(code *Opcode) string { - return fmt.Sprintf( - `[%03d]%s%s ([idx:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - ) -} - -func (c *Opcode) dumpMapEnd(code *Opcode) string { - return fmt.Sprintf( - `[%03d]%s%s ([idx:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - ) -} - -func (c *Opcode) dumpElem(code *Opcode) string { - var length uint32 - if code.Op.CodeType() == CodeArrayElem { - length = code.Length - } else { - length = code.Length / uintptrSize - } - return fmt.Sprintf( - `[%03d]%s%s ([idx:%d][elemIdx:%d][length:%d][size:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.ElemIdx/uintptrSize, - length, - code.Size, - ) -} - -func (c *Opcode) dumpField(code *Opcode) string { - return fmt.Sprintf( - `[%03d]%s%s ([idx:%d][key:%s][offset:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.DisplayKey, - code.Offset, - ) -} - -func (c *Opcode) dumpKey(code *Opcode) string { - return fmt.Sprintf( - `[%03d]%s%s ([idx:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - ) -} - -func (c *Opcode) dumpValue(code *Opcode) string { - return fmt.Sprintf( - `[%03d]%s%s ([idx:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - ) -} - -func (c *Opcode) Dump() string { - codes := []string{} - for code := c; !code.IsEnd(); { - switch code.Op.CodeType() { - case CodeSliceHead: - codes = append(codes, c.dumpHead(code)) - code = code.Next - case CodeMapHead: - codes = append(codes, c.dumpMapHead(code)) - code = code.Next - case CodeArrayElem, CodeSliceElem: - codes = append(codes, c.dumpElem(code)) - code = code.End - case CodeMapKey: - codes = append(codes, c.dumpKey(code)) - code = code.End - case CodeMapValue: - codes = append(codes, c.dumpValue(code)) - code = code.Next - case CodeMapEnd: - codes = append(codes, c.dumpMapEnd(code)) - code = code.Next - case CodeStructField: - codes = append(codes, c.dumpField(code)) - code = code.Next - case CodeStructEnd: - codes = append(codes, c.dumpField(code)) - code = code.Next - default: - codes = append(codes, fmt.Sprintf( - "[%03d]%s%s ([idx:%d])", - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - )) - code = code.Next - } - } - return strings.Join(codes, "\n") -} - -func (c *Opcode) DumpDOT() string { - type edge struct { - from, to *Opcode - label string - weight int - } - 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() -} - -func newSliceHeaderCode(ctx *compileContext, typ *runtime.Type) *Opcode { - idx := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - elemIdx := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - length := opcodeOffset(ctx.ptrIndex) - return &Opcode{ - Op: OpSlice, - Type: typ, - Idx: idx, - DisplayIdx: ctx.opcodeIndex, - ElemIdx: elemIdx, - Length: length, - Indent: ctx.indent, - } -} - -func newSliceElemCode(ctx *compileContext, typ *runtime.Type, head *Opcode, size uintptr) *Opcode { - return &Opcode{ - Op: OpSliceElem, - Type: typ, - Idx: head.Idx, - DisplayIdx: ctx.opcodeIndex, - ElemIdx: head.ElemIdx, - Length: head.Length, - Indent: ctx.indent, - Size: uint32(size), - } -} - -func newArrayHeaderCode(ctx *compileContext, typ *runtime.Type, 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, - Indent: ctx.indent, - Length: uint32(alen), - } -} - -func newArrayElemCode(ctx *compileContext, typ *runtime.Type, head *Opcode, length int, size uintptr) *Opcode { - return &Opcode{ - Op: OpArrayElem, - Type: typ, - Idx: head.Idx, - DisplayIdx: ctx.opcodeIndex, - ElemIdx: head.ElemIdx, - Length: uint32(length), - Indent: ctx.indent, - Size: uint32(size), - } -} - -func newMapHeaderCode(ctx *compileContext, typ *runtime.Type) *Opcode { - idx := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - return &Opcode{ - Op: OpMap, - Type: typ, - Idx: idx, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - } -} - -func newMapKeyCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opcode { - return &Opcode{ - Op: OpMapKey, - Type: typ, - Idx: head.Idx, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - } -} - -func newMapValueCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opcode { - return &Opcode{ - Op: OpMapValue, - Type: typ, - Idx: head.Idx, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - } -} - -func newMapEndCode(ctx *compileContext, typ *runtime.Type, head *Opcode) *Opcode { - return &Opcode{ - Op: OpMapEnd, - Type: typ, - Idx: head.Idx, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - Next: newEndOp(ctx, typ), - } -} - -func newRecursiveCode(ctx *compileContext, typ *runtime.Type, jmp *CompiledCode) *Opcode { - return &Opcode{ - Op: OpRecursive, - Type: typ, - Idx: opcodeOffset(ctx.ptrIndex), - Next: newEndOp(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 deleted file mode 100644 index 12c58e46c..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/option.go +++ /dev/null @@ -1,48 +0,0 @@ -package encoder - -import ( - "context" - "io" -) - -type OptionFlag uint8 - -const ( - HTMLEscapeOption OptionFlag = 1 << iota - IndentOption - UnorderedMapOption - DebugOption - ColorizeOption - ContextOption - NormalizeUTF8Option - FieldQueryOption -) - -type Option struct { - Flag OptionFlag - ColorScheme *ColorScheme - Context context.Context - DebugOut io.Writer - DebugDOTOut io.WriteCloser -} - -type EncodeFormat struct { - Header string - Footer string -} - -type EncodeFormatScheme struct { - Int EncodeFormat - Uint EncodeFormat - Float EncodeFormat - Bool EncodeFormat - String EncodeFormat - Binary EncodeFormat - ObjectKey EncodeFormat - Null EncodeFormat -} - -type ( - ColorScheme = EncodeFormatScheme - ColorFormat = EncodeFormat -) diff --git a/vendor/github.com/goccy/go-json/internal/encoder/optype.go b/vendor/github.com/goccy/go-json/internal/encoder/optype.go deleted file mode 100644 index 5c1241b47..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/optype.go +++ /dev/null @@ -1,932 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package encoder - -import ( - "strings" -) - -type CodeType int - -const ( - CodeOp CodeType = 0 - CodeArrayHead CodeType = 1 - CodeArrayElem CodeType = 2 - CodeSliceHead CodeType = 3 - CodeSliceElem CodeType = 4 - CodeMapHead CodeType = 5 - CodeMapKey CodeType = 6 - CodeMapValue CodeType = 7 - CodeMapEnd CodeType = 8 - CodeRecursive CodeType = 9 - CodeStructField CodeType = 10 - CodeStructEnd CodeType = 11 -) - -var opTypeStrings = [400]string{ - "End", - "Interface", - "Ptr", - "SliceElem", - "SliceEnd", - "ArrayElem", - "ArrayEnd", - "MapKey", - "MapValue", - "MapEnd", - "Recursive", - "RecursivePtr", - "RecursiveEnd", - "InterfaceEnd", - "Int", - "Uint", - "Float32", - "Float64", - "Bool", - "String", - "Bytes", - "Number", - "Array", - "Map", - "Slice", - "Struct", - "MarshalJSON", - "MarshalText", - "IntString", - "UintString", - "Float32String", - "Float64String", - "BoolString", - "StringString", - "NumberString", - "IntPtr", - "UintPtr", - "Float32Ptr", - "Float64Ptr", - "BoolPtr", - "StringPtr", - "BytesPtr", - "NumberPtr", - "ArrayPtr", - "MapPtr", - "SlicePtr", - "MarshalJSONPtr", - "MarshalTextPtr", - "InterfacePtr", - "IntPtrString", - "UintPtrString", - "Float32PtrString", - "Float64PtrString", - "BoolPtrString", - "StringPtrString", - "NumberPtrString", - "StructHeadInt", - "StructHeadOmitEmptyInt", - "StructPtrHeadInt", - "StructPtrHeadOmitEmptyInt", - "StructHeadUint", - "StructHeadOmitEmptyUint", - "StructPtrHeadUint", - "StructPtrHeadOmitEmptyUint", - "StructHeadFloat32", - "StructHeadOmitEmptyFloat32", - "StructPtrHeadFloat32", - "StructPtrHeadOmitEmptyFloat32", - "StructHeadFloat64", - "StructHeadOmitEmptyFloat64", - "StructPtrHeadFloat64", - "StructPtrHeadOmitEmptyFloat64", - "StructHeadBool", - "StructHeadOmitEmptyBool", - "StructPtrHeadBool", - "StructPtrHeadOmitEmptyBool", - "StructHeadString", - "StructHeadOmitEmptyString", - "StructPtrHeadString", - "StructPtrHeadOmitEmptyString", - "StructHeadBytes", - "StructHeadOmitEmptyBytes", - "StructPtrHeadBytes", - "StructPtrHeadOmitEmptyBytes", - "StructHeadNumber", - "StructHeadOmitEmptyNumber", - "StructPtrHeadNumber", - "StructPtrHeadOmitEmptyNumber", - "StructHeadArray", - "StructHeadOmitEmptyArray", - "StructPtrHeadArray", - "StructPtrHeadOmitEmptyArray", - "StructHeadMap", - "StructHeadOmitEmptyMap", - "StructPtrHeadMap", - "StructPtrHeadOmitEmptyMap", - "StructHeadSlice", - "StructHeadOmitEmptySlice", - "StructPtrHeadSlice", - "StructPtrHeadOmitEmptySlice", - "StructHeadStruct", - "StructHeadOmitEmptyStruct", - "StructPtrHeadStruct", - "StructPtrHeadOmitEmptyStruct", - "StructHeadMarshalJSON", - "StructHeadOmitEmptyMarshalJSON", - "StructPtrHeadMarshalJSON", - "StructPtrHeadOmitEmptyMarshalJSON", - "StructHeadMarshalText", - "StructHeadOmitEmptyMarshalText", - "StructPtrHeadMarshalText", - "StructPtrHeadOmitEmptyMarshalText", - "StructHeadIntString", - "StructHeadOmitEmptyIntString", - "StructPtrHeadIntString", - "StructPtrHeadOmitEmptyIntString", - "StructHeadUintString", - "StructHeadOmitEmptyUintString", - "StructPtrHeadUintString", - "StructPtrHeadOmitEmptyUintString", - "StructHeadFloat32String", - "StructHeadOmitEmptyFloat32String", - "StructPtrHeadFloat32String", - "StructPtrHeadOmitEmptyFloat32String", - "StructHeadFloat64String", - "StructHeadOmitEmptyFloat64String", - "StructPtrHeadFloat64String", - "StructPtrHeadOmitEmptyFloat64String", - "StructHeadBoolString", - "StructHeadOmitEmptyBoolString", - "StructPtrHeadBoolString", - "StructPtrHeadOmitEmptyBoolString", - "StructHeadStringString", - "StructHeadOmitEmptyStringString", - "StructPtrHeadStringString", - "StructPtrHeadOmitEmptyStringString", - "StructHeadNumberString", - "StructHeadOmitEmptyNumberString", - "StructPtrHeadNumberString", - "StructPtrHeadOmitEmptyNumberString", - "StructHeadIntPtr", - "StructHeadOmitEmptyIntPtr", - "StructPtrHeadIntPtr", - "StructPtrHeadOmitEmptyIntPtr", - "StructHeadUintPtr", - "StructHeadOmitEmptyUintPtr", - "StructPtrHeadUintPtr", - "StructPtrHeadOmitEmptyUintPtr", - "StructHeadFloat32Ptr", - "StructHeadOmitEmptyFloat32Ptr", - "StructPtrHeadFloat32Ptr", - "StructPtrHeadOmitEmptyFloat32Ptr", - "StructHeadFloat64Ptr", - "StructHeadOmitEmptyFloat64Ptr", - "StructPtrHeadFloat64Ptr", - "StructPtrHeadOmitEmptyFloat64Ptr", - "StructHeadBoolPtr", - "StructHeadOmitEmptyBoolPtr", - "StructPtrHeadBoolPtr", - "StructPtrHeadOmitEmptyBoolPtr", - "StructHeadStringPtr", - "StructHeadOmitEmptyStringPtr", - "StructPtrHeadStringPtr", - "StructPtrHeadOmitEmptyStringPtr", - "StructHeadBytesPtr", - "StructHeadOmitEmptyBytesPtr", - "StructPtrHeadBytesPtr", - "StructPtrHeadOmitEmptyBytesPtr", - "StructHeadNumberPtr", - "StructHeadOmitEmptyNumberPtr", - "StructPtrHeadNumberPtr", - "StructPtrHeadOmitEmptyNumberPtr", - "StructHeadArrayPtr", - "StructHeadOmitEmptyArrayPtr", - "StructPtrHeadArrayPtr", - "StructPtrHeadOmitEmptyArrayPtr", - "StructHeadMapPtr", - "StructHeadOmitEmptyMapPtr", - "StructPtrHeadMapPtr", - "StructPtrHeadOmitEmptyMapPtr", - "StructHeadSlicePtr", - "StructHeadOmitEmptySlicePtr", - "StructPtrHeadSlicePtr", - "StructPtrHeadOmitEmptySlicePtr", - "StructHeadMarshalJSONPtr", - "StructHeadOmitEmptyMarshalJSONPtr", - "StructPtrHeadMarshalJSONPtr", - "StructPtrHeadOmitEmptyMarshalJSONPtr", - "StructHeadMarshalTextPtr", - "StructHeadOmitEmptyMarshalTextPtr", - "StructPtrHeadMarshalTextPtr", - "StructPtrHeadOmitEmptyMarshalTextPtr", - "StructHeadInterfacePtr", - "StructHeadOmitEmptyInterfacePtr", - "StructPtrHeadInterfacePtr", - "StructPtrHeadOmitEmptyInterfacePtr", - "StructHeadIntPtrString", - "StructHeadOmitEmptyIntPtrString", - "StructPtrHeadIntPtrString", - "StructPtrHeadOmitEmptyIntPtrString", - "StructHeadUintPtrString", - "StructHeadOmitEmptyUintPtrString", - "StructPtrHeadUintPtrString", - "StructPtrHeadOmitEmptyUintPtrString", - "StructHeadFloat32PtrString", - "StructHeadOmitEmptyFloat32PtrString", - "StructPtrHeadFloat32PtrString", - "StructPtrHeadOmitEmptyFloat32PtrString", - "StructHeadFloat64PtrString", - "StructHeadOmitEmptyFloat64PtrString", - "StructPtrHeadFloat64PtrString", - "StructPtrHeadOmitEmptyFloat64PtrString", - "StructHeadBoolPtrString", - "StructHeadOmitEmptyBoolPtrString", - "StructPtrHeadBoolPtrString", - "StructPtrHeadOmitEmptyBoolPtrString", - "StructHeadStringPtrString", - "StructHeadOmitEmptyStringPtrString", - "StructPtrHeadStringPtrString", - "StructPtrHeadOmitEmptyStringPtrString", - "StructHeadNumberPtrString", - "StructHeadOmitEmptyNumberPtrString", - "StructPtrHeadNumberPtrString", - "StructPtrHeadOmitEmptyNumberPtrString", - "StructHead", - "StructHeadOmitEmpty", - "StructPtrHead", - "StructPtrHeadOmitEmpty", - "StructFieldInt", - "StructFieldOmitEmptyInt", - "StructEndInt", - "StructEndOmitEmptyInt", - "StructFieldUint", - "StructFieldOmitEmptyUint", - "StructEndUint", - "StructEndOmitEmptyUint", - "StructFieldFloat32", - "StructFieldOmitEmptyFloat32", - "StructEndFloat32", - "StructEndOmitEmptyFloat32", - "StructFieldFloat64", - "StructFieldOmitEmptyFloat64", - "StructEndFloat64", - "StructEndOmitEmptyFloat64", - "StructFieldBool", - "StructFieldOmitEmptyBool", - "StructEndBool", - "StructEndOmitEmptyBool", - "StructFieldString", - "StructFieldOmitEmptyString", - "StructEndString", - "StructEndOmitEmptyString", - "StructFieldBytes", - "StructFieldOmitEmptyBytes", - "StructEndBytes", - "StructEndOmitEmptyBytes", - "StructFieldNumber", - "StructFieldOmitEmptyNumber", - "StructEndNumber", - "StructEndOmitEmptyNumber", - "StructFieldArray", - "StructFieldOmitEmptyArray", - "StructEndArray", - "StructEndOmitEmptyArray", - "StructFieldMap", - "StructFieldOmitEmptyMap", - "StructEndMap", - "StructEndOmitEmptyMap", - "StructFieldSlice", - "StructFieldOmitEmptySlice", - "StructEndSlice", - "StructEndOmitEmptySlice", - "StructFieldStruct", - "StructFieldOmitEmptyStruct", - "StructEndStruct", - "StructEndOmitEmptyStruct", - "StructFieldMarshalJSON", - "StructFieldOmitEmptyMarshalJSON", - "StructEndMarshalJSON", - "StructEndOmitEmptyMarshalJSON", - "StructFieldMarshalText", - "StructFieldOmitEmptyMarshalText", - "StructEndMarshalText", - "StructEndOmitEmptyMarshalText", - "StructFieldIntString", - "StructFieldOmitEmptyIntString", - "StructEndIntString", - "StructEndOmitEmptyIntString", - "StructFieldUintString", - "StructFieldOmitEmptyUintString", - "StructEndUintString", - "StructEndOmitEmptyUintString", - "StructFieldFloat32String", - "StructFieldOmitEmptyFloat32String", - "StructEndFloat32String", - "StructEndOmitEmptyFloat32String", - "StructFieldFloat64String", - "StructFieldOmitEmptyFloat64String", - "StructEndFloat64String", - "StructEndOmitEmptyFloat64String", - "StructFieldBoolString", - "StructFieldOmitEmptyBoolString", - "StructEndBoolString", - "StructEndOmitEmptyBoolString", - "StructFieldStringString", - "StructFieldOmitEmptyStringString", - "StructEndStringString", - "StructEndOmitEmptyStringString", - "StructFieldNumberString", - "StructFieldOmitEmptyNumberString", - "StructEndNumberString", - "StructEndOmitEmptyNumberString", - "StructFieldIntPtr", - "StructFieldOmitEmptyIntPtr", - "StructEndIntPtr", - "StructEndOmitEmptyIntPtr", - "StructFieldUintPtr", - "StructFieldOmitEmptyUintPtr", - "StructEndUintPtr", - "StructEndOmitEmptyUintPtr", - "StructFieldFloat32Ptr", - "StructFieldOmitEmptyFloat32Ptr", - "StructEndFloat32Ptr", - "StructEndOmitEmptyFloat32Ptr", - "StructFieldFloat64Ptr", - "StructFieldOmitEmptyFloat64Ptr", - "StructEndFloat64Ptr", - "StructEndOmitEmptyFloat64Ptr", - "StructFieldBoolPtr", - "StructFieldOmitEmptyBoolPtr", - "StructEndBoolPtr", - "StructEndOmitEmptyBoolPtr", - "StructFieldStringPtr", - "StructFieldOmitEmptyStringPtr", - "StructEndStringPtr", - "StructEndOmitEmptyStringPtr", - "StructFieldBytesPtr", - "StructFieldOmitEmptyBytesPtr", - "StructEndBytesPtr", - "StructEndOmitEmptyBytesPtr", - "StructFieldNumberPtr", - "StructFieldOmitEmptyNumberPtr", - "StructEndNumberPtr", - "StructEndOmitEmptyNumberPtr", - "StructFieldArrayPtr", - "StructFieldOmitEmptyArrayPtr", - "StructEndArrayPtr", - "StructEndOmitEmptyArrayPtr", - "StructFieldMapPtr", - "StructFieldOmitEmptyMapPtr", - "StructEndMapPtr", - "StructEndOmitEmptyMapPtr", - "StructFieldSlicePtr", - "StructFieldOmitEmptySlicePtr", - "StructEndSlicePtr", - "StructEndOmitEmptySlicePtr", - "StructFieldMarshalJSONPtr", - "StructFieldOmitEmptyMarshalJSONPtr", - "StructEndMarshalJSONPtr", - "StructEndOmitEmptyMarshalJSONPtr", - "StructFieldMarshalTextPtr", - "StructFieldOmitEmptyMarshalTextPtr", - "StructEndMarshalTextPtr", - "StructEndOmitEmptyMarshalTextPtr", - "StructFieldInterfacePtr", - "StructFieldOmitEmptyInterfacePtr", - "StructEndInterfacePtr", - "StructEndOmitEmptyInterfacePtr", - "StructFieldIntPtrString", - "StructFieldOmitEmptyIntPtrString", - "StructEndIntPtrString", - "StructEndOmitEmptyIntPtrString", - "StructFieldUintPtrString", - "StructFieldOmitEmptyUintPtrString", - "StructEndUintPtrString", - "StructEndOmitEmptyUintPtrString", - "StructFieldFloat32PtrString", - "StructFieldOmitEmptyFloat32PtrString", - "StructEndFloat32PtrString", - "StructEndOmitEmptyFloat32PtrString", - "StructFieldFloat64PtrString", - "StructFieldOmitEmptyFloat64PtrString", - "StructEndFloat64PtrString", - "StructEndOmitEmptyFloat64PtrString", - "StructFieldBoolPtrString", - "StructFieldOmitEmptyBoolPtrString", - "StructEndBoolPtrString", - "StructEndOmitEmptyBoolPtrString", - "StructFieldStringPtrString", - "StructFieldOmitEmptyStringPtrString", - "StructEndStringPtrString", - "StructEndOmitEmptyStringPtrString", - "StructFieldNumberPtrString", - "StructFieldOmitEmptyNumberPtrString", - "StructEndNumberPtrString", - "StructEndOmitEmptyNumberPtrString", - "StructField", - "StructFieldOmitEmpty", - "StructEnd", - "StructEndOmitEmpty", -} - -type OpType uint16 - -const ( - OpEnd OpType = 0 - OpInterface OpType = 1 - OpPtr OpType = 2 - OpSliceElem OpType = 3 - OpSliceEnd OpType = 4 - OpArrayElem OpType = 5 - OpArrayEnd OpType = 6 - OpMapKey OpType = 7 - OpMapValue OpType = 8 - OpMapEnd OpType = 9 - OpRecursive OpType = 10 - 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 -) - -func (t OpType) String() string { - if int(t) >= 400 { - return "" - } - return opTypeStrings[int(t)] -} - -func (t OpType) CodeType() CodeType { - if strings.Contains(t.String(), "Struct") { - if strings.Contains(t.String(), "End") { - return CodeStructEnd - } - return CodeStructField - } - switch t { - case OpArray, OpArrayPtr: - return CodeArrayHead - case OpArrayElem: - return CodeArrayElem - case OpSlice, OpSlicePtr: - return CodeSliceHead - case OpSliceElem: - return CodeSliceElem - case OpMap, OpMapPtr: - return CodeMapHead - case OpMapKey: - return CodeMapKey - case OpMapValue: - return CodeMapValue - case OpMapEnd: - return CodeMapEnd - } - - return CodeOp -} - -func (t OpType) HeadToPtrHead() OpType { - if strings.Index(t.String(), "PtrHead") > 0 { - return t - } - - idx := strings.Index(t.String(), "Head") - if idx == -1 { - return t - } - suffix := "PtrHead" + t.String()[idx+len("Head"):] - - const toPtrOffset = 2 - if strings.Contains(OpType(int(t)+toPtrOffset).String(), suffix) { - return OpType(int(t) + toPtrOffset) - } - return t -} - -func (t OpType) HeadToOmitEmptyHead() OpType { - const toOmitEmptyOffset = 1 - if strings.Contains(OpType(int(t)+toOmitEmptyOffset).String(), "OmitEmpty") { - return OpType(int(t) + toOmitEmptyOffset) - } - - return t -} - -func (t OpType) PtrHeadToHead() OpType { - idx := strings.Index(t.String(), "PtrHead") - if idx == -1 { - return t - } - suffix := t.String()[idx+len("Ptr"):] - - const toPtrOffset = 2 - if strings.Contains(OpType(int(t)-toPtrOffset).String(), suffix) { - return OpType(int(t) - toPtrOffset) - } - return t -} - -func (t OpType) FieldToEnd() OpType { - idx := strings.Index(t.String(), "Field") - if idx == -1 { - return t - } - suffix := t.String()[idx+len("Field"):] - if suffix == "" || suffix == "OmitEmpty" { - return t - } - const toEndOffset = 2 - if strings.Contains(OpType(int(t)+toEndOffset).String(), "End"+suffix) { - return OpType(int(t) + toEndOffset) - } - return t -} - -func (t OpType) FieldToOmitEmptyField() OpType { - const toOmitEmptyOffset = 1 - if strings.Contains(OpType(int(t)+toOmitEmptyOffset).String(), "OmitEmpty") { - return OpType(int(t) + toOmitEmptyOffset) - } - 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 1e1850cc1..000000000 --- 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 deleted file mode 100644 index e4152b27c..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/string.go +++ /dev/null @@ -1,459 +0,0 @@ -package encoder - -import ( - "math/bits" - "reflect" - "unsafe" -) - -const ( - lsb = 0x0101010101010101 - msb = 0x8080808080808080 -) - -var hex = "0123456789abcdef" - -//nolint:govet -func stringToUint64Slice(s string) []uint64 { - return *(*[]uint64)(unsafe.Pointer(&reflect.SliceHeader{ - Data: ((*reflect.StringHeader)(unsafe.Pointer(&s))).Data, - Len: len(s) / 8, - Cap: len(s) / 8, - })) -} - -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&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, `""`...) - } - 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 needEscapeHTMLNormalizeUTF8[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 !needEscapeHTMLNormalizeUTF8[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 '<', '>', '&': - 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 - } - 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 - } - - 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++ - 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 - } - - return append(append(buf, s[i:]...), '"') -} - -func appendString(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 needEscape[s[i]] { - j = i - goto ESCAPE_END - } - } - return append(append(buf, s...), '"') - } -ESCAPE_END: - for j < valLen { - c := s[j] - - if !needEscape[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 - } - j++ - } - - 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 ebe42c92d..000000000 --- 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 deleted file mode 100644 index 82b6dd47f..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go +++ /dev/null @@ -1,41 +0,0 @@ -package vm - -import ( - "fmt" - "io" - - "github.com/goccy/go-json/internal/encoder" -) - -func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - defer func() { - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } 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, "===================================") - panic(err) - } - }() - - return Run(ctx, b, codeSet) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm/hack.go b/vendor/github.com/goccy/go-json/internal/encoder/vm/hack.go deleted file mode 100644 index 65252b4a5..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm/hack.go +++ /dev/null @@ -1,9 +0,0 @@ -package vm - -import ( - // HACK: compile order - // `vm`, `vm_indent`, `vm_color`, `vm_color_indent` packages uses a lot of memory to compile, - // so forcibly make dependencies and avoid compiling in concurrent. - // dependency order: vm => vm_indent => vm_color => vm_color_indent - _ "github.com/goccy/go-json/internal/encoder/vm_indent" -) 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 deleted file mode 100644 index 86291d7bb..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm/util.go +++ /dev/null @@ -1,207 +0,0 @@ -package vm - -import ( - "encoding/json" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -var ( - appendInt = encoder.AppendInt - appendUint = encoder.AppendUint - appendFloat32 = encoder.AppendFloat32 - appendFloat64 = encoder.AppendFloat64 - appendString = encoder.AppendString - appendByteSlice = encoder.AppendByteSlice - appendNumber = encoder.AppendNumber - errUnsupportedValue = encoder.ErrUnsupportedValue - errUnsupportedFloat = encoder.ErrUnsupportedFloat - mapiterinit = encoder.MapIterInit - mapiterkey = encoder.MapIterKey - mapitervalue = encoder.MapIterValue - mapiternext = encoder.MapIterNext - maplen = encoder.MapLen -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type nonEmptyInterface struct { - itab *struct { - ityp *runtime.Type // static interface type - typ *runtime.Type // dynamic concrete type - // unused fields... - } - ptr unsafe.Pointer -} - -func errUnimplementedOp(op encoder.OpType) error { - return fmt.Errorf("encoder: opcode %s has not been implemented", op) -} - -func load(base uintptr, idx uint32) uintptr { - addr := base + uintptr(idx) - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func store(base uintptr, idx uint32, p uintptr) { - addr := base + uintptr(idx) - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr { - addr := base + uintptr(idx) - p := **(**uintptr)(unsafe.Pointer(&addr)) - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - 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 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)) } -func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func ptrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func ptrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func ptrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func ptrToNPtr(p uintptr, ptrNum uint8) uintptr { - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func appendBool(_ *encoder.RuntimeContext, b []byte, v bool) []byte { - if v { - return append(b, "true"...) - } - return append(b, "false"...) -} - -func appendNull(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, "null"...) -} - -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] = ':' - return b -} - -func appendMapKeyValue(_ *encoder.RuntimeContext, _ *encoder.Opcode, b, key, value []byte) []byte { - b = append(b, key...) - b[len(b)-1] = ':' - return append(b, value...) -} - -func appendMapEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - b[len(b)-1] = '}' - b = append(b, ',') - return b -} - -func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalJSON(ctx, code, b, v) -} - -func appendMarshalText(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalText(ctx, code, b, v) -} - -func appendArrayHead(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - return append(b, '[') -} - -func appendArrayEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = ']' - return append(b, ',') -} - -func appendEmptyArray(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '[', ']', ',') -} - -func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '}', ',') -} - -func appendObjectEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = '}' - return append(b, ',') -} - -func appendStructHead(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{') -} - -func appendStructKey(_ *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return append(b, code.Key...) -} - -func appendStructEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - return append(b, '}', ',') -} - -func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - if b[last] == ',' { - b[last] = '}' - return appendComma(ctx, b) - } - return appendStructEnd(ctx, code, b) -} - -func restoreIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, _ uintptr) {} -func storeIndent(_ uintptr, _ *encoder.Opcode, _ uintptr) {} -func appendMapKeyIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { return b } -func appendArrayElemIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { return b } 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 deleted file mode 100644 index 645d20f9f..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go +++ /dev/null @@ -1,4859 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package vm - -import ( - "math" - "reflect" - "sort" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.Ptr() - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - for { - switch code.Op { - default: - return nil, errUnimplementedOp(code.Op) - case encoder.OpPtr: - p := load(ctxptr, code.Idx) - code = code.Next - store(ctxptr, code.Idx, ptrToPtr(p)) - case encoder.OpIntPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(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 = appendComma(ctx, b) - code = code.Next - case encoder.OpUintPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(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 = appendComma(ctx, b) - code = code.Next - case encoder.OpIntString: - b = append(b, '"') - b = appendInt(ctx, b, 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat32Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat32: - b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat64Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat64: - v := ptrToFloat64(load(ctxptr, code.Idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStringPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpString: - b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBoolPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBool: - b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBytesPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBytes: - b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpNumberPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpNumber: - bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpInterfacePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInterface: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if p == seen { - return nil, errUnsupportedValue(code, p) - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, p) - var ( - typ *runtime.Type - ifacePtr unsafe.Pointer - ) - up := ptrToUnsafePtr(p) - if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(up) - ifacePtr = iface.ptr - if iface.itab != nil { - 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 - } - } - ctx.KeepRefs = append(ctx.KeepRefs, up) - ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(code.Length) + 3 - nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3 - - var c *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - c = ifaceCodeSet.InterfaceEscapeKeyCode - } else { - c = ifaceCodeSet.InterfaceNoescapeKeyCode - } - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += totalLength * uintptrSize - oldBaseIndent := ctx.BaseIndent - ctx.BaseIndent += code.Indent - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - end := ifaceCodeSet.EndCode - store(ctxptr, c.Idx, uintptr(ifacePtr)) - store(ctxptr, end.Idx, oldOffset) - store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, end, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpInterfaceEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.Idx) - restoreIndent(ctx, code, ctxptr) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - b = append(b, `""`...) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpSlicePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpSlice: - p := load(ctxptr, code.Idx) - slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(slice.Len)) - store(ctxptr, code.Idx, uintptr(slice.Data)) - if slice.Len > 0 { - b = appendArrayHead(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, uintptr(slice.Data)) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpSliceElem: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if idx < length { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - data := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, data+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpArrayPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpArray: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - if code.Length > 0 { - b = appendArrayHead(ctx, code, b) - store(ctxptr, code.ElemIdx, 0) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpArrayElem: - idx := load(ctxptr, code.ElemIdx) - idx++ - if idx < uintptr(code.Length) { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - p := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, p+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpMapPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpMap: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - uptr := ptrToUnsafePtr(p) - mlen := maplen(uptr) - if mlen <= 0 { - b = appendEmptyObject(ctx, b) - code = code.End.Next - 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 { - b = appendMapKeyIndent(ctx, code.Next, b) - } else { - mapCtx.Start = len(b) - mapCtx.First = len(b) - } - key := mapiterkey(&mapCtx.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++ - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - if idx < mapCtx.Len { - b = appendMapKeyIndent(ctx, code, b) - mapCtx.Idx = int(idx) - key := mapiterkey(&mapCtx.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) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - code = code.End - } - } - 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) - } - value := mapitervalue(&mapCtx.Iter) - store(ctxptr, code.Next.Idx, uintptr(value)) - mapiternext(&mapCtx.Iter) - code = code.Next - case encoder.OpMapEnd: - // this operation only used by sorted map. - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx))) - 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 = append(b, buf...) - mapCtx.Buf = buf - encoder.ReleaseMapContext(mapCtx) - code = code.Next - case encoder.OpRecursivePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpRecursive: - ptr := load(ctxptr, code.Idx) - if ptr != 0 { - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, ptr) - c := code.Jmp.Code - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.Jmp.CurLen * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.Idx, ptr) - store(ctxptr, c.End.Next.Idx, oldOffset) - store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - restoreIndent(ctx, code, ctxptr) - offset := load(ctxptr, code.Idx) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpStructPtrHead: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHead: - 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) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if len(code.Key) > 0 { - if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - } - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmpty: - 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) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - u64 := ptrToUint64(p, code.NumBitSize) - 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset))))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - } - case encoder.OpStructPtrHeadNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructPtrHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadArray, encoder.OpStructHeadSlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyArray: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyArray: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptySlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptySlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - } else { - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - 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) - } - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructField: - if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - p := load(ctxptr, code.Idx) + uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmpty: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, 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) - 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 = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, 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) - 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 = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringString: - p := load(ctxptr, code.Idx) - s := ptrToString(p + uintptr(code.Offset)) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldMarshalJSON: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalJSONPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldMarshalText: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalTextPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldArrayPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldSlice: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlice: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldSlicePtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldMap: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMap: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldMapPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldStruct: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyStruct: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - 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 = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, 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) - 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 = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, 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) - 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 = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendStructEnd(ctx, code, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - s := ptrToString(p + uintptr(code.Offset)) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytesPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - code = code.Next - case encoder.OpStructEndOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpEnd: - goto END - } - } -END: - return b, nil -} 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 deleted file mode 100644 index 925f61ed8..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go +++ /dev/null @@ -1,35 +0,0 @@ -package vm_color - -import ( - "fmt" - - "github.com/goccy/go-json/internal/encoder" -) - -func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - 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, "===================================") - panic(err) - } - }() - - return Run(ctx, b, codeSet) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/hack.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/hack.go deleted file mode 100644 index 12ec56c5b..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/hack.go +++ /dev/null @@ -1,9 +0,0 @@ -package vm_color - -import ( - // HACK: compile order - // `vm`, `vm_indent`, `vm_color`, `vm_color_indent` packages uses a lot of memory to compile, - // so forcibly make dependencies and avoid compiling in concurrent. - // dependency order: vm => vm_indent => vm_color => vm_color_indent - _ "github.com/goccy/go-json/internal/encoder/vm_color_indent" -) 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 deleted file mode 100644 index 33f29aee4..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go +++ /dev/null @@ -1,274 +0,0 @@ -package vm_color - -import ( - "encoding/json" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -var ( - errUnsupportedValue = encoder.ErrUnsupportedValue - errUnsupportedFloat = encoder.ErrUnsupportedFloat - mapiterinit = encoder.MapIterInit - mapiterkey = encoder.MapIterKey - mapitervalue = encoder.MapIterValue - mapiternext = encoder.MapIterNext - maplen = encoder.MapLen -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type nonEmptyInterface struct { - itab *struct { - ityp *runtime.Type // static interface type - typ *runtime.Type // dynamic concrete type - // unused fields... - } - ptr unsafe.Pointer -} - -func errUnimplementedOp(op encoder.OpType) error { - return fmt.Errorf("encoder: opcode %s has not been implemented", op) -} - -func load(base uintptr, idx uint32) uintptr { - addr := base + uintptr(idx) - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func store(base uintptr, idx uint32, p uintptr) { - addr := base + uintptr(idx) - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr { - addr := base + uintptr(idx) - p := **(**uintptr)(unsafe.Pointer(&addr)) - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - 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 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)) } -func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func ptrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func ptrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func ptrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func ptrToNPtr(p uintptr, ptrNum uint8) uintptr { - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func appendInt(ctx *encoder.RuntimeContext, b []byte, p uintptr, code *encoder.Opcode) []byte { - format := ctx.Option.ColorScheme.Int - b = append(b, format.Header...) - b = encoder.AppendInt(ctx, b, p, code) - return append(b, format.Footer...) -} - -func appendUint(ctx *encoder.RuntimeContext, b []byte, p uintptr, code *encoder.Opcode) []byte { - format := ctx.Option.ColorScheme.Uint - b = append(b, format.Header...) - b = encoder.AppendUint(ctx, b, p, code) - return append(b, format.Footer...) -} - -func appendFloat32(ctx *encoder.RuntimeContext, b []byte, v float32) []byte { - format := ctx.Option.ColorScheme.Float - b = append(b, format.Header...) - b = encoder.AppendFloat32(ctx, b, v) - return append(b, format.Footer...) -} - -func appendFloat64(ctx *encoder.RuntimeContext, b []byte, v float64) []byte { - format := ctx.Option.ColorScheme.Float - b = append(b, format.Header...) - b = encoder.AppendFloat64(ctx, b, v) - return append(b, format.Footer...) -} - -func appendString(ctx *encoder.RuntimeContext, b []byte, v string) []byte { - format := ctx.Option.ColorScheme.String - b = append(b, format.Header...) - b = encoder.AppendString(ctx, b, v) - return append(b, format.Footer...) -} - -func appendByteSlice(ctx *encoder.RuntimeContext, b []byte, src []byte) []byte { - format := ctx.Option.ColorScheme.Binary - b = append(b, format.Header...) - b = encoder.AppendByteSlice(ctx, b, src) - return append(b, format.Footer...) -} - -func appendNumber(ctx *encoder.RuntimeContext, b []byte, n json.Number) ([]byte, error) { - format := ctx.Option.ColorScheme.Int - b = append(b, format.Header...) - bb, err := encoder.AppendNumber(ctx, b, n) - if err != nil { - return nil, err - } - return append(bb, format.Footer...), nil -} - -func appendBool(ctx *encoder.RuntimeContext, b []byte, v bool) []byte { - format := ctx.Option.ColorScheme.Bool - b = append(b, format.Header...) - if v { - b = append(b, "true"...) - } else { - b = append(b, "false"...) - } - return append(b, format.Footer...) -} - -func appendNull(ctx *encoder.RuntimeContext, b []byte) []byte { - format := ctx.Option.ColorScheme.Null - b = append(b, format.Header...) - b = append(b, "null"...) - return append(b, format.Footer...) -} - -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] = ':' - return b -} - -func appendMapKeyValue(_ *encoder.RuntimeContext, _ *encoder.Opcode, b, key, value []byte) []byte { - b = append(b, key[:len(key)-1]...) - b = append(b, ':') - return append(b, value...) -} - -func appendMapEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = '}' - b = append(b, ',') - return b -} - -func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalJSON(ctx, code, b, v) -} - -func appendMarshalText(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - format := ctx.Option.ColorScheme.String - b = append(b, format.Header...) - bb, err := encoder.AppendMarshalText(ctx, code, b, v) - if err != nil { - return nil, err - } - return append(bb, format.Footer...), nil -} - -func appendArrayHead(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - return append(b, '[') -} - -func appendArrayEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = ']' - return append(b, ',') -} - -func appendEmptyArray(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '[', ']', ',') -} - -func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '}', ',') -} - -func appendObjectEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = '}' - return append(b, ',') -} - -func appendStructHead(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{') -} - -func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - format := ctx.Option.ColorScheme.ObjectKey - b = append(b, format.Header...) - b = append(b, code.Key[:len(code.Key)-1]...) - b = append(b, format.Footer...) - - return append(b, ':') -} - -func appendStructEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - return append(b, '}', ',') -} - -func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - if b[last] == ',' { - b[last] = '}' - return appendComma(ctx, b) - } - return appendStructEnd(ctx, code, b) -} - -func restoreIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, _ uintptr) {} -func storeIndent(_ uintptr, _ *encoder.Opcode, _ uintptr) {} -func appendMapKeyIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { return b } -func appendArrayElemIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { return b } 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 deleted file mode 100644 index a63e83e55..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go +++ /dev/null @@ -1,4859 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package vm_color - -import ( - "math" - "reflect" - "sort" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.Ptr() - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - for { - switch code.Op { - default: - return nil, errUnimplementedOp(code.Op) - case encoder.OpPtr: - p := load(ctxptr, code.Idx) - code = code.Next - store(ctxptr, code.Idx, ptrToPtr(p)) - case encoder.OpIntPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(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 = appendComma(ctx, b) - code = code.Next - case encoder.OpUintPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(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 = appendComma(ctx, b) - code = code.Next - case encoder.OpIntString: - b = append(b, '"') - b = appendInt(ctx, b, 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat32Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat32: - b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat64Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat64: - v := ptrToFloat64(load(ctxptr, code.Idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStringPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpString: - b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBoolPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBool: - b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBytesPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBytes: - b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpNumberPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpNumber: - bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpInterfacePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInterface: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if p == seen { - return nil, errUnsupportedValue(code, p) - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, p) - var ( - typ *runtime.Type - ifacePtr unsafe.Pointer - ) - up := ptrToUnsafePtr(p) - if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(up) - ifacePtr = iface.ptr - if iface.itab != nil { - 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 - } - } - ctx.KeepRefs = append(ctx.KeepRefs, up) - ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(code.Length) + 3 - nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3 - - var c *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - c = ifaceCodeSet.InterfaceEscapeKeyCode - } else { - c = ifaceCodeSet.InterfaceNoescapeKeyCode - } - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += totalLength * uintptrSize - oldBaseIndent := ctx.BaseIndent - ctx.BaseIndent += code.Indent - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - end := ifaceCodeSet.EndCode - store(ctxptr, c.Idx, uintptr(ifacePtr)) - store(ctxptr, end.Idx, oldOffset) - store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, end, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpInterfaceEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.Idx) - restoreIndent(ctx, code, ctxptr) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - b = append(b, `""`...) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpSlicePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpSlice: - p := load(ctxptr, code.Idx) - slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(slice.Len)) - store(ctxptr, code.Idx, uintptr(slice.Data)) - if slice.Len > 0 { - b = appendArrayHead(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, uintptr(slice.Data)) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpSliceElem: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if idx < length { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - data := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, data+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpArrayPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpArray: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - if code.Length > 0 { - b = appendArrayHead(ctx, code, b) - store(ctxptr, code.ElemIdx, 0) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpArrayElem: - idx := load(ctxptr, code.ElemIdx) - idx++ - if idx < uintptr(code.Length) { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - p := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, p+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpMapPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpMap: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - uptr := ptrToUnsafePtr(p) - mlen := maplen(uptr) - if mlen <= 0 { - b = appendEmptyObject(ctx, b) - code = code.End.Next - 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 { - b = appendMapKeyIndent(ctx, code.Next, b) - } else { - mapCtx.Start = len(b) - mapCtx.First = len(b) - } - key := mapiterkey(&mapCtx.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++ - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - if idx < mapCtx.Len { - b = appendMapKeyIndent(ctx, code, b) - mapCtx.Idx = int(idx) - key := mapiterkey(&mapCtx.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) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - code = code.End - } - } - 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) - } - value := mapitervalue(&mapCtx.Iter) - store(ctxptr, code.Next.Idx, uintptr(value)) - mapiternext(&mapCtx.Iter) - code = code.Next - case encoder.OpMapEnd: - // this operation only used by sorted map. - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx))) - 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 = append(b, buf...) - mapCtx.Buf = buf - encoder.ReleaseMapContext(mapCtx) - code = code.Next - case encoder.OpRecursivePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpRecursive: - ptr := load(ctxptr, code.Idx) - if ptr != 0 { - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, ptr) - c := code.Jmp.Code - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.Jmp.CurLen * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.Idx, ptr) - store(ctxptr, c.End.Next.Idx, oldOffset) - store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - restoreIndent(ctx, code, ctxptr) - offset := load(ctxptr, code.Idx) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpStructPtrHead: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHead: - 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) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if len(code.Key) > 0 { - if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - } - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmpty: - 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) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - u64 := ptrToUint64(p, code.NumBitSize) - 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset))))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - } - case encoder.OpStructPtrHeadNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructPtrHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadArray, encoder.OpStructHeadSlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyArray: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyArray: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptySlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptySlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - } else { - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - 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) - } - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructField: - if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - p := load(ctxptr, code.Idx) + uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmpty: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, 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) - 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 = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, 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) - 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 = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringString: - p := load(ctxptr, code.Idx) - s := ptrToString(p + uintptr(code.Offset)) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldMarshalJSON: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalJSONPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldMarshalText: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalTextPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldArrayPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldSlice: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlice: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldSlicePtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldMap: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMap: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldMapPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldStruct: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyStruct: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - 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 = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, 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) - 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 = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, 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) - 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 = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendStructEnd(ctx, code, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - s := ptrToString(p + uintptr(code.Offset)) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytesPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - code = code.Next - case encoder.OpStructEndOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpEnd: - goto END - } - } -END: - return b, nil -} 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 deleted file mode 100644 index dd4cd489e..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go +++ /dev/null @@ -1,35 +0,0 @@ -package vm_color_indent - -import ( - "fmt" - - "github.com/goccy/go-json/internal/encoder" -) - -func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - 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, "===================================") - panic(err) - } - }() - - return Run(ctx, b, codeSet) -} 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 deleted file mode 100644 index 2395abec9..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go +++ /dev/null @@ -1,297 +0,0 @@ -package vm_color_indent - -import ( - "encoding/json" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -var ( - appendIndent = encoder.AppendIndent - appendStructEnd = encoder.AppendStructEndIndent - errUnsupportedValue = encoder.ErrUnsupportedValue - errUnsupportedFloat = encoder.ErrUnsupportedFloat - mapiterinit = encoder.MapIterInit - mapiterkey = encoder.MapIterKey - mapitervalue = encoder.MapIterValue - mapiternext = encoder.MapIterNext - maplen = encoder.MapLen -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type nonEmptyInterface struct { - itab *struct { - ityp *runtime.Type // static interface type - typ *runtime.Type // dynamic concrete type - // unused fields... - } - ptr unsafe.Pointer -} - -func errUnimplementedOp(op encoder.OpType) error { - return fmt.Errorf("encoder (indent): opcode %s has not been implemented", op) -} - -func load(base uintptr, idx uint32) uintptr { - addr := base + uintptr(idx) - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func store(base uintptr, idx uint32, p uintptr) { - addr := base + uintptr(idx) - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr { - addr := base + uintptr(idx) - p := **(**uintptr)(unsafe.Pointer(&addr)) - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - 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 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)) } -func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func ptrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func ptrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func ptrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func ptrToNPtr(p uintptr, ptrNum uint8) uintptr { - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func appendInt(ctx *encoder.RuntimeContext, b []byte, p uintptr, code *encoder.Opcode) []byte { - format := ctx.Option.ColorScheme.Int - b = append(b, format.Header...) - b = encoder.AppendInt(ctx, b, p, code) - return append(b, format.Footer...) -} - -func appendUint(ctx *encoder.RuntimeContext, b []byte, p uintptr, code *encoder.Opcode) []byte { - format := ctx.Option.ColorScheme.Uint - b = append(b, format.Header...) - b = encoder.AppendUint(ctx, b, p, code) - return append(b, format.Footer...) -} - -func appendFloat32(ctx *encoder.RuntimeContext, b []byte, v float32) []byte { - format := ctx.Option.ColorScheme.Float - b = append(b, format.Header...) - b = encoder.AppendFloat32(ctx, b, v) - return append(b, format.Footer...) -} - -func appendFloat64(ctx *encoder.RuntimeContext, b []byte, v float64) []byte { - format := ctx.Option.ColorScheme.Float - b = append(b, format.Header...) - b = encoder.AppendFloat64(ctx, b, v) - return append(b, format.Footer...) -} - -func appendString(ctx *encoder.RuntimeContext, b []byte, v string) []byte { - format := ctx.Option.ColorScheme.String - b = append(b, format.Header...) - b = encoder.AppendString(ctx, b, v) - return append(b, format.Footer...) -} - -func appendByteSlice(ctx *encoder.RuntimeContext, b []byte, src []byte) []byte { - format := ctx.Option.ColorScheme.Binary - b = append(b, format.Header...) - b = encoder.AppendByteSlice(ctx, b, src) - return append(b, format.Footer...) -} - -func appendNumber(ctx *encoder.RuntimeContext, b []byte, n json.Number) ([]byte, error) { - format := ctx.Option.ColorScheme.Int - b = append(b, format.Header...) - bb, err := encoder.AppendNumber(ctx, b, n) - if err != nil { - return nil, err - } - return append(bb, format.Footer...), nil -} - -func appendBool(ctx *encoder.RuntimeContext, b []byte, v bool) []byte { - format := ctx.Option.ColorScheme.Bool - b = append(b, format.Header...) - if v { - b = append(b, "true"...) - } else { - b = append(b, "false"...) - } - return append(b, format.Footer...) -} - -func appendNull(ctx *encoder.RuntimeContext, b []byte) []byte { - format := ctx.Option.ColorScheme.Null - b = append(b, format.Header...) - b = append(b, "null"...) - return append(b, format.Footer...) -} - -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], ':', ' ') -} - -func appendMapKeyValue(ctx *encoder.RuntimeContext, code *encoder.Opcode, b, key, value []byte) []byte { - b = appendIndent(ctx, b, code.Indent+1) - b = append(b, key...) - b[len(b)-2] = ':' - b[len(b)-1] = ' ' - return append(b, value...) -} - -func appendMapEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = b[:len(b)-2] - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent) - return append(b, '}', ',', '\n') -} - -func appendArrayHead(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = append(b, '[', '\n') - return appendIndent(ctx, b, code.Indent+1) -} - -func appendArrayEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = b[:len(b)-2] - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent) - return append(b, ']', ',', '\n') -} - -func appendEmptyArray(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '[', ']', ',', '\n') -} - -func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '}', ',', '\n') -} - -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) - return append(b, '}', ',', '\n') -} - -func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalJSONIndent(ctx, code, b, v) -} - -func appendMarshalText(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - format := ctx.Option.ColorScheme.String - b = append(b, format.Header...) - bb, err := encoder.AppendMarshalTextIndent(ctx, code, b, v) - if err != nil { - return nil, err - } - return append(bb, format.Footer...), nil -} - -func appendStructHead(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '\n') -} - -func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = appendIndent(ctx, b, code.Indent) - - format := ctx.Option.ColorScheme.ObjectKey - b = append(b, format.Header...) - b = append(b, code.Key[:len(code.Key)-1]...) - b = append(b, format.Footer...) - - return append(b, ':', ' ') -} - -func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - } else { - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent-1) - b = append(b, '}') - } - return appendComma(ctx, b) -} - -func restoreIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, ctxptr uintptr) { - ctx.BaseIndent = uint32(load(ctxptr, code.Length)) -} - -func storeIndent(ctxptr uintptr, code *encoder.Opcode, indent uintptr) { - store(ctxptr, code.Length, indent) -} - -func appendArrayElemIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return appendIndent(ctx, b, code.Indent+1) -} - -func appendMapKeyIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return appendIndent(ctx, b, code.Indent) -} 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 deleted file mode 100644 index 3b4e22e5d..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go +++ /dev/null @@ -1,4859 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package vm_color_indent - -import ( - "math" - "reflect" - "sort" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.Ptr() - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - for { - switch code.Op { - default: - return nil, errUnimplementedOp(code.Op) - case encoder.OpPtr: - p := load(ctxptr, code.Idx) - code = code.Next - store(ctxptr, code.Idx, ptrToPtr(p)) - case encoder.OpIntPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(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 = appendComma(ctx, b) - code = code.Next - case encoder.OpUintPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(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 = appendComma(ctx, b) - code = code.Next - case encoder.OpIntString: - b = append(b, '"') - b = appendInt(ctx, b, 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat32Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat32: - b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat64Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat64: - v := ptrToFloat64(load(ctxptr, code.Idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStringPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpString: - b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBoolPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBool: - b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBytesPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBytes: - b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpNumberPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpNumber: - bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpInterfacePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInterface: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if p == seen { - return nil, errUnsupportedValue(code, p) - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, p) - var ( - typ *runtime.Type - ifacePtr unsafe.Pointer - ) - up := ptrToUnsafePtr(p) - if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(up) - ifacePtr = iface.ptr - if iface.itab != nil { - 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 - } - } - ctx.KeepRefs = append(ctx.KeepRefs, up) - ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(code.Length) + 3 - nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3 - - var c *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - c = ifaceCodeSet.InterfaceEscapeKeyCode - } else { - c = ifaceCodeSet.InterfaceNoescapeKeyCode - } - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += totalLength * uintptrSize - oldBaseIndent := ctx.BaseIndent - ctx.BaseIndent += code.Indent - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - end := ifaceCodeSet.EndCode - store(ctxptr, c.Idx, uintptr(ifacePtr)) - store(ctxptr, end.Idx, oldOffset) - store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, end, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpInterfaceEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.Idx) - restoreIndent(ctx, code, ctxptr) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - b = append(b, `""`...) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpSlicePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpSlice: - p := load(ctxptr, code.Idx) - slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(slice.Len)) - store(ctxptr, code.Idx, uintptr(slice.Data)) - if slice.Len > 0 { - b = appendArrayHead(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, uintptr(slice.Data)) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpSliceElem: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if idx < length { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - data := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, data+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpArrayPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpArray: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - if code.Length > 0 { - b = appendArrayHead(ctx, code, b) - store(ctxptr, code.ElemIdx, 0) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpArrayElem: - idx := load(ctxptr, code.ElemIdx) - idx++ - if idx < uintptr(code.Length) { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - p := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, p+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpMapPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpMap: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - uptr := ptrToUnsafePtr(p) - mlen := maplen(uptr) - if mlen <= 0 { - b = appendEmptyObject(ctx, b) - code = code.End.Next - 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 { - b = appendMapKeyIndent(ctx, code.Next, b) - } else { - mapCtx.Start = len(b) - mapCtx.First = len(b) - } - key := mapiterkey(&mapCtx.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++ - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - if idx < mapCtx.Len { - b = appendMapKeyIndent(ctx, code, b) - mapCtx.Idx = int(idx) - key := mapiterkey(&mapCtx.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) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - code = code.End - } - } - 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) - } - value := mapitervalue(&mapCtx.Iter) - store(ctxptr, code.Next.Idx, uintptr(value)) - mapiternext(&mapCtx.Iter) - code = code.Next - case encoder.OpMapEnd: - // this operation only used by sorted map. - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx))) - 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 = append(b, buf...) - mapCtx.Buf = buf - encoder.ReleaseMapContext(mapCtx) - code = code.Next - case encoder.OpRecursivePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpRecursive: - ptr := load(ctxptr, code.Idx) - if ptr != 0 { - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, ptr) - c := code.Jmp.Code - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.Jmp.CurLen * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.Idx, ptr) - store(ctxptr, c.End.Next.Idx, oldOffset) - store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - restoreIndent(ctx, code, ctxptr) - offset := load(ctxptr, code.Idx) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpStructPtrHead: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHead: - 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) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if len(code.Key) > 0 { - if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - } - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmpty: - 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) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - u64 := ptrToUint64(p, code.NumBitSize) - 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset))))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - } - case encoder.OpStructPtrHeadNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructPtrHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadArray, encoder.OpStructHeadSlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyArray: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyArray: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptySlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptySlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - } else { - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - 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) - } - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructField: - if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - p := load(ctxptr, code.Idx) + uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmpty: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, 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) - 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 = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, 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) - 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 = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringString: - p := load(ctxptr, code.Idx) - s := ptrToString(p + uintptr(code.Offset)) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldMarshalJSON: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalJSONPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldMarshalText: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalTextPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldArrayPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldSlice: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlice: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldSlicePtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldMap: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMap: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldMapPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldStruct: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyStruct: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - 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 = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, 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) - 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 = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, 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) - 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 = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendStructEnd(ctx, code, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - s := ptrToString(p + uintptr(code.Offset)) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytesPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - code = code.Next - case encoder.OpStructEndOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpEnd: - goto END - } - } -END: - return b, nil -} 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 deleted file mode 100644 index 99395388c..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go +++ /dev/null @@ -1,35 +0,0 @@ -package vm_indent - -import ( - "fmt" - - "github.com/goccy/go-json/internal/encoder" -) - -func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - 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, "===================================") - panic(err) - } - }() - - return Run(ctx, b, codeSet) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/hack.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/hack.go deleted file mode 100644 index 9e245bfe5..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/hack.go +++ /dev/null @@ -1,9 +0,0 @@ -package vm_indent - -import ( - // HACK: compile order - // `vm`, `vm_indent`, `vm_color`, `vm_color_indent` packages uses a lot of memory to compile, - // so forcibly make dependencies and avoid compiling in concurrent. - // dependency order: vm => vm_indent => vm_color => vm_color_indent - _ "github.com/goccy/go-json/internal/encoder/vm_color" -) 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 deleted file mode 100644 index 6cb745e39..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go +++ /dev/null @@ -1,230 +0,0 @@ -package vm_indent - -import ( - "encoding/json" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -var ( - appendInt = encoder.AppendInt - appendUint = encoder.AppendUint - appendFloat32 = encoder.AppendFloat32 - appendFloat64 = encoder.AppendFloat64 - appendString = encoder.AppendString - appendByteSlice = encoder.AppendByteSlice - appendNumber = encoder.AppendNumber - appendStructEnd = encoder.AppendStructEndIndent - appendIndent = encoder.AppendIndent - errUnsupportedValue = encoder.ErrUnsupportedValue - errUnsupportedFloat = encoder.ErrUnsupportedFloat - mapiterinit = encoder.MapIterInit - mapiterkey = encoder.MapIterKey - mapitervalue = encoder.MapIterValue - mapiternext = encoder.MapIterNext - maplen = encoder.MapLen -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type nonEmptyInterface struct { - itab *struct { - ityp *runtime.Type // static interface type - typ *runtime.Type // dynamic concrete type - // unused fields... - } - ptr unsafe.Pointer -} - -func errUnimplementedOp(op encoder.OpType) error { - return fmt.Errorf("encoder (indent): opcode %s has not been implemented", op) -} - -func load(base uintptr, idx uint32) uintptr { - addr := base + uintptr(idx) - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func store(base uintptr, idx uint32, p uintptr) { - addr := base + uintptr(idx) - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr { - addr := base + uintptr(idx) - p := **(**uintptr)(unsafe.Pointer(&addr)) - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - 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 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)) } -func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func ptrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func ptrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func ptrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func ptrToNPtr(p uintptr, ptrNum uint8) uintptr { - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func appendBool(_ *encoder.RuntimeContext, b []byte, v bool) []byte { - if v { - return append(b, "true"...) - } - return append(b, "false"...) -} - -func appendNull(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, "null"...) -} - -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], ':', ' ') -} - -func appendMapKeyValue(ctx *encoder.RuntimeContext, code *encoder.Opcode, b, key, value []byte) []byte { - b = appendIndent(ctx, b, code.Indent+1) - b = append(b, key...) - b[len(b)-2] = ':' - b[len(b)-1] = ' ' - return append(b, value...) -} - -func appendMapEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = b[:len(b)-2] - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent) - return append(b, '}', ',', '\n') -} - -func appendArrayHead(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = append(b, '[', '\n') - return appendIndent(ctx, b, code.Indent+1) -} - -func appendArrayEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = b[:len(b)-2] - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent) - return append(b, ']', ',', '\n') -} - -func appendEmptyArray(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '[', ']', ',', '\n') -} - -func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '}', ',', '\n') -} - -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) - return append(b, '}', ',', '\n') -} - -func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalJSONIndent(ctx, code, b, v) -} - -func appendMarshalText(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalTextIndent(ctx, code, b, v) -} - -func appendStructHead(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '\n') -} - -func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = appendIndent(ctx, b, code.Indent) - b = append(b, code.Key...) - return append(b, ' ') -} - -func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - } else { - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent-1) - b = append(b, '}') - } - return appendComma(ctx, b) -} - -func restoreIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, ctxptr uintptr) { - ctx.BaseIndent = uint32(load(ctxptr, code.Length)) -} - -func storeIndent(ctxptr uintptr, code *encoder.Opcode, indent uintptr) { - store(ctxptr, code.Length, indent) -} - -func appendArrayElemIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return appendIndent(ctx, b, code.Indent+1) -} - -func appendMapKeyIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return appendIndent(ctx, b, code.Indent) -} 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 deleted file mode 100644 index 836c5c8a8..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go +++ /dev/null @@ -1,4859 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package vm_indent - -import ( - "math" - "reflect" - "sort" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.Ptr() - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - for { - switch code.Op { - default: - return nil, errUnimplementedOp(code.Op) - case encoder.OpPtr: - p := load(ctxptr, code.Idx) - code = code.Next - store(ctxptr, code.Idx, ptrToPtr(p)) - case encoder.OpIntPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(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 = appendComma(ctx, b) - code = code.Next - case encoder.OpUintPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(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 = appendComma(ctx, b) - code = code.Next - case encoder.OpIntString: - b = append(b, '"') - b = appendInt(ctx, b, 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat32Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat32: - b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat64Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat64: - v := ptrToFloat64(load(ctxptr, code.Idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStringPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpString: - b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBoolPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBool: - b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBytesPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBytes: - b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpNumberPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpNumber: - bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpInterfacePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInterface: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if p == seen { - return nil, errUnsupportedValue(code, p) - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, p) - var ( - typ *runtime.Type - ifacePtr unsafe.Pointer - ) - up := ptrToUnsafePtr(p) - if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(up) - ifacePtr = iface.ptr - if iface.itab != nil { - 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 - } - } - ctx.KeepRefs = append(ctx.KeepRefs, up) - ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(code.Length) + 3 - nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3 - - var c *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - c = ifaceCodeSet.InterfaceEscapeKeyCode - } else { - c = ifaceCodeSet.InterfaceNoescapeKeyCode - } - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += totalLength * uintptrSize - oldBaseIndent := ctx.BaseIndent - ctx.BaseIndent += code.Indent - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - end := ifaceCodeSet.EndCode - store(ctxptr, c.Idx, uintptr(ifacePtr)) - store(ctxptr, end.Idx, oldOffset) - store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, end, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpInterfaceEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.Idx) - restoreIndent(ctx, code, ctxptr) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - b = append(b, `""`...) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpSlicePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpSlice: - p := load(ctxptr, code.Idx) - slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(slice.Len)) - store(ctxptr, code.Idx, uintptr(slice.Data)) - if slice.Len > 0 { - b = appendArrayHead(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, uintptr(slice.Data)) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpSliceElem: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if idx < length { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - data := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, data+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpArrayPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpArray: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - if code.Length > 0 { - b = appendArrayHead(ctx, code, b) - store(ctxptr, code.ElemIdx, 0) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpArrayElem: - idx := load(ctxptr, code.ElemIdx) - idx++ - if idx < uintptr(code.Length) { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - p := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, p+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpMapPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpMap: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.End.Next - break - } - uptr := ptrToUnsafePtr(p) - mlen := maplen(uptr) - if mlen <= 0 { - b = appendEmptyObject(ctx, b) - code = code.End.Next - 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 { - b = appendMapKeyIndent(ctx, code.Next, b) - } else { - mapCtx.Start = len(b) - mapCtx.First = len(b) - } - key := mapiterkey(&mapCtx.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++ - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - if idx < mapCtx.Len { - b = appendMapKeyIndent(ctx, code, b) - mapCtx.Idx = int(idx) - key := mapiterkey(&mapCtx.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) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - code = code.End - } - } - 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) - } - value := mapitervalue(&mapCtx.Iter) - store(ctxptr, code.Next.Idx, uintptr(value)) - mapiternext(&mapCtx.Iter) - code = code.Next - case encoder.OpMapEnd: - // this operation only used by sorted map. - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx))) - 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 = append(b, buf...) - mapCtx.Buf = buf - encoder.ReleaseMapContext(mapCtx) - code = code.Next - case encoder.OpRecursivePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpRecursive: - ptr := load(ctxptr, code.Idx) - if ptr != 0 { - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, ptr) - c := code.Jmp.Code - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.Jmp.CurLen * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.Idx, ptr) - store(ctxptr, c.End.Next.Idx, oldOffset) - store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - restoreIndent(ctx, code, ctxptr) - offset := load(ctxptr, code.Idx) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpStructPtrHead: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHead: - 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) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if len(code.Key) > 0 { - if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - } - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmpty: - 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) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - u64 := ptrToUint64(p, code.NumBitSize) - 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - 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 = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset))))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - } - case encoder.OpStructPtrHeadNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructPtrHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadArray, encoder.OpStructHeadSlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyArray: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyArray: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptySlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptySlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - } else { - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - 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) - } - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - 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) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNullComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructField: - if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - p := load(ctxptr, code.Idx) + uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmpty: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, 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) - 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 = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, 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) - 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 = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNullComma(ctx, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringString: - p := load(ctxptr, code.Idx) - s := ptrToString(p + uintptr(code.Offset)) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldMarshalJSON: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalJSONPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldMarshalText: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalTextPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldArrayPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldSlice: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlice: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldSlicePtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldMap: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMap: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldMapPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldStruct: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyStruct: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - 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 = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p+uintptr(code.Offset), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, 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) - 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 = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, p, code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, p, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, p, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, 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) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p+uintptr(code.Offset), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, 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) - 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 = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, p, code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, p, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, p, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendStructEnd(ctx, code, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - s := ptrToString(p + uintptr(code.Offset)) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytesPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - code = code.Next - case encoder.OpStructEndOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpEnd: - goto END - } - } -END: - return b, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/errors/error.go b/vendor/github.com/goccy/go-json/internal/errors/error.go deleted file mode 100644 index 9207d0ff2..000000000 --- a/vendor/github.com/goccy/go-json/internal/errors/error.go +++ /dev/null @@ -1,183 +0,0 @@ -package errors - -import ( - "fmt" - "reflect" - "strconv" -) - -type InvalidUTF8Error struct { - S string // the whole string value that caused the error -} - -func (e *InvalidUTF8Error) Error() string { - return fmt.Sprintf("json: invalid UTF-8 in string: %s", strconv.Quote(e.S)) -} - -type InvalidUnmarshalError struct { - Type reflect.Type -} - -func (e *InvalidUnmarshalError) Error() string { - if e.Type == nil { - return "json: Unmarshal(nil)" - } - - if e.Type.Kind() != reflect.Ptr { - return fmt.Sprintf("json: Unmarshal(non-pointer %s)", e.Type) - } - return fmt.Sprintf("json: Unmarshal(nil %s)", e.Type) -} - -// A MarshalerError represents an error from calling a MarshalJSON or MarshalText method. -type MarshalerError struct { - Type reflect.Type - Err error - sourceFunc string -} - -func (e *MarshalerError) Error() string { - srcFunc := e.sourceFunc - if srcFunc == "" { - srcFunc = "MarshalJSON" - } - return fmt.Sprintf("json: error calling %s for type %s: %s", srcFunc, e.Type, e.Err.Error()) -} - -// Unwrap returns the underlying error. -func (e *MarshalerError) Unwrap() error { return e.Err } - -// A SyntaxError is a description of a JSON syntax error. -type SyntaxError struct { - msg string // description of error - Offset int64 // error occurred after reading Offset bytes -} - -func (e *SyntaxError) Error() string { return e.msg } - -// An UnmarshalFieldError describes a JSON object key that -// led to an unexported (and therefore unwritable) struct field. -// -// Deprecated: No longer used; kept for compatibility. -type UnmarshalFieldError struct { - Key string - Type reflect.Type - Field reflect.StructField -} - -func (e *UnmarshalFieldError) Error() string { - return fmt.Sprintf("json: cannot unmarshal object key %s into unexported field %s of type %s", - strconv.Quote(e.Key), e.Field.Name, e.Type.String(), - ) -} - -// An UnmarshalTypeError describes a JSON value that was -// not appropriate for a value of a specific Go type. -type UnmarshalTypeError struct { - Value string // description of JSON value - "bool", "array", "number -5" - Type reflect.Type // type of Go value it could not be assigned to - Offset int64 // error occurred after reading Offset bytes - Struct string // name of the struct type containing the field - Field string // the full path from root node to the field -} - -func (e *UnmarshalTypeError) Error() string { - if e.Struct != "" || e.Field != "" { - return fmt.Sprintf("json: cannot unmarshal %s into Go struct field %s.%s of type %s", - e.Value, e.Struct, e.Field, e.Type, - ) - } - return fmt.Sprintf("json: cannot unmarshal %s into Go value of type %s", e.Value, e.Type) -} - -// An UnsupportedTypeError is returned by Marshal when attempting -// to encode an unsupported value type. -type UnsupportedTypeError struct { - Type reflect.Type -} - -func (e *UnsupportedTypeError) Error() string { - return fmt.Sprintf("json: unsupported type: %s", e.Type) -} - -type UnsupportedValueError struct { - Value reflect.Value - Str string -} - -func (e *UnsupportedValueError) Error() string { - return fmt.Sprintf("json: unsupported value: %s", e.Str) -} - -func ErrSyntax(msg string, offset int64) *SyntaxError { - return &SyntaxError{msg: msg, Offset: offset} -} - -func ErrMarshaler(typ reflect.Type, err error, msg string) *MarshalerError { - return &MarshalerError{ - Type: typ, - Err: err, - sourceFunc: msg, - } -} - -func ErrExceededMaxDepth(c byte, cursor int64) *SyntaxError { - return &SyntaxError{ - msg: fmt.Sprintf(`invalid character "%c" exceeded max depth`, c), - Offset: cursor, - } -} - -func ErrNotAtBeginningOfValue(cursor int64) *SyntaxError { - return &SyntaxError{msg: "not at beginning of value", Offset: cursor} -} - -func ErrUnexpectedEndOfJSON(msg string, cursor int64) *SyntaxError { - return &SyntaxError{ - msg: fmt.Sprintf("json: %s unexpected end of JSON input", msg), - Offset: cursor, - } -} - -func ErrExpected(msg string, cursor int64) *SyntaxError { - return &SyntaxError{msg: fmt.Sprintf("expected %s", msg), Offset: cursor} -} - -func ErrInvalidCharacter(c byte, context string, cursor int64) *SyntaxError { - if c == 0 { - return &SyntaxError{ - msg: fmt.Sprintf("json: invalid character as %s", context), - Offset: cursor, - } - } - return &SyntaxError{ - msg: fmt.Sprintf("json: invalid character %c as %s", c, context), - Offset: cursor, - } -} - -func ErrInvalidBeginningOfValue(c byte, cursor int64) *SyntaxError { - return &SyntaxError{ - msg: fmt.Sprintf("invalid character '%c' looking for beginning of value", c), - 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 deleted file mode 100644 index 4db10debe..000000000 --- a/vendor/github.com/goccy/go-json/internal/runtime/rtype.go +++ /dev/null @@ -1,263 +0,0 @@ -package runtime - -import ( - "reflect" - "unsafe" -) - -// Type representing reflect.rtype for noescape trick -type Type struct{} - -//go:linkname rtype_Align reflect.(*rtype).Align -//go:noescape -func rtype_Align(*Type) int - -func (t *Type) Align() int { - return rtype_Align(t) -} - -//go:linkname rtype_FieldAlign reflect.(*rtype).FieldAlign -//go:noescape -func rtype_FieldAlign(*Type) int - -func (t *Type) FieldAlign() int { - return rtype_FieldAlign(t) -} - -//go:linkname rtype_Method reflect.(*rtype).Method -//go:noescape -func rtype_Method(*Type, int) reflect.Method - -func (t *Type) Method(a0 int) reflect.Method { - return rtype_Method(t, a0) -} - -//go:linkname rtype_MethodByName reflect.(*rtype).MethodByName -//go:noescape -func rtype_MethodByName(*Type, string) (reflect.Method, bool) - -func (t *Type) MethodByName(a0 string) (reflect.Method, bool) { - return rtype_MethodByName(t, a0) -} - -//go:linkname rtype_NumMethod reflect.(*rtype).NumMethod -//go:noescape -func rtype_NumMethod(*Type) int - -func (t *Type) NumMethod() int { - return rtype_NumMethod(t) -} - -//go:linkname rtype_Name reflect.(*rtype).Name -//go:noescape -func rtype_Name(*Type) string - -func (t *Type) Name() string { - return rtype_Name(t) -} - -//go:linkname rtype_PkgPath reflect.(*rtype).PkgPath -//go:noescape -func rtype_PkgPath(*Type) string - -func (t *Type) PkgPath() string { - return rtype_PkgPath(t) -} - -//go:linkname rtype_Size reflect.(*rtype).Size -//go:noescape -func rtype_Size(*Type) uintptr - -func (t *Type) Size() uintptr { - return rtype_Size(t) -} - -//go:linkname rtype_String reflect.(*rtype).String -//go:noescape -func rtype_String(*Type) string - -func (t *Type) String() string { - return rtype_String(t) -} - -//go:linkname rtype_Kind reflect.(*rtype).Kind -//go:noescape -func rtype_Kind(*Type) reflect.Kind - -func (t *Type) Kind() reflect.Kind { - return rtype_Kind(t) -} - -//go:linkname rtype_Implements reflect.(*rtype).Implements -//go:noescape -func rtype_Implements(*Type, reflect.Type) bool - -func (t *Type) Implements(u reflect.Type) bool { - return rtype_Implements(t, u) -} - -//go:linkname rtype_AssignableTo reflect.(*rtype).AssignableTo -//go:noescape -func rtype_AssignableTo(*Type, reflect.Type) bool - -func (t *Type) AssignableTo(u reflect.Type) bool { - return rtype_AssignableTo(t, u) -} - -//go:linkname rtype_ConvertibleTo reflect.(*rtype).ConvertibleTo -//go:noescape -func rtype_ConvertibleTo(*Type, reflect.Type) bool - -func (t *Type) ConvertibleTo(u reflect.Type) bool { - return rtype_ConvertibleTo(t, u) -} - -//go:linkname rtype_Comparable reflect.(*rtype).Comparable -//go:noescape -func rtype_Comparable(*Type) bool - -func (t *Type) Comparable() bool { - return rtype_Comparable(t) -} - -//go:linkname rtype_Bits reflect.(*rtype).Bits -//go:noescape -func rtype_Bits(*Type) int - -func (t *Type) Bits() int { - return rtype_Bits(t) -} - -//go:linkname rtype_ChanDir reflect.(*rtype).ChanDir -//go:noescape -func rtype_ChanDir(*Type) reflect.ChanDir - -func (t *Type) ChanDir() reflect.ChanDir { - return rtype_ChanDir(t) -} - -//go:linkname rtype_IsVariadic reflect.(*rtype).IsVariadic -//go:noescape -func rtype_IsVariadic(*Type) bool - -func (t *Type) IsVariadic() bool { - return rtype_IsVariadic(t) -} - -//go:linkname rtype_Elem reflect.(*rtype).Elem -//go:noescape -func rtype_Elem(*Type) reflect.Type - -func (t *Type) Elem() *Type { - return Type2RType(rtype_Elem(t)) -} - -//go:linkname rtype_Field reflect.(*rtype).Field -//go:noescape -func rtype_Field(*Type, int) reflect.StructField - -func (t *Type) Field(i int) reflect.StructField { - return rtype_Field(t, i) -} - -//go:linkname rtype_FieldByIndex reflect.(*rtype).FieldByIndex -//go:noescape -func rtype_FieldByIndex(*Type, []int) reflect.StructField - -func (t *Type) FieldByIndex(index []int) reflect.StructField { - return rtype_FieldByIndex(t, index) -} - -//go:linkname rtype_FieldByName reflect.(*rtype).FieldByName -//go:noescape -func rtype_FieldByName(*Type, string) (reflect.StructField, bool) - -func (t *Type) FieldByName(name string) (reflect.StructField, bool) { - return rtype_FieldByName(t, name) -} - -//go:linkname rtype_FieldByNameFunc reflect.(*rtype).FieldByNameFunc -//go:noescape -func rtype_FieldByNameFunc(*Type, func(string) bool) (reflect.StructField, bool) - -func (t *Type) FieldByNameFunc(match func(string) bool) (reflect.StructField, bool) { - return rtype_FieldByNameFunc(t, match) -} - -//go:linkname rtype_In reflect.(*rtype).In -//go:noescape -func rtype_In(*Type, int) reflect.Type - -func (t *Type) In(i int) reflect.Type { - return rtype_In(t, i) -} - -//go:linkname rtype_Key reflect.(*rtype).Key -//go:noescape -func rtype_Key(*Type) reflect.Type - -func (t *Type) Key() *Type { - return Type2RType(rtype_Key(t)) -} - -//go:linkname rtype_Len reflect.(*rtype).Len -//go:noescape -func rtype_Len(*Type) int - -func (t *Type) Len() int { - return rtype_Len(t) -} - -//go:linkname rtype_NumField reflect.(*rtype).NumField -//go:noescape -func rtype_NumField(*Type) int - -func (t *Type) NumField() int { - return rtype_NumField(t) -} - -//go:linkname rtype_NumIn reflect.(*rtype).NumIn -//go:noescape -func rtype_NumIn(*Type) int - -func (t *Type) NumIn() int { - return rtype_NumIn(t) -} - -//go:linkname rtype_NumOut reflect.(*rtype).NumOut -//go:noescape -func rtype_NumOut(*Type) int - -func (t *Type) NumOut() int { - return rtype_NumOut(t) -} - -//go:linkname rtype_Out reflect.(*rtype).Out -//go:noescape -func rtype_Out(*Type, int) reflect.Type - -//go:linkname PtrTo reflect.(*rtype).ptrTo -//go:noescape -func PtrTo(*Type) *Type - -func (t *Type) Out(i int) reflect.Type { - return rtype_Out(t, i) -} - -//go:linkname IfaceIndir reflect.ifaceIndir -//go:noescape -func IfaceIndir(*Type) bool - -//go:linkname RType2Type reflect.toType -//go:noescape -func RType2Type(t *Type) reflect.Type - -//go:nolint structcheck -type emptyInterface struct { - _ *Type - ptr unsafe.Pointer -} - -func Type2RType(t reflect.Type) *Type { - return (*Type)(((*emptyInterface)(unsafe.Pointer(&t))).ptr) -} 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 deleted file mode 100644 index baab0c597..000000000 --- a/vendor/github.com/goccy/go-json/internal/runtime/struct_field.go +++ /dev/null @@ -1,91 +0,0 @@ -package runtime - -import ( - "reflect" - "strings" - "unicode" -) - -func getTag(field reflect.StructField) string { - return field.Tag.Get("json") -} - -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 { - return true - } - } else { - // private field - return true - } - } - tag := getTag(field) - return tag == "-" -} - -type StructTag struct { - Key string - IsTaggedKey bool - IsOmitEmpty bool - IsString bool - Field reflect.StructField -} - -type StructTags []*StructTag - -func (t StructTags) ExistsKey(key string) bool { - for _, tt := range t { - if tt.Key == key { - return true - } - } - return false -} - -func isValidTag(s string) bool { - if s == "" { - return false - } - for _, c := range s { - switch { - case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c): - // Backslash and quote chars are reserved, but - // otherwise any punctuation chars are allowed - // in a tag name. - case !unicode.IsLetter(c) && !unicode.IsDigit(c): - return false - } - } - return true -} - -func StructTagFromField(field reflect.StructField) *StructTag { - keyName := field.Name - tag := getTag(field) - st := &StructTag{Field: field} - opts := strings.Split(tag, ",") - if len(opts) > 0 { - if opts[0] != "" && isValidTag(opts[0]) { - keyName = opts[0] - st.IsTaggedKey = true - } - } - st.Key = keyName - if len(opts) > 1 { - for _, opt := range opts[1:] { - switch opt { - case "omitempty": - st.IsOmitEmpty = true - case "string": - st.IsString = true - } - } - } - return st -} diff --git a/vendor/github.com/goccy/go-json/internal/runtime/type.go b/vendor/github.com/goccy/go-json/internal/runtime/type.go deleted file mode 100644 index 0167cd2c0..000000000 --- a/vendor/github.com/goccy/go-json/internal/runtime/type.go +++ /dev/null @@ -1,100 +0,0 @@ -package runtime - -import ( - "reflect" - "unsafe" -) - -type SliceHeader struct { - Data unsafe.Pointer - Len int - Cap int -} - -const ( - maxAcceptableTypeAddrRange = 1024 * 1024 * 2 // 2 Mib -) - -type TypeAddr struct { - BaseTypeAddr uintptr - MaxTypeAddr uintptr - AddrRange uintptr - AddrShift uintptr -} - -var ( - typeAddr *TypeAddr - alreadyAnalyzed bool -) - -//go:linkname typelinks reflect.typelinks -func typelinks() ([]unsafe.Pointer, [][]int32) - -//go:linkname rtypeOff reflect.rtypeOff -func rtypeOff(unsafe.Pointer, int32) unsafe.Pointer - -func AnalyzeTypeAddr() *TypeAddr { - 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 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 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 deleted file mode 100644 index 413cb20bf..000000000 --- a/vendor/github.com/goccy/go-json/json.go +++ /dev/null @@ -1,371 +0,0 @@ -package json - -import ( - "bytes" - "context" - "encoding/json" - - "github.com/goccy/go-json/internal/encoder" -) - -// Marshaler is the interface implemented by types that -// can marshal themselves into valid JSON. -type Marshaler interface { - MarshalJSON() ([]byte, error) -} - -// MarshalerContext is the interface implemented by types that -// can marshal themselves into valid JSON with context.Context. -type MarshalerContext interface { - MarshalJSON(context.Context) ([]byte, error) -} - -// Unmarshaler is the interface implemented by types -// that can unmarshal a JSON description of themselves. -// The input can be assumed to be a valid encoding of -// a JSON value. UnmarshalJSON must copy the JSON data -// if it wishes to retain the data after returning. -// -// By convention, to approximate the behavior of Unmarshal itself, -// Unmarshalers implement UnmarshalJSON([]byte("null")) as a no-op. -type Unmarshaler interface { - UnmarshalJSON([]byte) error -} - -// UnmarshalerContext is the interface implemented by types -// that can unmarshal with context.Context a JSON description of themselves. -type UnmarshalerContext interface { - UnmarshalJSON(context.Context, []byte) error -} - -// Marshal returns the JSON encoding of v. -// -// Marshal traverses the value v recursively. -// If an encountered value implements the Marshaler interface -// and is not a nil pointer, Marshal calls its MarshalJSON method -// to produce JSON. If no MarshalJSON method is present but the -// value implements encoding.TextMarshaler instead, Marshal calls -// its MarshalText method and encodes the result as a JSON string. -// The nil pointer exception is not strictly necessary -// but mimics a similar, necessary exception in the behavior of -// UnmarshalJSON. -// -// Otherwise, Marshal uses the following type-dependent default encodings: -// -// Boolean values encode as JSON booleans. -// -// Floating point, integer, and Number values encode as JSON numbers. -// -// String values encode as JSON strings coerced to valid UTF-8, -// replacing invalid bytes with the Unicode replacement rune. -// The angle brackets "<" and ">" are escaped to "\u003c" and "\u003e" -// to keep some browsers from misinterpreting JSON output as HTML. -// Ampersand "&" is also escaped to "\u0026" for the same reason. -// This escaping can be disabled using an Encoder that had SetEscapeHTML(false) -// called on it. -// -// Array and slice values encode as JSON arrays, except that -// []byte encodes as a base64-encoded string, and a nil slice -// encodes as the null JSON value. -// -// Struct values encode as JSON objects. -// Each exported struct field becomes a member of the object, using the -// field name as the object key, unless the field is omitted for one of the -// reasons given below. -// -// The encoding of each struct field can be customized by the format string -// stored under the "json" key in the struct field's tag. -// The format string gives the name of the field, possibly followed by a -// comma-separated list of options. The name may be empty in order to -// specify options without overriding the default field name. -// -// The "omitempty" option specifies that the field should be omitted -// from the encoding if the field has an empty value, defined as -// false, 0, a nil pointer, a nil interface value, and any empty array, -// slice, map, or string. -// -// As a special case, if the field tag is "-", the field is always omitted. -// Note that a field with name "-" can still be generated using the tag "-,". -// -// 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" 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 is ignored by this package. -// 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"` -// -// The key name will be used if it's a non-empty string consisting of -// only Unicode letters, digits, and ASCII punctuation except quotation -// marks, backslash, and comma. -// -// Anonymous struct fields are usually marshaled as if their inner exported fields -// were fields in the outer struct, subject to the usual Go visibility rules amended -// as described in the next paragraph. -// An anonymous struct field with a name given in its JSON tag is treated as -// having that name, rather than being anonymous. -// An anonymous struct field of interface type is treated the same as having -// that type as its name, rather than being anonymous. -// -// The Go visibility rules for struct fields are amended for JSON when -// deciding which field to marshal or unmarshal. If there are -// multiple fields at the same level, and that level is the least -// nested (and would therefore be the nesting level selected by the -// usual Go rules), the following extra rules apply: -// -// 1) Of those fields, if any are JSON-tagged, only tagged fields are considered, -// even if there are multiple untagged fields that would otherwise conflict. -// -// 2) If there is exactly one field (tagged or not according to the first rule), that is selected. -// -// 3) Otherwise there are multiple fields, and all are ignored; no error occurs. -// -// Handling of anonymous struct fields is new in Go 1.1. -// Prior to Go 1.1, anonymous struct fields were ignored. To force ignoring of -// an anonymous struct field in both current and earlier versions, give the field -// a JSON tag of "-". -// -// Map values encode as JSON objects. The map's key type must either be a -// string, an integer type, or implement encoding.TextMarshaler. The map keys -// are sorted and used as JSON object keys by applying the following rules, -// subject to the UTF-8 coercion described for string values above: -// - string keys are used directly -// - encoding.TextMarshalers are marshaled -// - integer keys are converted to strings -// -// Pointer values encode as the value pointed to. -// A nil pointer encodes as the null JSON value. -// -// Interface values encode as the value contained in the interface. -// A nil interface value encodes as the null JSON value. -// -// Channel, complex, and function values cannot be encoded in JSON. -// Attempting to encode such a value causes Marshal to return -// an UnsupportedTypeError. -// -// 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) -} - -// MarshalNoEscape returns the JSON encoding of v and doesn't escape v. -func MarshalNoEscape(v interface{}) ([]byte, error) { - return marshalNoEscape(v) -} - -// MarshalContext returns the JSON encoding of v with context.Context and EncodeOption. -func MarshalContext(ctx context.Context, v interface{}, optFuncs ...EncodeOptionFunc) ([]byte, error) { - return marshalContext(ctx, v, optFuncs...) -} - -// MarshalWithOption returns the JSON encoding of v with EncodeOption. -func MarshalWithOption(v interface{}, optFuncs ...EncodeOptionFunc) ([]byte, error) { - return marshal(v, optFuncs...) -} - -// MarshalIndent is like Marshal but applies Indent to format the output. -// Each JSON element in the output will begin on a new line beginning with prefix -// followed by one or more copies of indent according to the indentation nesting. -func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { - return MarshalIndentWithOption(v, prefix, indent) -} - -// MarshalIndentWithOption is like Marshal but applies Indent to format the output with EncodeOption. -func MarshalIndentWithOption(v interface{}, prefix, indent string, optFuncs ...EncodeOptionFunc) ([]byte, error) { - return marshalIndent(v, prefix, indent, optFuncs...) -} - -// Unmarshal parses the JSON-encoded data and stores the result -// in the value pointed to by v. If v is nil or not a pointer, -// Unmarshal returns an InvalidUnmarshalError. -// -// Unmarshal uses the inverse of the encodings that -// Marshal uses, allocating maps, slices, and pointers as necessary, -// with the following additional rules: -// -// To unmarshal JSON into a pointer, Unmarshal first handles the case of -// the JSON being the JSON literal null. In that case, Unmarshal sets -// the pointer to nil. Otherwise, Unmarshal unmarshals the JSON into -// the value pointed at by the pointer. If the pointer is nil, Unmarshal -// allocates a new value for it to point to. -// -// To unmarshal JSON into a value implementing the Unmarshaler interface, -// Unmarshal calls that value's UnmarshalJSON method, including -// when the input is a JSON null. -// Otherwise, if the value implements encoding.TextUnmarshaler -// and the input is a JSON quoted string, Unmarshal calls that value's -// UnmarshalText method with the unquoted form of the string. -// -// To unmarshal JSON into a struct, Unmarshal matches incoming object -// keys to the keys used by Marshal (either the struct field name or its tag), -// preferring an exact match but also accepting a case-insensitive match. By -// default, object keys which don't have a corresponding struct field are -// ignored (see Decoder.DisallowUnknownFields for an alternative). -// -// To unmarshal JSON into an interface value, -// Unmarshal stores one of these in the interface value: -// -// bool, for JSON booleans -// float64, for JSON numbers -// string, for JSON strings -// []interface{}, for JSON arrays -// map[string]interface{}, for JSON objects -// nil for JSON null -// -// To unmarshal a JSON array into a slice, Unmarshal resets the slice length -// to zero and then appends each element to the slice. -// As a special case, to unmarshal an empty JSON array into a slice, -// Unmarshal replaces the slice with a new empty slice. -// -// To unmarshal a JSON array into a Go array, Unmarshal decodes -// JSON array elements into corresponding Go array elements. -// If the Go array is smaller than the JSON array, -// the additional JSON array elements are discarded. -// If the JSON array is smaller than the Go array, -// the additional Go array elements are set to zero values. -// -// To unmarshal a JSON object into a map, Unmarshal first establishes a map to -// use. If the map is nil, Unmarshal allocates a new map. Otherwise Unmarshal -// reuses the existing map, keeping existing entries. Unmarshal then stores -// key-value pairs from the JSON object into the map. The map's key type must -// either be any string type, an integer, implement json.Unmarshaler, or -// implement encoding.TextUnmarshaler. -// -// If a JSON value is not appropriate for a given target type, -// or if a JSON number overflows the target type, Unmarshal -// skips that field and completes the unmarshaling as best it can. -// If no more serious errors are encountered, Unmarshal returns -// an UnmarshalTypeError describing the earliest such error. In any -// case, it's not guaranteed that all the remaining fields following -// the problematic one will be unmarshaled into the target object. -// -// 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 -// 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) -} - -// UnmarshalContext parses the JSON-encoded data and stores the result -// in the value pointed to by v. If you implement the UnmarshalerContext interface, -// call it with ctx as an argument. -func UnmarshalContext(ctx context.Context, data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - return unmarshalContext(ctx, data, v) -} - -func UnmarshalWithOption(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - return unmarshal(data, v, optFuncs...) -} - -func UnmarshalNoEscape(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - return unmarshalNoEscape(data, v, optFuncs...) -} - -// A Token holds a value of one of these types: -// -// Delim, for the four JSON delimiters [ ] { } -// bool, for JSON booleans -// float64, for JSON numbers -// Number, for JSON numbers -// string, for JSON string literals -// nil, for JSON null -// -type Token = json.Token - -// A Number represents a JSON number literal. -type Number = json.Number - -// RawMessage is a raw encoded JSON value. -// It implements Marshaler and Unmarshaler and can -// be used to delay JSON decoding or precompute a JSON encoding. -type RawMessage = json.RawMessage - -// A Delim is a JSON array or object delimiter, one of [ ] { or }. -type Delim = json.Delim - -// Compact appends to dst the JSON-encoded src with -// insignificant space characters elided. -func Compact(dst *bytes.Buffer, src []byte) error { - return encoder.Compact(dst, src, false) -} - -// Indent appends to dst an indented form of the JSON-encoded src. -// Each element in a JSON object or array begins on a new, -// indented line beginning with prefix followed by one or more -// copies of indent according to the indentation nesting. -// The data appended to dst does not begin with the prefix nor -// any indentation, to make it easier to embed inside other formatted JSON data. -// Although leading space characters (space, tab, carriage return, newline) -// at the beginning of src are dropped, trailing space characters -// at the end of src are preserved and copied to dst. -// For example, if src has no trailing spaces, neither will dst; -// if src ends in a trailing newline, so will dst. -func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error { - return encoder.Indent(dst, src, prefix, indent) -} - -// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029 -// characters inside string literals changed to \u003c, \u003e, \u0026, \u2028, \u2029 -// so that the JSON will be safe to embed inside HTML