From 1977be6091f3c845fff8f3a82d58e03f4a086d8d Mon Sep 17 00:00:00 2001 From: Preston Vasquez <24281431+prestonvasquez@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:51:43 -0600 Subject: [PATCH 01/12] GODRIVER-2690 Start migrating to v2 imports --- .evergreen/config.yml | 6 +- README.md | 30 +- benchmark/bson.go | 2 +- benchmark/bson_document.go | 2 +- benchmark/bson_map.go | 2 +- benchmark/bson_struct.go | 2 +- benchmark/bson_types.go | 2 +- benchmark/harness.go | 4 +- benchmark/multi.go | 2 +- benchmark/operation_test.go | 6 +- benchmark/single.go | 10 +- bson/bson.go | 4 +- bson/bson_corpus_spec_test.go | 6 +- bson/bson_test.go | 10 +- bson/bsoncodec/array_codec.go | 4 +- bson/bsoncodec/bsoncodec.go | 8 +- bson/bsoncodec/bsoncodec_test.go | 6 +- bson/bsoncodec/byte_slice_codec.go | 6 +- bson/bsoncodec/cond_addr_codec.go | 2 +- bson/bsoncodec/cond_addr_codec_test.go | 6 +- bson/bsoncodec/default_value_decoders.go | 8 +- bson/bsoncodec/default_value_decoders_test.go | 12 +- bson/bsoncodec/default_value_encoders.go | 8 +- bson/bsoncodec/default_value_encoders_test.go | 10 +- bson/bsoncodec/empty_interface_codec.go | 8 +- bson/bsoncodec/map_codec.go | 6 +- bson/bsoncodec/pointer_codec.go | 4 +- bson/bsoncodec/registry.go | 2 +- bson/bsoncodec/registry_examples_test.go | 8 +- bson/bsoncodec/registry_test.go | 6 +- bson/bsoncodec/slice_codec.go | 8 +- bson/bsoncodec/string_codec.go | 6 +- bson/bsoncodec/string_codec_test.go | 10 +- bson/bsoncodec/struct_codec.go | 6 +- bson/bsoncodec/struct_codec_test.go | 2 +- bson/bsoncodec/time_codec.go | 8 +- bson/bsoncodec/time_codec_test.go | 10 +- bson/bsoncodec/types.go | 4 +- bson/bsoncodec/uint_codec.go | 6 +- bson/bsonrw/bsonrwtest/bsonrwtest.go | 10 +- bson/bsonrw/copier.go | 6 +- bson/bsonrw/copier_test.go | 6 +- bson/bsonrw/doc.go | 2 +- bson/bsonrw/extjson_parser.go | 2 +- bson/bsonrw/extjson_parser_test.go | 2 +- bson/bsonrw/extjson_reader.go | 4 +- bson/bsonrw/extjson_reader_test.go | 2 +- bson/bsonrw/extjson_wrappers.go | 4 +- bson/bsonrw/extjson_writer.go | 2 +- bson/bsonrw/extjson_writer_test.go | 4 +- bson/bsonrw/reader.go | 4 +- bson/bsonrw/value_reader.go | 4 +- bson/bsonrw/value_reader_test.go | 6 +- bson/bsonrw/value_reader_writer_test.go | 6 +- bson/bsonrw/value_writer.go | 6 +- bson/bsonrw/value_writer_test.go | 6 +- bson/bsonrw/writer.go | 4 +- bson/bsontype/bsontype.go | 2 +- bson/decoder.go | 4 +- bson/decoder_example_test.go | 4 +- bson/decoder_test.go | 14 +- bson/encoder.go | 4 +- bson/encoder_example_test.go | 4 +- bson/encoder_test.go | 14 +- bson/example_test.go | 2 +- bson/extjson_prose_test.go | 4 +- bson/marshal.go | 6 +- bson/marshal_test.go | 12 +- bson/marshal_value_cases_test.go | 8 +- bson/marshal_value_test.go | 6 +- bson/marshaling_cases_test.go | 2 +- bson/mgocompat/bson_test.go | 12 +- bson/mgocompat/registry.go | 8 +- bson/mgocompat/setter_getter.go | 6 +- bson/primitive/decimal_test.go | 4 +- bson/primitive/objectid_test.go | 4 +- bson/primitive/primitive.go | 2 +- bson/primitive/primitive_test.go | 4 +- bson/primitive_codecs.go | 4 +- bson/primitive_codecs_test.go | 12 +- bson/raw.go | 2 +- bson/raw_element.go | 2 +- bson/raw_test.go | 6 +- bson/raw_value.go | 10 +- bson/raw_value_test.go | 8 +- bson/registry.go | 2 +- bson/truncation_test.go | 4 +- bson/types.go | 2 +- bson/unmarshal.go | 6 +- bson/unmarshal_test.go | 10 +- bson/unmarshal_value_test.go | 8 +- bson/unmarshaling_cases_test.go | 4 +- cmd/build-oss-fuzz-corpus/main.go | 2 +- cmd/testatlas/main.go | 8 +- cmd/testaws/main.go | 6 +- cmd/testentauth/main.go | 6 +- cmd/testkms/main.go | 8 +- docs/common-issues.md | 8 +- event/examples_test.go | 8 +- event/monitoring.go | 10 +- examples/_example_customdns_test.go | 6 +- examples/_logger/logrus/main.go | 6 +- examples/_logger/zap/main.go | 6 +- examples/_logger/zerolog/main.go | 6 +- examples/documentation_examples/examples.go | 18 +- .../documentation_examples/examples_test.go | 10 +- go.mod | 24 +- go.sum | 2 + .../assert/assertion_compare_go1.17_test.go | 8 +- internal/assert/assertion_compare_test.go | 12 +- internal/assert/assertion_mongo_test.go | 2 +- internal/aws/credentials/chain_provider.go | 2 +- .../aws/credentials/chain_provider_test.go | 2 +- internal/aws/credentials/credentials.go | 2 +- internal/aws/credentials/credentials_test.go | 2 +- internal/aws/signer/v4/v4.go | 4 +- internal/aws/signer/v4/v4_test.go | 6 +- internal/bsonutil/bsonutil.go | 2 +- internal/codecutil/encoding.go | 4 +- internal/codecutil/encoding_test.go | 10 +- .../credproviders/assume_role_provider.go | 4 +- internal/credproviders/ec2_provider.go | 2 +- internal/credproviders/ecs_provider.go | 2 +- internal/credproviders/env_provider.go | 2 +- internal/credproviders/imds_provider.go | 2 +- internal/credproviders/static_provider.go | 2 +- internal/csfle/csfle.go | 2 +- internal/integtest/integtest.go | 18 +- internal/logger/component.go | 2 +- internal/logger/component_test.go | 4 +- internal/logger/context_test.go | 4 +- internal/logger/logger_test.go | 2 +- internal/ptrutil/int64_test.go | 2 +- internal/rand/example_test.go | 2 +- internal/rand/regress_test.go | 2 +- internal/randutil/randutil.go | 2 +- internal/randutil/randutil_test.go | 2 +- internal/require/require.go | 2 +- internal/spectest/spectest.go | 2 +- internal/test/compilecheck/main.go | 6 +- internal/test/faas/awslambda/mongodb/main.go | 6 +- internal/uuid/uuid.go | 2 +- internal/uuid/uuid_test.go | 4 +- mongo/address/addr.go | 2 +- mongo/address/addr_test.go | 2 +- mongo/background_context_test.go | 2 +- mongo/batch_cursor.go | 4 +- mongo/bson_helpers_test.go | 4 +- mongo/bulk_write.go | 18 +- mongo/bulk_write_models.go | 2 +- mongo/change_stream.go | 24 +- mongo/change_stream_deployment.go | 4 +- mongo/change_stream_test.go | 2 +- mongo/client.go | 36 +- mongo/client_encryption.go | 16 +- mongo/client_examples_test.go | 8 +- mongo/client_side_encryption_examples_test.go | 6 +- mongo/client_test.go | 22 +- mongo/collection.go | 28 +- mongo/collection_test.go | 12 +- mongo/crud_examples_test.go | 12 +- mongo/crypt_retrievers.go | 2 +- mongo/cursor.go | 14 +- mongo/cursor_test.go | 12 +- mongo/database.go | 24 +- mongo/database_test.go | 16 +- mongo/description/description.go | 2 +- mongo/description/max_staleness_spec_test.go | 2 +- mongo/description/selector_spec_test.go | 2 +- mongo/description/selector_test.go | 10 +- mongo/description/server.go | 14 +- mongo/description/server_selector.go | 4 +- mongo/description/server_test.go | 8 +- mongo/description/shared_spec_test.go | 8 +- mongo/description/topology.go | 2 +- mongo/description/topology_version.go | 4 +- mongo/errors.go | 10 +- mongo/errors_test.go | 6 +- mongo/gridfs/bucket.go | 20 +- mongo/gridfs/download_stream.go | 4 +- mongo/gridfs/gridfs_examples_test.go | 8 +- mongo/gridfs/gridfs_test.go | 14 +- mongo/gridfs/upload_stream.go | 6 +- mongo/index_options_builder.go | 2 +- mongo/index_view.go | 20 +- mongo/integration/causal_consistency_test.go | 14 +- mongo/integration/change_stream_test.go | 18 +- mongo/integration/clam_prose_test.go | 14 +- mongo/integration/client_options_test.go | 10 +- .../client_side_encryption_prose_test.go | 28 +- .../client_side_encryption_test.go | 24 +- mongo/integration/client_test.go | 34 +- .../cmd_monitoring_helpers_test.go | 12 +- mongo/integration/collection_test.go | 18 +- mongo/integration/crud_helpers_test.go | 26 +- mongo/integration/crud_prose_test.go | 12 +- mongo/integration/crud_spec_test.go | 10 +- mongo/integration/csot_cse_prose_test.go | 14 +- mongo/integration/csot_prose_test.go | 14 +- mongo/integration/cursor_test.go | 10 +- mongo/integration/data_lake_test.go | 8 +- mongo/integration/database_test.go | 20 +- mongo/integration/errors_test.go | 16 +- mongo/integration/gridfs_test.go | 18 +- mongo/integration/handshake_test.go | 14 +- mongo/integration/index_view_test.go | 14 +- .../initial_dns_seedlist_discovery_test.go | 18 +- mongo/integration/json_helpers_test.go | 14 +- mongo/integration/load_balancer_prose_test.go | 12 +- mongo/integration/log_helpers_test.go | 4 +- mongo/integration/main.go | 2 +- mongo/integration/main_test.go | 2 +- mongo/integration/mock_find_test.go | 12 +- mongo/integration/mongos_pinning_test.go | 10 +- mongo/integration/mtest/deployment_helpers.go | 2 +- mongo/integration/mtest/global_state.go | 8 +- mongo/integration/mtest/mongotest.go | 22 +- mongo/integration/mtest/opmsg_deployment.go | 16 +- mongo/integration/mtest/options.go | 4 +- mongo/integration/mtest/proxy_dialer.go | 4 +- mongo/integration/mtest/received_message.go | 4 +- mongo/integration/mtest/sent_message.go | 4 +- mongo/integration/mtest/setup.go | 20 +- .../integration/mtest/wiremessage_helpers.go | 4 +- mongo/integration/primary_stepdown_test.go | 12 +- .../integration/retryable_reads_prose_test.go | 14 +- .../retryable_writes_prose_test.go | 20 +- .../integration/retryable_writes_spec_test.go | 6 +- mongo/integration/sdam_error_handling_test.go | 12 +- mongo/integration/sdam_prose_test.go | 10 +- .../server_selection_prose_test.go | 16 +- .../sessions_mongocryptd_prose_test.go | 16 +- mongo/integration/sessions_test.go | 18 +- mongo/integration/unified/admin_helpers.go | 10 +- mongo/integration/unified/bsonutil.go | 6 +- mongo/integration/unified/bucket_options.go | 4 +- .../integration/unified/bulkwrite_helpers.go | 8 +- .../client_encryption_operation_execution.go | 10 +- mongo/integration/unified/client_entity.go | 20 +- .../unified/client_operation_execution.go | 10 +- mongo/integration/unified/collection_data.go | 12 +- .../unified/collection_operation_execution.go | 12 +- mongo/integration/unified/common_options.go | 10 +- mongo/integration/unified/context.go | 2 +- mongo/integration/unified/crud_helpers.go | 8 +- .../unified/cursor_operation_execution.go | 2 +- .../unified/database_operation_execution.go | 8 +- .../unified/db_collection_options.go | 4 +- mongo/integration/unified/entity.go | 10 +- mongo/integration/unified/entity_test.go | 4 +- mongo/integration/unified/error.go | 4 +- mongo/integration/unified/event.go | 6 +- .../integration/unified/event_verification.go | 8 +- .../gridfs_bucket_operation_execution.go | 8 +- mongo/integration/unified/logger.go | 2 +- .../unified/logger_verification.go | 4 +- .../unified/logger_verification_test.go | 6 +- mongo/integration/unified/main_test.go | 2 +- mongo/integration/unified/matches.go | 4 +- mongo/integration/unified/matches_test.go | 8 +- mongo/integration/unified/operation.go | 6 +- mongo/integration/unified/result.go | 4 +- mongo/integration/unified/schema_version.go | 2 +- .../integration/unified/server_api_options.go | 4 +- .../unified/session_operation_execution.go | 6 +- mongo/integration/unified/session_options.go | 4 +- .../unified/testrunner_operation.go | 10 +- .../unified/unified_spec_runner.go | 10 +- .../unified_runner_events_helper_test.go | 14 +- .../unified_runner_thread_helpers_test.go | 6 +- mongo/integration/unified_spec_test.go | 34 +- mongo/mongo.go | 18 +- mongo/mongo_test.go | 18 +- mongo/mongocryptd.go | 8 +- mongo/ocsp_test.go | 8 +- mongo/options/aggregateoptions.go | 2 +- mongo/options/autoencryptionoptions.go | 2 +- mongo/options/changestreamoptions.go | 4 +- mongo/options/changestreamoptions_test.go | 2 +- mongo/options/clientencryptionoptions.go | 2 +- mongo/options/clientoptions.go | 22 +- mongo/options/clientoptions_test.go | 18 +- mongo/options/collation_test.go | 2 +- mongo/options/collectionoptions.go | 8 +- mongo/options/dboptions.go | 8 +- mongo/options/encryptoptions.go | 4 +- mongo/options/example_test.go | 4 +- mongo/options/gridfsoptions.go | 10 +- mongo/options/loggeroptions.go | 2 +- mongo/options/mongooptions.go | 6 +- mongo/options/runcmdoptions.go | 2 +- mongo/options/sessionoptions.go | 6 +- mongo/options/transactionoptions.go | 6 +- mongo/read_write_concern_spec_test.go | 14 +- mongo/readconcern/readconcern.go | 6 +- mongo/readconcern/readconcern_test.go | 6 +- mongo/readpref/mode_test.go | 2 +- mongo/readpref/options.go | 2 +- mongo/readpref/options_example_test.go | 8 +- mongo/readpref/readpref.go | 4 +- mongo/readpref/readpref_test.go | 6 +- mongo/results.go | 6 +- mongo/results_test.go | 4 +- mongo/session.go | 16 +- mongo/single_result.go | 6 +- mongo/single_result_test.go | 8 +- mongo/with_transactions_test.go | 20 +- mongo/writeconcern/writeconcern.go | 8 +- .../writeconcern/writeconcern_example_test.go | 6 +- mongo/writeconcern/writeconcern_test.go | 10 +- tag/tag.go | 2 +- tag/tag_test.go | 4 +- vendor/github.com/golang/snappy/go.mod | 1 - vendor/github.com/klauspost/compress/go.mod | 3 - vendor/github.com/klauspost/compress/go.sum | 0 vendor/github.com/xdg-go/pbkdf2/go.mod | 3 - vendor/github.com/xdg-go/scram/go.mod | 8 - vendor/github.com/xdg-go/scram/go.sum | 29 - vendor/github.com/xdg-go/stringprep/go.mod | 5 - vendor/github.com/xdg-go/stringprep/go.sum | 25 - vendor/go.mongodb.org/mongo-driver/LICENSE | 201 ++ .../mongo-driver/benchmark/bson.go | 56 + .../mongo-driver/benchmark/bson_document.go | 125 ++ .../mongo-driver/benchmark/bson_map.go | 88 + .../mongo-driver/benchmark/bson_struct.go | 103 + .../mongo-driver/benchmark/bson_types.go | 306 +++ .../mongo-driver/benchmark/canary.go | 27 + .../mongo-driver/benchmark/harness.go | 212 ++ .../mongo-driver/benchmark/harness_case.go | 150 ++ .../mongo-driver/benchmark/harness_main.go | 75 + .../mongo-driver/benchmark/harness_results.go | 147 ++ .../mongo-driver/benchmark/multi.go | 134 ++ .../mongo-driver/benchmark/single.go | 171 ++ .../go.mongodb.org/mongo-driver/bson/bson.go | 50 + .../bson/bsoncodec/array_codec.go | 56 + .../mongo-driver/bson/bsoncodec/bsoncodec.go | 382 ++++ .../bson/bsoncodec/byte_slice_codec.go | 123 ++ .../bson/bsoncodec/cond_addr_codec.go | 63 + .../bson/bsoncodec/default_value_decoders.go | 1807 ++++++++++++++++ .../bson/bsoncodec/default_value_encoders.go | 856 ++++++++ .../mongo-driver/bson/bsoncodec/doc.go | 95 + .../bson/bsoncodec/empty_interface_codec.go | 159 ++ .../mongo-driver/bson/bsoncodec/map_codec.go | 327 +++ .../mongo-driver/bson/bsoncodec/mode.go | 65 + .../bson/bsoncodec/pointer_codec.go | 115 + .../mongo-driver/bson/bsoncodec/proxy.go | 14 + .../mongo-driver/bson/bsoncodec/registry.go | 579 +++++ .../bson/bsoncodec/slice_codec.go | 199 ++ .../bson/bsoncodec/string_codec.go | 132 ++ .../bson/bsoncodec/struct_codec.go | 735 +++++++ .../bson/bsoncodec/struct_tag_parser.go | 148 ++ .../mongo-driver/bson/bsoncodec/time_codec.go | 137 ++ .../mongo-driver/bson/bsoncodec/types.go | 57 + .../mongo-driver/bson/bsoncodec/uint_codec.go | 184 ++ .../bsonoptions/byte_slice_codec_options.go | 49 + .../mongo-driver/bson/bsonoptions/doc.go | 8 + .../empty_interface_codec_options.go | 49 + .../bson/bsonoptions/map_codec_options.go | 82 + .../bson/bsonoptions/slice_codec_options.go | 49 + .../bson/bsonoptions/string_codec_options.go | 52 + .../bson/bsonoptions/struct_codec_options.go | 107 + .../bson/bsonoptions/time_codec_options.go | 49 + .../bson/bsonoptions/uint_codec_options.go | 49 + .../mongo-driver/bson/bsonrw/copier.go | 488 +++++ .../mongo-driver/bson/bsonrw/doc.go | 9 + .../bson/bsonrw/extjson_parser.go | 806 +++++++ .../bson/bsonrw/extjson_reader.go | 652 ++++++ .../bson/bsonrw/extjson_tables.go | 223 ++ .../bson/bsonrw/extjson_wrappers.go | 492 +++++ .../bson/bsonrw/extjson_writer.go | 751 +++++++ .../mongo-driver/bson/bsonrw/json_scanner.go | 528 +++++ .../mongo-driver/bson/bsonrw/mode.go | 108 + .../mongo-driver/bson/bsonrw/reader.go | 65 + .../mongo-driver/bson/bsonrw/value_reader.go | 882 ++++++++ .../mongo-driver/bson/bsonrw/value_writer.go | 616 ++++++ .../mongo-driver/bson/bsonrw/writer.go | 87 + .../mongo-driver/bson/bsontype/bsontype.go | 115 + .../mongo-driver/bson/decoder.go | 208 ++ .../go.mongodb.org/mongo-driver/bson/doc.go | 144 ++ .../mongo-driver/bson/encoder.go | 199 ++ .../mongo-driver/bson/marshal.go | 427 ++++ .../mongo-driver/bson/primitive/decimal.go | 437 ++++ .../mongo-driver/bson/primitive/objectid.go | 206 ++ .../mongo-driver/bson/primitive/primitive.go | 231 ++ .../mongo-driver/bson/primitive_codecs.go | 122 ++ .../go.mongodb.org/mongo-driver/bson/raw.go | 94 + .../mongo-driver/bson/raw_element.go | 48 + .../mongo-driver/bson/raw_value.go | 320 +++ .../mongo-driver/bson/registry.go | 35 + .../go.mongodb.org/mongo-driver/bson/types.go | 49 + .../mongo-driver/bson/unmarshal.go | 177 ++ .../go.mongodb.org/mongo-driver/event/doc.go | 56 + .../mongo-driver/event/monitoring.go | 210 ++ .../internal/assert/assertion_compare.go | 464 ++++ .../assert/assertion_compare_can_convert.go | 18 + .../assert/assertion_compare_legacy.go | 18 + .../internal/assert/assertion_format.go | 325 +++ .../internal/assert/assertion_mongo.go | 90 + .../internal/assert/assertions.go | 1038 +++++++++ .../mongo-driver/internal/assert/difflib.go | 766 +++++++ .../mongo-driver/internal/aws/awserr/error.go | 60 + .../mongo-driver/internal/aws/awserr/types.go | 144 ++ .../aws/credentials/chain_provider.go | 72 + .../internal/aws/credentials/credentials.go | 197 ++ .../internal/aws/signer/v4/header_rules.go | 51 + .../internal/aws/signer/v4/request.go | 80 + .../internal/aws/signer/v4/uri_path.go | 65 + .../mongo-driver/internal/aws/signer/v4/v4.go | 421 ++++ .../mongo-driver/internal/aws/types.go | 153 ++ .../internal/background_context.go | 34 + .../internal/cancellation_listener.go | 47 + .../mongo-driver/internal/const.go | 19 + .../credproviders/assume_role_provider.go | 148 ++ .../internal/credproviders/ec2_provider.go | 183 ++ .../internal/credproviders/ecs_provider.go | 112 + .../internal/credproviders/env_provider.go | 69 + .../internal/credproviders/imds_provider.go | 104 + .../internal/credproviders/static_provider.go | 59 + .../mongo-driver/internal/csfle_util.go | 39 + .../mongo-driver/internal/csot_util.go | 58 + .../mongo-driver/internal/error.go | 123 ++ .../mongo-driver/internal/http.go | 30 + .../mongo-driver/internal/logger/component.go | 201 ++ .../mongo-driver/internal/logger/io_sink.go | 58 + .../mongo-driver/internal/logger/level.go | 74 + .../mongo-driver/internal/logger/logger.go | 266 +++ .../internal/randutil/rand/bits.go | 38 + .../internal/randutil/rand/exp.go | 223 ++ .../internal/randutil/rand/normal.go | 158 ++ .../internal/randutil/rand/rand.go | 374 ++++ .../internal/randutil/rand/rng.go | 93 + .../internal/randutil/randutil.go | 39 + .../mongo-driver/internal/require/require.go | 819 +++++++ .../mongo-driver/internal/string_util.go | 45 + .../mongo-driver/internal/testutil/config.go | 275 +++ .../mongo-driver/internal/testutil/ops.go | 64 + .../internal/uri_validation_errors.go | 22 + .../mongo-driver/internal/uuid/uuid.go | 68 + .../mongo-driver/mongo/address/addr.go | 50 + .../mongo-driver/mongo/batch_cursor.go | 52 + .../mongo-driver/mongo/bulk_write.go | 596 +++++ .../mongo-driver/mongo/bulk_write_models.go | 305 +++ .../mongo-driver/mongo/change_stream.go | 722 +++++++ .../mongo/change_stream_deployment.go | 49 + .../mongo-driver/mongo/client.go | 867 ++++++++ .../mongo-driver/mongo/client_encryption.go | 432 ++++ .../mongo-driver/mongo/collection.go | 1914 +++++++++++++++++ .../mongo-driver/mongo/crypt_retrievers.go | 65 + .../mongo-driver/mongo/cursor.go | 400 ++++ .../mongo-driver/mongo/database.go | 835 +++++++ .../mongo/description/description.go | 11 + .../mongo-driver/mongo/description/server.go | 488 +++++ .../mongo/description/server_kind.go | 46 + .../mongo/description/server_selector.go | 350 +++ .../mongo/description/topology.go | 142 ++ .../mongo/description/topology_kind.go | 40 + .../mongo/description/topology_version.go | 66 + .../mongo/description/version_range.go | 42 + .../go.mongodb.org/mongo-driver/mongo/doc.go | 157 ++ .../mongo-driver/mongo/errors.go | 664 ++++++ .../mongo/index_options_builder.go | 176 ++ .../mongo-driver/mongo/index_view.go | 490 +++++ .../mongo-driver/mongo/mongo.go | 489 +++++ .../mongo-driver/mongo/mongocryptd.go | 164 ++ .../mongo/options/aggregateoptions.go | 184 ++ .../mongo/options/autoencryptionoptions.go | 210 ++ .../mongo/options/bulkwriteoptions.go | 94 + .../mongo/options/changestreamoptions.go | 207 ++ .../mongo/options/clientencryptionoptions.go | 150 ++ .../mongo/options/clientoptions.go | 1265 +++++++++++ .../mongo/options/collectionoptions.go | 101 + .../mongo/options/countoptions.go | 122 ++ .../mongo/options/createcollectionoptions.go | 360 ++++ .../mongo/options/datakeyoptions.go | 104 + .../mongo-driver/mongo/options/dboptions.go | 101 + .../mongo/options/deleteoptions.go | 89 + .../mongo/options/distinctoptions.go | 81 + .../mongo-driver/mongo/options/doc.go | 8 + .../mongo/options/encryptoptions.go | 151 ++ .../mongo/options/estimatedcountoptions.go | 67 + .../mongo-driver/mongo/options/findoptions.go | 1110 ++++++++++ .../mongo/options/gridfsoptions.go | 341 +++ .../mongo/options/indexoptions.go | 494 +++++ .../mongo/options/insertoptions.go | 125 ++ .../mongo/options/listcollectionsoptions.go | 69 + .../mongo/options/listdatabasesoptions.go | 58 + .../mongo/options/loggeroptions.go | 115 + .../mongo/options/mongooptions.go | 183 ++ .../mongo/options/replaceoptions.go | 118 + .../mongo/options/rewrapdatakeyoptions.go | 55 + .../mongo/options/runcmdoptions.go | 45 + .../mongo/options/serverapioptions.go | 60 + .../mongo/options/sessionoptions.go | 134 ++ .../mongo/options/transactionoptions.go | 103 + .../mongo/options/updateoptions.go | 131 ++ .../mongo/readconcern/readconcern.go | 129 ++ .../mongo-driver/mongo/readpref/mode.go | 88 + .../mongo-driver/mongo/readpref/options.go | 83 + .../mongo-driver/mongo/readpref/readpref.go | 133 ++ .../mongo-driver/mongo/results.go | 286 +++ .../mongo-driver/mongo/session.go | 390 ++++ .../mongo-driver/mongo/single_result.go | 132 ++ .../go.mongodb.org/mongo-driver/mongo/util.go | 7 + .../mongo/writeconcern/writeconcern.go | 439 ++++ vendor/go.mongodb.org/mongo-driver/tag/tag.go | 89 + .../mongo-driver/version/version.go | 11 + .../mongo-driver/x/bsonx/bsoncore/array.go | 164 ++ .../x/bsonx/bsoncore/bson_arraybuilder.go | 201 ++ .../x/bsonx/bsoncore/bson_documentbuilder.go | 189 ++ .../mongo-driver/x/bsonx/bsoncore/bsoncore.go | 846 ++++++++ .../mongo-driver/x/bsonx/bsoncore/doc.go | 29 + .../mongo-driver/x/bsonx/bsoncore/document.go | 386 ++++ .../x/bsonx/bsoncore/document_sequence.go | 189 ++ .../mongo-driver/x/bsonx/bsoncore/element.go | 152 ++ .../mongo-driver/x/bsonx/bsoncore/tables.go | 223 ++ .../mongo-driver/x/bsonx/bsoncore/value.go | 965 +++++++++ .../mongo-driver/x/mongo/driver/DESIGN.md | 23 + .../mongo-driver/x/mongo/driver/auth/auth.go | 229 ++ .../x/mongo/driver/auth/aws_conv.go | 189 ++ .../x/mongo/driver/auth/conversation.go | 31 + .../mongo-driver/x/mongo/driver/auth/cred.go | 16 + .../x/mongo/driver/auth/creds/awscreds.go | 58 + .../x/mongo/driver/auth/creds/azurecreds.go | 40 + .../x/mongo/driver/auth/creds/gcpcreds.go | 69 + .../x/mongo/driver/auth/default.go | 98 + .../mongo-driver/x/mongo/driver/auth/doc.go | 23 + .../x/mongo/driver/auth/gssapi.go | 59 + .../x/mongo/driver/auth/gssapi_not_enabled.go | 17 + .../mongo/driver/auth/gssapi_not_supported.go | 22 + .../mongo/driver/auth/internal/gssapi/gss.go | 167 ++ .../driver/auth/internal/gssapi/gss_wrapper.c | 254 +++ .../driver/auth/internal/gssapi/gss_wrapper.h | 72 + .../mongo/driver/auth/internal/gssapi/sspi.go | 353 +++ .../auth/internal/gssapi/sspi_wrapper.c | 249 +++ .../auth/internal/gssapi/sspi_wrapper.h | 64 + .../x/mongo/driver/auth/mongodbaws.go | 87 + .../x/mongo/driver/auth/mongodbcr.go | 110 + .../mongo-driver/x/mongo/driver/auth/plain.go | 55 + .../mongo-driver/x/mongo/driver/auth/sasl.go | 174 ++ .../mongo-driver/x/mongo/driver/auth/scram.go | 130 ++ .../mongo-driver/x/mongo/driver/auth/util.go | 30 + .../mongo-driver/x/mongo/driver/auth/x509.go | 85 + .../x/mongo/driver/batch_cursor.go | 479 +++++ .../mongo-driver/x/mongo/driver/batches.go | 76 + .../x/mongo/driver/compression.go | 151 ++ .../x/mongo/driver/connstring/connstring.go | 1036 +++++++++ .../mongo-driver/x/mongo/driver/crypt.go | 418 ++++ .../mongo-driver/x/mongo/driver/dns/dns.go | 146 ++ .../mongo-driver/x/mongo/driver/driver.go | 269 +++ .../mongo-driver/x/mongo/driver/errors.go | 520 +++++ .../mongo-driver/x/mongo/driver/legacy.go | 22 + .../driver/list_collections_batch_cursor.go | 134 ++ .../x/mongo/driver/mongocrypt/binary.go | 56 + .../x/mongo/driver/mongocrypt/errors.go | 44 + .../driver/mongocrypt/errors_not_enabled.go | 21 + .../x/mongo/driver/mongocrypt/mongocrypt.go | 519 +++++ .../driver/mongocrypt/mongocrypt_context.go | 115 + .../mongocrypt_context_not_enabled.go | 62 + .../mongocrypt/mongocrypt_kms_context.go | 76 + .../mongocrypt_kms_context_not_enabled.go | 39 + .../mongocrypt/mongocrypt_not_enabled.go | 90 + .../options/mongocrypt_context_options.go | 157 ++ .../mongocrypt/options/mongocrypt_options.go | 72 + .../x/mongo/driver/mongocrypt/state.go | 47 + .../mongo-driver/x/mongo/driver/ocsp/cache.go | 121 ++ .../x/mongo/driver/ocsp/config.go | 68 + .../mongo-driver/x/mongo/driver/ocsp/ocsp.go | 321 +++ .../x/mongo/driver/ocsp/options.go | 16 + .../mongo-driver/x/mongo/driver/operation.go | 1914 +++++++++++++++++ .../driver/operation/abort_transaction.go | 199 ++ .../x/mongo/driver/operation/aggregate.go | 419 ++++ .../x/mongo/driver/operation/command.go | 234 ++ .../driver/operation/commit_transaction.go | 201 ++ .../x/mongo/driver/operation/count.go | 311 +++ .../x/mongo/driver/operation/create.go | 402 ++++ .../x/mongo/driver/operation/createIndexes.go | 278 +++ .../x/mongo/driver/operation/delete.go | 328 +++ .../x/mongo/driver/operation/distinct.go | 311 +++ .../mongo/driver/operation/drop_collection.go | 222 ++ .../x/mongo/driver/operation/drop_database.go | 154 ++ .../x/mongo/driver/operation/drop_indexes.go | 242 +++ .../x/mongo/driver/operation/end_sessions.go | 161 ++ .../x/mongo/driver/operation/errors.go | 13 + .../x/mongo/driver/operation/find.go | 561 +++++ .../mongo/driver/operation/find_and_modify.go | 477 ++++ .../x/mongo/driver/operation/hello.go | 592 +++++ .../x/mongo/driver/operation/insert.go | 306 +++ .../x/mongo/driver/operation/listDatabases.go | 327 +++ .../driver/operation/list_collections.go | 266 +++ .../x/mongo/driver/operation/list_indexes.go | 233 ++ .../x/mongo/driver/operation/update.go | 414 ++++ .../x/mongo/driver/operation_exhaust.go | 37 + .../x/mongo/driver/serverapioptions.go | 36 + .../x/mongo/driver/session/client_session.go | 546 +++++ .../x/mongo/driver/session/cluster_clock.go | 36 + .../x/mongo/driver/session/options.go | 62 + .../x/mongo/driver/session/server_session.go | 74 + .../x/mongo/driver/session/session_pool.go | 192 ++ .../x/mongo/driver/topology/DESIGN.md | 40 + .../driver/topology/cancellation_listener.go | 14 + .../x/mongo/driver/topology/connection.go | 842 ++++++++ .../driver/topology/connection_legacy.go | 7 + .../driver/topology/connection_options.go | 214 ++ .../x/mongo/driver/topology/diff.go | 73 + .../x/mongo/driver/topology/errors.go | 111 + .../x/mongo/driver/topology/fsm.go | 438 ++++ .../x/mongo/driver/topology/pool.go | 1325 ++++++++++++ .../topology/pool_generation_counter.go | 152 ++ .../x/mongo/driver/topology/rtt_monitor.go | 307 +++ .../x/mongo/driver/topology/server.go | 1023 +++++++++ .../x/mongo/driver/topology/server_options.go | 204 ++ .../topology/tls_connection_source_1_16.go | 58 + .../topology/tls_connection_source_1_17.go | 47 + .../x/mongo/driver/topology/topology.go | 856 ++++++++ .../mongo/driver/topology/topology_options.go | 364 ++++ .../x/mongo/driver/wiremessage/wiremessage.go | 600 ++++++ vendor/golang.org/x/xerrors/go.mod | 3 - vendor/modules.txt | 59 + version/version.go | 4 +- x/bsonx/bsoncore/array_test.go | 2 +- x/bsonx/bsoncore/bson_arraybuilder.go | 4 +- x/bsonx/bsoncore/bson_arraybuilder_test.go | 2 +- x/bsonx/bsoncore/bson_documentbuilder.go | 4 +- x/bsonx/bsoncore/bson_documentbuilder_test.go | 2 +- x/bsonx/bsoncore/bsoncore.go | 6 +- x/bsonx/bsoncore/bsoncore_test.go | 6 +- x/bsonx/bsoncore/document.go | 2 +- x/bsonx/bsoncore/document_sequence.go | 2 +- x/bsonx/bsoncore/document_test.go | 2 +- x/bsonx/bsoncore/element.go | 2 +- x/bsonx/bsoncore/element_test.go | 2 +- x/bsonx/bsoncore/value.go | 4 +- x/bsonx/bsoncore/value_test.go | 4 +- x/mongo/driver/auth/auth.go | 10 +- x/mongo/driver/auth/auth_spec_test.go | 6 +- x/mongo/driver/auth/auth_test.go | 8 +- x/mongo/driver/auth/aws_conv.go | 10 +- x/mongo/driver/auth/conversation.go | 2 +- x/mongo/driver/auth/creds/awscreds.go | 6 +- x/mongo/driver/auth/creds/azurecreds.go | 6 +- .../driver/auth/creds/credscaching_test.go | 6 +- x/mongo/driver/auth/creds/gcpcreds.go | 2 +- x/mongo/driver/auth/gssapi.go | 2 +- x/mongo/driver/auth/gssapi_test.go | 4 +- x/mongo/driver/auth/mongodbaws.go | 6 +- x/mongo/driver/auth/mongodbaws_test.go | 2 +- x/mongo/driver/auth/mongodbcr.go | 8 +- x/mongo/driver/auth/mongodbcr_test.go | 8 +- x/mongo/driver/auth/plain_test.go | 10 +- x/mongo/driver/auth/sasl.go | 8 +- x/mongo/driver/auth/scram.go | 2 +- x/mongo/driver/auth/scram_test.go | 8 +- x/mongo/driver/auth/speculative_scram_test.go | 12 +- x/mongo/driver/auth/speculative_x509_test.go | 12 +- x/mongo/driver/auth/x509.go | 6 +- x/mongo/driver/batch_cursor.go | 16 +- x/mongo/driver/batch_cursor_test.go | 2 +- x/mongo/driver/batches.go | 2 +- x/mongo/driver/batches_test.go | 4 +- x/mongo/driver/command_monitoring_test.go | 6 +- x/mongo/driver/compression.go | 2 +- x/mongo/driver/compression_test.go | 4 +- x/mongo/driver/connstring/connstring.go | 10 +- .../driver/connstring/connstring_spec_test.go | 6 +- x/mongo/driver/connstring/connstring_test.go | 6 +- x/mongo/driver/crypt.go | 8 +- x/mongo/driver/dns/dns.go | 2 +- x/mongo/driver/driver.go | 12 +- x/mongo/driver/drivertest/channel_conn.go | 8 +- x/mongo/driver/errors.go | 6 +- x/mongo/driver/integration/aggregate_test.go | 20 +- x/mongo/driver/integration/compressor_test.go | 12 +- x/mongo/driver/integration/insert_test.go | 8 +- x/mongo/driver/integration/main_test.go | 20 +- x/mongo/driver/integration/scram_test.go | 14 +- x/mongo/driver/mongocrypt/mongocrypt.go | 10 +- .../driver/mongocrypt/mongocrypt_context.go | 2 +- .../mongocrypt_context_not_enabled.go | 2 +- .../mongocrypt/mongocrypt_not_enabled.go | 4 +- x/mongo/driver/mongocrypt/mongocrypt_test.go | 8 +- .../options/mongocrypt_context_options.go | 4 +- .../mongocrypt/options/mongocrypt_options.go | 2 +- x/mongo/driver/ocsp/cache_test.go | 2 +- x/mongo/driver/ocsp/config.go | 2 +- x/mongo/driver/ocsp/ocsp_test.go | 4 +- x/mongo/driver/operation.go | 32 +- x/mongo/driver/operation/abort_transaction.go | 14 +- x/mongo/driver/operation/aggregate.go | 20 +- x/mongo/driver/operation/command.go | 16 +- .../driver/operation/commit_transaction.go | 14 +- x/mongo/driver/operation/count.go | 18 +- x/mongo/driver/operation/create.go | 12 +- x/mongo/driver/operation/createIndexes.go | 16 +- x/mongo/driver/operation/delete.go | 18 +- x/mongo/driver/operation/distinct.go | 18 +- x/mongo/driver/operation/drop_collection.go | 14 +- x/mongo/driver/operation/drop_database.go | 14 +- x/mongo/driver/operation/drop_indexes.go | 14 +- x/mongo/driver/operation/end_sessions.go | 12 +- x/mongo/driver/operation/find.go | 20 +- x/mongo/driver/operation/find_and_modify.go | 18 +- x/mongo/driver/operation/hello.go | 18 +- x/mongo/driver/operation/hello_test.go | 10 +- x/mongo/driver/operation/insert.go | 18 +- x/mongo/driver/operation/listDatabases.go | 16 +- x/mongo/driver/operation/list_collections.go | 14 +- x/mongo/driver/operation/list_indexes.go | 12 +- x/mongo/driver/operation/update.go | 20 +- x/mongo/driver/operation_test.go | 32 +- x/mongo/driver/session/client_session.go | 20 +- x/mongo/driver/session/client_session_test.go | 12 +- x/mongo/driver/session/cluster_clock.go | 2 +- x/mongo/driver/session/cluster_clock_test.go | 2 +- x/mongo/driver/session/options.go | 6 +- x/mongo/driver/session/server_session.go | 6 +- x/mongo/driver/session/server_session_test.go | 4 +- x/mongo/driver/session/session_pool.go | 4 +- x/mongo/driver/session/session_pool_test.go | 4 +- x/mongo/driver/testdata/compression.go | 2 +- x/mongo/driver/topology/CMAP_spec_test.go | 10 +- x/mongo/driver/topology/cmap_prose_test.go | 8 +- x/mongo/driver/topology/connection.go | 12 +- .../driver/topology/connection_errors_test.go | 6 +- x/mongo/driver/topology/connection_options.go | 10 +- x/mongo/driver/topology/connection_test.go | 10 +- x/mongo/driver/topology/diff.go | 2 +- x/mongo/driver/topology/diff_test.go | 4 +- x/mongo/driver/topology/errors.go | 2 +- x/mongo/driver/topology/example_test.go | 2 +- x/mongo/driver/topology/fsm.go | 8 +- x/mongo/driver/topology/fsm_test.go | 4 +- .../topology/polling_srv_records_test.go | 12 +- x/mongo/driver/topology/pool.go | 10 +- .../topology/pool_generation_counter.go | 2 +- x/mongo/driver/topology/pool_test.go | 6 +- x/mongo/driver/topology/rtt_monitor.go | 4 +- x/mongo/driver/topology/rtt_monitor_test.go | 14 +- x/mongo/driver/topology/sdam_spec_test.go | 20 +- x/mongo/driver/topology/server.go | 14 +- x/mongo/driver/topology/server_options.go | 12 +- x/mongo/driver/topology/server_rtt_test.go | 4 +- x/mongo/driver/topology/server_test.go | 24 +- x/mongo/driver/topology/topology.go | 20 +- .../driver/topology/topology_errors_test.go | 4 +- x/mongo/driver/topology/topology_options.go | 18 +- .../driver/topology/topology_options_test.go | 4 +- x/mongo/driver/topology/topology_test.go | 18 +- x/mongo/driver/wiremessage/wiremessage.go | 2 +- 748 files changed, 72190 insertions(+), 1875 deletions(-) delete mode 100644 vendor/github.com/golang/snappy/go.mod delete mode 100644 vendor/github.com/klauspost/compress/go.mod delete mode 100644 vendor/github.com/klauspost/compress/go.sum delete mode 100644 vendor/github.com/xdg-go/pbkdf2/go.mod delete mode 100644 vendor/github.com/xdg-go/scram/go.mod delete mode 100644 vendor/github.com/xdg-go/scram/go.sum delete mode 100644 vendor/github.com/xdg-go/stringprep/go.mod delete mode 100644 vendor/github.com/xdg-go/stringprep/go.sum create mode 100644 vendor/go.mongodb.org/mongo-driver/LICENSE create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/bson.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/bson_document.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/bson_map.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/bson_struct.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/bson_types.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/canary.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/harness.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/harness_case.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/harness_main.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/harness_results.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/multi.go create mode 100644 vendor/go.mongodb.org/mongo-driver/benchmark/single.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bson.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/bsoncodec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/cond_addr_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/doc.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/mode.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/proxy.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/slice_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/string_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_tag_parser.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/time_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/types.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/uint_codec.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/byte_slice_codec_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/doc.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/empty_interface_codec_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/map_codec_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/slice_codec_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/string_codec_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/struct_codec_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/time_codec_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonoptions/uint_codec_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/copier.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/doc.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_parser.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_tables.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_wrappers.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/mode.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/reader.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_reader.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_writer.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsonrw/writer.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/bsontype/bsontype.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/decoder.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/doc.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/encoder.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/marshal.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/primitive/objectid.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/primitive/primitive.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/primitive_codecs.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/raw.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/raw_element.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/raw_value.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/registry.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/types.go create mode 100644 vendor/go.mongodb.org/mongo-driver/bson/unmarshal.go create mode 100644 vendor/go.mongodb.org/mongo-driver/event/doc.go create mode 100644 vendor/go.mongodb.org/mongo-driver/event/monitoring.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/assert/assertion_compare.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/assert/assertion_compare_can_convert.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/assert/assertion_compare_legacy.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/assert/assertion_format.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/assert/assertion_mongo.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/assert/assertions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/assert/difflib.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/aws/awserr/error.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/aws/awserr/types.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/aws/credentials/chain_provider.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/aws/credentials/credentials.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/aws/signer/v4/header_rules.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/aws/signer/v4/request.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/aws/signer/v4/uri_path.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/aws/signer/v4/v4.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/aws/types.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/background_context.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/cancellation_listener.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/const.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/credproviders/assume_role_provider.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/credproviders/ec2_provider.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/credproviders/ecs_provider.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/credproviders/env_provider.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/credproviders/imds_provider.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/credproviders/static_provider.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/csfle_util.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/csot_util.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/error.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/http.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/logger/component.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/logger/io_sink.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/logger/level.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/logger/logger.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/randutil/rand/bits.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/randutil/rand/exp.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/randutil/rand/normal.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/randutil/rand/rand.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/randutil/rand/rng.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/randutil/randutil.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/require/require.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/string_util.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/testutil/config.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/testutil/ops.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/uri_validation_errors.go create mode 100644 vendor/go.mongodb.org/mongo-driver/internal/uuid/uuid.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/address/addr.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/batch_cursor.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/bulk_write.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/bulk_write_models.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/change_stream.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/change_stream_deployment.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/client.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/client_encryption.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/collection.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/crypt_retrievers.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/cursor.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/database.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/description/description.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/description/server.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/description/server_kind.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/description/server_selector.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/description/topology.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/description/topology_kind.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/description/topology_version.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/description/version_range.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/doc.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/errors.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/index_options_builder.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/index_view.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/mongo.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/mongocryptd.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/aggregateoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/autoencryptionoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/bulkwriteoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/changestreamoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/clientencryptionoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/collectionoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/countoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/createcollectionoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/datakeyoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/dboptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/deleteoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/distinctoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/doc.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/encryptoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/estimatedcountoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/findoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/gridfsoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/indexoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/insertoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/listcollectionsoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/listdatabasesoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/loggeroptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/mongooptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/replaceoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/rewrapdatakeyoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/runcmdoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/serverapioptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/sessionoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/transactionoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/options/updateoptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/readconcern/readconcern.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/readpref/mode.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/readpref/options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/readpref/readpref.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/results.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/session.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/single_result.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/util.go create mode 100644 vendor/go.mongodb.org/mongo-driver/mongo/writeconcern/writeconcern.go create mode 100644 vendor/go.mongodb.org/mongo-driver/tag/tag.go create mode 100644 vendor/go.mongodb.org/mongo-driver/version/version.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/array.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bson_arraybuilder.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bson_documentbuilder.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/doc.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/document.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/document_sequence.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/element.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/tables.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/value.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/DESIGN.md create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/auth.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/aws_conv.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/conversation.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/cred.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/creds/awscreds.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/creds/azurecreds.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/creds/gcpcreds.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/default.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/doc.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/gssapi.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/gssapi_not_enabled.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/gssapi_not_supported.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/gss.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/gss_wrapper.c create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/gss_wrapper.h create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/sspi.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/sspi_wrapper.c create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/sspi_wrapper.h create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/mongodbaws.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/mongodbcr.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/plain.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/sasl.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/scram.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/util.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/x509.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/batch_cursor.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/batches.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/compression.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/connstring/connstring.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/crypt.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/dns/dns.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/driver.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/errors.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/legacy.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/list_collections_batch_cursor.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/binary.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/errors.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/errors_not_enabled.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt_context.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt_context_not_enabled.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt_kms_context.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt_kms_context_not_enabled.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/mongocrypt_not_enabled.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options/mongocrypt_context_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options/mongocrypt_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/state.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/cache.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/config.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/ocsp.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/ocsp/options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/abort_transaction.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/aggregate.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/command.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/commit_transaction.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/count.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/create.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/createIndexes.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/delete.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/distinct.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/drop_collection.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/drop_database.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/drop_indexes.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/end_sessions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/errors.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/find.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/find_and_modify.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/hello.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/insert.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/listDatabases.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/list_collections.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/list_indexes.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/update.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation_exhaust.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/serverapioptions.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/session/client_session.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/session/cluster_clock.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/session/options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/session/server_session.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/session/session_pool.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/DESIGN.md create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/cancellation_listener.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection_legacy.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/diff.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/errors.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/fsm.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool_generation_counter.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/rtt_monitor.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/server_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/tls_connection_source_1_16.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/tls_connection_source_1_17.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology_options.go create mode 100644 vendor/go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage/wiremessage.go delete mode 100644 vendor/golang.org/x/xerrors/go.mod diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 6e71fd660f..f36e114a64 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1923,15 +1923,13 @@ tasks: MONGO_GO_DRIVER_COMPRESSOR: "snappy" # Build with the oldest supported version of Go. - - name: go1.13-build + - name: go1.18-build tags: ["compile-check"] commands: - func: run-make vars: - # We only test building the compilecheck submodule with Go 1.13 because the root module's - # go.mod file contains retract directives, which are not supported until Go 1.16. targets: "build-compile-check" - BUILD_ENV: "PATH=/opt/golang/go1.13/bin:$PATH GOROOT=/opt/golang/go1.13" + BUILD_ENV: "PATH=/opt/golang/go1.18/bin:$PATH GOROOT=/opt/golang/go1.18" # Build with the same Go version that we're using for tests. - name: build diff --git a/README.md b/README.md index 1e5746a23f..f9923f7c36 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@
@@ -22,17 +22,17 @@ The MongoDB supported driver for Go. ## Installation The recommended way to get started using the MongoDB Go driver is by using Go modules to install the dependency in -your project. This can be done either by importing packages from `go.mongodb.org/mongo-driver` and having the build +your project. This can be done either by importing packages from `go.mongodb.org/mongo-driver/v2` and having the build step install the dependency or by explicitly running ```bash -go get go.mongodb.org/mongo-driver/mongo +go get go.mongodb.org/mongo-driver/v2/mongo ``` When using a version of Go that does not support modules, the driver can be installed using `dep` by running ```bash -dep ensure -add "go.mongodb.org/mongo-driver/mongo" +dep ensure -add "go.mongodb.org/mongo-driver/v2/mongo" ``` ------------------------- @@ -45,9 +45,9 @@ import ( "context" "time" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) @@ -65,7 +65,7 @@ defer func() { }() ``` -For more advanced configuration and authentication, see the [documentation for mongo.Connect](https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Connect). +For more advanced configuration and authentication, see the [documentation for mongo.Connect](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo#Connect). Calling `Connect` does not block for server discovery. If you wish to know if a MongoDB server has been found and connected to, use the `Ping` method: @@ -91,7 +91,7 @@ res, err := collection.InsertOne(ctx, bson.D{{"name", "pi"}, {"value", 3.14159}} id := res.InsertedID ``` -To use `bson.D`, you will need to add `"go.mongodb.org/mongo-driver/bson"` to your imports. +To use `bson.D`, you will need to add `"go.mongodb.org/mongo-driver/v2/bson"` to your imports. Your import statement should now look like this: @@ -101,10 +101,10 @@ import ( "log" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) ``` diff --git a/benchmark/bson.go b/benchmark/bson.go index 2992fb3fad..2e1dc45a73 100644 --- a/benchmark/bson.go +++ b/benchmark/bson.go @@ -11,7 +11,7 @@ import ( "io/ioutil" "path/filepath" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) const ( diff --git a/benchmark/bson_document.go b/benchmark/bson_document.go index da25714e22..b531e59eab 100644 --- a/benchmark/bson_document.go +++ b/benchmark/bson_document.go @@ -10,7 +10,7 @@ import ( "context" "errors" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) func bsonDocumentEncoding(tm TimerManager, iters int, source string) error { diff --git a/benchmark/bson_map.go b/benchmark/bson_map.go index 8fd56ee81e..4b5b423749 100644 --- a/benchmark/bson_map.go +++ b/benchmark/bson_map.go @@ -11,7 +11,7 @@ import ( "errors" "fmt" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) func bsonMapDecoding(tm TimerManager, iters int, dataSet string) error { diff --git a/benchmark/bson_struct.go b/benchmark/bson_struct.go index 3fec93cc2c..5143f43609 100644 --- a/benchmark/bson_struct.go +++ b/benchmark/bson_struct.go @@ -10,7 +10,7 @@ import ( "context" "errors" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) func BSONFlatStructDecoding(_ context.Context, tm TimerManager, iters int) error { diff --git a/benchmark/bson_types.go b/benchmark/bson_types.go index 9d46cbcb03..fa6fe2b8f7 100644 --- a/benchmark/bson_types.go +++ b/benchmark/bson_types.go @@ -6,7 +6,7 @@ package benchmark -import "go.mongodb.org/mongo-driver/bson/primitive" +import "go.mongodb.org/mongo-driver/v2/bson/primitive" type flatBSONTags struct { ID primitive.ObjectID `bson:"_id"` diff --git a/benchmark/harness.go b/benchmark/harness.go index 0c93879a86..bbbf95f53c 100644 --- a/benchmark/harness.go +++ b/benchmark/harness.go @@ -4,14 +4,14 @@ // 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 -package benchmark // import "go.mongodb.org/mongo-driver/benchmark" +package benchmark // import "go.mongodb.org/mongo-driver/v2/benchmark" import ( "context" "testing" "time" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/require" ) const ( diff --git a/benchmark/multi.go b/benchmark/multi.go index b16023ffec..94409da698 100644 --- a/benchmark/multi.go +++ b/benchmark/multi.go @@ -10,7 +10,7 @@ import ( "context" "errors" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) func MultiFindMany(ctx context.Context, tm TimerManager, iters int) error { diff --git a/benchmark/operation_test.go b/benchmark/operation_test.go index 80f20ddc75..9b271a55a9 100644 --- a/benchmark/operation_test.go +++ b/benchmark/operation_test.go @@ -10,9 +10,9 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) var teststrings = []string{ diff --git a/benchmark/single.go b/benchmark/single.go index b85b46f34f..84284f4677 100644 --- a/benchmark/single.go +++ b/benchmark/single.go @@ -10,11 +10,11 @@ import ( "context" "errors" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/handshake" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/handshake" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) const ( diff --git a/bson/bson.go b/bson/bson.go index a0d8185826..d5aa85c13d 100644 --- a/bson/bson.go +++ b/bson/bson.go @@ -7,10 +7,10 @@ // Based on gopkg.in/mgo.v2/bson by Gustavo Niemeyer // See THIRD-PARTY-NOTICES for original license terms. -package bson // import "go.mongodb.org/mongo-driver/bson" +package bson // import "go.mongodb.org/mongo-driver/v2/bson" import ( - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // Zeroer allows custom struct types to implement a report of zero diff --git a/bson/bson_corpus_spec_test.go b/bson/bson_corpus_spec_test.go index 8a27b06272..424609d953 100644 --- a/bson/bson_corpus_spec_test.go +++ b/bson/bson_corpus_spec_test.go @@ -22,9 +22,9 @@ import ( "unicode/utf8" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" ) type testCase struct { diff --git a/bson/bson_test.go b/bson/bson_test.go index e2c1bf9e8b..6139ca86d1 100644 --- a/bson/bson_test.go +++ b/bson/bson_test.go @@ -16,11 +16,11 @@ import ( "time" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func noerr(t *testing.T, err error) { diff --git a/bson/bsoncodec/array_codec.go b/bson/bsoncodec/array_codec.go index 6ca8d9ad6c..f9f3ff8494 100644 --- a/bson/bsoncodec/array_codec.go +++ b/bson/bsoncodec/array_codec.go @@ -9,8 +9,8 @@ package bsoncodec import ( "reflect" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // ArrayCodec is the Codec used for bsoncore.Array values. diff --git a/bson/bsoncodec/bsoncodec.go b/bson/bsoncodec/bsoncodec.go index 0693bd432f..ca13f00c01 100644 --- a/bson/bsoncodec/bsoncodec.go +++ b/bson/bsoncodec/bsoncodec.go @@ -4,16 +4,16 @@ // 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 -package bsoncodec // import "go.mongodb.org/mongo-driver/bson/bsoncodec" +package bsoncodec // import "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" import ( "fmt" "reflect" "strings" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) var ( diff --git a/bson/bsoncodec/bsoncodec_test.go b/bson/bsoncodec/bsoncodec_test.go index 2051b08539..2be96eca8d 100644 --- a/bson/bsoncodec/bsoncodec_test.go +++ b/bson/bsoncodec/bsoncodec_test.go @@ -12,9 +12,9 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) func ExampleValueEncoder() { diff --git a/bson/bsoncodec/byte_slice_codec.go b/bson/bsoncodec/byte_slice_codec.go index dde3e76815..1da3d555da 100644 --- a/bson/bsoncodec/byte_slice_codec.go +++ b/bson/bsoncodec/byte_slice_codec.go @@ -10,9 +10,9 @@ import ( "fmt" "reflect" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) // ByteSliceCodec is the Codec used for []byte values. diff --git a/bson/bsoncodec/cond_addr_codec.go b/bson/bsoncodec/cond_addr_codec.go index cb8180f25c..16a96121c9 100644 --- a/bson/bsoncodec/cond_addr_codec.go +++ b/bson/bsoncodec/cond_addr_codec.go @@ -9,7 +9,7 @@ package bsoncodec import ( "reflect" - "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" ) // condAddrEncoder is the encoder used when a pointer to the encoding value has an encoder. diff --git a/bson/bsoncodec/cond_addr_codec_test.go b/bson/bsoncodec/cond_addr_codec_test.go index 4d308f9172..049d6c1aef 100644 --- a/bson/bsoncodec/cond_addr_codec_test.go +++ b/bson/bsoncodec/cond_addr_codec_test.go @@ -10,9 +10,9 @@ import ( "reflect" "testing" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw/bsonrwtest" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestCondAddrCodec(t *testing.T) { diff --git a/bson/bsoncodec/default_value_decoders.go b/bson/bsoncodec/default_value_decoders.go index e479c3585b..f4993eb5fa 100644 --- a/bson/bsoncodec/default_value_decoders.go +++ b/bson/bsoncodec/default_value_decoders.go @@ -16,10 +16,10 @@ import ( "strconv" "time" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var ( diff --git a/bson/bsoncodec/default_value_decoders_test.go b/bson/bsoncodec/default_value_decoders_test.go index bac92e04f8..e3c09cb026 100644 --- a/bson/bsoncodec/default_value_decoders_test.go +++ b/bson/bsoncodec/default_value_decoders_test.go @@ -19,12 +19,12 @@ import ( "time" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw/bsonrwtest" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var ( diff --git a/bson/bsoncodec/default_value_encoders.go b/bson/bsoncodec/default_value_encoders.go index 4ab14a668c..784ccfd20f 100644 --- a/bson/bsoncodec/default_value_encoders.go +++ b/bson/bsoncodec/default_value_encoders.go @@ -16,10 +16,10 @@ import ( "sync" "time" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var defaultValueEncoders DefaultValueEncoders diff --git a/bson/bsoncodec/default_value_encoders_test.go b/bson/bsoncodec/default_value_encoders_test.go index 0cb35a1ae2..c456b98df3 100644 --- a/bson/bsoncodec/default_value_encoders_test.go +++ b/bson/bsoncodec/default_value_encoders_test.go @@ -18,11 +18,11 @@ import ( "time" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw/bsonrwtest" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) type myInterface interface { diff --git a/bson/bsoncodec/empty_interface_codec.go b/bson/bsoncodec/empty_interface_codec.go index 94f7dcf1eb..8dd27cc8a3 100644 --- a/bson/bsoncodec/empty_interface_codec.go +++ b/bson/bsoncodec/empty_interface_codec.go @@ -9,10 +9,10 @@ package bsoncodec import ( "reflect" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // EmptyInterfaceCodec is the Codec used for interface{} values. diff --git a/bson/bsoncodec/map_codec.go b/bson/bsoncodec/map_codec.go index 325c1738ab..c820ea1f15 100644 --- a/bson/bsoncodec/map_codec.go +++ b/bson/bsoncodec/map_codec.go @@ -12,9 +12,9 @@ import ( "reflect" "strconv" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) var defaultMapCodec = NewMapCodec() diff --git a/bson/bsoncodec/pointer_codec.go b/bson/bsoncodec/pointer_codec.go index e5923230b0..6e445a7604 100644 --- a/bson/bsoncodec/pointer_codec.go +++ b/bson/bsoncodec/pointer_codec.go @@ -9,8 +9,8 @@ package bsoncodec import ( "reflect" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) var _ ValueEncoder = &PointerCodec{} diff --git a/bson/bsoncodec/registry.go b/bson/bsoncodec/registry.go index f309ee2b39..b698e8de6b 100644 --- a/bson/bsoncodec/registry.go +++ b/bson/bsoncodec/registry.go @@ -12,7 +12,7 @@ import ( "reflect" "sync" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) // ErrNilType is returned when nil is passed to either LookupEncoder or LookupDecoder. diff --git a/bson/bsoncodec/registry_examples_test.go b/bson/bsoncodec/registry_examples_test.go index 9dc72bd503..4b44ddbc2a 100644 --- a/bson/bsoncodec/registry_examples_test.go +++ b/bson/bsoncodec/registry_examples_test.go @@ -11,10 +11,10 @@ import ( "math" "reflect" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) func ExampleRegistry_customEncoder() { diff --git a/bson/bsoncodec/registry_test.go b/bson/bsoncodec/registry_test.go index d09f32be5e..bfee222853 100644 --- a/bson/bsoncodec/registry_test.go +++ b/bson/bsoncodec/registry_test.go @@ -11,9 +11,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestRegistryBuilder(t *testing.T) { diff --git a/bson/bsoncodec/slice_codec.go b/bson/bsoncodec/slice_codec.go index a43daf005f..465ecd6ec6 100644 --- a/bson/bsoncodec/slice_codec.go +++ b/bson/bsoncodec/slice_codec.go @@ -10,10 +10,10 @@ import ( "fmt" "reflect" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) var defaultSliceCodec = NewSliceCodec() diff --git a/bson/bsoncodec/string_codec.go b/bson/bsoncodec/string_codec.go index ff931b7253..56d663483e 100644 --- a/bson/bsoncodec/string_codec.go +++ b/bson/bsoncodec/string_codec.go @@ -10,9 +10,9 @@ import ( "fmt" "reflect" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) // StringCodec is the Codec used for string values. diff --git a/bson/bsoncodec/string_codec_test.go b/bson/bsoncodec/string_codec_test.go index 4e544f4727..76921a8df2 100644 --- a/bson/bsoncodec/string_codec_test.go +++ b/bson/bsoncodec/string_codec_test.go @@ -10,11 +10,11 @@ import ( "reflect" "testing" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw/bsonrwtest" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestStringCodec(t *testing.T) { diff --git a/bson/bsoncodec/struct_codec.go b/bson/bsoncodec/struct_codec.go index 4cde0a4d6b..d9a8f98c77 100644 --- a/bson/bsoncodec/struct_codec.go +++ b/bson/bsoncodec/struct_codec.go @@ -15,9 +15,9 @@ import ( "sync" "time" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) // DecodeError represents an error that occurs when unmarshalling BSON bytes into a native Go type. diff --git a/bson/bsoncodec/struct_codec_test.go b/bson/bsoncodec/struct_codec_test.go index 573b374b14..2517782782 100644 --- a/bson/bsoncodec/struct_codec_test.go +++ b/bson/bsoncodec/struct_codec_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) var _ Zeroer = zeroer{} diff --git a/bson/bsoncodec/time_codec.go b/bson/bsoncodec/time_codec.go index 7b005a9958..81c26c2262 100644 --- a/bson/bsoncodec/time_codec.go +++ b/bson/bsoncodec/time_codec.go @@ -11,10 +11,10 @@ import ( "reflect" "time" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) const ( diff --git a/bson/bsoncodec/time_codec_test.go b/bson/bsoncodec/time_codec_test.go index 3bb9f51ea7..b675d9ab14 100644 --- a/bson/bsoncodec/time_codec_test.go +++ b/bson/bsoncodec/time_codec_test.go @@ -11,11 +11,11 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw/bsonrwtest" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestTimeCodec(t *testing.T) { diff --git a/bson/bsoncodec/types.go b/bson/bsoncodec/types.go index 6ade17b7d3..8caf1c4798 100644 --- a/bson/bsoncodec/types.go +++ b/bson/bsoncodec/types.go @@ -12,8 +12,8 @@ import ( "reflect" "time" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var tBool = reflect.TypeOf(false) diff --git a/bson/bsoncodec/uint_codec.go b/bson/bsoncodec/uint_codec.go index 7eb1069050..b0f5eb01d8 100644 --- a/bson/bsoncodec/uint_codec.go +++ b/bson/bsoncodec/uint_codec.go @@ -11,9 +11,9 @@ import ( "math" "reflect" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) // UIntCodec is the Codec used for uint values. diff --git a/bson/bsonrw/bsonrwtest/bsonrwtest.go b/bson/bsonrw/bsonrwtest/bsonrwtest.go index b28cd7f23b..7d9f848d50 100644 --- a/bson/bsonrw/bsonrwtest/bsonrwtest.go +++ b/bson/bsonrw/bsonrwtest/bsonrwtest.go @@ -5,15 +5,15 @@ // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 // Package bsonrwtest provides utilities for testing the "bson/bsonrw" package. -package bsonrwtest // import "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest" +package bsonrwtest // import "go.mongodb.org/mongo-driver/v2/bson/bsonrw/bsonrwtest" import ( "testing" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var _ bsonrw.ValueReader = (*ValueReaderWriter)(nil) diff --git a/bson/bsonrw/copier.go b/bson/bsonrw/copier.go index c146d02e58..2e33917028 100644 --- a/bson/bsonrw/copier.go +++ b/bson/bsonrw/copier.go @@ -10,9 +10,9 @@ import ( "fmt" "io" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // Copier is a type that allows copying between ValueReaders, ValueWriters, and diff --git a/bson/bsonrw/copier_test.go b/bson/bsonrw/copier_test.go index c57235cb56..e35e9ea233 100644 --- a/bson/bsonrw/copier_test.go +++ b/bson/bsonrw/copier_test.go @@ -12,9 +12,9 @@ import ( "fmt" "testing" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestCopier(t *testing.T) { diff --git a/bson/bsonrw/doc.go b/bson/bsonrw/doc.go index 750b0d2af5..795ab10977 100644 --- a/bson/bsonrw/doc.go +++ b/bson/bsonrw/doc.go @@ -6,4 +6,4 @@ // Package bsonrw contains abstractions for reading and writing // BSON and BSON like types from sources. -package bsonrw // import "go.mongodb.org/mongo-driver/bson/bsonrw" +package bsonrw // import "go.mongodb.org/mongo-driver/v2/bson/bsonrw" diff --git a/bson/bsonrw/extjson_parser.go b/bson/bsonrw/extjson_parser.go index 54c76bf746..da63101dec 100644 --- a/bson/bsonrw/extjson_parser.go +++ b/bson/bsonrw/extjson_parser.go @@ -14,7 +14,7 @@ import ( "io" "strings" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) const maxNestingDepth = 200 diff --git a/bson/bsonrw/extjson_parser_test.go b/bson/bsonrw/extjson_parser_test.go index 6808b14174..79d6edd4bf 100644 --- a/bson/bsonrw/extjson_parser_test.go +++ b/bson/bsonrw/extjson_parser_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) var ( diff --git a/bson/bsonrw/extjson_reader.go b/bson/bsonrw/extjson_reader.go index 2aca37a91f..c5805bf3eb 100644 --- a/bson/bsonrw/extjson_reader.go +++ b/bson/bsonrw/extjson_reader.go @@ -11,8 +11,8 @@ import ( "io" "sync" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // ExtJSONValueReaderPool is a pool for ValueReaders that read ExtJSON. diff --git a/bson/bsonrw/extjson_reader_test.go b/bson/bsonrw/extjson_reader_test.go index 8a9f0cc24d..fbe0071128 100644 --- a/bson/bsonrw/extjson_reader_test.go +++ b/bson/bsonrw/extjson_reader_test.go @@ -13,7 +13,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) func TestExtJSONReader(t *testing.T) { diff --git a/bson/bsonrw/extjson_wrappers.go b/bson/bsonrw/extjson_wrappers.go index 9695704246..8e1868eff3 100644 --- a/bson/bsonrw/extjson_wrappers.go +++ b/bson/bsonrw/extjson_wrappers.go @@ -14,8 +14,8 @@ import ( "strconv" "time" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) func wrapperKeyBSONType(key string) bsontype.Type { diff --git a/bson/bsonrw/extjson_writer.go b/bson/bsonrw/extjson_writer.go index bb9303167c..a9a3fdb2fc 100644 --- a/bson/bsonrw/extjson_writer.go +++ b/bson/bsonrw/extjson_writer.go @@ -19,7 +19,7 @@ import ( "time" "unicode/utf8" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // ExtJSONValueWriterPool is a pool for ExtJSON ValueWriters. diff --git a/bson/bsonrw/extjson_writer_test.go b/bson/bsonrw/extjson_writer_test.go index 43c339f362..d8b1c0fdff 100644 --- a/bson/bsonrw/extjson_writer_test.go +++ b/bson/bsonrw/extjson_writer_test.go @@ -13,8 +13,8 @@ import ( "strings" "testing" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) func TestExtJSONValueWriter(t *testing.T) { diff --git a/bson/bsonrw/reader.go b/bson/bsonrw/reader.go index 324b10b616..7aa14f9c1b 100644 --- a/bson/bsonrw/reader.go +++ b/bson/bsonrw/reader.go @@ -7,8 +7,8 @@ package bsonrw import ( - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // ArrayReader is implemented by types that allow reading values from a BSON diff --git a/bson/bsonrw/value_reader.go b/bson/bsonrw/value_reader.go index a242bb57cf..69a2bf560e 100644 --- a/bson/bsonrw/value_reader.go +++ b/bson/bsonrw/value_reader.go @@ -15,8 +15,8 @@ import ( "math" "sync" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) var _ ValueReader = (*valueReader)(nil) diff --git a/bson/bsonrw/value_reader_test.go b/bson/bsonrw/value_reader_test.go index 1716eb54c4..ea3e69ef4a 100644 --- a/bson/bsonrw/value_reader_test.go +++ b/bson/bsonrw/value_reader_test.go @@ -14,9 +14,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestValueReader(t *testing.T) { diff --git a/bson/bsonrw/value_reader_writer_test.go b/bson/bsonrw/value_reader_writer_test.go index 0f5d3a53dd..0696308b36 100644 --- a/bson/bsonrw/value_reader_writer_test.go +++ b/bson/bsonrw/value_reader_writer_test.go @@ -9,9 +9,9 @@ package bsonrw import ( "testing" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) type VRWInvoked byte diff --git a/bson/bsonrw/value_writer.go b/bson/bsonrw/value_writer.go index 311518a80d..084973bfc6 100644 --- a/bson/bsonrw/value_writer.go +++ b/bson/bsonrw/value_writer.go @@ -15,9 +15,9 @@ import ( "strings" "sync" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var _ ValueWriter = (*valueWriter)(nil) diff --git a/bson/bsonrw/value_writer_test.go b/bson/bsonrw/value_writer_test.go index 100cd267e0..33322525be 100644 --- a/bson/bsonrw/value_writer_test.go +++ b/bson/bsonrw/value_writer_test.go @@ -16,9 +16,9 @@ import ( "strings" "testing" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestNewBSONValueWriter(t *testing.T) { diff --git a/bson/bsonrw/writer.go b/bson/bsonrw/writer.go index 628f452932..fb91d3e9b8 100644 --- a/bson/bsonrw/writer.go +++ b/bson/bsonrw/writer.go @@ -7,8 +7,8 @@ package bsonrw import ( - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // ArrayWriter is the interface used to create a BSON or BSON adjacent array. diff --git a/bson/bsontype/bsontype.go b/bson/bsontype/bsontype.go index 255d9909e3..cc65c94ddd 100644 --- a/bson/bsontype/bsontype.go +++ b/bson/bsontype/bsontype.go @@ -6,7 +6,7 @@ // Package bsontype is a utility package that contains types for each BSON type and the // a stringifier for the Type to enable easier debugging when working with BSON. -package bsontype // import "go.mongodb.org/mongo-driver/bson/bsontype" +package bsontype // import "go.mongodb.org/mongo-driver/v2/bson/bsontype" // BSON element types as described in https://bsonspec.org/spec.html. // diff --git a/bson/decoder.go b/bson/decoder.go index eac74cd399..a8837f9282 100644 --- a/bson/decoder.go +++ b/bson/decoder.go @@ -12,8 +12,8 @@ import ( "reflect" "sync" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" ) // ErrDecodeToNil is the error returned when trying to decode to a nil value diff --git a/bson/decoder_example_test.go b/bson/decoder_example_test.go index a59d995972..b51e317b12 100644 --- a/bson/decoder_example_test.go +++ b/bson/decoder_example_test.go @@ -11,8 +11,8 @@ import ( "fmt" "io" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" ) func ExampleDecoder() { diff --git a/bson/decoder_test.go b/bson/decoder_test.go index c91f4e0491..107524b725 100644 --- a/bson/decoder_test.go +++ b/bson/decoder_test.go @@ -14,13 +14,13 @@ import ( "time" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw/bsonrwtest" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestBasicDecode(t *testing.T) { diff --git a/bson/encoder.go b/bson/encoder.go index 0be2a97fbc..e635971d27 100644 --- a/bson/encoder.go +++ b/bson/encoder.go @@ -11,8 +11,8 @@ import ( "reflect" "sync" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" ) // This pool is used to keep the allocations of Encoders down. This is only used for the Marshal* diff --git a/bson/encoder_example_test.go b/bson/encoder_example_test.go index 054c6497ec..4b5c926d8c 100644 --- a/bson/encoder_example_test.go +++ b/bson/encoder_example_test.go @@ -11,8 +11,8 @@ import ( "fmt" "io" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" ) func ExampleEncoder() { diff --git a/bson/encoder_test.go b/bson/encoder_test.go index 9458b8d06e..4d62b08f1d 100644 --- a/bson/encoder_test.go +++ b/bson/encoder_test.go @@ -12,13 +12,13 @@ import ( "reflect" "testing" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw/bsonrwtest" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestBasicEncode(t *testing.T) { diff --git a/bson/example_test.go b/bson/example_test.go index a534de9cf9..5b5a429701 100644 --- a/bson/example_test.go +++ b/bson/example_test.go @@ -10,7 +10,7 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // This example uses Raw to skip parsing a nested document in a BSON message. diff --git a/bson/extjson_prose_test.go b/bson/extjson_prose_test.go index 704cc82894..309105cf8f 100644 --- a/bson/extjson_prose_test.go +++ b/bson/extjson_prose_test.go @@ -10,8 +10,8 @@ import ( "fmt" "testing" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestExtJSON(t *testing.T) { diff --git a/bson/marshal.go b/bson/marshal.go index 17ce6697e0..6682c52bcd 100644 --- a/bson/marshal.go +++ b/bson/marshal.go @@ -11,9 +11,9 @@ import ( "encoding/json" "sync" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) const defaultDstCap = 256 diff --git a/bson/marshal_test.go b/bson/marshal_test.go index 54b27dfcf1..9d4bee00ec 100644 --- a/bson/marshal_test.go +++ b/bson/marshal_test.go @@ -15,12 +15,12 @@ import ( "time" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var tInt32 = reflect.TypeOf(int32(0)) diff --git a/bson/marshal_value_cases_test.go b/bson/marshal_value_cases_test.go index a889cc5845..2727cfcba0 100644 --- a/bson/marshal_value_cases_test.go +++ b/bson/marshal_value_cases_test.go @@ -10,10 +10,10 @@ import ( "io" "testing" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // helper type for testing MarshalValue that implements io.Reader diff --git a/bson/marshal_value_test.go b/bson/marshal_value_test.go index cfc273f0de..692b0e70c2 100644 --- a/bson/marshal_value_test.go +++ b/bson/marshal_value_test.go @@ -10,9 +10,9 @@ import ( "strings" "testing" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestMarshalValue(t *testing.T) { diff --git a/bson/marshaling_cases_test.go b/bson/marshaling_cases_test.go index 4ed95d6759..6e9ee3bc37 100644 --- a/bson/marshaling_cases_test.go +++ b/bson/marshaling_cases_test.go @@ -7,7 +7,7 @@ package bson import ( - "go.mongodb.org/mongo-driver/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" ) type marshalingTestCase struct { diff --git a/bson/mgocompat/bson_test.go b/bson/mgocompat/bson_test.go index 9b4495dcc3..5e4836e249 100644 --- a/bson/mgocompat/bson_test.go +++ b/bson/mgocompat/bson_test.go @@ -20,12 +20,12 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) // Wrap up the document elements contained in data, prepending the int32 diff --git a/bson/mgocompat/registry.go b/bson/mgocompat/registry.go index fc051f466d..5c2ee85fb0 100644 --- a/bson/mgocompat/registry.go +++ b/bson/mgocompat/registry.go @@ -11,10 +11,10 @@ import ( "reflect" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonoptions" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonoptions" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) var ( diff --git a/bson/mgocompat/setter_getter.go b/bson/mgocompat/setter_getter.go index e9c9cae834..a7ea912d0f 100644 --- a/bson/mgocompat/setter_getter.go +++ b/bson/mgocompat/setter_getter.go @@ -10,9 +10,9 @@ import ( "errors" "reflect" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" ) // Setter interface: a value implementing the bson.Setter interface will receive the BSON diff --git a/bson/primitive/decimal_test.go b/bson/primitive/decimal_test.go index e67e11265b..deef88f031 100644 --- a/bson/primitive/decimal_test.go +++ b/bson/primitive/decimal_test.go @@ -12,8 +12,8 @@ import ( "math/big" "testing" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" ) type bigIntTestCase struct { diff --git a/bson/primitive/objectid_test.go b/bson/primitive/objectid_test.go index 36f64a2b9a..8d58a4570a 100644 --- a/bson/primitive/objectid_test.go +++ b/bson/primitive/objectid_test.go @@ -14,8 +14,8 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" ) func TestString(t *testing.T) { diff --git a/bson/primitive/primitive.go b/bson/primitive/primitive.go index 65f4fbb949..1d06d0e8e6 100644 --- a/bson/primitive/primitive.go +++ b/bson/primitive/primitive.go @@ -6,7 +6,7 @@ // Package primitive contains types similar to Go primitives for BSON types that do not have direct // Go primitive representations. -package primitive // import "go.mongodb.org/mongo-driver/bson/primitive" +package primitive // import "go.mongodb.org/mongo-driver/v2/bson/primitive" import ( "bytes" diff --git a/bson/primitive/primitive_test.go b/bson/primitive/primitive_test.go index 821d651ae4..76dc4e2722 100644 --- a/bson/primitive/primitive_test.go +++ b/bson/primitive/primitive_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" ) // The same interface as bsoncodec.Zeroer implemented for tests. diff --git a/bson/primitive_codecs.go b/bson/primitive_codecs.go index ff32a87a79..5978b2302d 100644 --- a/bson/primitive_codecs.go +++ b/bson/primitive_codecs.go @@ -11,8 +11,8 @@ import ( "fmt" "reflect" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" ) var tRawValue = reflect.TypeOf(RawValue{}) diff --git a/bson/primitive_codecs_test.go b/bson/primitive_codecs_test.go index 466f135e83..7be8e1b58a 100644 --- a/bson/primitive_codecs_test.go +++ b/bson/primitive_codecs_test.go @@ -17,12 +17,12 @@ import ( "time" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw/bsonrwtest" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func bytesFromDoc(doc interface{}) []byte { diff --git a/bson/raw.go b/bson/raw.go index fe990a1771..a11b3306d6 100644 --- a/bson/raw.go +++ b/bson/raw.go @@ -10,7 +10,7 @@ import ( "errors" "io" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // ErrNilReader indicates that an operation was attempted on a nil bson.Reader. diff --git a/bson/raw_element.go b/bson/raw_element.go index 8ce13c2cc7..75a00350e3 100644 --- a/bson/raw_element.go +++ b/bson/raw_element.go @@ -7,7 +7,7 @@ package bson import ( - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // RawElement is a raw encoded BSON document or array element. diff --git a/bson/raw_test.go b/bson/raw_test.go index 02c9f63136..2d056b423a 100644 --- a/bson/raw_test.go +++ b/bson/raw_test.go @@ -15,9 +15,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func ExampleRaw_Validate() { diff --git a/bson/raw_value.go b/bson/raw_value.go index 4d1bfb3160..0f96517649 100644 --- a/bson/raw_value.go +++ b/bson/raw_value.go @@ -13,11 +13,11 @@ import ( "reflect" "time" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // ErrNilContext is returned when the provided DecodeContext is nil. diff --git a/bson/raw_value_test.go b/bson/raw_value_test.go index 87f08c4a55..45d95d46da 100644 --- a/bson/raw_value_test.go +++ b/bson/raw_value_test.go @@ -11,10 +11,10 @@ import ( "reflect" "testing" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestRawValue(t *testing.T) { diff --git a/bson/registry.go b/bson/registry.go index b5b0f35687..0fcbf9b839 100644 --- a/bson/registry.go +++ b/bson/registry.go @@ -7,7 +7,7 @@ package bson import ( - "go.mongodb.org/mongo-driver/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" ) // DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the diff --git a/bson/truncation_test.go b/bson/truncation_test.go index c8ba759a33..9e3d061b12 100644 --- a/bson/truncation_test.go +++ b/bson/truncation_test.go @@ -9,8 +9,8 @@ package bson import ( "testing" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) type inputArgs struct { diff --git a/bson/types.go b/bson/types.go index ef39812467..c611a3072b 100644 --- a/bson/types.go +++ b/bson/types.go @@ -7,7 +7,7 @@ package bson import ( - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) // BSON element types as described in https://bsonspec.org/spec.html. diff --git a/bson/unmarshal.go b/bson/unmarshal.go index 66da17ee01..f2ec490833 100644 --- a/bson/unmarshal.go +++ b/bson/unmarshal.go @@ -9,9 +9,9 @@ package bson import ( "bytes" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) // Unmarshaler is the interface implemented by types that can unmarshal a BSON diff --git a/bson/unmarshal_test.go b/bson/unmarshal_test.go index 11452a895c..5c77bc6d1c 100644 --- a/bson/unmarshal_test.go +++ b/bson/unmarshal_test.go @@ -11,11 +11,11 @@ import ( "reflect" "testing" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestUnmarshal(t *testing.T) { diff --git a/bson/unmarshal_value_test.go b/bson/unmarshal_value_test.go index ef91da1659..b85af945a8 100644 --- a/bson/unmarshal_value_test.go +++ b/bson/unmarshal_value_test.go @@ -11,10 +11,10 @@ import ( "strings" "testing" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestUnmarshalValue(t *testing.T) { diff --git a/bson/unmarshaling_cases_test.go b/bson/unmarshaling_cases_test.go index 37d9ded318..c50085e6e9 100644 --- a/bson/unmarshaling_cases_test.go +++ b/bson/unmarshaling_cases_test.go @@ -9,8 +9,8 @@ package bson import ( "reflect" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) type unmarshalingTestCase struct { diff --git a/cmd/build-oss-fuzz-corpus/main.go b/cmd/build-oss-fuzz-corpus/main.go index 4dc014b5aa..547103c805 100644 --- a/cmd/build-oss-fuzz-corpus/main.go +++ b/cmd/build-oss-fuzz-corpus/main.go @@ -19,7 +19,7 @@ import ( "path" "path/filepath" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) const dataDir = "testdata/bson-corpus/" diff --git a/cmd/testatlas/main.go b/cmd/testatlas/main.go index fa50d7cde7..8cdf2c0a02 100644 --- a/cmd/testatlas/main.go +++ b/cmd/testatlas/main.go @@ -12,10 +12,10 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/handshake" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/handshake" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func main() { diff --git a/cmd/testaws/main.go b/cmd/testaws/main.go index dc767e5add..0d305feb6a 100644 --- a/cmd/testaws/main.go +++ b/cmd/testaws/main.go @@ -11,9 +11,9 @@ import ( "fmt" "os" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func main() { diff --git a/cmd/testentauth/main.go b/cmd/testentauth/main.go index 9bcea33294..a7851c2ee7 100644 --- a/cmd/testentauth/main.go +++ b/cmd/testentauth/main.go @@ -12,9 +12,9 @@ import ( "os" "time" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/connstring" ) func main() { diff --git a/cmd/testkms/main.go b/cmd/testkms/main.go index af86eca523..86831308aa 100644 --- a/cmd/testkms/main.go +++ b/cmd/testkms/main.go @@ -12,10 +12,10 @@ import ( "os" "strings" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) var datakeyopts = map[string]primitive.M{ diff --git a/docs/common-issues.md b/docs/common-issues.md index 0dc3c6ae56..904f2073dc 100644 --- a/docs/common-issues.md +++ b/docs/common-issues.md @@ -4,7 +4,7 @@ These are fixes or information for common issues encountered by Go Driver users. ## `WriteXXX` can only write while positioned on a Element or Value but is positioned on a TopLevel -The [`bson.Marshal`](https://pkg.go.dev/go.mongodb.org/mongo-driver/bson#Marshal) function requires a parameter that can be decoded into a BSON Document, i.e. a [`primitive.D`](https://github.com/mongodb/mongo-go-driver/blob/master/bson/bson.go#L31). Therefore the error message +The [`bson.Marshal`](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson#Marshal) function requires a parameter that can be decoded into a BSON Document, i.e. a [`primitive.D`](https://github.com/mongodb/mongo-go-driver/v2/blob/master/bson/bson.go#L31). Therefore the error message > `WriteXXX` can only write while positioned on a Element or Value but is positioned on a TopLevel @@ -14,7 +14,7 @@ occurs when the input to `bson.Marshal` is something *other* than a BSON Documen - `WriteNull`: the input into `bson.Marshal` is null - `WriteInt32`: the input into `bson.Marshal` is an integer -Many CRUD operations in the Go Driver use `bson.Marshal` under the hood, so it's possible to encounter this particular error without directly attempting to encode data. For example, when using a sort on [`FindOneAndUpdate`](https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Collection.FindOneAndUpdate) this error can occur when not properly initializing the `sort` variable: +Many CRUD operations in the Go Driver use `bson.Marshal` under the hood, so it's possible to encounter this particular error without directly attempting to encode data. For example, when using a sort on [`FindOneAndUpdate`](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo#Collection.FindOneAndUpdate) this error can occur when not properly initializing the `sort` variable: ```go var sort bson.D // this is nil and will result in a WriteNull error @@ -34,7 +34,7 @@ sort := bson.D{} ## Convert BSON Document to JSON -There are a variety of marshalers that can be used to encode a BSON document as JSON, including [MarshalExtJSON](https://pkg.go.dev/github.com/mongodb/mongo-go-driver/bson#MarshalExtJSON): +There are a variety of marshalers that can be used to encode a BSON document as JSON, including [MarshalExtJSON](https://pkg.go.dev/github.com/mongodb/mongo-go-driver/v2/bson#MarshalExtJSON): ```go doc := bson.D{{"x", 1}} @@ -62,4 +62,4 @@ That error can be caused by a number of issues. The error message intentionally - Incorrect username. - Incorrect authentication database (i.e. [authSource](https://www.mongodb.com/docs/manual/reference/connection-string/#mongodb-urioption-urioption.authSource)). -If you encounter an `AuthenticationFailed` error like the one above, check that the username and password in your [connection string](https://www.mongodb.com/docs/manual/reference/connection-string/) or [SetAuth](https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo/options#ClientOptions.SetAuth) call are correct. In most cases, [authSource](https://www.mongodb.com/docs/manual/reference/connection-string/#mongodb-urioption-urioption.authSource) does not need to be specified unless you are using a non-default authentication database (the default is "admin"). +If you encounter an `AuthenticationFailed` error like the one above, check that the username and password in your [connection string](https://www.mongodb.com/docs/manual/reference/connection-string/) or [SetAuth](https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo/options#ClientOptions.SetAuth) call are correct. In most cases, [authSource](https://www.mongodb.com/docs/manual/reference/connection-string/#mongodb-urioption-urioption.authSource) does not need to be specified unless you are using a non-default authentication database (the default is "admin"). diff --git a/event/examples_test.go b/event/examples_test.go index 5041006568..e387a94e39 100644 --- a/event/examples_test.go +++ b/event/examples_test.go @@ -10,10 +10,10 @@ import ( "context" "log" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // Event examples diff --git a/event/monitoring.go b/event/monitoring.go index 53d1caf2e3..4c6878e188 100644 --- a/event/monitoring.go +++ b/event/monitoring.go @@ -4,16 +4,16 @@ // 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 -package event // import "go.mongodb.org/mongo-driver/event" +package event // import "go.mongodb.org/mongo-driver/v2/event" import ( "context" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo/address" - "go.mongodb.org/mongo-driver/mongo/description" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo/address" + "go.mongodb.org/mongo-driver/v2/mongo/description" ) // CommandStartedEvent represents an event generated when a command is sent to a server. diff --git a/examples/_example_customdns_test.go b/examples/_example_customdns_test.go index 7b378550c6..eeb0682250 100644 --- a/examples/_example_customdns_test.go +++ b/examples/_example_customdns_test.go @@ -15,9 +15,9 @@ import ( "time" "github.com/miekg/dns" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func resolve(ctx context.Context, cache *dnsCache, in *dns.Conn, out *dns.Conn) { diff --git a/examples/_logger/logrus/main.go b/examples/_logger/logrus/main.go index c75d72ccc2..8153a99dc5 100644 --- a/examples/_logger/logrus/main.go +++ b/examples/_logger/logrus/main.go @@ -14,9 +14,9 @@ import ( "github.com/bombsimon/logrusr/v4" "github.com/sirupsen/logrus" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func main() { diff --git a/examples/_logger/zap/main.go b/examples/_logger/zap/main.go index ff061413f4..5e0589c46f 100644 --- a/examples/_logger/zap/main.go +++ b/examples/_logger/zap/main.go @@ -13,9 +13,9 @@ import ( "log" "github.com/go-logr/zapr" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" "go.uber.org/zap" ) diff --git a/examples/_logger/zerolog/main.go b/examples/_logger/zerolog/main.go index 58efe415b1..408949b988 100644 --- a/examples/_logger/zerolog/main.go +++ b/examples/_logger/zerolog/main.go @@ -15,9 +15,9 @@ import ( "github.com/go-logr/zerologr" "github.com/rs/zerolog" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func main() { diff --git a/examples/documentation_examples/examples.go b/examples/documentation_examples/examples.go index b188448a02..4240a76937 100644 --- a/examples/documentation_examples/examples.go +++ b/examples/documentation_examples/examples.go @@ -16,15 +16,15 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) func requireCursorLength(t *testing.T, cursor *mongo.Cursor, length int) { diff --git a/examples/documentation_examples/examples_test.go b/examples/documentation_examples/examples_test.go index 563146b9dc..90f7880f95 100644 --- a/examples/documentation_examples/examples_test.go +++ b/examples/documentation_examples/examples_test.go @@ -14,11 +14,11 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/examples/documentation_examples" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/examples/documentation_examples" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestMain(m *testing.M) { diff --git a/go.mod b/go.mod index db41f350c3..f0774ca6b1 100644 --- a/go.mod +++ b/go.mod @@ -1,20 +1,6 @@ -module go.mongodb.org/mongo-driver +module go.mongodb.org/mongo-driver/v2 -go 1.13 - -retract ( - v1.11.8 // Contains minor changes meant for v1.12.1. - v1.11.5 // Contains import failure. - - // Retract v1.11.0 through v1.11.2 because they contain a data race bug in - // operation memory pooling that may cause undefined behavior when reading - // raw BSON responses in error documents. Resolved by GODRIVER-2677. - [v1.11.0, v1.11.2] - - v1.10.0 // Contains a possible data corruption bug in RewrapManyDataKey when using libmongocrypt versions less than 1.5.2. - [v1.7.0, v1.7.1] // Contains data race bug in background connection establishment. - [v1.6.0, v1.6.1] // Contains data race bug in background connection establishment. -) +go 1.18 require ( github.com/davecgh/go-spew v1.1.1 @@ -25,7 +11,13 @@ require ( github.com/xdg-go/scram v1.1.2 github.com/xdg-go/stringprep v1.0.4 github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d + go.mongodb.org/mongo-driver v1.12.1 golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 +) + +require ( + github.com/xdg-go/pbkdf2 v1.0.0 // indirect golang.org/x/text v0.7.0 // indirect + golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect ) diff --git a/go.sum b/go.sum index 9d99279a16..9a8e1a0670 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= +go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= diff --git a/internal/assert/assertion_compare_go1.17_test.go b/internal/assert/assertion_compare_go1.17_test.go index 4953ca3820..49ce4599ee 100644 --- a/internal/assert/assertion_compare_go1.17_test.go +++ b/internal/assert/assertion_compare_go1.17_test.go @@ -86,7 +86,7 @@ func TestGreater17(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, Greater(out, currCase.less, currCase.greater)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.Greater") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.Greater") } } @@ -117,7 +117,7 @@ func TestGreaterOrEqual17(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, GreaterOrEqual(out, currCase.less, currCase.greater)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.GreaterOrEqual") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.GreaterOrEqual") } } @@ -148,7 +148,7 @@ func TestLess17(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, Less(out, currCase.greater, currCase.less)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.Less") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.Less") } } @@ -179,6 +179,6 @@ func TestLessOrEqual17(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, LessOrEqual(out, currCase.greater, currCase.less)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.LessOrEqual") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.LessOrEqual") } } diff --git a/internal/assert/assertion_compare_test.go b/internal/assert/assertion_compare_test.go index ef8862ee67..36acdd87f4 100644 --- a/internal/assert/assertion_compare_test.go +++ b/internal/assert/assertion_compare_test.go @@ -158,7 +158,7 @@ func TestGreater(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, Greater(out, currCase.less, currCase.greater)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.Greater") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.Greater") } } @@ -199,7 +199,7 @@ func TestGreaterOrEqual(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, GreaterOrEqual(out, currCase.less, currCase.greater)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.GreaterOrEqual") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.GreaterOrEqual") } } @@ -240,7 +240,7 @@ func TestLess(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, Less(out, currCase.greater, currCase.less)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.Less") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.Less") } } @@ -281,7 +281,7 @@ func TestLessOrEqual(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, LessOrEqual(out, currCase.greater, currCase.less)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.LessOrEqual") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.LessOrEqual") } } @@ -320,7 +320,7 @@ func TestPositive(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, Positive(out, currCase.e)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.Positive") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.Positive") } } @@ -359,7 +359,7 @@ func TestNegative(t *testing.T) { out := &outputT{buf: bytes.NewBuffer(nil)} False(t, Negative(out, currCase.e)) Contains(t, out.buf.String(), currCase.msg) - Contains(t, out.helpers, "go.mongodb.org/mongo-driver/internal/assert.Negative") + Contains(t, out.helpers, "go.mongodb.org/mongo-driver/v2/internal/assert.Negative") } } diff --git a/internal/assert/assertion_mongo_test.go b/internal/assert/assertion_mongo_test.go index 3f16af10ec..9fe6f485d5 100644 --- a/internal/assert/assertion_mongo_test.go +++ b/internal/assert/assertion_mongo_test.go @@ -9,7 +9,7 @@ package assert import ( "testing" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) func TestDifferentAddressRanges(t *testing.T) { diff --git a/internal/aws/credentials/chain_provider.go b/internal/aws/credentials/chain_provider.go index 6843927153..942c7690fa 100644 --- a/internal/aws/credentials/chain_provider.go +++ b/internal/aws/credentials/chain_provider.go @@ -11,7 +11,7 @@ package credentials import ( - "go.mongodb.org/mongo-driver/internal/aws/awserr" + "go.mongodb.org/mongo-driver/v2/internal/aws/awserr" ) // A ChainProvider will search for a provider which returns credentials diff --git a/internal/aws/credentials/chain_provider_test.go b/internal/aws/credentials/chain_provider_test.go index 2e731338fb..3680b78105 100644 --- a/internal/aws/credentials/chain_provider_test.go +++ b/internal/aws/credentials/chain_provider_test.go @@ -14,7 +14,7 @@ import ( "reflect" "testing" - "go.mongodb.org/mongo-driver/internal/aws/awserr" + "go.mongodb.org/mongo-driver/v2/internal/aws/awserr" ) type secondStubProvider struct { diff --git a/internal/aws/credentials/credentials.go b/internal/aws/credentials/credentials.go index 53181aa163..919d0819b1 100644 --- a/internal/aws/credentials/credentials.go +++ b/internal/aws/credentials/credentials.go @@ -15,7 +15,7 @@ import ( "sync" "time" - "go.mongodb.org/mongo-driver/internal/aws/awserr" + "go.mongodb.org/mongo-driver/v2/internal/aws/awserr" "golang.org/x/sync/singleflight" ) diff --git a/internal/aws/credentials/credentials_test.go b/internal/aws/credentials/credentials_test.go index d964ea419f..e10848c7ac 100644 --- a/internal/aws/credentials/credentials_test.go +++ b/internal/aws/credentials/credentials_test.go @@ -16,7 +16,7 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/aws/awserr" + "go.mongodb.org/mongo-driver/v2/internal/aws/awserr" ) func isExpired(c *Credentials) bool { diff --git a/internal/aws/signer/v4/v4.go b/internal/aws/signer/v4/v4.go index 6cf4586bb9..eaf5cca3ee 100644 --- a/internal/aws/signer/v4/v4.go +++ b/internal/aws/signer/v4/v4.go @@ -23,8 +23,8 @@ import ( "strings" "time" - "go.mongodb.org/mongo-driver/internal/aws" - "go.mongodb.org/mongo-driver/internal/aws/credentials" + "go.mongodb.org/mongo-driver/v2/internal/aws" + "go.mongodb.org/mongo-driver/v2/internal/aws/credentials" ) const ( diff --git a/internal/aws/signer/v4/v4_test.go b/internal/aws/signer/v4/v4_test.go index a71fe300c7..2767755efe 100644 --- a/internal/aws/signer/v4/v4_test.go +++ b/internal/aws/signer/v4/v4_test.go @@ -22,9 +22,9 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/aws" - "go.mongodb.org/mongo-driver/internal/aws/credentials" - "go.mongodb.org/mongo-driver/internal/credproviders" + "go.mongodb.org/mongo-driver/v2/internal/aws" + "go.mongodb.org/mongo-driver/v2/internal/aws/credentials" + "go.mongodb.org/mongo-driver/v2/internal/credproviders" ) func epochTime() time.Time { return time.Unix(0, 0) } diff --git a/internal/bsonutil/bsonutil.go b/internal/bsonutil/bsonutil.go index eebb328906..86c0fd0b78 100644 --- a/internal/bsonutil/bsonutil.go +++ b/internal/bsonutil/bsonutil.go @@ -9,7 +9,7 @@ package bsonutil import ( "fmt" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // StringSliceFromRawValue decodes the provided BSON value into a []string. This function returns an error if the value diff --git a/internal/codecutil/encoding.go b/internal/codecutil/encoding.go index 2aaf8f2719..5fa031efb9 100644 --- a/internal/codecutil/encoding.go +++ b/internal/codecutil/encoding.go @@ -13,8 +13,8 @@ import ( "io" "reflect" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var ErrNilValue = errors.New("value is nil") diff --git a/internal/codecutil/encoding_test.go b/internal/codecutil/encoding_test.go index 9696048f71..e1045c20a7 100644 --- a/internal/codecutil/encoding_test.go +++ b/internal/codecutil/encoding_test.go @@ -10,11 +10,11 @@ import ( "io" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" ) func testEncFn(t *testing.T) EncoderFn { diff --git a/internal/credproviders/assume_role_provider.go b/internal/credproviders/assume_role_provider.go index 3a95cf401d..eec2247c70 100644 --- a/internal/credproviders/assume_role_provider.go +++ b/internal/credproviders/assume_role_provider.go @@ -15,8 +15,8 @@ import ( "net/http" "time" - "go.mongodb.org/mongo-driver/internal/aws/credentials" - "go.mongodb.org/mongo-driver/internal/uuid" + "go.mongodb.org/mongo-driver/v2/internal/aws/credentials" + "go.mongodb.org/mongo-driver/v2/internal/uuid" ) const ( diff --git a/internal/credproviders/ec2_provider.go b/internal/credproviders/ec2_provider.go index 771bfca134..df15a7f2c3 100644 --- a/internal/credproviders/ec2_provider.go +++ b/internal/credproviders/ec2_provider.go @@ -15,7 +15,7 @@ import ( "net/http" "time" - "go.mongodb.org/mongo-driver/internal/aws/credentials" + "go.mongodb.org/mongo-driver/v2/internal/aws/credentials" ) const ( diff --git a/internal/credproviders/ecs_provider.go b/internal/credproviders/ecs_provider.go index 0c3a27e626..6816a3182d 100644 --- a/internal/credproviders/ecs_provider.go +++ b/internal/credproviders/ecs_provider.go @@ -14,7 +14,7 @@ import ( "net/http" "time" - "go.mongodb.org/mongo-driver/internal/aws/credentials" + "go.mongodb.org/mongo-driver/v2/internal/aws/credentials" ) const ( diff --git a/internal/credproviders/env_provider.go b/internal/credproviders/env_provider.go index 59ca633635..cf6bb60b31 100644 --- a/internal/credproviders/env_provider.go +++ b/internal/credproviders/env_provider.go @@ -9,7 +9,7 @@ package credproviders import ( "os" - "go.mongodb.org/mongo-driver/internal/aws/credentials" + "go.mongodb.org/mongo-driver/v2/internal/aws/credentials" ) // envProviderName provides a name of Env provider diff --git a/internal/credproviders/imds_provider.go b/internal/credproviders/imds_provider.go index 96dad1a829..f3674c727b 100644 --- a/internal/credproviders/imds_provider.go +++ b/internal/credproviders/imds_provider.go @@ -15,7 +15,7 @@ import ( "net/url" "time" - "go.mongodb.org/mongo-driver/internal/aws/credentials" + "go.mongodb.org/mongo-driver/v2/internal/aws/credentials" ) const ( diff --git a/internal/credproviders/static_provider.go b/internal/credproviders/static_provider.go index 6b49613941..bbb0e8033a 100644 --- a/internal/credproviders/static_provider.go +++ b/internal/credproviders/static_provider.go @@ -9,7 +9,7 @@ package credproviders import ( "errors" - "go.mongodb.org/mongo-driver/internal/aws/credentials" + "go.mongodb.org/mongo-driver/v2/internal/aws/credentials" ) // staticProviderName provides a name of Static provider diff --git a/internal/csfle/csfle.go b/internal/csfle/csfle.go index 71e71b4687..708b2cfde6 100644 --- a/internal/csfle/csfle.go +++ b/internal/csfle/csfle.go @@ -9,7 +9,7 @@ package csfle import ( "fmt" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) const ( diff --git a/internal/integtest/integtest.go b/internal/integtest/integtest.go index d89bcd7539..38264f9e9d 100644 --- a/internal/integtest/integtest.go +++ b/internal/integtest/integtest.go @@ -18,15 +18,15 @@ import ( "sync" "testing" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" - "go.mongodb.org/mongo-driver/x/mongo/driver/operation" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/connstring" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) var connectionString connstring.ConnString diff --git a/internal/logger/component.go b/internal/logger/component.go index 0a3d553208..5cb1f91715 100644 --- a/internal/logger/component.go +++ b/internal/logger/component.go @@ -10,7 +10,7 @@ import ( "os" "strconv" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) const ( diff --git a/internal/logger/component_test.go b/internal/logger/component_test.go index cf752d2ad7..3bbb9ba3bd 100644 --- a/internal/logger/component_test.go +++ b/internal/logger/component_test.go @@ -9,8 +9,8 @@ package logger import ( "testing" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func verifySerialization(t *testing.T, got, want KeyValues) { diff --git a/internal/logger/context_test.go b/internal/logger/context_test.go index 9fee41552d..b8238ea9cb 100644 --- a/internal/logger/context_test.go +++ b/internal/logger/context_test.go @@ -10,8 +10,8 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/logger" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/logger" ) func TestContext_WithOperationName(t *testing.T) { diff --git a/internal/logger/logger_test.go b/internal/logger/logger_test.go index 8629a10748..b71ac06204 100644 --- a/internal/logger/logger_test.go +++ b/internal/logger/logger_test.go @@ -15,7 +15,7 @@ import ( "sync" "testing" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) type mockLogSink struct{} diff --git a/internal/ptrutil/int64_test.go b/internal/ptrutil/int64_test.go index 6a267484d8..b7b8605101 100644 --- a/internal/ptrutil/int64_test.go +++ b/internal/ptrutil/int64_test.go @@ -9,7 +9,7 @@ package ptrutil import ( "testing" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestCompareInt64(t *testing.T) { diff --git a/internal/rand/example_test.go b/internal/rand/example_test.go index 1bf04da8bb..81fab024dd 100644 --- a/internal/rand/example_test.go +++ b/internal/rand/example_test.go @@ -12,7 +12,7 @@ import ( "strings" "text/tabwriter" - "go.mongodb.org/mongo-driver/internal/rand" + "go.mongodb.org/mongo-driver/v2/internal/rand" ) // These tests serve as an example but also make sure we don't change diff --git a/internal/rand/regress_test.go b/internal/rand/regress_test.go index 023c02962c..c9413a2a1e 100644 --- a/internal/rand/regress_test.go +++ b/internal/rand/regress_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - . "go.mongodb.org/mongo-driver/internal/rand" + . "go.mongodb.org/mongo-driver/v2/internal/rand" ) var printgolden = flag.Bool("printgolden", false, "print golden results for regression test") diff --git a/internal/randutil/randutil.go b/internal/randutil/randutil.go index dd8c6d6f41..a11bf5ea6d 100644 --- a/internal/randutil/randutil.go +++ b/internal/randutil/randutil.go @@ -12,7 +12,7 @@ import ( "fmt" "io" - xrand "go.mongodb.org/mongo-driver/internal/rand" + xrand "go.mongodb.org/mongo-driver/v2/internal/rand" ) // NewLockedRand returns a new "x/exp/rand" pseudo-random number generator seeded with a diff --git a/internal/randutil/randutil_test.go b/internal/randutil/randutil_test.go index ca49ac6dde..08eff7e990 100644 --- a/internal/randutil/randutil_test.go +++ b/internal/randutil/randutil_test.go @@ -9,7 +9,7 @@ package randutil import ( "testing" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/require" ) func TestCryptoSeed(t *testing.T) { diff --git a/internal/require/require.go b/internal/require/require.go index 901c3818ee..1e27460a83 100644 --- a/internal/require/require.go +++ b/internal/require/require.go @@ -9,7 +9,7 @@ package require import ( time "time" - assert "go.mongodb.org/mongo-driver/internal/assert" + assert "go.mongodb.org/mongo-driver/v2/internal/assert" ) // TestingT is an interface wrapper around *testing.T diff --git a/internal/spectest/spectest.go b/internal/spectest/spectest.go index 276fc35572..363b072c2c 100644 --- a/internal/spectest/spectest.go +++ b/internal/spectest/spectest.go @@ -11,7 +11,7 @@ import ( "path" "testing" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/require" ) // FindJSONFilesInDir finds the JSON files in a directory. diff --git a/internal/test/compilecheck/main.go b/internal/test/compilecheck/main.go index 1678e64cde..0c0d390f32 100644 --- a/internal/test/compilecheck/main.go +++ b/internal/test/compilecheck/main.go @@ -10,9 +10,9 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func main() { diff --git a/internal/test/faas/awslambda/mongodb/main.go b/internal/test/faas/awslambda/mongodb/main.go index a0c55f9085..4697da71ff 100644 --- a/internal/test/faas/awslambda/mongodb/main.go +++ b/internal/test/faas/awslambda/mongodb/main.go @@ -16,9 +16,9 @@ import ( "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-lambda-go/lambda" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) const timeout = 60 * time.Second diff --git a/internal/uuid/uuid.go b/internal/uuid/uuid.go index 86c2a33a73..be233bb96a 100644 --- a/internal/uuid/uuid.go +++ b/internal/uuid/uuid.go @@ -10,7 +10,7 @@ import ( "encoding/hex" "io" - "go.mongodb.org/mongo-driver/internal/randutil" + "go.mongodb.org/mongo-driver/v2/internal/randutil" ) // UUID represents a UUID. diff --git a/internal/uuid/uuid_test.go b/internal/uuid/uuid_test.go index 0426d07cdd..76ea4d35ce 100644 --- a/internal/uuid/uuid_test.go +++ b/internal/uuid/uuid_test.go @@ -10,8 +10,8 @@ import ( "sync" "testing" - "go.mongodb.org/mongo-driver/internal/israce" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/israce" + "go.mongodb.org/mongo-driver/v2/internal/require" ) // GODRIVER-2349 diff --git a/mongo/address/addr.go b/mongo/address/addr.go index fb6abbcd7c..b3c1a52342 100644 --- a/mongo/address/addr.go +++ b/mongo/address/addr.go @@ -5,7 +5,7 @@ // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 // Package address provides structured representations of network addresses. -package address // import "go.mongodb.org/mongo-driver/mongo/address" +package address // import "go.mongodb.org/mongo-driver/v2/mongo/address" import ( "net" diff --git a/mongo/address/addr_test.go b/mongo/address/addr_test.go index 2242b6d49c..834c976df2 100644 --- a/mongo/address/addr_test.go +++ b/mongo/address/addr_test.go @@ -9,7 +9,7 @@ package address import ( "testing" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/require" ) func TestAddress_String(t *testing.T) { diff --git a/mongo/background_context_test.go b/mongo/background_context_test.go index fe679ed1e8..691411c8fa 100644 --- a/mongo/background_context_test.go +++ b/mongo/background_context_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestBackgroundContext(t *testing.T) { diff --git a/mongo/batch_cursor.go b/mongo/batch_cursor.go index 51d59d0ffa..40d346d91f 100644 --- a/mongo/batch_cursor.go +++ b/mongo/batch_cursor.go @@ -10,8 +10,8 @@ import ( "context" "time" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" ) // batchCursor is the interface implemented by types that can provide batches of document results. diff --git a/mongo/bson_helpers_test.go b/mongo/bson_helpers_test.go index 56dba24f3d..1608de562b 100644 --- a/mongo/bson_helpers_test.go +++ b/mongo/bson_helpers_test.go @@ -9,8 +9,8 @@ package mongo import ( "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) // compare expected and actual BSON documents. comparison succeeds if actual contains each element in expected. diff --git a/mongo/bulk_write.go b/mongo/bulk_write.go index 58e64f1d9a..1acbceb3d8 100644 --- a/mongo/bulk_write.go +++ b/mongo/bulk_write.go @@ -9,15 +9,15 @@ package mongo import ( "context" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/operation" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" ) type bulkWriteBatch struct { diff --git a/mongo/bulk_write_models.go b/mongo/bulk_write_models.go index 64f4589189..0e0cadf082 100644 --- a/mongo/bulk_write_models.go +++ b/mongo/bulk_write_models.go @@ -7,7 +7,7 @@ package mongo import ( - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // WriteModel is an interface implemented by models that can be used in a BulkWrite operation. Each WriteModel diff --git a/mongo/change_stream.go b/mongo/change_stream.go index 773cbb0e5d..cc141e095a 100644 --- a/mongo/change_stream.go +++ b/mongo/change_stream.go @@ -14,18 +14,18 @@ import ( "strconv" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/csot" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/operation" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/csot" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" ) var ( diff --git a/mongo/change_stream_deployment.go b/mongo/change_stream_deployment.go index 4dca59f91c..b410c480c9 100644 --- a/mongo/change_stream_deployment.go +++ b/mongo/change_stream_deployment.go @@ -9,8 +9,8 @@ package mongo import ( "context" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" ) type changeStreamDeployment struct { diff --git a/mongo/change_stream_test.go b/mongo/change_stream_test.go index 31066a8c06..0db5e03381 100644 --- a/mongo/change_stream_test.go +++ b/mongo/change_stream_test.go @@ -9,7 +9,7 @@ package mongo import ( "testing" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestChangeStream(t *testing.T) { diff --git a/mongo/client.go b/mongo/client.go index 5929274831..44a71b698f 100644 --- a/mongo/client.go +++ b/mongo/client.go @@ -13,24 +13,24 @@ import ( "net/http" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/httputil" - "go.mongodb.org/mongo-driver/internal/logger" - "go.mongodb.org/mongo-driver/internal/uuid" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt" - mcopts "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options" - "go.mongodb.org/mongo-driver/x/mongo/driver/operation" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/httputil" + "go.mongodb.org/mongo-driver/v2/internal/logger" + "go.mongodb.org/mongo-driver/v2/internal/uuid" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt" + mcopts "go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/options" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) const ( diff --git a/mongo/client_encryption.go b/mongo/client_encryption.go index 01c2ec3193..7e0154ec67 100644 --- a/mongo/client_encryption.go +++ b/mongo/client_encryption.go @@ -12,14 +12,14 @@ import ( "fmt" "strings" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt" - mcopts "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt" + mcopts "go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/options" ) // ClientEncryption is used to create data keys and explicitly encrypt and decrypt BSON values. diff --git a/mongo/client_examples_test.go b/mongo/client_examples_test.go index 4123e8e0e4..aecd7b4894 100644 --- a/mongo/client_examples_test.go +++ b/mongo/client_examples_test.go @@ -11,10 +11,10 @@ import ( "fmt" "log" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) func ExampleClient() { diff --git a/mongo/client_side_encryption_examples_test.go b/mongo/client_side_encryption_examples_test.go index 2680849013..818d3d1e54 100644 --- a/mongo/client_side_encryption_examples_test.go +++ b/mongo/client_side_encryption_examples_test.go @@ -13,9 +13,9 @@ import ( "fmt" "log" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func Example_clientSideEncryption() { diff --git a/mongo/client_test.go b/mongo/client_test.go index e1e8f322a8..7cc53a5239 100644 --- a/mongo/client_test.go +++ b/mongo/client_test.go @@ -14,17 +14,17 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/tag" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/tag" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) var bgCtx = context.Background() diff --git a/mongo/collection.go b/mongo/collection.go index 6abbea9792..ae9b898400 100644 --- a/mongo/collection.go +++ b/mongo/collection.go @@ -14,20 +14,20 @@ import ( "strings" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/csfle" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/operation" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/csfle" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" ) // Collection is a handle to a MongoDB collection. It is safe for concurrent use by multiple goroutines. diff --git a/mongo/collection_test.go b/mongo/collection_test.go index f17e6dfda7..d1bb5f0dae 100644 --- a/mongo/collection_test.go +++ b/mongo/collection_test.go @@ -10,12 +10,12 @@ import ( "errors" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) const ( diff --git a/mongo/crud_examples_test.go b/mongo/crud_examples_test.go index d657ed6965..0772c23129 100644 --- a/mongo/crud_examples_test.go +++ b/mongo/crud_examples_test.go @@ -13,12 +13,12 @@ import ( "sync" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) // Client examples diff --git a/mongo/crypt_retrievers.go b/mongo/crypt_retrievers.go index 5e96da731a..2354328d1c 100644 --- a/mongo/crypt_retrievers.go +++ b/mongo/crypt_retrievers.go @@ -9,7 +9,7 @@ package mongo import ( "context" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // keyRetriever gets keys from the key vault collection. diff --git a/mongo/cursor.go b/mongo/cursor.go index d2228ed9c4..b6f7d5acec 100644 --- a/mongo/cursor.go +++ b/mongo/cursor.go @@ -14,13 +14,13 @@ import ( "reflect" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" ) // Cursor is used to iterate over a stream of documents. Each document can be decoded into a Go type via the Decode diff --git a/mongo/cursor_test.go b/mongo/cursor_test.go index 3781109019..ac6ed06dbb 100644 --- a/mongo/cursor_test.go +++ b/mongo/cursor_test.go @@ -12,12 +12,12 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" ) type testBatchCursor struct { diff --git a/mongo/database.go b/mongo/database.go index f5d5ad379b..f45334993c 100644 --- a/mongo/database.go +++ b/mongo/database.go @@ -12,18 +12,18 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/internal/csfle" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/operation" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/internal/csfle" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" ) var ( diff --git a/mongo/database_test.go b/mongo/database_test.go index 46e1fc3f19..78172e7e92 100644 --- a/mongo/database_test.go +++ b/mongo/database_test.go @@ -12,14 +12,14 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) func setupDb(name string, opts ...*options.DatabaseOptions) *Database { diff --git a/mongo/description/description.go b/mongo/description/description.go index e750e33b14..a6319ffe47 100644 --- a/mongo/description/description.go +++ b/mongo/description/description.go @@ -5,7 +5,7 @@ // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 // Package description contains types and functions for describing the state of MongoDB clusters. -package description // import "go.mongodb.org/mongo-driver/mongo/description" +package description // import "go.mongodb.org/mongo-driver/v2/mongo/description" // Unknown is an unknown server or topology kind. const Unknown = 0 diff --git a/mongo/description/max_staleness_spec_test.go b/mongo/description/max_staleness_spec_test.go index 0bab617c6a..af4f7f577f 100644 --- a/mongo/description/max_staleness_spec_test.go +++ b/mongo/description/max_staleness_spec_test.go @@ -10,7 +10,7 @@ import ( "path" "testing" - "go.mongodb.org/mongo-driver/internal/spectest" + "go.mongodb.org/mongo-driver/v2/internal/spectest" ) const maxStalenessTestsDir = "../../testdata/max-staleness" diff --git a/mongo/description/selector_spec_test.go b/mongo/description/selector_spec_test.go index f5d2eb3291..0687573914 100644 --- a/mongo/description/selector_spec_test.go +++ b/mongo/description/selector_spec_test.go @@ -10,7 +10,7 @@ import ( "path" "testing" - "go.mongodb.org/mongo-driver/internal/spectest" + "go.mongodb.org/mongo-driver/v2/internal/spectest" ) const selectorTestsDir = "../../testdata/server-selection/server_selection" diff --git a/mongo/description/selector_test.go b/mongo/description/selector_test.go index e83a751b94..14623568fa 100644 --- a/mongo/description/selector_test.go +++ b/mongo/description/selector_test.go @@ -11,11 +11,11 @@ import ( "time" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/address" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/address" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/tag" ) func TestServerSelection(t *testing.T) { diff --git a/mongo/description/server.go b/mongo/description/server.go index cf39423839..776099ca88 100644 --- a/mongo/description/server.go +++ b/mongo/description/server.go @@ -11,13 +11,13 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/internal/handshake" - "go.mongodb.org/mongo-driver/internal/ptrutil" - "go.mongodb.org/mongo-driver/mongo/address" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/internal/handshake" + "go.mongodb.org/mongo-driver/v2/internal/ptrutil" + "go.mongodb.org/mongo-driver/v2/mongo/address" + "go.mongodb.org/mongo-driver/v2/tag" ) // SelectedServer augments the Server type by also including the TopologyKind of the topology that includes the server. diff --git a/mongo/description/server_selector.go b/mongo/description/server_selector.go index aee1f050cb..a2eb29ce82 100644 --- a/mongo/description/server_selector.go +++ b/mongo/description/server_selector.go @@ -12,8 +12,8 @@ import ( "math" "time" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/tag" ) // ServerSelector is an interface implemented by types that can perform server selection given a topology description diff --git a/mongo/description/server_test.go b/mongo/description/server_test.go index 027cd21700..bb5fc653b7 100644 --- a/mongo/description/server_test.go +++ b/mongo/description/server_test.go @@ -11,10 +11,10 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/address" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/address" + "go.mongodb.org/mongo-driver/v2/tag" ) func TestServer(t *testing.T) { diff --git a/mongo/description/shared_spec_test.go b/mongo/description/shared_spec_test.go index f7fb250844..aa60875858 100644 --- a/mongo/description/shared_spec_test.go +++ b/mongo/description/shared_spec_test.go @@ -14,10 +14,10 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/address" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/address" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/tag" ) type testCase struct { diff --git a/mongo/description/topology.go b/mongo/description/topology.go index b082515e53..916c27e935 100644 --- a/mongo/description/topology.go +++ b/mongo/description/topology.go @@ -9,7 +9,7 @@ package description import ( "fmt" - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) // Topology contains information about a MongoDB cluster. diff --git a/mongo/description/topology_version.go b/mongo/description/topology_version.go index e6674ea762..d76f7668cd 100644 --- a/mongo/description/topology_version.go +++ b/mongo/description/topology_version.go @@ -9,8 +9,8 @@ package description import ( "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // TopologyVersion represents a software version. diff --git a/mongo/errors.go b/mongo/errors.go index 72c3bcc243..bede43272f 100644 --- a/mongo/errors.go +++ b/mongo/errors.go @@ -14,11 +14,11 @@ import ( "net" "strings" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/codecutil" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/codecutil" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) // ErrUnacknowledgedWrite is returned by operations that have an unacknowledged write concern. diff --git a/mongo/errors_test.go b/mongo/errors_test.go index fd89c65f5f..eabcab8afb 100644 --- a/mongo/errors_test.go +++ b/mongo/errors_test.go @@ -9,9 +9,9 @@ package mongo import ( "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" ) func TestErrorMessages(t *testing.T) { diff --git a/mongo/gridfs/bucket.go b/mongo/gridfs/bucket.go index c9f40744f2..ad01d563ab 100644 --- a/mongo/gridfs/bucket.go +++ b/mongo/gridfs/bucket.go @@ -4,7 +4,7 @@ // 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 -package gridfs // import "go.mongodb.org/mongo-driver/mongo/gridfs" +package gridfs // import "go.mongodb.org/mongo-driver/v2/mongo/gridfs" import ( "bytes" @@ -14,15 +14,15 @@ import ( "io" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/csot" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/csot" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // TODO: add sessions options diff --git a/mongo/gridfs/download_stream.go b/mongo/gridfs/download_stream.go index 20c8df8a6f..88e3a1d0a7 100644 --- a/mongo/gridfs/download_stream.go +++ b/mongo/gridfs/download_stream.go @@ -13,8 +13,8 @@ import ( "math" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" ) // ErrWrongIndex is used when the chunk retrieved from the server does not have the expected index. diff --git a/mongo/gridfs/gridfs_examples_test.go b/mongo/gridfs/gridfs_examples_test.go index 7203444dd4..365e4c55b3 100644 --- a/mongo/gridfs/gridfs_examples_test.go +++ b/mongo/gridfs/gridfs_examples_test.go @@ -14,10 +14,10 @@ import ( "log" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo/gridfs" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo/gridfs" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func ExampleBucket_OpenUploadStream() { diff --git a/mongo/gridfs/gridfs_test.go b/mongo/gridfs/gridfs_test.go index c95cf1f8d6..6329fdac49 100644 --- a/mongo/gridfs/gridfs_test.go +++ b/mongo/gridfs/gridfs_test.go @@ -10,13 +10,13 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) var ( diff --git a/mongo/gridfs/upload_stream.go b/mongo/gridfs/upload_stream.go index cf1997db80..941d786c55 100644 --- a/mongo/gridfs/upload_stream.go +++ b/mongo/gridfs/upload_stream.go @@ -14,9 +14,9 @@ import ( "math" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo" ) // UploadBufferSize is the size in bytes of one stream batch. Chunks will be written to the db after the sum of chunk diff --git a/mongo/index_options_builder.go b/mongo/index_options_builder.go index d12deaee28..5aad922646 100644 --- a/mongo/index_options_builder.go +++ b/mongo/index_options_builder.go @@ -7,7 +7,7 @@ package mongo import ( - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // IndexOptionsBuilder specifies options for a new index. diff --git a/mongo/index_view.go b/mongo/index_view.go index 41a93a2145..63a49901fc 100644 --- a/mongo/index_view.go +++ b/mongo/index_view.go @@ -13,16 +13,16 @@ import ( "fmt" "strconv" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/operation" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" ) // ErrInvalidIndexValue is returned if an index is created with a keys document that has a value that is not a number diff --git a/mongo/integration/causal_consistency_test.go b/mongo/integration/causal_consistency_test.go index 8c59025399..661a4a9ec8 100644 --- a/mongo/integration/causal_consistency_test.go +++ b/mongo/integration/causal_consistency_test.go @@ -10,13 +10,13 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" ) // set of operations that support read concerns taken from read/write concern spec. diff --git a/mongo/integration/change_stream_test.go b/mongo/integration/change_stream_test.go index 868706ad1e..d9f166f081 100644 --- a/mongo/integration/change_stream_test.go +++ b/mongo/integration/change_stream_test.go @@ -13,15 +13,15 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/eventtest" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/eventtest" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) type resumeType int diff --git a/mongo/integration/clam_prose_test.go b/mongo/integration/clam_prose_test.go index 3b0ad2cde1..204cd34920 100644 --- a/mongo/integration/clam_prose_test.go +++ b/mongo/integration/clam_prose_test.go @@ -12,13 +12,13 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/internal/logger" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/internal/logger" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) var ErrInvalidTruncation = fmt.Errorf("invalid truncation") diff --git a/mongo/integration/client_options_test.go b/mongo/integration/client_options_test.go index 0fb068bc5e..003badc58a 100644 --- a/mongo/integration/client_options_test.go +++ b/mongo/integration/client_options_test.go @@ -12,11 +12,11 @@ import ( "sync/atomic" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestClientOptions_CustomDialer(t *testing.T) { diff --git a/mongo/integration/client_side_encryption_prose_test.go b/mongo/integration/client_side_encryption_prose_test.go index 45a2ef01c8..07d3e1407a 100644 --- a/mongo/integration/client_side_encryption_prose_test.go +++ b/mongo/integration/client_side_encryption_prose_test.go @@ -23,20 +23,20 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/handshake" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt" - mongocryptopts "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/handshake" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt" + mongocryptopts "go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/options" ) var ( diff --git a/mongo/integration/client_side_encryption_test.go b/mongo/integration/client_side_encryption_test.go index 88fe567932..86a40f85b4 100644 --- a/mongo/integration/client_side_encryption_test.go +++ b/mongo/integration/client_side_encryption_test.go @@ -13,18 +13,18 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - mcopts "go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + mcopts "go.mongodb.org/mongo-driver/v2/x/mongo/driver/mongocrypt/options" ) // createDataKeyAndEncrypt creates a data key with the alternate name @keyName. diff --git a/mongo/integration/client_test.go b/mongo/integration/client_test.go index 038ed25d72..5326baafaf 100644 --- a/mongo/integration/client_test.go +++ b/mongo/integration/client_test.go @@ -16,23 +16,23 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/eventtest" - "go.mongodb.org/mongo-driver/internal/handshake" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/eventtest" + "go.mongodb.org/mongo-driver/v2/internal/handshake" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/wiremessage" "golang.org/x/sync/errgroup" ) diff --git a/mongo/integration/cmd_monitoring_helpers_test.go b/mongo/integration/cmd_monitoring_helpers_test.go index 6c4931d26c..919116e75a 100644 --- a/mongo/integration/cmd_monitoring_helpers_test.go +++ b/mongo/integration/cmd_monitoring_helpers_test.go @@ -13,12 +13,12 @@ import ( "fmt" "strings" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // Helper functions to compare BSON values and command monitoring expectations. diff --git a/mongo/integration/collection_test.go b/mongo/integration/collection_test.go index 4e7f24813d..bd3b2a74fa 100644 --- a/mongo/integration/collection_test.go +++ b/mongo/integration/collection_test.go @@ -12,15 +12,15 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) const ( diff --git a/mongo/integration/crud_helpers_test.go b/mongo/integration/crud_helpers_test.go index a60adeb683..eab1c469e8 100644 --- a/mongo/integration/crud_helpers_test.go +++ b/mongo/integration/crud_helpers_test.go @@ -15,19 +15,19 @@ import ( "strings" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/gridfs" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/integration/unified" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/gridfs" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/integration/unified" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) // Helper functions to execute and verify results from CRUD methods. diff --git a/mongo/integration/crud_prose_test.go b/mongo/integration/crud_prose_test.go index 00a1f0ff36..19cb4bc0f2 100644 --- a/mongo/integration/crud_prose_test.go +++ b/mongo/integration/crud_prose_test.go @@ -12,12 +12,12 @@ import ( "errors" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestWriteErrorsWithLabels(t *testing.T) { diff --git a/mongo/integration/crud_spec_test.go b/mongo/integration/crud_spec_test.go index a80a9dd53c..ec24fcc1df 100644 --- a/mongo/integration/crud_spec_test.go +++ b/mongo/integration/crud_spec_test.go @@ -16,11 +16,11 @@ import ( "strings" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" ) const ( diff --git a/mongo/integration/csot_cse_prose_test.go b/mongo/integration/csot_cse_prose_test.go index e3b30f5c3c..121a3418b6 100644 --- a/mongo/integration/csot_cse_prose_test.go +++ b/mongo/integration/csot_cse_prose_test.go @@ -13,13 +13,13 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // CSOT prose tests that require the 'cse' Go build tag. diff --git a/mongo/integration/csot_prose_test.go b/mongo/integration/csot_prose_test.go index 4f9f112b3f..fff65a90d5 100644 --- a/mongo/integration/csot_prose_test.go +++ b/mongo/integration/csot_prose_test.go @@ -12,13 +12,13 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestCSOTProse(t *testing.T) { diff --git a/mongo/integration/cursor_test.go b/mongo/integration/cursor_test.go index 9f57d3a6dd..8d6ed41d6f 100644 --- a/mongo/integration/cursor_test.go +++ b/mongo/integration/cursor_test.go @@ -13,11 +13,11 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) const ( diff --git a/mongo/integration/data_lake_test.go b/mongo/integration/data_lake_test.go index e0add0299e..77596e8778 100644 --- a/mongo/integration/data_lake_test.go +++ b/mongo/integration/data_lake_test.go @@ -11,10 +11,10 @@ import ( "fmt" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestAtlasDataLake(t *testing.T) { diff --git a/mongo/integration/database_test.go b/mongo/integration/database_test.go index 29b75ddc8a..5be7a3c61a 100644 --- a/mongo/integration/database_test.go +++ b/mongo/integration/database_test.go @@ -13,16 +13,16 @@ import ( "reflect" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/handshake" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/handshake" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) const ( diff --git a/mongo/integration/errors_test.go b/mongo/integration/errors_test.go index 89bae83b90..fe7318801e 100644 --- a/mongo/integration/errors_test.go +++ b/mongo/integration/errors_test.go @@ -17,14 +17,14 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) type netErr struct { diff --git a/mongo/integration/gridfs_test.go b/mongo/integration/gridfs_test.go index 509c008d51..cd370fa20c 100644 --- a/mongo/integration/gridfs_test.go +++ b/mongo/integration/gridfs_test.go @@ -15,15 +15,15 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/israce" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/gridfs" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/israce" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/gridfs" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestGridFS(x *testing.T) { diff --git a/mongo/integration/handshake_test.go b/mongo/integration/handshake_test.go index 3e9989158e..7fe2ef329a 100644 --- a/mongo/integration/handshake_test.go +++ b/mongo/integration/handshake_test.go @@ -13,13 +13,13 @@ import ( "runtime" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/handshake" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/version" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/handshake" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/version" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestHandshakeProse(t *testing.T) { diff --git a/mongo/integration/index_view_test.go b/mongo/integration/index_view_test.go index e0cc6e2f87..822975f5d8 100644 --- a/mongo/integration/index_view_test.go +++ b/mongo/integration/index_view_test.go @@ -12,13 +12,13 @@ import ( "time" "github.com/google/go-cmp/cmp" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) type index struct { diff --git a/mongo/integration/initial_dns_seedlist_discovery_test.go b/mongo/integration/initial_dns_seedlist_discovery_test.go index 92a20a721a..16a21973cc 100644 --- a/mongo/integration/initial_dns_seedlist_discovery_test.go +++ b/mongo/integration/initial_dns_seedlist_discovery_test.go @@ -17,15 +17,15 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/connstring" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) const ( diff --git a/mongo/integration/json_helpers_test.go b/mongo/integration/json_helpers_test.go index 749de6a5b1..e9407ff492 100644 --- a/mongo/integration/json_helpers_test.go +++ b/mongo/integration/json_helpers_test.go @@ -17,13 +17,13 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) var ( diff --git a/mongo/integration/load_balancer_prose_test.go b/mongo/integration/load_balancer_prose_test.go index 430e063540..01c41b2cbb 100644 --- a/mongo/integration/load_balancer_prose_test.go +++ b/mongo/integration/load_balancer_prose_test.go @@ -13,12 +13,12 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestLoadBalancerSupport(t *testing.T) { diff --git a/mongo/integration/log_helpers_test.go b/mongo/integration/log_helpers_test.go index 9b31c166de..f82e6ef70d 100644 --- a/mongo/integration/log_helpers_test.go +++ b/mongo/integration/log_helpers_test.go @@ -10,8 +10,8 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/internal/logger" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/internal/logger" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" ) type testLogSink struct { diff --git a/mongo/integration/main.go b/mongo/integration/main.go index 16e89d3263..c8addd2158 100644 --- a/mongo/integration/main.go +++ b/mongo/integration/main.go @@ -9,5 +9,5 @@ package integration // This file exists to allow the build scripts (and standard Go builds for some early Go versions) // to succeed. Without it, the build may encounter an error like: // -// go build go.mongodb.org/mongo-driver/mongo/integration: build constraints exclude all Go files in ./go.mongodb.org/mongo-driver/mongo/integration +// go build go.mongodb.org/mongo-driver/v2/mongo/integration: build constraints exclude all Go files in ./go.mongodb.org/mongo-driver/v2/mongo/integration // diff --git a/mongo/integration/main_test.go b/mongo/integration/main_test.go index 394fd5be6c..169b9eed77 100644 --- a/mongo/integration/main_test.go +++ b/mongo/integration/main_test.go @@ -12,7 +12,7 @@ import ( "os" "testing" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" ) func TestMain(m *testing.M) { diff --git a/mongo/integration/mock_find_test.go b/mongo/integration/mock_find_test.go index ad90c82fba..b4c061583d 100644 --- a/mongo/integration/mock_find_test.go +++ b/mongo/integration/mock_find_test.go @@ -10,12 +10,12 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // finder is an object that implements FindOne and Find. diff --git a/mongo/integration/mongos_pinning_test.go b/mongo/integration/mongos_pinning_test.go index a436ca981c..0c44f9e0d7 100644 --- a/mongo/integration/mongos_pinning_test.go +++ b/mongo/integration/mongos_pinning_test.go @@ -12,11 +12,11 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestMongosPinning(t *testing.T) { diff --git a/mongo/integration/mtest/deployment_helpers.go b/mongo/integration/mtest/deployment_helpers.go index 299fae5672..86833032a5 100644 --- a/mongo/integration/mtest/deployment_helpers.go +++ b/mongo/integration/mtest/deployment_helpers.go @@ -7,7 +7,7 @@ package mtest import ( - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // BatchIdentifier specifies the keyword to identify the batch in a cursor response. diff --git a/mongo/integration/mtest/global_state.go b/mongo/integration/mtest/global_state.go index 4ca4219977..1f27449cd8 100644 --- a/mongo/integration/mtest/global_state.go +++ b/mongo/integration/mtest/global_state.go @@ -10,10 +10,10 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/connstring" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) // AuthEnabled returns whether or not the cluster requires auth. diff --git a/mongo/integration/mtest/mongotest.go b/mongo/integration/mtest/mongotest.go index d5235d228e..fdc7465d17 100644 --- a/mongo/integration/mtest/mongotest.go +++ b/mongo/integration/mtest/mongotest.go @@ -15,17 +15,17 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/csfle" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/csfle" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" ) var ( diff --git a/mongo/integration/mtest/opmsg_deployment.go b/mongo/integration/mtest/opmsg_deployment.go index ae4e359380..93dfaabe7e 100644 --- a/mongo/integration/mtest/opmsg_deployment.go +++ b/mongo/integration/mtest/opmsg_deployment.go @@ -10,14 +10,14 @@ import ( "context" "errors" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/csot" - "go.mongodb.org/mongo-driver/mongo/address" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" - "go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/csot" + "go.mongodb.org/mongo-driver/v2/mongo/address" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/wiremessage" ) const ( diff --git a/mongo/integration/mtest/options.go b/mongo/integration/mtest/options.go index c756c414c5..567a61c6fb 100644 --- a/mongo/integration/mtest/options.go +++ b/mongo/integration/mtest/options.go @@ -10,8 +10,8 @@ import ( "errors" "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // TopologyKind describes the topology that a test is run on. diff --git a/mongo/integration/mtest/proxy_dialer.go b/mongo/integration/mtest/proxy_dialer.go index b50f37488a..888d3005e4 100644 --- a/mongo/integration/mtest/proxy_dialer.go +++ b/mongo/integration/mtest/proxy_dialer.go @@ -14,8 +14,8 @@ import ( "sync" "time" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // ProxyMessage represents a sent/received pair of parsed wire messages. diff --git a/mongo/integration/mtest/received_message.go b/mongo/integration/mtest/received_message.go index 3df507e5a5..c801ed3094 100644 --- a/mongo/integration/mtest/received_message.go +++ b/mongo/integration/mtest/received_message.go @@ -10,8 +10,8 @@ import ( "errors" "fmt" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/wiremessage" ) // ReceivedMessage represents a message received from the server. diff --git a/mongo/integration/mtest/sent_message.go b/mongo/integration/mtest/sent_message.go index 6b96e061bc..81f395425a 100644 --- a/mongo/integration/mtest/sent_message.go +++ b/mongo/integration/mtest/sent_message.go @@ -10,8 +10,8 @@ import ( "errors" "fmt" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/wiremessage" ) // SentMessage represents a message sent by the driver to the server. diff --git a/mongo/integration/mtest/setup.go b/mongo/integration/mtest/setup.go index be2dae93b8..61b314b608 100644 --- a/mongo/integration/mtest/setup.go +++ b/mongo/integration/mtest/setup.go @@ -16,16 +16,16 @@ import ( "strings" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/connstring" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) const ( diff --git a/mongo/integration/mtest/wiremessage_helpers.go b/mongo/integration/mtest/wiremessage_helpers.go index 192271a7f4..fa08b358bc 100644 --- a/mongo/integration/mtest/wiremessage_helpers.go +++ b/mongo/integration/mtest/wiremessage_helpers.go @@ -10,8 +10,8 @@ import ( "errors" "fmt" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/wiremessage" ) func copyBytes(original []byte) []byte { diff --git a/mongo/integration/primary_stepdown_test.go b/mongo/integration/primary_stepdown_test.go index 4a51d83b02..1eb07fb3f3 100644 --- a/mongo/integration/primary_stepdown_test.go +++ b/mongo/integration/primary_stepdown_test.go @@ -10,12 +10,12 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/eventtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/eventtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) const ( diff --git a/mongo/integration/retryable_reads_prose_test.go b/mongo/integration/retryable_reads_prose_test.go index 80f4d3329a..e854f47e27 100644 --- a/mongo/integration/retryable_reads_prose_test.go +++ b/mongo/integration/retryable_reads_prose_test.go @@ -12,13 +12,13 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/eventtest" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/eventtest" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestRetryableReadsProse(t *testing.T) { diff --git a/mongo/integration/retryable_writes_prose_test.go b/mongo/integration/retryable_writes_prose_test.go index 1c8d353f14..3d54d8e59a 100644 --- a/mongo/integration/retryable_writes_prose_test.go +++ b/mongo/integration/retryable_writes_prose_test.go @@ -14,16 +14,16 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/eventtest" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/eventtest" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" ) func TestRetryableWritesProse(t *testing.T) { diff --git a/mongo/integration/retryable_writes_spec_test.go b/mongo/integration/retryable_writes_spec_test.go index c1e104ab80..1f6c310836 100644 --- a/mongo/integration/retryable_writes_spec_test.go +++ b/mongo/integration/retryable_writes_spec_test.go @@ -11,9 +11,9 @@ import ( "path" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" ) const retryableWritesTestDir = "../../testdata/retryable-writes/legacy" diff --git a/mongo/integration/sdam_error_handling_test.go b/mongo/integration/sdam_error_handling_test.go index 58cac9ccdd..dc166512d5 100644 --- a/mongo/integration/sdam_error_handling_test.go +++ b/mongo/integration/sdam_error_handling_test.go @@ -16,12 +16,12 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/eventtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/eventtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestSDAMErrorHandling(t *testing.T) { diff --git a/mongo/integration/sdam_prose_test.go b/mongo/integration/sdam_prose_test.go index 21b1fea4ba..8f83a642e5 100644 --- a/mongo/integration/sdam_prose_test.go +++ b/mongo/integration/sdam_prose_test.go @@ -12,11 +12,11 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/handshake" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/handshake" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestSDAMProse(t *testing.T) { diff --git a/mongo/integration/server_selection_prose_test.go b/mongo/integration/server_selection_prose_test.go index e6486ae123..71d24eff43 100644 --- a/mongo/integration/server_selection_prose_test.go +++ b/mongo/integration/server_selection_prose_test.go @@ -12,14 +12,14 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/eventtest" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/eventtest" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) type saturatedConnections map[uint64]bool diff --git a/mongo/integration/sessions_mongocryptd_prose_test.go b/mongo/integration/sessions_mongocryptd_prose_test.go index fd516445df..0c7b36f610 100644 --- a/mongo/integration/sessions_mongocryptd_prose_test.go +++ b/mongo/integration/sessions_mongocryptd_prose_test.go @@ -15,14 +15,14 @@ import ( "strconv" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) type mongocryptdProcess struct { diff --git a/mongo/integration/sessions_test.go b/mongo/integration/sessions_test.go index dfd3e2d260..f22f1ce940 100644 --- a/mongo/integration/sessions_test.go +++ b/mongo/integration/sessions_test.go @@ -16,15 +16,15 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" "golang.org/x/sync/errgroup" ) diff --git a/mongo/integration/unified/admin_helpers.go b/mongo/integration/unified/admin_helpers.go index f7bcb99146..c41b371af2 100644 --- a/mongo/integration/unified/admin_helpers.go +++ b/mongo/integration/unified/admin_helpers.go @@ -11,11 +11,11 @@ import ( "fmt" "strings" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) var ( diff --git a/mongo/integration/unified/bsonutil.go b/mongo/integration/unified/bsonutil.go index e95af0b7cb..20cfa52de6 100644 --- a/mongo/integration/unified/bsonutil.go +++ b/mongo/integration/unified/bsonutil.go @@ -9,9 +9,9 @@ package unified import ( "sort" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var ( diff --git a/mongo/integration/unified/bucket_options.go b/mongo/integration/unified/bucket_options.go index a738a42aa6..44ac0f3d54 100644 --- a/mongo/integration/unified/bucket_options.go +++ b/mongo/integration/unified/bucket_options.go @@ -9,8 +9,8 @@ package unified import ( "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // gridFSBucketOptions is a wrapper for *options.BucketOptions. This type implements the bson.Unmarshaler interface to diff --git a/mongo/integration/unified/bulkwrite_helpers.go b/mongo/integration/unified/bulkwrite_helpers.go index 895c57e990..784208b2ce 100644 --- a/mongo/integration/unified/bulkwrite_helpers.go +++ b/mongo/integration/unified/bulkwrite_helpers.go @@ -9,10 +9,10 @@ package unified import ( "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // This file provides helper functions to convert BSON documents to WriteModel instances. diff --git a/mongo/integration/unified/client_encryption_operation_execution.go b/mongo/integration/unified/client_encryption_operation_execution.go index 2a6b55f11c..a39ff16acc 100644 --- a/mongo/integration/unified/client_encryption_operation_execution.go +++ b/mongo/integration/unified/client_encryption_operation_execution.go @@ -10,11 +10,11 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // parseDataKeyOptions will parse an options document and return an options.DataKeyOptions instance. diff --git a/mongo/integration/unified/client_entity.go b/mongo/integration/unified/client_entity.go index e63c891039..a42014528c 100644 --- a/mongo/integration/unified/client_entity.go +++ b/mongo/integration/unified/client_entity.go @@ -14,16 +14,16 @@ import ( "sync/atomic" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/handshake" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/internal/logger" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/handshake" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/internal/logger" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // There are no automated tests for truncation. Given that, setting the diff --git a/mongo/integration/unified/client_operation_execution.go b/mongo/integration/unified/client_operation_execution.go index 506ca4f351..2a6e0f792b 100644 --- a/mongo/integration/unified/client_operation_execution.go +++ b/mongo/integration/unified/client_operation_execution.go @@ -11,11 +11,11 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // This file contains helpers to execute client operations. diff --git a/mongo/integration/unified/collection_data.go b/mongo/integration/unified/collection_data.go index 979ecccf05..f37733e3a4 100644 --- a/mongo/integration/unified/collection_data.go +++ b/mongo/integration/unified/collection_data.go @@ -11,12 +11,12 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) type collectionData struct { diff --git a/mongo/integration/unified/collection_operation_execution.go b/mongo/integration/unified/collection_operation_execution.go index 18c6e040fe..37b0e2dee2 100644 --- a/mongo/integration/unified/collection_operation_execution.go +++ b/mongo/integration/unified/collection_operation_execution.go @@ -11,12 +11,12 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // This file contains helpers to execute collection operations. diff --git a/mongo/integration/unified/common_options.go b/mongo/integration/unified/common_options.go index 04a462d7b6..5b42ad4d9b 100644 --- a/mongo/integration/unified/common_options.go +++ b/mongo/integration/unified/common_options.go @@ -10,11 +10,11 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/tag" ) // This file defines helper types to convert BSON documents to ReadConcern, WriteConcern, and ReadPref objects. diff --git a/mongo/integration/unified/context.go b/mongo/integration/unified/context.go index d97abaf023..cf82de1f53 100644 --- a/mongo/integration/unified/context.go +++ b/mongo/integration/unified/context.go @@ -10,7 +10,7 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/mongo" ) // ctxKey is used to define keys for values stored in context.Context objects. diff --git a/mongo/integration/unified/crud_helpers.go b/mongo/integration/unified/crud_helpers.go index 245d0e02a9..da471b9551 100644 --- a/mongo/integration/unified/crud_helpers.go +++ b/mongo/integration/unified/crud_helpers.go @@ -9,10 +9,10 @@ package unified import ( "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // newMissingArgumentError creates an error to convey that an argument that is required to run an operation is missing diff --git a/mongo/integration/unified/cursor_operation_execution.go b/mongo/integration/unified/cursor_operation_execution.go index 390e844ad0..672a079ed4 100644 --- a/mongo/integration/unified/cursor_operation_execution.go +++ b/mongo/integration/unified/cursor_operation_execution.go @@ -10,7 +10,7 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) func executeIterateOnce(ctx context.Context, operation *operation) (*operationResult, error) { diff --git a/mongo/integration/unified/database_operation_execution.go b/mongo/integration/unified/database_operation_execution.go index 661f982982..2efe643cad 100644 --- a/mongo/integration/unified/database_operation_execution.go +++ b/mongo/integration/unified/database_operation_execution.go @@ -11,10 +11,10 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // This file contains helpers to execute database operations. diff --git a/mongo/integration/unified/db_collection_options.go b/mongo/integration/unified/db_collection_options.go index 934f2530ef..51d4e7e674 100644 --- a/mongo/integration/unified/db_collection_options.go +++ b/mongo/integration/unified/db_collection_options.go @@ -9,8 +9,8 @@ package unified import ( "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) type dbOrCollectionOptions struct { diff --git a/mongo/integration/unified/entity.go b/mongo/integration/unified/entity.go index 06de9b6e78..cf5eadf308 100644 --- a/mongo/integration/unified/entity.go +++ b/mongo/integration/unified/entity.go @@ -17,11 +17,11 @@ import ( "sync/atomic" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/gridfs" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/gridfs" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) var ( diff --git a/mongo/integration/unified/entity_test.go b/mongo/integration/unified/entity_test.go index 134e882e2f..05fbde3292 100644 --- a/mongo/integration/unified/entity_test.go +++ b/mongo/integration/unified/entity_test.go @@ -10,8 +10,8 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestEntityMap(t *testing.T) { diff --git a/mongo/integration/unified/error.go b/mongo/integration/unified/error.go index 2137fa3432..af79ce0f79 100644 --- a/mongo/integration/unified/error.go +++ b/mongo/integration/unified/error.go @@ -11,8 +11,8 @@ import ( "fmt" "strings" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" ) // expectedError represents an error that is expected to occur during a test. This type ignores the "isError" field in diff --git a/mongo/integration/unified/event.go b/mongo/integration/unified/event.go index a6da6bf327..b967dc1916 100644 --- a/mongo/integration/unified/event.go +++ b/mongo/integration/unified/event.go @@ -9,9 +9,9 @@ package unified import ( "strings" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/mongo/description" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/mongo/description" ) type monitoringEventType string diff --git a/mongo/integration/unified/event_verification.go b/mongo/integration/unified/event_verification.go index 91f7452907..fbda153baf 100644 --- a/mongo/integration/unified/event_verification.go +++ b/mongo/integration/unified/event_verification.go @@ -11,10 +11,10 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/event" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/event" ) type commandMonitoringEvent struct { diff --git a/mongo/integration/unified/gridfs_bucket_operation_execution.go b/mongo/integration/unified/gridfs_bucket_operation_execution.go index 3be6fded0c..1f94d9e118 100644 --- a/mongo/integration/unified/gridfs_bucket_operation_execution.go +++ b/mongo/integration/unified/gridfs_bucket_operation_execution.go @@ -14,10 +14,10 @@ import ( "io" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func createBucketFindCursor(ctx context.Context, operation *operation) (*cursorResult, error) { diff --git a/mongo/integration/unified/logger.go b/mongo/integration/unified/logger.go index 6dcadacf4a..06eae3b1a7 100644 --- a/mongo/integration/unified/logger.go +++ b/mongo/integration/unified/logger.go @@ -7,7 +7,7 @@ package unified import ( - "go.mongodb.org/mongo-driver/internal/logger" + "go.mongodb.org/mongo-driver/v2/internal/logger" ) // orderedLogMessage is a logMessage with an "order" field representing the diff --git a/mongo/integration/unified/logger_verification.go b/mongo/integration/unified/logger_verification.go index 2b8e4e9d11..586745e9b5 100644 --- a/mongo/integration/unified/logger_verification.go +++ b/mongo/integration/unified/logger_verification.go @@ -11,8 +11,8 @@ import ( "fmt" "sync" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/logger" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/logger" ) // errLoggerVerification is use to wrap errors associated with validating the diff --git a/mongo/integration/unified/logger_verification_test.go b/mongo/integration/unified/logger_verification_test.go index 5defb8d1c0..bf0c7f25ee 100644 --- a/mongo/integration/unified/logger_verification_test.go +++ b/mongo/integration/unified/logger_verification_test.go @@ -10,9 +10,9 @@ import ( "context" "testing" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/logger" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/logger" + "go.mongodb.org/mongo-driver/v2/internal/require" ) func newTestLogMessage(t *testing.T, level int, msg string, args ...interface{}) *logMessage { diff --git a/mongo/integration/unified/main_test.go b/mongo/integration/unified/main_test.go index 3758b2856e..37d437d7fe 100644 --- a/mongo/integration/unified/main_test.go +++ b/mongo/integration/unified/main_test.go @@ -12,7 +12,7 @@ import ( "os" "testing" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" ) func TestMain(m *testing.M) { diff --git a/mongo/integration/unified/matches.go b/mongo/integration/unified/matches.go index 51df30a7dd..e3ed7e5696 100644 --- a/mongo/integration/unified/matches.go +++ b/mongo/integration/unified/matches.go @@ -13,8 +13,8 @@ import ( "fmt" "strings" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) // keyPathCtxKey is used as a key for a Context object. The value conveys the BSON key path that is currently being diff --git a/mongo/integration/unified/matches_test.go b/mongo/integration/unified/matches_test.go index fed9ce925e..0ec0adfece 100644 --- a/mongo/integration/unified/matches_test.go +++ b/mongo/integration/unified/matches_test.go @@ -11,10 +11,10 @@ import ( "encoding/hex" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestMatches(t *testing.T) { diff --git a/mongo/integration/unified/operation.go b/mongo/integration/unified/operation.go index bd46820009..1cddcbfd84 100644 --- a/mongo/integration/unified/operation.go +++ b/mongo/integration/unified/operation.go @@ -11,9 +11,9 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/csot" - "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/csot" + "go.mongodb.org/mongo-driver/v2/mongo" ) type operation struct { diff --git a/mongo/integration/unified/result.go b/mongo/integration/unified/result.go index 6c7a71a565..5c2cd0add6 100644 --- a/mongo/integration/unified/result.go +++ b/mongo/integration/unified/result.go @@ -10,8 +10,8 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" ) // operationResult holds the result and/or error returned by an op. diff --git a/mongo/integration/unified/schema_version.go b/mongo/integration/unified/schema_version.go index c85a2efa79..c655aa7a3c 100644 --- a/mongo/integration/unified/schema_version.go +++ b/mongo/integration/unified/schema_version.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" ) var ( diff --git a/mongo/integration/unified/server_api_options.go b/mongo/integration/unified/server_api_options.go index 1e619aca13..e9379386d2 100644 --- a/mongo/integration/unified/server_api_options.go +++ b/mongo/integration/unified/server_api_options.go @@ -9,8 +9,8 @@ package unified import ( "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // serverAPIOptions is a wrapper for *options.ServerAPIOptions. This type implements the bson.Unmarshaler interface diff --git a/mongo/integration/unified/session_operation_execution.go b/mongo/integration/unified/session_operation_execution.go index 98e576093d..7f03f17b3b 100644 --- a/mongo/integration/unified/session_operation_execution.go +++ b/mongo/integration/unified/session_operation_execution.go @@ -10,9 +10,9 @@ import ( "context" "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func executeAbortTransaction(ctx context.Context, operation *operation) (*operationResult, error) { diff --git a/mongo/integration/unified/session_options.go b/mongo/integration/unified/session_options.go index 9882073b22..da4d389e13 100644 --- a/mongo/integration/unified/session_options.go +++ b/mongo/integration/unified/session_options.go @@ -10,8 +10,8 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // transactionOptions is a wrapper for *options.transactionOptions. This type implements the bson.Unmarshaler interface diff --git a/mongo/integration/unified/testrunner_operation.go b/mongo/integration/unified/testrunner_operation.go index 474c01c88a..8556e7a069 100644 --- a/mongo/integration/unified/testrunner_operation.go +++ b/mongo/integration/unified/testrunner_operation.go @@ -12,11 +12,11 @@ import ( "strings" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" ) var waitForEventTimeout = 10 * time.Second diff --git a/mongo/integration/unified/unified_spec_runner.go b/mongo/integration/unified/unified_spec_runner.go index 1b1cbeb533..a2422c3ea1 100644 --- a/mongo/integration/unified/unified_spec_runner.go +++ b/mongo/integration/unified/unified_spec_runner.go @@ -15,11 +15,11 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/spectest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/spectest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" ) var ( diff --git a/mongo/integration/unified_runner_events_helper_test.go b/mongo/integration/unified_runner_events_helper_test.go index 44d5cf5c8b..5fd5b698f0 100644 --- a/mongo/integration/unified_runner_events_helper_test.go +++ b/mongo/integration/unified_runner_events_helper_test.go @@ -11,13 +11,13 @@ import ( "sync" "time" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/address" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/address" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) // Helper functions for the operations in the unified spec test runner that require assertions about SDAM and connection diff --git a/mongo/integration/unified_runner_thread_helpers_test.go b/mongo/integration/unified_runner_thread_helpers_test.go index 8ab2530b3d..ac5ef1f5ff 100644 --- a/mongo/integration/unified_runner_thread_helpers_test.go +++ b/mongo/integration/unified_runner_thread_helpers_test.go @@ -10,9 +10,9 @@ import ( "fmt" "sync" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" ) // Helper functions for the operations in the unified spec test runner that require creating and synchronizing diff --git a/mongo/integration/unified_spec_test.go b/mongo/integration/unified_spec_test.go index c12df5f6ea..89762545f5 100644 --- a/mongo/integration/unified_spec_test.go +++ b/mongo/integration/unified_spec_test.go @@ -19,23 +19,23 @@ import ( "time" "unsafe" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/bsonutil" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/address" - "go.mongodb.org/mongo-driver/mongo/gridfs" - "go.mongodb.org/mongo-driver/mongo/integration/mtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/bsonutil" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/address" + "go.mongodb.org/mongo-driver/v2/mongo/gridfs" + "go.mongodb.org/mongo-driver/v2/mongo/integration/mtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) const ( diff --git a/mongo/mongo.go b/mongo/mongo.go index 393c5b7713..76b1977d55 100644 --- a/mongo/mongo.go +++ b/mongo/mongo.go @@ -4,7 +4,7 @@ // 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 -package mongo // import "go.mongodb.org/mongo-driver/mongo" +package mongo // import "go.mongodb.org/mongo-driver/v2/mongo" import ( "bytes" @@ -17,15 +17,15 @@ import ( "strconv" "strings" - "go.mongodb.org/mongo-driver/internal/codecutil" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/internal/codecutil" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsonrw" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsonrw" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // Dialer is used to make network connections. diff --git a/mongo/mongo_test.go b/mongo/mongo_test.go index fd3f1ce869..e441d5eda9 100644 --- a/mongo/mongo_test.go +++ b/mongo/mongo_test.go @@ -11,15 +11,15 @@ import ( "fmt" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/codecutil" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/codecutil" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestEnsureID(t *testing.T) { diff --git a/mongo/mongocryptd.go b/mongo/mongocryptd.go index 41aebc76c1..bf94b31957 100644 --- a/mongo/mongocryptd.go +++ b/mongo/mongocryptd.go @@ -12,10 +12,10 @@ import ( "strings" "time" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) const ( diff --git a/mongo/ocsp_test.go b/mongo/ocsp_test.go index 5bf7d0c085..8e7a5e997f 100644 --- a/mongo/ocsp_test.go +++ b/mongo/ocsp_test.go @@ -14,10 +14,10 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) func TestOCSP(t *testing.T) { diff --git a/mongo/options/aggregateoptions.go b/mongo/options/aggregateoptions.go index 20e1c70439..c4e96abc5b 100644 --- a/mongo/options/aggregateoptions.go +++ b/mongo/options/aggregateoptions.go @@ -9,7 +9,7 @@ package options import ( "time" - "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/v2/bson" ) // AggregateOptions represents options that can be used to configure an Aggregate operation. diff --git a/mongo/options/autoencryptionoptions.go b/mongo/options/autoencryptionoptions.go index 15d513862d..2565c9fdb8 100644 --- a/mongo/options/autoencryptionoptions.go +++ b/mongo/options/autoencryptionoptions.go @@ -10,7 +10,7 @@ import ( "crypto/tls" "net/http" - "go.mongodb.org/mongo-driver/internal/httputil" + "go.mongodb.org/mongo-driver/v2/internal/httputil" ) // AutoEncryptionOptions represents options used to configure auto encryption/decryption behavior for a mongo.Client diff --git a/mongo/options/changestreamoptions.go b/mongo/options/changestreamoptions.go index 3d06a668e5..04652b617a 100644 --- a/mongo/options/changestreamoptions.go +++ b/mongo/options/changestreamoptions.go @@ -9,8 +9,8 @@ package options import ( "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // ChangeStreamOptions represents options that can be used to configure a Watch operation. diff --git a/mongo/options/changestreamoptions_test.go b/mongo/options/changestreamoptions_test.go index 7b9179c2ff..d1fe83d78a 100644 --- a/mongo/options/changestreamoptions_test.go +++ b/mongo/options/changestreamoptions_test.go @@ -9,7 +9,7 @@ package options import ( "testing" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestMergeChangeStreamOptions(t *testing.T) { diff --git a/mongo/options/clientencryptionoptions.go b/mongo/options/clientencryptionoptions.go index 2457f682ba..c79815c1f5 100644 --- a/mongo/options/clientencryptionoptions.go +++ b/mongo/options/clientencryptionoptions.go @@ -11,7 +11,7 @@ import ( "fmt" "net/http" - "go.mongodb.org/mongo-driver/internal/httputil" + "go.mongodb.org/mongo-driver/v2/internal/httputil" ) // ClientEncryptionOptions represents all possible options used to configure a ClientEncryption instance. diff --git a/mongo/options/clientoptions.go b/mongo/options/clientoptions.go index f014da418b..ecb581ae4f 100644 --- a/mongo/options/clientoptions.go +++ b/mongo/options/clientoptions.go @@ -4,7 +4,7 @@ // 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 -package options // import "go.mongodb.org/mongo-driver/mongo/options" +package options // import "go.mongodb.org/mongo-driver/v2/mongo/options" import ( "bytes" @@ -21,16 +21,16 @@ import ( "time" "github.com/youmark/pkcs8" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/httputil" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/tag" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" - "go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/httputil" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/tag" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/connstring" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/wiremessage" ) // ContextDialer is an interface that can be implemented by types that can create connections. It should be used to diff --git a/mongo/options/clientoptions_test.go b/mongo/options/clientoptions_test.go index 7c148ca0bd..908eb392ad 100644 --- a/mongo/options/clientoptions_test.go +++ b/mongo/options/clientoptions_test.go @@ -24,15 +24,15 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/httputil" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/httputil" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/connstring" ) var tClientOptions = reflect.TypeOf(&ClientOptions{}) diff --git a/mongo/options/collation_test.go b/mongo/options/collation_test.go index 084c4a9910..9ec61ca66a 100644 --- a/mongo/options/collation_test.go +++ b/mongo/options/collation_test.go @@ -10,7 +10,7 @@ import ( "bytes" "testing" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestCollation(t *testing.T) { diff --git a/mongo/options/collectionoptions.go b/mongo/options/collectionoptions.go index 04fda6d779..72277e6b8c 100644 --- a/mongo/options/collectionoptions.go +++ b/mongo/options/collectionoptions.go @@ -7,10 +7,10 @@ package options import ( - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) // CollectionOptions represents options that can be used to configure a Collection. diff --git a/mongo/options/dboptions.go b/mongo/options/dboptions.go index 8a380d2168..55a291059c 100644 --- a/mongo/options/dboptions.go +++ b/mongo/options/dboptions.go @@ -7,10 +7,10 @@ package options import ( - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) // DatabaseOptions represents options that can be used to configure a Database. diff --git a/mongo/options/encryptoptions.go b/mongo/options/encryptoptions.go index 88517d0c8d..3d4bfc0187 100644 --- a/mongo/options/encryptoptions.go +++ b/mongo/options/encryptoptions.go @@ -7,8 +7,8 @@ package options import ( - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" ) // These constants specify valid values for QueryType diff --git a/mongo/options/example_test.go b/mongo/options/example_test.go index 66c8f58b19..d09015fc95 100644 --- a/mongo/options/example_test.go +++ b/mongo/options/example_test.go @@ -14,8 +14,8 @@ import ( "log" "sync" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) type CustomLogger struct { diff --git a/mongo/options/gridfsoptions.go b/mongo/options/gridfsoptions.go index c8d347f4e7..4c6462792c 100644 --- a/mongo/options/gridfsoptions.go +++ b/mongo/options/gridfsoptions.go @@ -9,11 +9,11 @@ package options import ( "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) // DefaultName is the default name for a GridFS bucket. diff --git a/mongo/options/loggeroptions.go b/mongo/options/loggeroptions.go index b837935812..c554702c25 100644 --- a/mongo/options/loggeroptions.go +++ b/mongo/options/loggeroptions.go @@ -7,7 +7,7 @@ package options import ( - "go.mongodb.org/mongo-driver/internal/logger" + "go.mongodb.org/mongo-driver/v2/internal/logger" ) // LogLevel is an enumeration representing the supported log severity levels. diff --git a/mongo/options/mongooptions.go b/mongo/options/mongooptions.go index fd17ce44e1..81b87b6276 100644 --- a/mongo/options/mongooptions.go +++ b/mongo/options/mongooptions.go @@ -11,9 +11,9 @@ import ( "reflect" "strconv" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // Collation allows users to specify language-specific rules for string comparison, such as diff --git a/mongo/options/runcmdoptions.go b/mongo/options/runcmdoptions.go index b0cdec32ce..12f8e81fc8 100644 --- a/mongo/options/runcmdoptions.go +++ b/mongo/options/runcmdoptions.go @@ -7,7 +7,7 @@ package options import ( - "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" ) // RunCmdOptions represents options that can be used to configure a RunCommand operation. diff --git a/mongo/options/sessionoptions.go b/mongo/options/sessionoptions.go index e1eab098be..c5bbe81124 100644 --- a/mongo/options/sessionoptions.go +++ b/mongo/options/sessionoptions.go @@ -9,9 +9,9 @@ package options import ( "time" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) // DefaultCausalConsistency is the default value for the CausalConsistency option. diff --git a/mongo/options/transactionoptions.go b/mongo/options/transactionoptions.go index 9270cd20d4..31173768a0 100644 --- a/mongo/options/transactionoptions.go +++ b/mongo/options/transactionoptions.go @@ -9,9 +9,9 @@ package options import ( "time" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) // TransactionOptions represents options that can be used to configure a transaction. diff --git a/mongo/read_write_concern_spec_test.go b/mongo/read_write_concern_spec_test.go index 51d46b4c2a..d960656907 100644 --- a/mongo/read_write_concern_spec_test.go +++ b/mongo/read_write_concern_spec_test.go @@ -14,13 +14,13 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/connstring" ) const ( diff --git a/mongo/readconcern/readconcern.go b/mongo/readconcern/readconcern.go index 51408e142d..c5f3ad93d8 100644 --- a/mongo/readconcern/readconcern.go +++ b/mongo/readconcern/readconcern.go @@ -8,13 +8,13 @@ // // For more information about MongoDB read concerns, see // https://www.mongodb.com/docs/manual/reference/read-concern/ -package readconcern // import "go.mongodb.org/mongo-driver/mongo/readconcern" +package readconcern // import "go.mongodb.org/mongo-driver/v2/mongo/readconcern" import ( "errors" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) // A ReadConcern defines a MongoDB read concern, which allows you to control the consistency and diff --git a/mongo/readconcern/readconcern_test.go b/mongo/readconcern/readconcern_test.go index 2f6ea79f3e..6dc1e1812f 100644 --- a/mongo/readconcern/readconcern_test.go +++ b/mongo/readconcern/readconcern_test.go @@ -9,9 +9,9 @@ package readconcern_test import ( "testing" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/mongo/readconcern" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/mongo/readconcern" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) func TestReadConcern_MarshalBSONValue(t *testing.T) { diff --git a/mongo/readpref/mode_test.go b/mongo/readpref/mode_test.go index 572043f0ae..e92d4a35fb 100644 --- a/mongo/readpref/mode_test.go +++ b/mongo/readpref/mode_test.go @@ -9,7 +9,7 @@ package readpref import ( "testing" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestMode_String(t *testing.T) { diff --git a/mongo/readpref/options.go b/mongo/readpref/options.go index c59b0705f1..f4671d5d36 100644 --- a/mongo/readpref/options.go +++ b/mongo/readpref/options.go @@ -10,7 +10,7 @@ import ( "errors" "time" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/tag" ) // ErrInvalidTagSet indicates that an invalid set of tags was specified. diff --git a/mongo/readpref/options_example_test.go b/mongo/readpref/options_example_test.go index af4e220ae6..9976c3c1f4 100644 --- a/mongo/readpref/options_example_test.go +++ b/mongo/readpref/options_example_test.go @@ -9,10 +9,10 @@ package readpref_test import ( "context" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/tag" ) // Configure a Client with a read preference that selects the nearest replica diff --git a/mongo/readpref/readpref.go b/mongo/readpref/readpref.go index e2a1d7f340..5b09732552 100644 --- a/mongo/readpref/readpref.go +++ b/mongo/readpref/readpref.go @@ -5,7 +5,7 @@ // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 // Package readpref defines read preferences for MongoDB queries. -package readpref // import "go.mongodb.org/mongo-driver/mongo/readpref" +package readpref // import "go.mongodb.org/mongo-driver/v2/mongo/readpref" import ( "bytes" @@ -13,7 +13,7 @@ import ( "fmt" "time" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/tag" ) var ( diff --git a/mongo/readpref/readpref_test.go b/mongo/readpref/readpref_test.go index d1ccb4554d..e0c7bf7d4b 100644 --- a/mongo/readpref/readpref_test.go +++ b/mongo/readpref/readpref_test.go @@ -10,9 +10,9 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/tag" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/tag" ) func TestPrimary(t *testing.T) { diff --git a/mongo/results.go b/mongo/results.go index 8408e8ba1b..d558d1f4ab 100644 --- a/mongo/results.go +++ b/mongo/results.go @@ -9,9 +9,9 @@ package mongo import ( "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/x/mongo/driver/operation" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation" ) // BulkWriteResult is the result type returned by a BulkWrite operation. diff --git a/mongo/results_test.go b/mongo/results_test.go index fd98e6b1dd..c752a0bd09 100644 --- a/mongo/results_test.go +++ b/mongo/results_test.go @@ -9,8 +9,8 @@ package mongo import ( "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" ) func TestResults(t *testing.T) { diff --git a/mongo/session.go b/mongo/session.go index 22aa026c9e..b7c81240a6 100644 --- a/mongo/session.go +++ b/mongo/session.go @@ -11,14 +11,14 @@ import ( "errors" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/operation" - "go.mongodb.org/mongo-driver/x/mongo/driver/session" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/primitive" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/operation" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/session" ) // ErrWrongClient is returned when a user attempts to pass in a session created by a different client than diff --git a/mongo/single_result.go b/mongo/single_result.go index 9c9b4f4fc6..21c9e9b37d 100644 --- a/mongo/single_result.go +++ b/mongo/single_result.go @@ -11,9 +11,9 @@ import ( "errors" "fmt" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsoncodec" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsoncodec" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) // ErrNoDocuments is returned by SingleResult methods when the operation that created the SingleResult did not return diff --git a/mongo/single_result_test.go b/mongo/single_result_test.go index 3e561208ce..0f15b80c11 100644 --- a/mongo/single_result_test.go +++ b/mongo/single_result_test.go @@ -12,10 +12,10 @@ import ( "fmt" "testing" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/options" ) func TestSingleResult(t *testing.T) { diff --git a/mongo/with_transactions_test.go b/mongo/with_transactions_test.go index 743d6ef052..f722bdf0f3 100644 --- a/mongo/with_transactions_test.go +++ b/mongo/with_transactions_test.go @@ -15,16 +15,16 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/event" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/integtest" - "go.mongodb.org/mongo-driver/mongo/description" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/readpref" - "go.mongodb.org/mongo-driver/mongo/writeconcern" - "go.mongodb.org/mongo-driver/x/mongo/driver" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/event" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/integtest" + "go.mongodb.org/mongo-driver/v2/mongo/description" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/readpref" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver" + "go.mongodb.org/mongo-driver/v2/x/mongo/driver/topology" ) var ( diff --git a/mongo/writeconcern/writeconcern.go b/mongo/writeconcern/writeconcern.go index 8e288d10b7..80a14c93a7 100644 --- a/mongo/writeconcern/writeconcern.go +++ b/mongo/writeconcern/writeconcern.go @@ -8,16 +8,16 @@ // // For more information about MongoDB write concerns, see // https://www.mongodb.com/docs/manual/reference/write-concern/ -package writeconcern // import "go.mongodb.org/mongo-driver/mongo/writeconcern" +package writeconcern // import "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" import ( "errors" "fmt" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" ) const majority = "majority" diff --git a/mongo/writeconcern/writeconcern_example_test.go b/mongo/writeconcern/writeconcern_example_test.go index dda4b15e9c..428862cfcb 100644 --- a/mongo/writeconcern/writeconcern_example_test.go +++ b/mongo/writeconcern/writeconcern_example_test.go @@ -9,9 +9,9 @@ package writeconcern_test import ( "context" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/mongo" + "go.mongodb.org/mongo-driver/v2/mongo/options" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) // Configure a Client with write concern "majority" that requests diff --git a/mongo/writeconcern/writeconcern_test.go b/mongo/writeconcern/writeconcern_test.go index 459e0eabe3..eabf095840 100644 --- a/mongo/writeconcern/writeconcern_test.go +++ b/mongo/writeconcern/writeconcern_test.go @@ -11,11 +11,11 @@ import ( "testing" "time" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/bsontype" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" - "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.mongodb.org/mongo-driver/v2/bson" + "go.mongodb.org/mongo-driver/v2/bson/bsontype" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" + "go.mongodb.org/mongo-driver/v2/mongo/writeconcern" ) func TestWriteConcernWithOptions(t *testing.T) { diff --git a/tag/tag.go b/tag/tag.go index 4faff52549..ca458e5efa 100644 --- a/tag/tag.go +++ b/tag/tag.go @@ -8,7 +8,7 @@ // // For more information about read preference tags, see // https://www.mongodb.com/docs/manual/core/read-preference-tags/ -package tag // import "go.mongodb.org/mongo-driver/tag" +package tag // import "go.mongodb.org/mongo-driver/v2/tag" import ( "bytes" diff --git a/tag/tag_test.go b/tag/tag_test.go index 45f29ad866..cdd6ca6efe 100644 --- a/tag/tag_test.go +++ b/tag/tag_test.go @@ -9,8 +9,8 @@ package tag import ( "testing" - "go.mongodb.org/mongo-driver/internal/assert" - "go.mongodb.org/mongo-driver/internal/require" + "go.mongodb.org/mongo-driver/v2/internal/assert" + "go.mongodb.org/mongo-driver/v2/internal/require" ) func TestTag_String(t *testing.T) { diff --git a/vendor/github.com/golang/snappy/go.mod b/vendor/github.com/golang/snappy/go.mod deleted file mode 100644 index f6406bb2c7..0000000000 --- a/vendor/github.com/golang/snappy/go.mod +++ /dev/null @@ -1 +0,0 @@ -module github.com/golang/snappy diff --git a/vendor/github.com/klauspost/compress/go.mod b/vendor/github.com/klauspost/compress/go.mod deleted file mode 100644 index 5aa64a436a..0000000000 --- a/vendor/github.com/klauspost/compress/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/klauspost/compress - -go 1.15 diff --git a/vendor/github.com/klauspost/compress/go.sum b/vendor/github.com/klauspost/compress/go.sum deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/vendor/github.com/xdg-go/pbkdf2/go.mod b/vendor/github.com/xdg-go/pbkdf2/go.mod deleted file mode 100644 index 2d4dc9099a..0000000000 --- a/vendor/github.com/xdg-go/pbkdf2/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/xdg-go/pbkdf2 - -go 1.9 diff --git a/vendor/github.com/xdg-go/scram/go.mod b/vendor/github.com/xdg-go/scram/go.mod deleted file mode 100644 index d6415536f9..0000000000 --- a/vendor/github.com/xdg-go/scram/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/xdg-go/scram - -go 1.11 - -require ( - github.com/xdg-go/pbkdf2 v1.0.0 - github.com/xdg-go/stringprep v1.0.4 -) diff --git a/vendor/github.com/xdg-go/scram/go.sum b/vendor/github.com/xdg-go/scram/go.sum deleted file mode 100644 index 5edb2d654a..0000000000 --- a/vendor/github.com/xdg-go/scram/go.sum +++ /dev/null @@ -1,29 +0,0 @@ -github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= -github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/vendor/github.com/xdg-go/stringprep/go.mod b/vendor/github.com/xdg-go/stringprep/go.mod deleted file mode 100644 index 0af0f601ff..0000000000 --- a/vendor/github.com/xdg-go/stringprep/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/xdg-go/stringprep - -go 1.11 - -require golang.org/x/text v0.3.8 diff --git a/vendor/github.com/xdg-go/stringprep/go.sum b/vendor/github.com/xdg-go/stringprep/go.sum deleted file mode 100644 index b691fa8e1c..0000000000 --- a/vendor/github.com/xdg-go/stringprep/go.sum +++ /dev/null @@ -1,25 +0,0 @@ -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/vendor/go.mongodb.org/mongo-driver/LICENSE b/vendor/go.mongodb.org/mongo-driver/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/LICENSE @@ -0,0 +1,201 @@ + 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/go.mongodb.org/mongo-driver/benchmark/bson.go b/vendor/go.mongodb.org/mongo-driver/benchmark/bson.go new file mode 100644 index 0000000000..2992fb3fad --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/bson.go @@ -0,0 +1,56 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "errors" + "io/ioutil" + "path/filepath" + + "go.mongodb.org/mongo-driver/bson" +) + +const ( + perfDataDir = "perf" + bsonDataDir = "extended_bson" + flatBSONData = "flat_bson.json" + deepBSONData = "deep_bson.json" + fullBSONData = "full_bson.json" +) + +// utility functions for the bson benchmarks + +func loadSourceDocument(pathParts ...string) (bson.D, error) { + data, err := ioutil.ReadFile(filepath.Join(pathParts...)) + if err != nil { + return nil, err + } + var doc bson.D + err = bson.UnmarshalExtJSON(data, true, &doc) + if err != nil { + return nil, err + } + + if len(doc) == 0 { + return nil, errors.New("empty bson document") + } + + return doc, nil +} + +func loadSourceRaw(pathParts ...string) (bson.Raw, error) { + doc, err := loadSourceDocument(pathParts...) + if err != nil { + return nil, err + } + raw, err := bson.Marshal(doc) + if err != nil { + return nil, err + } + + return bson.Raw(raw), nil +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/bson_document.go b/vendor/go.mongodb.org/mongo-driver/benchmark/bson_document.go new file mode 100644 index 0000000000..da25714e22 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/bson_document.go @@ -0,0 +1,125 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "context" + "errors" + + "go.mongodb.org/mongo-driver/bson" +) + +func bsonDocumentEncoding(tm TimerManager, iters int, source string) error { + doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, bsonDataDir, source) + if err != nil { + return err + } + + tm.ResetTimer() + + for i := 0; i < iters; i++ { + out, err := bson.Marshal(doc) + if err != nil { + return err + } + if len(out) == 0 { + return errors.New("marshaling error") + } + } + + return nil +} + +func bsonDocumentDecodingLazy(tm TimerManager, iters int, source string) error { + doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, bsonDataDir, source) + if err != nil { + return err + } + + raw, err := bson.Marshal(doc) + if err != nil { + return err + } + + tm.ResetTimer() + + for i := 0; i < iters; i++ { + var out bson.D + err := bson.Unmarshal(raw, &out) + if err != nil { + return err + } + if len(out) == 0 { + return errors.New("marshaling error") + } + } + return nil +} + +func bsonDocumentDecoding(tm TimerManager, iters, numKeys int, source string) error { + doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, bsonDataDir, source) + if err != nil { + return err + } + + raw, err := bson.Marshal(doc) + if err != nil { + return err + } + + tm.ResetTimer() + + for i := 0; i < iters; i++ { + var out bson.D + err := bson.Unmarshal(raw, &out) + if err != nil { + return err + } + + if len(out) != numKeys { + return errors.New("document parsing error") + } + } + return nil + +} + +func BSONFlatDocumentEncoding(_ context.Context, tm TimerManager, iters int) error { + return bsonDocumentEncoding(tm, iters, flatBSONData) +} + +func BSONFlatDocumentDecodingLazy(_ context.Context, tm TimerManager, iters int) error { + return bsonDocumentDecodingLazy(tm, iters, flatBSONData) +} + +func BSONFlatDocumentDecoding(_ context.Context, tm TimerManager, iters int) error { + return bsonDocumentDecoding(tm, iters, 145, flatBSONData) +} + +func BSONDeepDocumentEncoding(_ context.Context, tm TimerManager, iters int) error { + return bsonDocumentEncoding(tm, iters, deepBSONData) +} + +func BSONDeepDocumentDecodingLazy(_ context.Context, tm TimerManager, iters int) error { + return bsonDocumentDecodingLazy(tm, iters, deepBSONData) +} + +func BSONDeepDocumentDecoding(_ context.Context, tm TimerManager, iters int) error { + return bsonDocumentDecoding(tm, iters, 126, deepBSONData) +} + +func BSONFullDocumentEncoding(_ context.Context, tm TimerManager, iters int) error { + return bsonDocumentEncoding(tm, iters, fullBSONData) +} + +func BSONFullDocumentDecodingLazy(_ context.Context, tm TimerManager, iters int) error { + return bsonDocumentDecodingLazy(tm, iters, fullBSONData) +} + +func BSONFullDocumentDecoding(_ context.Context, tm TimerManager, iters int) error { + return bsonDocumentDecoding(tm, iters, 145, fullBSONData) +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/bson_map.go b/vendor/go.mongodb.org/mongo-driver/benchmark/bson_map.go new file mode 100644 index 0000000000..8fd56ee81e --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/bson_map.go @@ -0,0 +1,88 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "context" + "errors" + "fmt" + + "go.mongodb.org/mongo-driver/bson" +) + +func bsonMapDecoding(tm TimerManager, iters int, dataSet string) error { + r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, dataSet) + if err != nil { + return err + } + + tm.ResetTimer() + + for i := 0; i < iters; i++ { + out := make(map[string]interface{}) + err := bson.Unmarshal(r, &out) + if err != nil { + return nil + } + if len(out) == 0 { + return fmt.Errorf("decoding failed") + } + } + return nil +} + +func bsonMapEncoding(tm TimerManager, iters int, dataSet string) error { + r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, dataSet) + if err != nil { + return err + } + + doc := make(map[string]interface{}) + err = bson.Unmarshal(r, &doc) + if err != nil { + return err + } + + var buf []byte + tm.ResetTimer() + for i := 0; i < iters; i++ { + buf, err = bson.MarshalAppend(buf[:0], doc) + if err != nil { + return nil + } + + if len(buf) == 0 { + return errors.New("encoding failed") + } + } + + return nil +} + +func BSONFlatMapDecoding(_ context.Context, tm TimerManager, iters int) error { + return bsonMapDecoding(tm, iters, flatBSONData) +} + +func BSONFlatMapEncoding(_ context.Context, tm TimerManager, iters int) error { + return bsonMapEncoding(tm, iters, flatBSONData) +} + +func BSONDeepMapDecoding(_ context.Context, tm TimerManager, iters int) error { + return bsonMapDecoding(tm, iters, deepBSONData) +} + +func BSONDeepMapEncoding(_ context.Context, tm TimerManager, iters int) error { + return bsonMapEncoding(tm, iters, deepBSONData) +} + +func BSONFullMapDecoding(_ context.Context, tm TimerManager, iters int) error { + return bsonMapDecoding(tm, iters, fullBSONData) +} + +func BSONFullMapEncoding(_ context.Context, tm TimerManager, iters int) error { + return bsonMapEncoding(tm, iters, fullBSONData) +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/bson_struct.go b/vendor/go.mongodb.org/mongo-driver/benchmark/bson_struct.go new file mode 100644 index 0000000000..3fec93cc2c --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/bson_struct.go @@ -0,0 +1,103 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "context" + "errors" + + "go.mongodb.org/mongo-driver/bson" +) + +func BSONFlatStructDecoding(_ context.Context, tm TimerManager, iters int) error { + r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, flatBSONData) + if err != nil { + return err + } + + tm.ResetTimer() + + for i := 0; i < iters; i++ { + out := flatBSON{} + err := bson.Unmarshal(r, &out) + if err != nil { + return err + } + } + return nil +} + +func BSONFlatStructEncoding(_ context.Context, tm TimerManager, iters int) error { + r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, flatBSONData) + if err != nil { + return err + } + + doc := flatBSON{} + err = bson.Unmarshal(r, &doc) + if err != nil { + return err + } + + var buf []byte + + tm.ResetTimer() + for i := 0; i < iters; i++ { + buf, err = bson.Marshal(doc) + if err != nil { + return err + } + if len(buf) == 0 { + return errors.New("encoding failed") + } + } + return nil +} + +func BSONFlatStructTagsEncoding(_ context.Context, tm TimerManager, iters int) error { + r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, flatBSONData) + if err != nil { + return err + } + + doc := flatBSONTags{} + err = bson.Unmarshal(r, &doc) + if err != nil { + return err + } + + var buf []byte + + tm.ResetTimer() + for i := 0; i < iters; i++ { + buf, err = bson.MarshalAppend(buf[:0], doc) + if err != nil { + return err + } + if len(buf) == 0 { + return errors.New("encoding failed") + } + } + return nil +} + +func BSONFlatStructTagsDecoding(_ context.Context, tm TimerManager, iters int) error { + r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, flatBSONData) + if err != nil { + return err + } + + tm.ResetTimer() + for i := 0; i < iters; i++ { + out := flatBSONTags{} + err := bson.Unmarshal(r, &out) + if err != nil { + return err + } + } + return nil +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/bson_types.go b/vendor/go.mongodb.org/mongo-driver/benchmark/bson_types.go new file mode 100644 index 0000000000..9d46cbcb03 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/bson_types.go @@ -0,0 +1,306 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import "go.mongodb.org/mongo-driver/bson/primitive" + +type flatBSONTags struct { + ID primitive.ObjectID `bson:"_id"` + + AA int64 `bson:"AAgSNVyBb"` + AI bool `bson:"aicoMxZq"` + AM int64 `bson:"AMQrGQmu"` + Ag int `bson:"AgYYbYPr"` + Ah int64 `bson:"ahFCBmqT"` + At int64 `bson:"AtWNZJXa"` + BB string `bson:"BBqZInWV"` + BK int64 `bson:"bkuaZWRT"` + Bw int `bson:"BwTXiovJ"` + CD int `bson:"CDIGOuIZ"` + CEA string `bson:"CEtYKsdd"` + CEB string `bson:"cepcgozk"` + CF int `bson:"CFujXoob"` + CV int64 `bson:"cVjWCrlu"` + CX string `bson:"cxOHMeDJ"` + CY string `bson:"CYhSCkWB"` + Cq string `bson:"CqCssWxW"` + DC int `bson:"dCLfYqqM"` + DDA int `bson:"ddPdLgGg"` + DDB int `bson:"ddVenEkK"` + DH string `bson:"dHsYhRbV"` + DJ int `bson:"DJsnHZIC"` + DN string `bson:"dNSuxlSU"` + DO int64 `bson:"doshbrpF"` + DP string `bson:"dpbwfSRb"` + DQ int64 `bson:"DQBQcQFj"` + DT string `bson:"dtywOLeD"` + DV int `bson:"dVkWIafN"` + EG bool `bson:"egxZaSsw"` + ER string `bson:"eRTIdIJR"` + FD int64 `bson:"FDYGeSiR"` + FE string `bson:"fEheUtop"` + Fp bool `bson:"FpduyhQP"` + GE string `bson:"gErhgZTh"` + GY int `bson:"gySFZeAE"` + Gi uint `bson:"GiAHzFII"` + HN string `bson:"hnVgYIQi"` + HQA int `bson:"HQeCoswW"` + HQB int `bson:"HQiykral"` + HV int64 `bson:"HVHyetUM"` + HW int `bson:"hwHOTmmW"` + Hi bool `bson:"HicJbMpj"` + Hr int `bson:"HrUPbFHD"` + IF string `bson:"iFFGfTXc"` + IJ int `bson:"ijwXMKqI"` + IW int `bson:"iwfbMdcv"` + Ib string `bson:"Ibrdrtgg"` + Is bool `bson:"IsorvnMR"` + JB string `bson:"jbUymqiB"` + JM string `bson:"jmglLvAS"` + JW int `bson:"jWaFvVAz"` + JX int `bson:"JXMyYkfb"` + Jh bool `bson:"JhImQOkw"` + Jr string `bson:"JrJzKiIx"` + Jz int `bson:"JzgaUWVG"` + KF bool `bson:"kfvcFmKw"` + KM int64 `bson:"KMKBtlov"` + Kn string `bson:"KnhgtAOJ"` + Ky int `bson:"KyxOoCqS"` + LU string `bson:"LUPqMOHS"` + LV bool `bson:"LVNIFCYm"` + Ln int `bson:"LngvlnTV"` + ML int `bson:"mlfZVfVT"` + MN bool `bson:"MNuWZMLP"` + MX int `bson:"MXMxLVBk"` + Mc string `bson:"McpOBmaR"` + Me string `bson:"MeUYSkPS"` + Mq int `bson:"MqfkBZJF"` + NB int `bson:"nBKWWUWk"` + NK int `bson:"nKhiSITP"` + OB int `bson:"obcwwqWZ"` + OC string `bson:"OCsIhHxq"` + OM int `bson:"omnwvBbA"` + OR string `bson:"oRWMNJTE"` + Of string `bson:"OfTmCvDx"` + PA int `bson:"pacTBmxE"` + PF int `bson:"PFZSRHNN"` + PK bool `bson:"pKjOghFa"` + PO int `bson:"pOMEwSod"` + PP string `bson:"pPtPsgRl"` + PQ int `bson:"pQyCJaEd"` + Pj int `bson:"PjKiuWnQ"` + Pv int `bson:"PvfnpsMV"` + QH int `bson:"qHzOMXeT"` + QR bool `bson:"qrJASGzU"` + Qo string `bson:"QobifTeZ"` + RE int64 `bson:"reiKnuza"` + RM string `bson:"rmzUAgmk"` + RP string `bson:"RPsQhgRD"` + Rb uint `bson:"Rbxpznea"` + ReA bool `bson:"RemSsnnR"` + ReB int `bson:"ReOZakjB"` + Rw string `bson:"RwAVVKHM"` + SG bool `bson:"sGWJTAcT"` + SU uint8 `bson:"SUWXijHT"` + SYA int64 `bson:"sYtnozSc"` + SYB string `bson:"SYtZkQbC"` + Sq int64 `bson:"SqNvlUZF"` + TA int `bson:"taoNnQYY"` + TD string `bson:"TDUzNJiH"` + TI string `bson:"tIJEYSYM"` + TR bool `bson:"TRpgnInA"` + Tg int `bson:"TgSwBbgp"` + Tk int64 `bson:"TkXMwZlU"` + Tm int64 `bson:"TmUnYUrv"` + UK int `bson:"UKwbAKGw"` + UM string `bson:"uMDWqLMf"` + Up bool `bson:"UpdMADoN"` + Ut int64 `bson:"UtbwOKLt"` + VC int64 `bson:"VCSKFCoE"` + VK string `bson:"vkEDWgmN"` + VL string `bson:"vlSZaxCV"` + VS string `bson:"vSLTtfDF"` + VVA bool `bson:"vvUeXASH"` + VVB int `bson:"VVvwKVRG"` + Vc bool `bson:"VcCSqSmp"` + Vp int16 `bson:"VplFgewF"` + Vt string `bson:"VtzeOlCT"` + WH bool `bson:"WHSQVLKG"` + WJA bool `bson:"wjfyueDC"` + WJB string `bson:"wjAWaOog"` + WM int64 `bson:"wmDLUkXt"` + WY string `bson:"WYJdGJLu"` + Wm bool `bson:"WmMOvgFc"` + Wo string `bson:"WoFGfdvb"` + XE int `bson:"XEBqaXkB"` + XG bool `bson:"XGxlHrXf"` + XR string `bson:"xrzGnsEK"` + XWA int64 `bson:"xWpeGNjl"` + XWB string `bson:"xWUlYggc"` + XX int64 `bson:"XXKbyIXG"` + XZ int64 `bson:"xZOksssj"` + Xe uint `bson:"XeRkAyCq"` + Xx int `bson:"XxvXmHiQ"` + YD string `bson:"YDHWnEXV"` + YE bool `bson:"yeTUgNrU"` + YK int `bson:"yKfZnGKG"` + YX string `bson:"yXSBbPeT"` + ZD bool `bson:"zDzSGNnW"` + ZE bool `bson:"zEgGhhZf"` + ZM string `bson:"zMCFzcWY"` + ZSA int64 `bson:"zSYvADVf"` + ZSB int64 `bson:"zswQbWEI"` + Zm string `bson:"ZmtEJFSO"` +} + +type flatBSON struct { + AMQrGQmu int64 + AAgSNVyBb int64 + AgYYbYPr int + AtWNZJXa int64 + BBqZInWV string + BwTXiovJ int + CDIGOuIZ int + CEtYKsdd string + CFujXoob int + CYhSCkWB string + CqCssWxW string + DJsnHZIC int + DQBQcQFj int64 + FDYGeSiR int64 + FpduyhQP bool + GiAHzFII uint + HQeCoswW int + HQiykral int + HVHyetUM int64 + HicJbMpj bool + HrUPbFHD int + Ibrdrtgg string + IsorvnMR bool + JXMyYkfb int + JhImQOkw bool + JrJzKiIx string + JzgaUWVG int + KMKBtlov int64 + KnhgtAOJ string + KyxOoCqS int + LUPqMOHS string + LVNIFCYm bool + LngvlnTV int + MNuWZMLP bool + MXMxLVBk int + McpOBmaR string + MeUYSkPS string + MqfkBZJF int + OCsIhHxq string + OfTmCvDx string + PjKiuWnQ int + PvfnpsMV int + QobifTeZ string + RPsQhgRD string + Rbxpznea uint + ReOZakjB int + RemSsnnR bool + RwAVVKHM string + SUWXijHT uint8 + SYtZkQbC string + SqNvlUZF int64 + TDUzNJiH string + TRpgnInA bool + TgSwBbgp int + TkXMwZlU int64 + TmUnYUrv int64 + UKwbAKGw int + UpdMADoN bool + UtbwOKLt int64 + VCSKFCoE int64 + VVvwKVRG int + VcCSqSmp bool + VplFgewF int16 + VtzeOlCT string + WHSQVLKG bool + WYJdGJLu string + WmMOvgFc bool + WoFGfdvb string + XEBqaXkB int + XGxlHrXf bool + XXKbyIXG int64 + XeRkAyCq uint + XxvXmHiQ int + YDHWnEXV string + ZmtEJFSO string + ID primitive.ObjectID `bson:"_id"` + AhFCBmqT int64 + AicoMxZq bool + BkuaZWRT int64 + CVjWCrlu int64 + Cepcgozk string + CxOHMeDJ string + DCLfYqqM int + DHsYhRbV string + DNSuxlSU string + DVkWIafN int + DdPdLgGg int + DdVenEkK int + DoshbrpF int64 + DpbwfSRb string + DtywOLeD string + ERTIdIJR string + EgxZaSsw bool + FEheUtop string + GErhgZTh string + GySFZeAE int + HnVgYIQi string + HwHOTmmW int + IFFGfTXc string + IjwXMKqI int + IwfbMdcv int + JWaFvVAz int + JbUymqiB string + JmglLvAS string + KfvcFmKw bool + MlfZVfVT int + NBKWWUWk int + NKhiSITP int + ORWMNJTE string + ObcwwqWZ int + OmnwvBbA int + PKjOghFa bool + POMEwSod int + PPtPsgRl string + PQyCJaEd int + PacTBmxE int + QHzOMXeT int + QrJASGzU bool + ReiKnuza int64 + RmzUAgmk string + SGWJTAcT bool + SYtnozSc int64 + TIJEYSYM string + TaoNnQYY int + UMDWqLMf string + VSLTtfDF string + VkEDWgmN string + VlSZaxCV string + VvUeXASH bool + WjAWaOog string + WjfyueDC bool + WmDLUkXt int64 + XWUlYggc string + XWpeGNjl int64 + XZOksssj int64 + XrzGnsEK string + YKfZnGKG int + YXSBbPeT string + YeTUgNrU bool + ZDzSGNnW bool + ZEgGhhZf bool + ZMCFzcWY string + ZSYvADVf int64 + ZswQbWEI int64 + PfZSRHnn int +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/canary.go b/vendor/go.mongodb.org/mongo-driver/benchmark/canary.go new file mode 100644 index 0000000000..8742c79a9c --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/canary.go @@ -0,0 +1,27 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "context" +) + +// CanaryIncCase is a no-op. +// +// Deprecated: CanaryIncCase has no observable effect, so recent versions of the Go compiler may +// bypass calls to it in the compiled binary. It should not be used in benchmarks. +func CanaryIncCase(context.Context, TimerManager, int) error { + return nil +} + +// GlobalCanaryIncCase is a no-op. +// +// Deprecated: GlobalCanaryIncCase has no observable effect, so recent versions of the Go compiler +// may bypass calls to it in the compiled binary. It should not be used in benchmarks. +func GlobalCanaryIncCase(context.Context, TimerManager, int) error { + return nil +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/harness.go b/vendor/go.mongodb.org/mongo-driver/benchmark/harness.go new file mode 100644 index 0000000000..0c93879a86 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/harness.go @@ -0,0 +1,212 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark // import "go.mongodb.org/mongo-driver/benchmark" + +import ( + "context" + "testing" + "time" + + "go.mongodb.org/mongo-driver/internal/require" +) + +const ( + five = 5 + ten = 2 * five + hundred = ten * ten + thousand = ten * hundred + tenThousand = ten * thousand + hundredThousand = hundred * thousand + million = hundred * hundredThousand + + ExecutionTimeout = five * time.Minute + StandardRuntime = time.Minute + MinimumRuntime = five * time.Second + MinIterations = hundred +) + +type BenchCase func(context.Context, TimerManager, int) error +type BenchFunction func(*testing.B) + +func WrapCase(bench BenchCase) BenchFunction { + name := getName(bench) + return func(b *testing.B) { + ctx := context.Background() + b.ResetTimer() + b.ReportAllocs() + err := bench(ctx, b, b.N) + require.NoError(b, err, "case='%s'", name) + } +} + +func getAllCases() []*CaseDefinition { + return []*CaseDefinition{ + { + Bench: BSONFlatDocumentEncoding, + Count: tenThousand, + Size: 75310000, + Runtime: StandardRuntime, + }, + { + Bench: BSONFlatDocumentDecodingLazy, + Count: tenThousand, + Size: 75310000, + Runtime: StandardRuntime, + }, + { + Bench: BSONFlatDocumentDecoding, + Count: tenThousand, + Size: 75310000, + Runtime: StandardRuntime, + }, + { + Bench: BSONDeepDocumentEncoding, + Count: tenThousand, + Size: 19640000, + Runtime: StandardRuntime, + }, + { + Bench: BSONDeepDocumentDecodingLazy, + Count: tenThousand, + Size: 19640000, + Runtime: StandardRuntime, + }, + { + Bench: BSONDeepDocumentDecoding, + Count: tenThousand, + Size: 19640000, + Runtime: StandardRuntime, + }, + // { + // Bench: BSONFullDocumentEncoding, + // Count: tenThousand, + // Size: 57340000, + // Runtime: StandardRuntime, + // }, + // { + // Bench: BSONFullDocumentDecodingLazy, + // Count: tenThousand, + // Size: 57340000, + // Runtime: StandardRuntime, + // }, + // { + // Bench: BSONFullDocumentDecoding, + // Count: tenThousand, + // Size: 57340000, + // Runtime: StandardRuntime, + // }, + // { + // Bench: BSONFullReaderDecoding, + // Count: tenThousand, + // Size: 57340000, + // Runtime: StandardRuntime, + // }, + { + Bench: BSONFlatMapDecoding, + Count: tenThousand, + Size: 75310000, + Runtime: StandardRuntime, + }, + { + Bench: BSONFlatMapEncoding, + Count: tenThousand, + Size: 75310000, + Runtime: StandardRuntime, + }, + { + Bench: BSONDeepMapDecoding, + Count: tenThousand, + Size: 19640000, + Runtime: StandardRuntime, + }, + { + Bench: BSONDeepMapEncoding, + Count: tenThousand, + Size: 19640000, + Runtime: StandardRuntime, + }, + // { + // Bench: BSONFullMapDecoding, + // Count: tenThousand, + // Size: 57340000, + // Runtime: StandardRuntime, + // }, + // { + // Bench: BSONFullMapEncoding, + // Count: tenThousand, + // Size: 57340000, + // Runtime: StandardRuntime, + // }, + { + Bench: BSONFlatStructDecoding, + Count: tenThousand, + Size: 75310000, + Runtime: StandardRuntime, + }, + { + Bench: BSONFlatStructTagsDecoding, + Count: tenThousand, + Size: 75310000, + Runtime: StandardRuntime, + }, + { + Bench: BSONFlatStructEncoding, + Count: tenThousand, + Size: 75310000, + Runtime: StandardRuntime, + }, + { + Bench: BSONFlatStructTagsEncoding, + Count: tenThousand, + Size: 75310000, + Runtime: StandardRuntime, + }, + { + Bench: SingleRunCommand, + Count: tenThousand, + Size: 160000, + Runtime: StandardRuntime, + }, + { + Bench: SingleFindOneByID, + Count: tenThousand, + Size: 16220000, + Runtime: StandardRuntime, + }, + { + Bench: SingleInsertSmallDocument, + Count: tenThousand, + Size: 2750000, + Runtime: StandardRuntime, + }, + { + Bench: SingleInsertLargeDocument, + Count: ten, + Size: 27310890, + Runtime: StandardRuntime, + }, + { + Bench: MultiFindMany, + Count: tenThousand, + Size: 16220000, + Runtime: StandardRuntime, + }, + { + Bench: MultiInsertSmallDocument, + Count: tenThousand, + Size: 2750000, + Runtime: StandardRuntime, + }, + { + Bench: MultiInsertLargeDocument, + Count: ten, + Size: 27310890, + Runtime: StandardRuntime, + RequiredIterations: tenThousand, + }, + } +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/harness_case.go b/vendor/go.mongodb.org/mongo-driver/benchmark/harness_case.go new file mode 100644 index 0000000000..fb2e0a0922 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/harness_case.go @@ -0,0 +1,150 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "context" + "fmt" + "path/filepath" + "reflect" + "runtime" + "strings" + "time" +) + +type CaseDefinition struct { + Bench BenchCase + Count int + Size int + RequiredIterations int + Runtime time.Duration + + cumulativeRuntime time.Duration + elapsed time.Duration + startAt time.Time + isRunning bool +} + +// TimerManager is a subset of the testing.B tool, used to manage +// setup code. +type TimerManager interface { + ResetTimer() + StartTimer() + StopTimer() +} + +func (c *CaseDefinition) ResetTimer() { + c.startAt = time.Now() + c.elapsed = 0 + c.isRunning = true +} + +func (c *CaseDefinition) StartTimer() { + c.startAt = time.Now() + c.isRunning = true +} + +func (c *CaseDefinition) StopTimer() { + if !c.isRunning { + return + } + c.elapsed += time.Since(c.startAt) + c.isRunning = false +} + +func (c *CaseDefinition) Run(ctx context.Context) *BenchResult { + out := &BenchResult{ + Trials: 1, + DataSize: c.Size, + Name: c.Name(), + Operations: c.Count, + } + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, 2*ExecutionTimeout) + defer cancel() + + fmt.Println("=== RUN", out.Name) + if c.RequiredIterations == 0 { + c.RequiredIterations = MinIterations + } + +benchRepeat: + for { + if ctx.Err() != nil { + break + } + if c.cumulativeRuntime >= c.Runtime { + if out.Trials >= c.RequiredIterations { + break + } else if c.cumulativeRuntime >= ExecutionTimeout { + break + } + } + + res := Result{ + Iterations: c.Count, + } + + c.StartTimer() + res.Error = c.Bench(ctx, c, c.Count) + c.StopTimer() + res.Duration = c.elapsed + c.cumulativeRuntime += res.Duration + + switch res.Error { + case context.DeadlineExceeded: + break benchRepeat + case context.Canceled: + break benchRepeat + case nil: + out.Trials++ + c.elapsed = 0 + out.Raw = append(out.Raw, res) + default: + continue + } + + } + + out.Duration = out.totalDuration() + fmt.Printf(" --- REPORT: count=%d trials=%d requiredTrials=%d runtime=%s\n", + c.Count, out.Trials, c.RequiredIterations, c.Runtime) + if out.HasErrors() { + fmt.Printf(" --- ERRORS: %s\n", strings.Join(out.errReport(), "\n ")) + fmt.Printf("--- FAIL: %s (%s)\n", out.Name, out.roundedRuntime()) + } else { + fmt.Printf("--- PASS: %s (%s)\n", out.Name, out.roundedRuntime()) + } + + return out + +} + +func (c *CaseDefinition) String() string { + return fmt.Sprintf("name=%s, count=%d, runtime=%s timeout=%s", + c.Name(), c.Count, c.Runtime, ExecutionTimeout) +} + +func (c *CaseDefinition) Name() string { return getName(c.Bench) } +func getName(i interface{}) string { + n := runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name() + parts := strings.Split(n, ".") + if len(parts) > 1 { + return parts[len(parts)-1] + } + + return n + +} + +func getProjectRoot() string { return filepath.Dir(getDirectoryOfFile()) } + +func getDirectoryOfFile() string { + _, file, _, _ := runtime.Caller(1) + + return filepath.Dir(file) +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/harness_main.go b/vendor/go.mongodb.org/mongo-driver/benchmark/harness_main.go new file mode 100644 index 0000000000..9c0b3f3709 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/harness_main.go @@ -0,0 +1,75 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "context" + "encoding/json" + "flag" + "fmt" + "io/ioutil" + "os" +) + +func DriverBenchmarkMain() int { + var hasErrors bool + var outputFileName string + flag.StringVar(&outputFileName, "output", "perf.json", "path to write the 'perf.json' file") + flag.Parse() + + ctx := context.Background() + output := []interface{}{} + for _, res := range runDriverCases(ctx) { + if res.HasErrors() { + hasErrors = true + } + + evg, err := res.EvergreenPerfFormat() + if err != nil { + hasErrors = true + continue + } + + output = append(output, evg...) + } + + evgOutput, err := json.MarshalIndent(output, "", " ") + if err != nil { + return 1 + } + evgOutput = append(evgOutput, []byte("\n")...) + + if outputFileName == "" { + fmt.Println(string(evgOutput)) + } else { + // Ignore gosec warning "Expect WriteFile permissions to be 0600 or less" for benchmark + // result file. + /* #nosec G306 */ + err := ioutil.WriteFile(outputFileName, evgOutput, 0644) + if err != nil { + fmt.Fprintf(os.Stderr, "problem writing file '%s': %s", outputFileName, err.Error()) + return 1 + } + } + + if hasErrors { + return 1 + } + + return 0 +} + +func runDriverCases(ctx context.Context) []*BenchResult { + cases := getAllCases() + + results := []*BenchResult{} + for _, bc := range cases { + results = append(results, bc.Run(ctx)) + } + + return results +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/harness_results.go b/vendor/go.mongodb.org/mongo-driver/benchmark/harness_results.go new file mode 100644 index 0000000000..9548596585 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/harness_results.go @@ -0,0 +1,147 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "fmt" + "time" + + "github.com/montanaflynn/stats" +) + +type BenchResult struct { + Name string + Trials int + Duration time.Duration + Raw []Result + DataSize int + Operations int + hasErrors *bool +} + +type Metric struct { + Name string `json:"name"` + Value interface{} `json:"value"` +} + +func (r *BenchResult) EvergreenPerfFormat() ([]interface{}, error) { + timings := r.timings() + + median, err := stats.Median(timings) + if err != nil { + return nil, err + } + + min, err := stats.Min(timings) + if err != nil { + return nil, err + } + + max, err := stats.Max(timings) + if err != nil { + return nil, err + } + + out := []interface{}{ + map[string]interface{}{ + "info": map[string]interface{}{ + "test_name": r.Name + "-throughput", + "args": map[string]interface{}{ + "threads": 1, + }, + }, + "metrics": []Metric{ + {Name: "seconds", Value: r.Duration.Round(time.Millisecond).Seconds()}, + {Name: "ops_per_second", Value: r.getThroughput(median)}, + {Name: "ops_per_second_min", Value: r.getThroughput(min)}, + {Name: "ops_per_second_max", Value: r.getThroughput(max)}, + }, + }, + } + + if r.DataSize > 0 { + out = append(out, interface{}(map[string]interface{}{ + "info": map[string]interface{}{ + "test_name": r.Name + "-MB-adjusted", + "args": map[string]interface{}{ + "threads": 1, + }, + }, + "metrics": []Metric{ + {Name: "seconds", Value: r.Duration.Round(time.Millisecond).Seconds()}, + {Name: "ops_per_second", Value: r.adjustResults(median)}, + {Name: "ops_per_second_min", Value: r.adjustResults(min)}, + {Name: "ops_per_second_max", Value: r.adjustResults(max)}, + }, + })) + } + + return out, nil +} + +func (r *BenchResult) timings() []float64 { + out := []float64{} + for _, r := range r.Raw { + out = append(out, r.Duration.Seconds()) + } + return out +} + +func (r *BenchResult) totalDuration() time.Duration { + var out time.Duration + for _, trial := range r.Raw { + out += trial.Duration + } + return out +} + +func (r *BenchResult) adjustResults(data float64) float64 { return float64(r.DataSize) / data } +func (r *BenchResult) getThroughput(data float64) float64 { return float64(r.Operations) / data } +func (r *BenchResult) roundedRuntime() time.Duration { return roundDurationMS(r.Duration) } + +func (r *BenchResult) String() string { + return fmt.Sprintf("name=%s, trials=%d, secs=%s", r.Name, r.Trials, r.Duration) +} + +func (r *BenchResult) HasErrors() bool { + if r.hasErrors == nil { + var val bool + for _, res := range r.Raw { + if res.Error != nil { + val = true + break + } + } + r.hasErrors = &val + } + + return *r.hasErrors +} + +func (r *BenchResult) errReport() []string { + errs := []string{} + for _, res := range r.Raw { + if res.Error != nil { + errs = append(errs, res.Error.Error()) + } + } + return errs +} + +type Result struct { + Duration time.Duration + Iterations int + Error error +} + +func roundDurationMS(d time.Duration) time.Duration { + rounded := d.Round(time.Millisecond) + if rounded == 1<<63-1 { + return 0 + } + return rounded +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/multi.go b/vendor/go.mongodb.org/mongo-driver/benchmark/multi.go new file mode 100644 index 0000000000..b16023ffec --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/multi.go @@ -0,0 +1,134 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "context" + "errors" + + "go.mongodb.org/mongo-driver/bson" +) + +func MultiFindMany(ctx context.Context, tm TimerManager, iters int) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + db, err := getClientDB(ctx) + if err != nil { + return err + } + defer db.Client().Disconnect(ctx) + + db = db.Client().Database("perftest") + if err = db.Drop(ctx); err != nil { + return err + } + + doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, singleAndMultiDataDir, tweetData) + if err != nil { + return err + } + + coll := db.Collection("corpus") + + payload := make([]interface{}, iters) + for idx := range payload { + payload[idx] = doc + } + + if _, err = coll.InsertMany(ctx, payload); err != nil { + return err + } + + tm.ResetTimer() + + cursor, err := coll.Find(ctx, bson.D{}) + if err != nil { + return err + } + defer cursor.Close(ctx) + + counter := 0 + for cursor.Next(ctx) { + err = cursor.Err() + if err != nil { + return err + } + if len(cursor.Current) == 0 { + return errors.New("error retrieving document") + } + + counter++ + } + + if counter != iters { + return errors.New("problem iterating cursors") + + } + + tm.StopTimer() + + if err = cursor.Close(ctx); err != nil { + return err + } + + return db.Drop(ctx) +} + +func multiInsertCase(ctx context.Context, tm TimerManager, iters int, data string) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + db, err := getClientDB(ctx) + if err != nil { + return err + } + defer db.Client().Disconnect(ctx) + + db = db.Client().Database("perftest") + if err = db.Drop(ctx); err != nil { + return err + } + + doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, singleAndMultiDataDir, data) + if err != nil { + return err + } + + err = db.RunCommand(ctx, bson.D{{"create", "corpus"}}).Err() + if err != nil { + return err + } + + payload := make([]interface{}, iters) + for idx := range payload { + payload[idx] = doc + } + + coll := db.Collection("corpus") + + tm.ResetTimer() + res, err := coll.InsertMany(ctx, payload) + if err != nil { + return err + } + tm.StopTimer() + + if len(res.InsertedIDs) != iters { + return errors.New("bulk operation did not complete") + } + + return db.Drop(ctx) +} + +func MultiInsertSmallDocument(ctx context.Context, tm TimerManager, iters int) error { + return multiInsertCase(ctx, tm, iters, smallData) +} + +func MultiInsertLargeDocument(ctx context.Context, tm TimerManager, iters int) error { + return multiInsertCase(ctx, tm, iters, largeData) +} diff --git a/vendor/go.mongodb.org/mongo-driver/benchmark/single.go b/vendor/go.mongodb.org/mongo-driver/benchmark/single.go new file mode 100644 index 0000000000..37ca6b1eac --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/benchmark/single.go @@ -0,0 +1,171 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package benchmark + +import ( + "context" + "errors" + + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/internal" + "go.mongodb.org/mongo-driver/internal/testutil" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" +) + +const ( + singleAndMultiDataDir = "single_and_multi_document" + tweetData = "tweet.json" + smallData = "small_doc.json" + largeData = "large_doc.json" +) + +func getClientDB(ctx context.Context) (*mongo.Database, error) { + cs, err := testutil.GetConnString() + if err != nil { + return nil, err + } + client, err := mongo.NewClient(options.Client().ApplyURI(cs.String())) + if err != nil { + return nil, err + } + if err = client.Connect(ctx); err != nil { + return nil, err + } + + db := client.Database(testutil.GetDBName(cs)) + return db, nil +} + +func SingleRunCommand(ctx context.Context, tm TimerManager, iters int) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + db, err := getClientDB(ctx) + if err != nil { + return err + } + defer db.Client().Disconnect(ctx) + + cmd := bson.D{{internal.LegacyHelloLowercase, true}} + + tm.ResetTimer() + for i := 0; i < iters; i++ { + var doc bson.D + err := db.RunCommand(ctx, cmd).Decode(&doc) + if err != nil { + return err + } + // read the document and then throw it away to prevent + out, err := bson.Marshal(doc) + if err != nil { + return err + } + if len(out) == 0 { + return errors.New("output of command is empty") + } + } + tm.StopTimer() + + return nil +} + +func SingleFindOneByID(ctx context.Context, tm TimerManager, iters int) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + db, err := getClientDB(ctx) + if err != nil { + return err + } + + db = db.Client().Database("perftest") + if err = db.Drop(ctx); err != nil { + return err + } + + doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, singleAndMultiDataDir, tweetData) + if err != nil { + return err + } + coll := db.Collection("corpus") + + for i := 0; i < iters; i++ { + idDoc := make(bson.D, 0, len(doc)+1) + idDoc = append(idDoc, bson.E{"_id", i}) + idDoc = append(idDoc, doc...) + res, err := coll.InsertOne(ctx, idDoc) + if err != nil { + return err + } + if res.InsertedID == nil { + return errors.New("no inserted ID returned") + } + } + + tm.ResetTimer() + + for i := 0; i < iters; i++ { + var res bson.D + err := coll.FindOne(ctx, bson.D{{"_id", i}}).Decode(&res) + if err != nil { + return err + } + } + + tm.StopTimer() + + return db.Drop(ctx) +} + +func singleInsertCase(ctx context.Context, tm TimerManager, iters int, data string) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + db, err := getClientDB(ctx) + if err != nil { + return err + } + defer db.Client().Disconnect(ctx) + + db = db.Client().Database("perftest") + if err = db.Drop(ctx); err != nil { + return err + } + + doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, singleAndMultiDataDir, data) + if err != nil { + return err + } + + err = db.RunCommand(ctx, bson.D{{"create", "corpus"}}).Err() + if err != nil { + return err + } + + coll := db.Collection("corpus") + + tm.ResetTimer() + + for i := 0; i < iters; i++ { + if _, err = coll.InsertOne(ctx, doc); err != nil { + return err + } + } + + tm.StopTimer() + + return db.Drop(ctx) +} + +func SingleInsertSmallDocument(ctx context.Context, tm TimerManager, iters int) error { + return singleInsertCase(ctx, tm, iters, smallData) +} + +func SingleInsertLargeDocument(ctx context.Context, tm TimerManager, iters int) error { + return singleInsertCase(ctx, tm, iters, largeData) +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bson.go b/vendor/go.mongodb.org/mongo-driver/bson/bson.go new file mode 100644 index 0000000000..a0d8185826 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bson.go @@ -0,0 +1,50 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 +// +// Based on gopkg.in/mgo.v2/bson by Gustavo Niemeyer +// See THIRD-PARTY-NOTICES for original license terms. + +package bson // import "go.mongodb.org/mongo-driver/bson" + +import ( + "go.mongodb.org/mongo-driver/bson/primitive" +) + +// Zeroer allows custom struct types to implement a report of zero +// state. All struct types that don't implement Zeroer or where IsZero +// returns false are considered to be not zero. +type Zeroer interface { + IsZero() bool +} + +// D is an ordered representation of a BSON document. This type should be used when the order of the elements matters, +// such as MongoDB command documents. If the order of the elements does not matter, an M should be used instead. +// +// A D should not be constructed with duplicate key names, as that can cause undefined server behavior. +// +// Example usage: +// +// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} +type D = primitive.D + +// E represents a BSON element for a D. It is usually used inside a D. +type E = primitive.E + +// M is an unordered representation of a BSON document. This type should be used when the order of the elements does not +// matter. This type is handled as a regular map[string]interface{} when encoding and decoding. Elements will be +// serialized in an undefined, random order. If the order of the elements matters, a D should be used instead. +// +// Example usage: +// +// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159} +type M = primitive.M + +// An A is an ordered representation of a BSON array. +// +// Example usage: +// +// bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}} +type A = primitive.A diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go new file mode 100644 index 0000000000..6ca8d9ad6c --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go @@ -0,0 +1,56 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import ( + "reflect" + + "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" +) + +// ArrayCodec is the Codec used for bsoncore.Array values. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// ArrayCodec registered. +type ArrayCodec struct{} + +var defaultArrayCodec = NewArrayCodec() + +// NewArrayCodec returns an ArrayCodec. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// ArrayCodec registered. +func NewArrayCodec() *ArrayCodec { + return &ArrayCodec{} +} + +// EncodeValue is the ValueEncoder for bsoncore.Array values. +func (ac *ArrayCodec) EncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tCoreArray { + return ValueEncoderError{Name: "CoreArrayEncodeValue", Types: []reflect.Type{tCoreArray}, Received: val} + } + + arr := val.Interface().(bsoncore.Array) + return bsonrw.Copier{}.CopyArrayFromBytes(vw, arr) +} + +// DecodeValue is the ValueDecoder for bsoncore.Array values. +func (ac *ArrayCodec) DecodeValue(_ DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tCoreArray { + return ValueDecoderError{Name: "CoreArrayDecodeValue", Types: []reflect.Type{tCoreArray}, Received: val} + } + + if val.IsNil() { + val.Set(reflect.MakeSlice(val.Type(), 0, 0)) + } + + val.SetLen(0) + arr, err := bsonrw.Copier{}.AppendArrayBytes(val.Interface().(bsoncore.Array), vr) + val.Set(reflect.ValueOf(arr)) + return err +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/bsoncodec.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/bsoncodec.go new file mode 100644 index 0000000000..0693bd432f --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/bsoncodec.go @@ -0,0 +1,382 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec // import "go.mongodb.org/mongo-driver/bson/bsoncodec" + +import ( + "fmt" + "reflect" + "strings" + + "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +var ( + emptyValue = reflect.Value{} +) + +// Marshaler is an interface implemented by types that can marshal themselves +// into a BSON document represented as bytes. The bytes returned must be a valid +// BSON document if the error is nil. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Marshaler] instead. +type Marshaler interface { + MarshalBSON() ([]byte, error) +} + +// ValueMarshaler is an interface implemented by types that can marshal +// themselves into a BSON value as bytes. The type must be the valid type for +// the bytes returned. The bytes and byte type together must be valid if the +// error is nil. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.ValueMarshaler] instead. +type ValueMarshaler interface { + MarshalBSONValue() (bsontype.Type, []byte, error) +} + +// Unmarshaler is an interface implemented by types that can unmarshal a BSON +// document representation of themselves. The BSON bytes can be assumed to be +// valid. UnmarshalBSON must copy the BSON bytes if it wishes to retain the data +// after returning. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Unmarshaler] instead. +type Unmarshaler interface { + UnmarshalBSON([]byte) error +} + +// ValueUnmarshaler is an interface implemented by types that can unmarshal a +// BSON value representation of themselves. The BSON bytes and type can be +// assumed to be valid. UnmarshalBSONValue must copy the BSON value bytes if it +// wishes to retain the data after returning. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.ValueUnmarshaler] instead. +type ValueUnmarshaler interface { + UnmarshalBSONValue(bsontype.Type, []byte) error +} + +// ValueEncoderError is an error returned from a ValueEncoder when the provided value can't be +// encoded by the ValueEncoder. +type ValueEncoderError struct { + Name string + Types []reflect.Type + Kinds []reflect.Kind + Received reflect.Value +} + +func (vee ValueEncoderError) Error() string { + typeKinds := make([]string, 0, len(vee.Types)+len(vee.Kinds)) + for _, t := range vee.Types { + typeKinds = append(typeKinds, t.String()) + } + for _, k := range vee.Kinds { + if k == reflect.Map { + typeKinds = append(typeKinds, "map[string]*") + continue + } + typeKinds = append(typeKinds, k.String()) + } + received := vee.Received.Kind().String() + if vee.Received.IsValid() { + received = vee.Received.Type().String() + } + return fmt.Sprintf("%s can only encode valid %s, but got %s", vee.Name, strings.Join(typeKinds, ", "), received) +} + +// ValueDecoderError is an error returned from a ValueDecoder when the provided value can't be +// decoded by the ValueDecoder. +type ValueDecoderError struct { + Name string + Types []reflect.Type + Kinds []reflect.Kind + Received reflect.Value +} + +func (vde ValueDecoderError) Error() string { + typeKinds := make([]string, 0, len(vde.Types)+len(vde.Kinds)) + for _, t := range vde.Types { + typeKinds = append(typeKinds, t.String()) + } + for _, k := range vde.Kinds { + if k == reflect.Map { + typeKinds = append(typeKinds, "map[string]*") + continue + } + typeKinds = append(typeKinds, k.String()) + } + received := vde.Received.Kind().String() + if vde.Received.IsValid() { + received = vde.Received.Type().String() + } + return fmt.Sprintf("%s can only decode valid and settable %s, but got %s", vde.Name, strings.Join(typeKinds, ", "), received) +} + +// EncodeContext is the contextual information required for a Codec to encode a +// value. +type EncodeContext struct { + *Registry + + // MinSize causes the Encoder to marshal Go integer values (int, int8, int16, int32, int64, + // uint, uint8, uint16, uint32, or uint64) as the minimum BSON int size (either 32 or 64 bits) + // that can represent the integer value. + // + // Deprecated: Use bson.Encoder.IntMinSize instead. + MinSize bool + + errorOnInlineDuplicates bool + stringifyMapKeysWithFmt bool + nilMapAsEmpty bool + nilSliceAsEmpty bool + nilByteSliceAsEmpty bool + omitZeroStruct bool + useJSONStructTags bool +} + +// ErrorOnInlineDuplicates causes the Encoder to return an error if there is a duplicate field in +// the marshaled BSON when the "inline" struct tag option is set. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.ErrorOnInlineDuplicates] instead. +func (ec *EncodeContext) ErrorOnInlineDuplicates() { + ec.errorOnInlineDuplicates = true +} + +// StringifyMapKeysWithFmt causes the Encoder to convert Go map keys to BSON document field name +// strings using fmt.Sprintf() instead of the default string conversion logic. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.StringifyMapKeysWithFmt] instead. +func (ec *EncodeContext) StringifyMapKeysWithFmt() { + ec.stringifyMapKeysWithFmt = true +} + +// NilMapAsEmpty causes the Encoder to marshal nil Go maps as empty BSON documents instead of BSON +// null. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.NilMapAsEmpty] instead. +func (ec *EncodeContext) NilMapAsEmpty() { + ec.nilMapAsEmpty = true +} + +// NilSliceAsEmpty causes the Encoder to marshal nil Go slices as empty BSON arrays instead of BSON +// null. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.NilSliceAsEmpty] instead. +func (ec *EncodeContext) NilSliceAsEmpty() { + ec.nilSliceAsEmpty = true +} + +// NilByteSliceAsEmpty causes the Encoder to marshal nil Go byte slices as empty BSON binary values +// instead of BSON null. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.NilByteSliceAsEmpty] instead. +func (ec *EncodeContext) NilByteSliceAsEmpty() { + ec.nilByteSliceAsEmpty = true +} + +// OmitZeroStruct causes the Encoder to consider the zero value for a struct (e.g. MyStruct{}) +// as empty and omit it from the marshaled BSON when the "omitempty" struct tag option is set. +// +// Note that the Encoder only examines exported struct fields when determining if a struct is the +// zero value. It considers pointers to a zero struct value (e.g. &MyStruct{}) not empty. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.OmitZeroStruct] instead. +func (ec *EncodeContext) OmitZeroStruct() { + ec.omitZeroStruct = true +} + +// UseJSONStructTags causes the Encoder to fall back to using the "json" struct tag if a "bson" +// struct tag is not specified. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.UseJSONStructTags] instead. +func (ec *EncodeContext) UseJSONStructTags() { + ec.useJSONStructTags = true +} + +// DecodeContext is the contextual information required for a Codec to decode a +// value. +type DecodeContext struct { + *Registry + + // Truncate, if true, instructs decoders to to truncate the fractional part of BSON "double" + // values when attempting to unmarshal them into a Go integer (int, int8, int16, int32, int64, + // uint, uint8, uint16, uint32, or uint64) struct field. The truncation logic does not apply to + // BSON "decimal128" values. + // + // Deprecated: Use bson.Decoder.AllowTruncatingDoubles instead. + Truncate bool + + // Ancestor is the type of a containing document. This is mainly used to determine what type + // should be used when decoding an embedded document into an empty interface. For example, if + // Ancestor is a bson.M, BSON embedded document values being decoded into an empty interface + // will be decoded into a bson.M. + // + // Deprecated: Use bson.Decoder.DefaultDocumentM or bson.Decoder.DefaultDocumentD instead. + Ancestor reflect.Type + + // defaultDocumentType specifies the Go type to decode top-level and nested BSON documents into. In particular, the + // usage for this field is restricted to data typed as "interface{}" or "map[string]interface{}". If DocumentType is + // set to a type that a BSON document cannot be unmarshaled into (e.g. "string"), unmarshalling will result in an + // error. DocumentType overrides the Ancestor field. + defaultDocumentType reflect.Type + + binaryAsSlice bool + useJSONStructTags bool + useLocalTimeZone bool + zeroMaps bool + zeroStructs bool +} + +// BinaryAsSlice causes the Decoder to unmarshal BSON binary field values that are the "Generic" or +// "Old" BSON binary subtype as a Go byte slice instead of a primitive.Binary. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Decoder.BinaryAsSlice] instead. +func (dc *DecodeContext) BinaryAsSlice() { + dc.binaryAsSlice = true +} + +// UseJSONStructTags causes the Decoder to fall back to using the "json" struct tag if a "bson" +// struct tag is not specified. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Decoder.UseJSONStructTags] instead. +func (dc *DecodeContext) UseJSONStructTags() { + dc.useJSONStructTags = true +} + +// UseLocalTimeZone causes the Decoder to unmarshal time.Time values in the local timezone instead +// of the UTC timezone. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Decoder.UseLocalTimeZone] instead. +func (dc *DecodeContext) UseLocalTimeZone() { + dc.useLocalTimeZone = true +} + +// ZeroMaps causes the Decoder to delete any existing values from Go maps in the destination value +// passed to Decode before unmarshaling BSON documents into them. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Decoder.ZeroMaps] instead. +func (dc *DecodeContext) ZeroMaps() { + dc.zeroMaps = true +} + +// ZeroStructs causes the Decoder to delete any existing values from Go structs in the destination +// value passed to Decode before unmarshaling BSON documents into them. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Decoder.ZeroStructs] instead. +func (dc *DecodeContext) ZeroStructs() { + dc.zeroStructs = true +} + +// DefaultDocumentM causes the Decoder to always unmarshal documents into the primitive.M type. This +// behavior is restricted to data typed as "interface{}" or "map[string]interface{}". +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Decoder.DefaultDocumentM] instead. +func (dc *DecodeContext) DefaultDocumentM() { + dc.defaultDocumentType = reflect.TypeOf(primitive.M{}) +} + +// DefaultDocumentD causes the Decoder to always unmarshal documents into the primitive.D type. This +// behavior is restricted to data typed as "interface{}" or "map[string]interface{}". +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.Decoder.DefaultDocumentD] instead. +func (dc *DecodeContext) DefaultDocumentD() { + dc.defaultDocumentType = reflect.TypeOf(primitive.D{}) +} + +// ValueCodec is an interface for encoding and decoding a reflect.Value. +// values. +// +// Deprecated: Use [ValueEncoder] and [ValueDecoder] instead. +type ValueCodec interface { + ValueEncoder + ValueDecoder +} + +// ValueEncoder is the interface implemented by types that can handle the encoding of a value. +type ValueEncoder interface { + EncodeValue(EncodeContext, bsonrw.ValueWriter, reflect.Value) error +} + +// ValueEncoderFunc is an adapter function that allows a function with the correct signature to be +// used as a ValueEncoder. +type ValueEncoderFunc func(EncodeContext, bsonrw.ValueWriter, reflect.Value) error + +// EncodeValue implements the ValueEncoder interface. +func (fn ValueEncoderFunc) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + return fn(ec, vw, val) +} + +// ValueDecoder is the interface implemented by types that can handle the decoding of a value. +type ValueDecoder interface { + DecodeValue(DecodeContext, bsonrw.ValueReader, reflect.Value) error +} + +// ValueDecoderFunc is an adapter function that allows a function with the correct signature to be +// used as a ValueDecoder. +type ValueDecoderFunc func(DecodeContext, bsonrw.ValueReader, reflect.Value) error + +// DecodeValue implements the ValueDecoder interface. +func (fn ValueDecoderFunc) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + return fn(dc, vr, val) +} + +// typeDecoder is the interface implemented by types that can handle the decoding of a value given its type. +type typeDecoder interface { + decodeType(DecodeContext, bsonrw.ValueReader, reflect.Type) (reflect.Value, error) +} + +// typeDecoderFunc is an adapter function that allows a function with the correct signature to be used as a typeDecoder. +type typeDecoderFunc func(DecodeContext, bsonrw.ValueReader, reflect.Type) (reflect.Value, error) + +func (fn typeDecoderFunc) decodeType(dc DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + return fn(dc, vr, t) +} + +// decodeAdapter allows two functions with the correct signatures to be used as both a ValueDecoder and typeDecoder. +type decodeAdapter struct { + ValueDecoderFunc + typeDecoderFunc +} + +var _ ValueDecoder = decodeAdapter{} +var _ typeDecoder = decodeAdapter{} + +// decodeTypeOrValue calls decoder.decodeType is decoder is a typeDecoder. Otherwise, it allocates a new element of type +// t and calls decoder.DecodeValue on it. +func decodeTypeOrValue(decoder ValueDecoder, dc DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + td, _ := decoder.(typeDecoder) + return decodeTypeOrValueWithInfo(decoder, td, dc, vr, t, true) +} + +func decodeTypeOrValueWithInfo(vd ValueDecoder, td typeDecoder, dc DecodeContext, vr bsonrw.ValueReader, t reflect.Type, convert bool) (reflect.Value, error) { + if td != nil { + val, err := td.decodeType(dc, vr, t) + if err == nil && convert && val.Type() != t { + // This conversion step is necessary for slices and maps. If a user declares variables like: + // + // type myBool bool + // var m map[string]myBool + // + // and tries to decode BSON bytes into the map, the decoding will fail if this conversion is not present + // because we'll try to assign a value of type bool to one of type myBool. + val = val.Convert(t) + } + return val, err + } + + val := reflect.New(t).Elem() + err := vd.DecodeValue(dc, vr, val) + return val, err +} + +// CodecZeroer is the interface implemented by Codecs that can also determine if +// a value of the type that would be encoded is zero. +// +// Deprecated: Defining custom rules for the zero/empty value will not be supported in Go Driver +// 2.0. Users who want to omit empty complex values should use a pointer field and set the value to +// nil instead. +type CodecZeroer interface { + IsTypeZero(interface{}) bool +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go new file mode 100644 index 0000000000..dde3e76815 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go @@ -0,0 +1,123 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import ( + "fmt" + "reflect" + + "go.mongodb.org/mongo-driver/bson/bsonoptions" + "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/bson/bsontype" +) + +// ByteSliceCodec is the Codec used for []byte values. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// ByteSliceCodec registered. +type ByteSliceCodec struct { + // EncodeNilAsEmpty causes EncodeValue to marshal nil Go byte slices as empty BSON binary values + // instead of BSON null. + // + // Deprecated: Use bson.Encoder.NilByteSliceAsEmpty instead. + EncodeNilAsEmpty bool +} + +var ( + defaultByteSliceCodec = NewByteSliceCodec() + + // Assert that defaultByteSliceCodec satisfies the typeDecoder interface, which allows it to be + // used by collection type decoders (e.g. map, slice, etc) to set individual values in a + // collection. + _ typeDecoder = defaultByteSliceCodec +) + +// NewByteSliceCodec returns a ByteSliceCodec with options opts. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// ByteSliceCodec registered. +func NewByteSliceCodec(opts ...*bsonoptions.ByteSliceCodecOptions) *ByteSliceCodec { + byteSliceOpt := bsonoptions.MergeByteSliceCodecOptions(opts...) + codec := ByteSliceCodec{} + if byteSliceOpt.EncodeNilAsEmpty != nil { + codec.EncodeNilAsEmpty = *byteSliceOpt.EncodeNilAsEmpty + } + return &codec +} + +// EncodeValue is the ValueEncoder for []byte. +func (bsc *ByteSliceCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tByteSlice { + return ValueEncoderError{Name: "ByteSliceEncodeValue", Types: []reflect.Type{tByteSlice}, Received: val} + } + if val.IsNil() && !bsc.EncodeNilAsEmpty && !ec.nilByteSliceAsEmpty { + return vw.WriteNull() + } + return vw.WriteBinary(val.Interface().([]byte)) +} + +func (bsc *ByteSliceCodec) decodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tByteSlice { + return emptyValue, ValueDecoderError{ + Name: "ByteSliceDecodeValue", + Types: []reflect.Type{tByteSlice}, + Received: reflect.Zero(t), + } + } + + var data []byte + var err error + switch vrType := vr.Type(); vrType { + case bsontype.String: + str, err := vr.ReadString() + if err != nil { + return emptyValue, err + } + data = []byte(str) + case bsontype.Symbol: + sym, err := vr.ReadSymbol() + if err != nil { + return emptyValue, err + } + data = []byte(sym) + case bsontype.Binary: + var subtype byte + data, subtype, err = vr.ReadBinary() + if err != nil { + return emptyValue, err + } + if subtype != bsontype.BinaryGeneric && subtype != bsontype.BinaryBinaryOld { + return emptyValue, decodeBinaryError{subtype: subtype, typeName: "[]byte"} + } + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a []byte", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(data), nil +} + +// DecodeValue is the ValueDecoder for []byte. +func (bsc *ByteSliceCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tByteSlice { + return ValueDecoderError{Name: "ByteSliceDecodeValue", Types: []reflect.Type{tByteSlice}, Received: val} + } + + elem, err := bsc.decodeType(dc, vr, tByteSlice) + if err != nil { + return err + } + + val.Set(elem) + return nil +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/cond_addr_codec.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/cond_addr_codec.go new file mode 100644 index 0000000000..cb8180f25c --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/cond_addr_codec.go @@ -0,0 +1,63 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import ( + "reflect" + + "go.mongodb.org/mongo-driver/bson/bsonrw" +) + +// condAddrEncoder is the encoder used when a pointer to the encoding value has an encoder. +type condAddrEncoder struct { + canAddrEnc ValueEncoder + elseEnc ValueEncoder +} + +var _ ValueEncoder = (*condAddrEncoder)(nil) + +// newCondAddrEncoder returns an condAddrEncoder. +func newCondAddrEncoder(canAddrEnc, elseEnc ValueEncoder) *condAddrEncoder { + encoder := condAddrEncoder{canAddrEnc: canAddrEnc, elseEnc: elseEnc} + return &encoder +} + +// EncodeValue is the ValueEncoderFunc for a value that may be addressable. +func (cae *condAddrEncoder) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if val.CanAddr() { + return cae.canAddrEnc.EncodeValue(ec, vw, val) + } + if cae.elseEnc != nil { + return cae.elseEnc.EncodeValue(ec, vw, val) + } + return ErrNoEncoder{Type: val.Type()} +} + +// condAddrDecoder is the decoder used when a pointer to the value has a decoder. +type condAddrDecoder struct { + canAddrDec ValueDecoder + elseDec ValueDecoder +} + +var _ ValueDecoder = (*condAddrDecoder)(nil) + +// newCondAddrDecoder returns an CondAddrDecoder. +func newCondAddrDecoder(canAddrDec, elseDec ValueDecoder) *condAddrDecoder { + decoder := condAddrDecoder{canAddrDec: canAddrDec, elseDec: elseDec} + return &decoder +} + +// DecodeValue is the ValueDecoderFunc for a value that may be addressable. +func (cad *condAddrDecoder) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if val.CanAddr() { + return cad.canAddrDec.DecodeValue(dc, vr, val) + } + if cad.elseDec != nil { + return cad.elseDec.DecodeValue(dc, vr, val) + } + return ErrNoDecoder{Type: val.Type()} +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go new file mode 100644 index 0000000000..e479c3585b --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go @@ -0,0 +1,1807 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import ( + "encoding/json" + "errors" + "fmt" + "math" + "net/url" + "reflect" + "strconv" + "time" + + "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" +) + +var ( + defaultValueDecoders DefaultValueDecoders + errCannotTruncate = errors.New("float64 can only be truncated to an integer type when truncation is enabled") +) + +type decodeBinaryError struct { + subtype byte + typeName string +} + +func (d decodeBinaryError) Error() string { + return fmt.Sprintf("only binary values with subtype 0x00 or 0x02 can be decoded into %s, but got subtype %v", d.typeName, d.subtype) +} + +func newDefaultStructCodec() *StructCodec { + codec, err := NewStructCodec(DefaultStructTagParser) + if err != nil { + // This function is called from the codec registration path, so errors can't be propagated. If there's an error + // constructing the StructCodec, we panic to avoid losing it. + panic(fmt.Errorf("error creating default StructCodec: %v", err)) + } + return codec +} + +// DefaultValueDecoders is a namespace type for the default ValueDecoders used +// when creating a registry. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +type DefaultValueDecoders struct{} + +// RegisterDefaultDecoders will register the decoder methods attached to DefaultValueDecoders with +// the provided RegistryBuilder. +// +// There is no support for decoding map[string]interface{} because there is no decoder for +// interface{}, so users must either register this decoder themselves or use the +// EmptyInterfaceDecoder available in the bson package. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) RegisterDefaultDecoders(rb *RegistryBuilder) { + if rb == nil { + panic(errors.New("argument to RegisterDefaultDecoders must not be nil")) + } + + intDecoder := decodeAdapter{dvd.IntDecodeValue, dvd.intDecodeType} + floatDecoder := decodeAdapter{dvd.FloatDecodeValue, dvd.floatDecodeType} + + rb. + RegisterTypeDecoder(tD, ValueDecoderFunc(dvd.DDecodeValue)). + RegisterTypeDecoder(tBinary, decodeAdapter{dvd.BinaryDecodeValue, dvd.binaryDecodeType}). + RegisterTypeDecoder(tUndefined, decodeAdapter{dvd.UndefinedDecodeValue, dvd.undefinedDecodeType}). + RegisterTypeDecoder(tDateTime, decodeAdapter{dvd.DateTimeDecodeValue, dvd.dateTimeDecodeType}). + RegisterTypeDecoder(tNull, decodeAdapter{dvd.NullDecodeValue, dvd.nullDecodeType}). + RegisterTypeDecoder(tRegex, decodeAdapter{dvd.RegexDecodeValue, dvd.regexDecodeType}). + RegisterTypeDecoder(tDBPointer, decodeAdapter{dvd.DBPointerDecodeValue, dvd.dBPointerDecodeType}). + RegisterTypeDecoder(tTimestamp, decodeAdapter{dvd.TimestampDecodeValue, dvd.timestampDecodeType}). + RegisterTypeDecoder(tMinKey, decodeAdapter{dvd.MinKeyDecodeValue, dvd.minKeyDecodeType}). + RegisterTypeDecoder(tMaxKey, decodeAdapter{dvd.MaxKeyDecodeValue, dvd.maxKeyDecodeType}). + RegisterTypeDecoder(tJavaScript, decodeAdapter{dvd.JavaScriptDecodeValue, dvd.javaScriptDecodeType}). + RegisterTypeDecoder(tSymbol, decodeAdapter{dvd.SymbolDecodeValue, dvd.symbolDecodeType}). + RegisterTypeDecoder(tByteSlice, defaultByteSliceCodec). + RegisterTypeDecoder(tTime, defaultTimeCodec). + RegisterTypeDecoder(tEmpty, defaultEmptyInterfaceCodec). + RegisterTypeDecoder(tCoreArray, defaultArrayCodec). + RegisterTypeDecoder(tOID, decodeAdapter{dvd.ObjectIDDecodeValue, dvd.objectIDDecodeType}). + RegisterTypeDecoder(tDecimal, decodeAdapter{dvd.Decimal128DecodeValue, dvd.decimal128DecodeType}). + RegisterTypeDecoder(tJSONNumber, decodeAdapter{dvd.JSONNumberDecodeValue, dvd.jsonNumberDecodeType}). + RegisterTypeDecoder(tURL, decodeAdapter{dvd.URLDecodeValue, dvd.urlDecodeType}). + RegisterTypeDecoder(tCoreDocument, ValueDecoderFunc(dvd.CoreDocumentDecodeValue)). + RegisterTypeDecoder(tCodeWithScope, decodeAdapter{dvd.CodeWithScopeDecodeValue, dvd.codeWithScopeDecodeType}). + RegisterDefaultDecoder(reflect.Bool, decodeAdapter{dvd.BooleanDecodeValue, dvd.booleanDecodeType}). + RegisterDefaultDecoder(reflect.Int, intDecoder). + RegisterDefaultDecoder(reflect.Int8, intDecoder). + RegisterDefaultDecoder(reflect.Int16, intDecoder). + RegisterDefaultDecoder(reflect.Int32, intDecoder). + RegisterDefaultDecoder(reflect.Int64, intDecoder). + RegisterDefaultDecoder(reflect.Uint, defaultUIntCodec). + RegisterDefaultDecoder(reflect.Uint8, defaultUIntCodec). + RegisterDefaultDecoder(reflect.Uint16, defaultUIntCodec). + RegisterDefaultDecoder(reflect.Uint32, defaultUIntCodec). + RegisterDefaultDecoder(reflect.Uint64, defaultUIntCodec). + RegisterDefaultDecoder(reflect.Float32, floatDecoder). + RegisterDefaultDecoder(reflect.Float64, floatDecoder). + RegisterDefaultDecoder(reflect.Array, ValueDecoderFunc(dvd.ArrayDecodeValue)). + RegisterDefaultDecoder(reflect.Map, defaultMapCodec). + RegisterDefaultDecoder(reflect.Slice, defaultSliceCodec). + RegisterDefaultDecoder(reflect.String, defaultStringCodec). + RegisterDefaultDecoder(reflect.Struct, newDefaultStructCodec()). + RegisterDefaultDecoder(reflect.Ptr, NewPointerCodec()). + RegisterTypeMapEntry(bsontype.Double, tFloat64). + RegisterTypeMapEntry(bsontype.String, tString). + RegisterTypeMapEntry(bsontype.Array, tA). + RegisterTypeMapEntry(bsontype.Binary, tBinary). + RegisterTypeMapEntry(bsontype.Undefined, tUndefined). + RegisterTypeMapEntry(bsontype.ObjectID, tOID). + RegisterTypeMapEntry(bsontype.Boolean, tBool). + RegisterTypeMapEntry(bsontype.DateTime, tDateTime). + RegisterTypeMapEntry(bsontype.Regex, tRegex). + RegisterTypeMapEntry(bsontype.DBPointer, tDBPointer). + RegisterTypeMapEntry(bsontype.JavaScript, tJavaScript). + RegisterTypeMapEntry(bsontype.Symbol, tSymbol). + RegisterTypeMapEntry(bsontype.CodeWithScope, tCodeWithScope). + RegisterTypeMapEntry(bsontype.Int32, tInt32). + RegisterTypeMapEntry(bsontype.Int64, tInt64). + RegisterTypeMapEntry(bsontype.Timestamp, tTimestamp). + RegisterTypeMapEntry(bsontype.Decimal128, tDecimal). + RegisterTypeMapEntry(bsontype.MinKey, tMinKey). + RegisterTypeMapEntry(bsontype.MaxKey, tMaxKey). + RegisterTypeMapEntry(bsontype.Type(0), tD). + RegisterTypeMapEntry(bsontype.EmbeddedDocument, tD). + RegisterHookDecoder(tValueUnmarshaler, ValueDecoderFunc(dvd.ValueUnmarshalerDecodeValue)). + RegisterHookDecoder(tUnmarshaler, ValueDecoderFunc(dvd.UnmarshalerDecodeValue)) +} + +// DDecodeValue is the ValueDecoderFunc for primitive.D instances. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) DDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.IsValid() || !val.CanSet() || val.Type() != tD { + return ValueDecoderError{Name: "DDecodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: val} + } + + switch vrType := vr.Type(); vrType { + case bsontype.Type(0), bsontype.EmbeddedDocument: + dc.Ancestor = tD + case bsontype.Null: + val.Set(reflect.Zero(val.Type())) + return vr.ReadNull() + default: + return fmt.Errorf("cannot decode %v into a primitive.D", vrType) + } + + dr, err := vr.ReadDocument() + if err != nil { + return err + } + + decoder, err := dc.LookupDecoder(tEmpty) + if err != nil { + return err + } + tEmptyTypeDecoder, _ := decoder.(typeDecoder) + + // Use the elements in the provided value if it's non nil. Otherwise, allocate a new D instance. + var elems primitive.D + if !val.IsNil() { + val.SetLen(0) + elems = val.Interface().(primitive.D) + } else { + elems = make(primitive.D, 0) + } + + for { + key, elemVr, err := dr.ReadElement() + if err == bsonrw.ErrEOD { + break + } else if err != nil { + return err + } + + // Pass false for convert because we don't need to call reflect.Value.Convert for tEmpty. + elem, err := decodeTypeOrValueWithInfo(decoder, tEmptyTypeDecoder, dc, elemVr, tEmpty, false) + if err != nil { + return err + } + + elems = append(elems, primitive.E{Key: key, Value: elem.Interface()}) + } + + val.Set(reflect.ValueOf(elems)) + return nil +} + +func (dvd DefaultValueDecoders) booleanDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t.Kind() != reflect.Bool { + return emptyValue, ValueDecoderError{ + Name: "BooleanDecodeValue", + Kinds: []reflect.Kind{reflect.Bool}, + Received: reflect.Zero(t), + } + } + + var b bool + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Int32: + i32, err := vr.ReadInt32() + if err != nil { + return emptyValue, err + } + b = (i32 != 0) + case bsontype.Int64: + i64, err := vr.ReadInt64() + if err != nil { + return emptyValue, err + } + b = (i64 != 0) + case bsontype.Double: + f64, err := vr.ReadDouble() + if err != nil { + return emptyValue, err + } + b = (f64 != 0) + case bsontype.Boolean: + b, err = vr.ReadBoolean() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a boolean", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(b), nil +} + +// BooleanDecodeValue is the ValueDecoderFunc for bool types. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) BooleanDecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.IsValid() || !val.CanSet() || val.Kind() != reflect.Bool { + return ValueDecoderError{Name: "BooleanDecodeValue", Kinds: []reflect.Kind{reflect.Bool}, Received: val} + } + + elem, err := dvd.booleanDecodeType(dctx, vr, val.Type()) + if err != nil { + return err + } + + val.SetBool(elem.Bool()) + return nil +} + +func (DefaultValueDecoders) intDecodeType(dc DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + var i64 int64 + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Int32: + i32, err := vr.ReadInt32() + if err != nil { + return emptyValue, err + } + i64 = int64(i32) + case bsontype.Int64: + i64, err = vr.ReadInt64() + if err != nil { + return emptyValue, err + } + case bsontype.Double: + f64, err := vr.ReadDouble() + if err != nil { + return emptyValue, err + } + if !dc.Truncate && math.Floor(f64) != f64 { + return emptyValue, errCannotTruncate + } + if f64 > float64(math.MaxInt64) { + return emptyValue, fmt.Errorf("%g overflows int64", f64) + } + i64 = int64(f64) + case bsontype.Boolean: + b, err := vr.ReadBoolean() + if err != nil { + return emptyValue, err + } + if b { + i64 = 1 + } + case bsontype.Null: + if err = vr.ReadNull(); err != nil { + return emptyValue, err + } + case bsontype.Undefined: + if err = vr.ReadUndefined(); err != nil { + return emptyValue, err + } + default: + return emptyValue, fmt.Errorf("cannot decode %v into an integer type", vrType) + } + + switch t.Kind() { + case reflect.Int8: + if i64 < math.MinInt8 || i64 > math.MaxInt8 { + return emptyValue, fmt.Errorf("%d overflows int8", i64) + } + + return reflect.ValueOf(int8(i64)), nil + case reflect.Int16: + if i64 < math.MinInt16 || i64 > math.MaxInt16 { + return emptyValue, fmt.Errorf("%d overflows int16", i64) + } + + return reflect.ValueOf(int16(i64)), nil + case reflect.Int32: + if i64 < math.MinInt32 || i64 > math.MaxInt32 { + return emptyValue, fmt.Errorf("%d overflows int32", i64) + } + + return reflect.ValueOf(int32(i64)), nil + case reflect.Int64: + return reflect.ValueOf(i64), nil + case reflect.Int: + if int64(int(i64)) != i64 { // Can we fit this inside of an int + return emptyValue, fmt.Errorf("%d overflows int", i64) + } + + return reflect.ValueOf(int(i64)), nil + default: + return emptyValue, ValueDecoderError{ + Name: "IntDecodeValue", + Kinds: []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int}, + Received: reflect.Zero(t), + } + } +} + +// IntDecodeValue is the ValueDecoderFunc for int types. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) IntDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() { + return ValueDecoderError{ + Name: "IntDecodeValue", + Kinds: []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int}, + Received: val, + } + } + + elem, err := dvd.intDecodeType(dc, vr, val.Type()) + if err != nil { + return err + } + + val.SetInt(elem.Int()) + return nil +} + +// UintDecodeValue is the ValueDecoderFunc for uint types. +// +// Deprecated: UintDecodeValue is not registered by default. Use UintCodec.DecodeValue instead. +func (dvd DefaultValueDecoders) UintDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + var i64 int64 + var err error + switch vr.Type() { + case bsontype.Int32: + i32, err := vr.ReadInt32() + if err != nil { + return err + } + i64 = int64(i32) + case bsontype.Int64: + i64, err = vr.ReadInt64() + if err != nil { + return err + } + case bsontype.Double: + f64, err := vr.ReadDouble() + if err != nil { + return err + } + if !dc.Truncate && math.Floor(f64) != f64 { + return errors.New("UintDecodeValue can only truncate float64 to an integer type when truncation is enabled") + } + if f64 > float64(math.MaxInt64) { + return fmt.Errorf("%g overflows int64", f64) + } + i64 = int64(f64) + case bsontype.Boolean: + b, err := vr.ReadBoolean() + if err != nil { + return err + } + if b { + i64 = 1 + } + default: + return fmt.Errorf("cannot decode %v into an integer type", vr.Type()) + } + + if !val.CanSet() { + return ValueDecoderError{ + Name: "UintDecodeValue", + Kinds: []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint}, + Received: val, + } + } + + switch val.Kind() { + case reflect.Uint8: + if i64 < 0 || i64 > math.MaxUint8 { + return fmt.Errorf("%d overflows uint8", i64) + } + case reflect.Uint16: + if i64 < 0 || i64 > math.MaxUint16 { + return fmt.Errorf("%d overflows uint16", i64) + } + case reflect.Uint32: + if i64 < 0 || i64 > math.MaxUint32 { + return fmt.Errorf("%d overflows uint32", i64) + } + case reflect.Uint64: + if i64 < 0 { + return fmt.Errorf("%d overflows uint64", i64) + } + case reflect.Uint: + if i64 < 0 || int64(uint(i64)) != i64 { // Can we fit this inside of an uint + return fmt.Errorf("%d overflows uint", i64) + } + default: + return ValueDecoderError{ + Name: "UintDecodeValue", + Kinds: []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint}, + Received: val, + } + } + + val.SetUint(uint64(i64)) + return nil +} + +func (dvd DefaultValueDecoders) floatDecodeType(dc DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + var f float64 + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Int32: + i32, err := vr.ReadInt32() + if err != nil { + return emptyValue, err + } + f = float64(i32) + case bsontype.Int64: + i64, err := vr.ReadInt64() + if err != nil { + return emptyValue, err + } + f = float64(i64) + case bsontype.Double: + f, err = vr.ReadDouble() + if err != nil { + return emptyValue, err + } + case bsontype.Boolean: + b, err := vr.ReadBoolean() + if err != nil { + return emptyValue, err + } + if b { + f = 1 + } + case bsontype.Null: + if err = vr.ReadNull(); err != nil { + return emptyValue, err + } + case bsontype.Undefined: + if err = vr.ReadUndefined(); err != nil { + return emptyValue, err + } + default: + return emptyValue, fmt.Errorf("cannot decode %v into a float32 or float64 type", vrType) + } + + switch t.Kind() { + case reflect.Float32: + if !dc.Truncate && float64(float32(f)) != f { + return emptyValue, errCannotTruncate + } + + return reflect.ValueOf(float32(f)), nil + case reflect.Float64: + return reflect.ValueOf(f), nil + default: + return emptyValue, ValueDecoderError{ + Name: "FloatDecodeValue", + Kinds: []reflect.Kind{reflect.Float32, reflect.Float64}, + Received: reflect.Zero(t), + } + } +} + +// FloatDecodeValue is the ValueDecoderFunc for float types. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) FloatDecodeValue(ec DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() { + return ValueDecoderError{ + Name: "FloatDecodeValue", + Kinds: []reflect.Kind{reflect.Float32, reflect.Float64}, + Received: val, + } + } + + elem, err := dvd.floatDecodeType(ec, vr, val.Type()) + if err != nil { + return err + } + + val.SetFloat(elem.Float()) + return nil +} + +// StringDecodeValue is the ValueDecoderFunc for string types. +// +// Deprecated: StringDecodeValue is not registered by default. Use StringCodec.DecodeValue instead. +func (dvd DefaultValueDecoders) StringDecodeValue(_ DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + var str string + var err error + switch vr.Type() { + // TODO(GODRIVER-577): Handle JavaScript and Symbol BSON types when allowed. + case bsontype.String: + str, err = vr.ReadString() + if err != nil { + return err + } + default: + return fmt.Errorf("cannot decode %v into a string type", vr.Type()) + } + if !val.CanSet() || val.Kind() != reflect.String { + return ValueDecoderError{Name: "StringDecodeValue", Kinds: []reflect.Kind{reflect.String}, Received: val} + } + + val.SetString(str) + return nil +} + +func (DefaultValueDecoders) javaScriptDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tJavaScript { + return emptyValue, ValueDecoderError{ + Name: "JavaScriptDecodeValue", + Types: []reflect.Type{tJavaScript}, + Received: reflect.Zero(t), + } + } + + var js string + var err error + switch vrType := vr.Type(); vrType { + case bsontype.JavaScript: + js, err = vr.ReadJavascript() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a primitive.JavaScript", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.JavaScript(js)), nil +} + +// JavaScriptDecodeValue is the ValueDecoderFunc for the primitive.JavaScript type. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) JavaScriptDecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tJavaScript { + return ValueDecoderError{Name: "JavaScriptDecodeValue", Types: []reflect.Type{tJavaScript}, Received: val} + } + + elem, err := dvd.javaScriptDecodeType(dctx, vr, tJavaScript) + if err != nil { + return err + } + + val.SetString(elem.String()) + return nil +} + +func (DefaultValueDecoders) symbolDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tSymbol { + return emptyValue, ValueDecoderError{ + Name: "SymbolDecodeValue", + Types: []reflect.Type{tSymbol}, + Received: reflect.Zero(t), + } + } + + var symbol string + var err error + switch vrType := vr.Type(); vrType { + case bsontype.String: + symbol, err = vr.ReadString() + case bsontype.Symbol: + symbol, err = vr.ReadSymbol() + case bsontype.Binary: + data, subtype, err := vr.ReadBinary() + if err != nil { + return emptyValue, err + } + + if subtype != bsontype.BinaryGeneric && subtype != bsontype.BinaryBinaryOld { + return emptyValue, decodeBinaryError{subtype: subtype, typeName: "primitive.Symbol"} + } + symbol = string(data) + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a primitive.Symbol", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.Symbol(symbol)), nil +} + +// SymbolDecodeValue is the ValueDecoderFunc for the primitive.Symbol type. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) SymbolDecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tSymbol { + return ValueDecoderError{Name: "SymbolDecodeValue", Types: []reflect.Type{tSymbol}, Received: val} + } + + elem, err := dvd.symbolDecodeType(dctx, vr, tSymbol) + if err != nil { + return err + } + + val.SetString(elem.String()) + return nil +} + +func (DefaultValueDecoders) binaryDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tBinary { + return emptyValue, ValueDecoderError{ + Name: "BinaryDecodeValue", + Types: []reflect.Type{tBinary}, + Received: reflect.Zero(t), + } + } + + var data []byte + var subtype byte + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Binary: + data, subtype, err = vr.ReadBinary() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a Binary", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.Binary{Subtype: subtype, Data: data}), nil +} + +// BinaryDecodeValue is the ValueDecoderFunc for Binary. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) BinaryDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tBinary { + return ValueDecoderError{Name: "BinaryDecodeValue", Types: []reflect.Type{tBinary}, Received: val} + } + + elem, err := dvd.binaryDecodeType(dc, vr, tBinary) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (DefaultValueDecoders) undefinedDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tUndefined { + return emptyValue, ValueDecoderError{ + Name: "UndefinedDecodeValue", + Types: []reflect.Type{tUndefined}, + Received: reflect.Zero(t), + } + } + + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Undefined: + err = vr.ReadUndefined() + case bsontype.Null: + err = vr.ReadNull() + default: + return emptyValue, fmt.Errorf("cannot decode %v into an Undefined", vr.Type()) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.Undefined{}), nil +} + +// UndefinedDecodeValue is the ValueDecoderFunc for Undefined. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) UndefinedDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tUndefined { + return ValueDecoderError{Name: "UndefinedDecodeValue", Types: []reflect.Type{tUndefined}, Received: val} + } + + elem, err := dvd.undefinedDecodeType(dc, vr, tUndefined) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +// Accept both 12-byte string and pretty-printed 24-byte hex string formats. +func (dvd DefaultValueDecoders) objectIDDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tOID { + return emptyValue, ValueDecoderError{ + Name: "ObjectIDDecodeValue", + Types: []reflect.Type{tOID}, + Received: reflect.Zero(t), + } + } + + var oid primitive.ObjectID + var err error + switch vrType := vr.Type(); vrType { + case bsontype.ObjectID: + oid, err = vr.ReadObjectID() + if err != nil { + return emptyValue, err + } + case bsontype.String: + str, err := vr.ReadString() + if err != nil { + return emptyValue, err + } + if oid, err = primitive.ObjectIDFromHex(str); err == nil { + break + } + if len(str) != 12 { + return emptyValue, fmt.Errorf("an ObjectID string must be exactly 12 bytes long (got %v)", len(str)) + } + byteArr := []byte(str) + copy(oid[:], byteArr) + case bsontype.Null: + if err = vr.ReadNull(); err != nil { + return emptyValue, err + } + case bsontype.Undefined: + if err = vr.ReadUndefined(); err != nil { + return emptyValue, err + } + default: + return emptyValue, fmt.Errorf("cannot decode %v into an ObjectID", vrType) + } + + return reflect.ValueOf(oid), nil +} + +// ObjectIDDecodeValue is the ValueDecoderFunc for primitive.ObjectID. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) ObjectIDDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tOID { + return ValueDecoderError{Name: "ObjectIDDecodeValue", Types: []reflect.Type{tOID}, Received: val} + } + + elem, err := dvd.objectIDDecodeType(dc, vr, tOID) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (DefaultValueDecoders) dateTimeDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tDateTime { + return emptyValue, ValueDecoderError{ + Name: "DateTimeDecodeValue", + Types: []reflect.Type{tDateTime}, + Received: reflect.Zero(t), + } + } + + var dt int64 + var err error + switch vrType := vr.Type(); vrType { + case bsontype.DateTime: + dt, err = vr.ReadDateTime() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a DateTime", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.DateTime(dt)), nil +} + +// DateTimeDecodeValue is the ValueDecoderFunc for DateTime. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) DateTimeDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tDateTime { + return ValueDecoderError{Name: "DateTimeDecodeValue", Types: []reflect.Type{tDateTime}, Received: val} + } + + elem, err := dvd.dateTimeDecodeType(dc, vr, tDateTime) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (DefaultValueDecoders) nullDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tNull { + return emptyValue, ValueDecoderError{ + Name: "NullDecodeValue", + Types: []reflect.Type{tNull}, + Received: reflect.Zero(t), + } + } + + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Undefined: + err = vr.ReadUndefined() + case bsontype.Null: + err = vr.ReadNull() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a Null", vr.Type()) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.Null{}), nil +} + +// NullDecodeValue is the ValueDecoderFunc for Null. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) NullDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tNull { + return ValueDecoderError{Name: "NullDecodeValue", Types: []reflect.Type{tNull}, Received: val} + } + + elem, err := dvd.nullDecodeType(dc, vr, tNull) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (DefaultValueDecoders) regexDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tRegex { + return emptyValue, ValueDecoderError{ + Name: "RegexDecodeValue", + Types: []reflect.Type{tRegex}, + Received: reflect.Zero(t), + } + } + + var pattern, options string + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Regex: + pattern, options, err = vr.ReadRegex() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a Regex", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.Regex{Pattern: pattern, Options: options}), nil +} + +// RegexDecodeValue is the ValueDecoderFunc for Regex. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) RegexDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tRegex { + return ValueDecoderError{Name: "RegexDecodeValue", Types: []reflect.Type{tRegex}, Received: val} + } + + elem, err := dvd.regexDecodeType(dc, vr, tRegex) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (DefaultValueDecoders) dBPointerDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tDBPointer { + return emptyValue, ValueDecoderError{ + Name: "DBPointerDecodeValue", + Types: []reflect.Type{tDBPointer}, + Received: reflect.Zero(t), + } + } + + var ns string + var pointer primitive.ObjectID + var err error + switch vrType := vr.Type(); vrType { + case bsontype.DBPointer: + ns, pointer, err = vr.ReadDBPointer() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a DBPointer", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.DBPointer{DB: ns, Pointer: pointer}), nil +} + +// DBPointerDecodeValue is the ValueDecoderFunc for DBPointer. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) DBPointerDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tDBPointer { + return ValueDecoderError{Name: "DBPointerDecodeValue", Types: []reflect.Type{tDBPointer}, Received: val} + } + + elem, err := dvd.dBPointerDecodeType(dc, vr, tDBPointer) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (DefaultValueDecoders) timestampDecodeType(_ DecodeContext, vr bsonrw.ValueReader, reflectType reflect.Type) (reflect.Value, error) { + if reflectType != tTimestamp { + return emptyValue, ValueDecoderError{ + Name: "TimestampDecodeValue", + Types: []reflect.Type{tTimestamp}, + Received: reflect.Zero(reflectType), + } + } + + var t, incr uint32 + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Timestamp: + t, incr, err = vr.ReadTimestamp() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a Timestamp", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.Timestamp{T: t, I: incr}), nil +} + +// TimestampDecodeValue is the ValueDecoderFunc for Timestamp. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) TimestampDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tTimestamp { + return ValueDecoderError{Name: "TimestampDecodeValue", Types: []reflect.Type{tTimestamp}, Received: val} + } + + elem, err := dvd.timestampDecodeType(dc, vr, tTimestamp) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (DefaultValueDecoders) minKeyDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tMinKey { + return emptyValue, ValueDecoderError{ + Name: "MinKeyDecodeValue", + Types: []reflect.Type{tMinKey}, + Received: reflect.Zero(t), + } + } + + var err error + switch vrType := vr.Type(); vrType { + case bsontype.MinKey: + err = vr.ReadMinKey() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a MinKey", vr.Type()) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.MinKey{}), nil +} + +// MinKeyDecodeValue is the ValueDecoderFunc for MinKey. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) MinKeyDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tMinKey { + return ValueDecoderError{Name: "MinKeyDecodeValue", Types: []reflect.Type{tMinKey}, Received: val} + } + + elem, err := dvd.minKeyDecodeType(dc, vr, tMinKey) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (DefaultValueDecoders) maxKeyDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tMaxKey { + return emptyValue, ValueDecoderError{ + Name: "MaxKeyDecodeValue", + Types: []reflect.Type{tMaxKey}, + Received: reflect.Zero(t), + } + } + + var err error + switch vrType := vr.Type(); vrType { + case bsontype.MaxKey: + err = vr.ReadMaxKey() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a MaxKey", vr.Type()) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(primitive.MaxKey{}), nil +} + +// MaxKeyDecodeValue is the ValueDecoderFunc for MaxKey. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) MaxKeyDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tMaxKey { + return ValueDecoderError{Name: "MaxKeyDecodeValue", Types: []reflect.Type{tMaxKey}, Received: val} + } + + elem, err := dvd.maxKeyDecodeType(dc, vr, tMaxKey) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (dvd DefaultValueDecoders) decimal128DecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tDecimal { + return emptyValue, ValueDecoderError{ + Name: "Decimal128DecodeValue", + Types: []reflect.Type{tDecimal}, + Received: reflect.Zero(t), + } + } + + var d128 primitive.Decimal128 + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Decimal128: + d128, err = vr.ReadDecimal128() + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a primitive.Decimal128", vr.Type()) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(d128), nil +} + +// Decimal128DecodeValue is the ValueDecoderFunc for primitive.Decimal128. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) Decimal128DecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tDecimal { + return ValueDecoderError{Name: "Decimal128DecodeValue", Types: []reflect.Type{tDecimal}, Received: val} + } + + elem, err := dvd.decimal128DecodeType(dctx, vr, tDecimal) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (dvd DefaultValueDecoders) jsonNumberDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tJSONNumber { + return emptyValue, ValueDecoderError{ + Name: "JSONNumberDecodeValue", + Types: []reflect.Type{tJSONNumber}, + Received: reflect.Zero(t), + } + } + + var jsonNum json.Number + var err error + switch vrType := vr.Type(); vrType { + case bsontype.Double: + f64, err := vr.ReadDouble() + if err != nil { + return emptyValue, err + } + jsonNum = json.Number(strconv.FormatFloat(f64, 'f', -1, 64)) + case bsontype.Int32: + i32, err := vr.ReadInt32() + if err != nil { + return emptyValue, err + } + jsonNum = json.Number(strconv.FormatInt(int64(i32), 10)) + case bsontype.Int64: + i64, err := vr.ReadInt64() + if err != nil { + return emptyValue, err + } + jsonNum = json.Number(strconv.FormatInt(i64, 10)) + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a json.Number", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(jsonNum), nil +} + +// JSONNumberDecodeValue is the ValueDecoderFunc for json.Number. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) JSONNumberDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tJSONNumber { + return ValueDecoderError{Name: "JSONNumberDecodeValue", Types: []reflect.Type{tJSONNumber}, Received: val} + } + + elem, err := dvd.jsonNumberDecodeType(dc, vr, tJSONNumber) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (dvd DefaultValueDecoders) urlDecodeType(_ DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tURL { + return emptyValue, ValueDecoderError{ + Name: "URLDecodeValue", + Types: []reflect.Type{tURL}, + Received: reflect.Zero(t), + } + } + + urlPtr := &url.URL{} + var err error + switch vrType := vr.Type(); vrType { + case bsontype.String: + var str string // Declare str here to avoid shadowing err during the ReadString call. + str, err = vr.ReadString() + if err != nil { + return emptyValue, err + } + + urlPtr, err = url.Parse(str) + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a *url.URL", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(urlPtr).Elem(), nil +} + +// URLDecodeValue is the ValueDecoderFunc for url.URL. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) URLDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tURL { + return ValueDecoderError{Name: "URLDecodeValue", Types: []reflect.Type{tURL}, Received: val} + } + + elem, err := dvd.urlDecodeType(dc, vr, tURL) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +// TimeDecodeValue is the ValueDecoderFunc for time.Time. +// +// Deprecated: TimeDecodeValue is not registered by default. Use TimeCodec.DecodeValue instead. +func (dvd DefaultValueDecoders) TimeDecodeValue(_ DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if vr.Type() != bsontype.DateTime { + return fmt.Errorf("cannot decode %v into a time.Time", vr.Type()) + } + + dt, err := vr.ReadDateTime() + if err != nil { + return err + } + + if !val.CanSet() || val.Type() != tTime { + return ValueDecoderError{Name: "TimeDecodeValue", Types: []reflect.Type{tTime}, Received: val} + } + + val.Set(reflect.ValueOf(time.Unix(dt/1000, dt%1000*1000000).UTC())) + return nil +} + +// ByteSliceDecodeValue is the ValueDecoderFunc for []byte. +// +// Deprecated: ByteSliceDecodeValue is not registered by default. Use ByteSliceCodec.DecodeValue instead. +func (dvd DefaultValueDecoders) ByteSliceDecodeValue(_ DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if vr.Type() != bsontype.Binary && vr.Type() != bsontype.Null { + return fmt.Errorf("cannot decode %v into a []byte", vr.Type()) + } + + if !val.CanSet() || val.Type() != tByteSlice { + return ValueDecoderError{Name: "ByteSliceDecodeValue", Types: []reflect.Type{tByteSlice}, Received: val} + } + + if vr.Type() == bsontype.Null { + val.Set(reflect.Zero(val.Type())) + return vr.ReadNull() + } + + data, subtype, err := vr.ReadBinary() + if err != nil { + return err + } + if subtype != 0x00 { + return fmt.Errorf("ByteSliceDecodeValue can only be used to decode subtype 0x00 for %s, got %v", bsontype.Binary, subtype) + } + + val.Set(reflect.ValueOf(data)) + return nil +} + +// MapDecodeValue is the ValueDecoderFunc for map[string]* types. +// +// Deprecated: MapDecodeValue is not registered by default. Use MapCodec.DecodeValue instead. +func (dvd DefaultValueDecoders) MapDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Kind() != reflect.Map || val.Type().Key().Kind() != reflect.String { + return ValueDecoderError{Name: "MapDecodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: val} + } + + switch vr.Type() { + case bsontype.Type(0), bsontype.EmbeddedDocument: + case bsontype.Null: + val.Set(reflect.Zero(val.Type())) + return vr.ReadNull() + default: + return fmt.Errorf("cannot decode %v into a %s", vr.Type(), val.Type()) + } + + dr, err := vr.ReadDocument() + if err != nil { + return err + } + + if val.IsNil() { + val.Set(reflect.MakeMap(val.Type())) + } + + eType := val.Type().Elem() + decoder, err := dc.LookupDecoder(eType) + if err != nil { + return err + } + + if eType == tEmpty { + dc.Ancestor = val.Type() + } + + keyType := val.Type().Key() + for { + key, vr, err := dr.ReadElement() + if err == bsonrw.ErrEOD { + break + } + if err != nil { + return err + } + + elem := reflect.New(eType).Elem() + + err = decoder.DecodeValue(dc, vr, elem) + if err != nil { + return err + } + + val.SetMapIndex(reflect.ValueOf(key).Convert(keyType), elem) + } + return nil +} + +// ArrayDecodeValue is the ValueDecoderFunc for array types. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) ArrayDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.IsValid() || val.Kind() != reflect.Array { + return ValueDecoderError{Name: "ArrayDecodeValue", Kinds: []reflect.Kind{reflect.Array}, Received: val} + } + + switch vrType := vr.Type(); vrType { + case bsontype.Array: + case bsontype.Type(0), bsontype.EmbeddedDocument: + if val.Type().Elem() != tE { + return fmt.Errorf("cannot decode document into %s", val.Type()) + } + case bsontype.Binary: + if val.Type().Elem() != tByte { + return fmt.Errorf("ArrayDecodeValue can only be used to decode binary into a byte array, got %v", vrType) + } + data, subtype, err := vr.ReadBinary() + if err != nil { + return err + } + if subtype != bsontype.BinaryGeneric && subtype != bsontype.BinaryBinaryOld { + return fmt.Errorf("ArrayDecodeValue can only be used to decode subtype 0x00 or 0x02 for %s, got %v", bsontype.Binary, subtype) + } + + if len(data) > val.Len() { + return fmt.Errorf("more elements returned in array than can fit inside %s", val.Type()) + } + + for idx, elem := range data { + val.Index(idx).Set(reflect.ValueOf(elem)) + } + return nil + case bsontype.Null: + val.Set(reflect.Zero(val.Type())) + return vr.ReadNull() + case bsontype.Undefined: + val.Set(reflect.Zero(val.Type())) + return vr.ReadUndefined() + default: + return fmt.Errorf("cannot decode %v into an array", vrType) + } + + var elemsFunc func(DecodeContext, bsonrw.ValueReader, reflect.Value) ([]reflect.Value, error) + switch val.Type().Elem() { + case tE: + elemsFunc = dvd.decodeD + default: + elemsFunc = dvd.decodeDefault + } + + elems, err := elemsFunc(dc, vr, val) + if err != nil { + return err + } + + if len(elems) > val.Len() { + return fmt.Errorf("more elements returned in array than can fit inside %s, got %v elements", val.Type(), len(elems)) + } + + for idx, elem := range elems { + val.Index(idx).Set(elem) + } + + return nil +} + +// SliceDecodeValue is the ValueDecoderFunc for slice types. +// +// Deprecated: SliceDecodeValue is not registered by default. Use SliceCodec.DecodeValue instead. +func (dvd DefaultValueDecoders) SliceDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Kind() != reflect.Slice { + return ValueDecoderError{Name: "SliceDecodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: val} + } + + switch vr.Type() { + case bsontype.Array: + case bsontype.Null: + val.Set(reflect.Zero(val.Type())) + return vr.ReadNull() + case bsontype.Type(0), bsontype.EmbeddedDocument: + if val.Type().Elem() != tE { + return fmt.Errorf("cannot decode document into %s", val.Type()) + } + default: + return fmt.Errorf("cannot decode %v into a slice", vr.Type()) + } + + var elemsFunc func(DecodeContext, bsonrw.ValueReader, reflect.Value) ([]reflect.Value, error) + switch val.Type().Elem() { + case tE: + dc.Ancestor = val.Type() + elemsFunc = dvd.decodeD + default: + elemsFunc = dvd.decodeDefault + } + + elems, err := elemsFunc(dc, vr, val) + if err != nil { + return err + } + + if val.IsNil() { + val.Set(reflect.MakeSlice(val.Type(), 0, len(elems))) + } + + val.SetLen(0) + val.Set(reflect.Append(val, elems...)) + + return nil +} + +// ValueUnmarshalerDecodeValue is the ValueDecoderFunc for ValueUnmarshaler implementations. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) ValueUnmarshalerDecodeValue(_ DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.IsValid() || (!val.Type().Implements(tValueUnmarshaler) && !reflect.PtrTo(val.Type()).Implements(tValueUnmarshaler)) { + return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val} + } + + if val.Kind() == reflect.Ptr && val.IsNil() { + if !val.CanSet() { + return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val} + } + val.Set(reflect.New(val.Type().Elem())) + } + + if !val.Type().Implements(tValueUnmarshaler) { + if !val.CanAddr() { + return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val} + } + val = val.Addr() // If the type doesn't implement the interface, a pointer to it must. + } + + t, src, err := bsonrw.Copier{}.CopyValueToBytes(vr) + if err != nil { + return err + } + + m, ok := val.Interface().(ValueUnmarshaler) + if !ok { + // NB: this error should be unreachable due to the above checks + return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val} + } + return m.UnmarshalBSONValue(t, src) +} + +// UnmarshalerDecodeValue is the ValueDecoderFunc for Unmarshaler implementations. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) UnmarshalerDecodeValue(_ DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.IsValid() || (!val.Type().Implements(tUnmarshaler) && !reflect.PtrTo(val.Type()).Implements(tUnmarshaler)) { + return ValueDecoderError{Name: "UnmarshalerDecodeValue", Types: []reflect.Type{tUnmarshaler}, Received: val} + } + + if val.Kind() == reflect.Ptr && val.IsNil() { + if !val.CanSet() { + return ValueDecoderError{Name: "UnmarshalerDecodeValue", Types: []reflect.Type{tUnmarshaler}, Received: val} + } + val.Set(reflect.New(val.Type().Elem())) + } + + _, src, err := bsonrw.Copier{}.CopyValueToBytes(vr) + if err != nil { + return err + } + + // If the target Go value is a pointer and the BSON field value is empty, set the value to the + // zero value of the pointer (nil) and don't call UnmarshalBSON. UnmarshalBSON has no way to + // change the pointer value from within the function (only the value at the pointer address), + // so it can't set the pointer to "nil" itself. Since the most common Go value for an empty BSON + // field value is "nil", we set "nil" here and don't call UnmarshalBSON. This behavior matches + // the behavior of the Go "encoding/json" unmarshaler when the target Go value is a pointer and + // the JSON field value is "null". + if val.Kind() == reflect.Ptr && len(src) == 0 { + val.Set(reflect.Zero(val.Type())) + return nil + } + + if !val.Type().Implements(tUnmarshaler) { + if !val.CanAddr() { + return ValueDecoderError{Name: "UnmarshalerDecodeValue", Types: []reflect.Type{tUnmarshaler}, Received: val} + } + val = val.Addr() // If the type doesn't implement the interface, a pointer to it must. + } + + m, ok := val.Interface().(Unmarshaler) + if !ok { + // NB: this error should be unreachable due to the above checks + return ValueDecoderError{Name: "UnmarshalerDecodeValue", Types: []reflect.Type{tUnmarshaler}, Received: val} + } + return m.UnmarshalBSON(src) +} + +// EmptyInterfaceDecodeValue is the ValueDecoderFunc for interface{}. +// +// Deprecated: EmptyInterfaceDecodeValue is not registered by default. Use EmptyInterfaceCodec.DecodeValue instead. +func (dvd DefaultValueDecoders) EmptyInterfaceDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tEmpty { + return ValueDecoderError{Name: "EmptyInterfaceDecodeValue", Types: []reflect.Type{tEmpty}, Received: val} + } + + rtype, err := dc.LookupTypeMapEntry(vr.Type()) + if err != nil { + switch vr.Type() { + case bsontype.EmbeddedDocument: + if dc.Ancestor != nil { + rtype = dc.Ancestor + break + } + rtype = tD + case bsontype.Null: + val.Set(reflect.Zero(val.Type())) + return vr.ReadNull() + default: + return err + } + } + + decoder, err := dc.LookupDecoder(rtype) + if err != nil { + return err + } + + elem := reflect.New(rtype).Elem() + err = decoder.DecodeValue(dc, vr, elem) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +// CoreDocumentDecodeValue is the ValueDecoderFunc for bsoncore.Document. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (DefaultValueDecoders) CoreDocumentDecodeValue(_ DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tCoreDocument { + return ValueDecoderError{Name: "CoreDocumentDecodeValue", Types: []reflect.Type{tCoreDocument}, Received: val} + } + + if val.IsNil() { + val.Set(reflect.MakeSlice(val.Type(), 0, 0)) + } + + val.SetLen(0) + + cdoc, err := bsonrw.Copier{}.AppendDocumentBytes(val.Interface().(bsoncore.Document), vr) + val.Set(reflect.ValueOf(cdoc)) + return err +} + +func (dvd DefaultValueDecoders) decodeDefault(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) ([]reflect.Value, error) { + elems := make([]reflect.Value, 0) + + ar, err := vr.ReadArray() + if err != nil { + return nil, err + } + + eType := val.Type().Elem() + + decoder, err := dc.LookupDecoder(eType) + if err != nil { + return nil, err + } + eTypeDecoder, _ := decoder.(typeDecoder) + + idx := 0 + for { + vr, err := ar.ReadValue() + if err == bsonrw.ErrEOA { + break + } + if err != nil { + return nil, err + } + + elem, err := decodeTypeOrValueWithInfo(decoder, eTypeDecoder, dc, vr, eType, true) + if err != nil { + return nil, newDecodeError(strconv.Itoa(idx), err) + } + elems = append(elems, elem) + idx++ + } + + return elems, nil +} + +func (dvd DefaultValueDecoders) readCodeWithScope(dc DecodeContext, vr bsonrw.ValueReader) (primitive.CodeWithScope, error) { + var cws primitive.CodeWithScope + + code, dr, err := vr.ReadCodeWithScope() + if err != nil { + return cws, err + } + + scope := reflect.New(tD).Elem() + elems, err := dvd.decodeElemsFromDocumentReader(dc, dr) + if err != nil { + return cws, err + } + + scope.Set(reflect.MakeSlice(tD, 0, len(elems))) + scope.Set(reflect.Append(scope, elems...)) + + cws = primitive.CodeWithScope{ + Code: primitive.JavaScript(code), + Scope: scope.Interface().(primitive.D), + } + return cws, nil +} + +func (dvd DefaultValueDecoders) codeWithScopeDecodeType(dc DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tCodeWithScope { + return emptyValue, ValueDecoderError{ + Name: "CodeWithScopeDecodeValue", + Types: []reflect.Type{tCodeWithScope}, + Received: reflect.Zero(t), + } + } + + var cws primitive.CodeWithScope + var err error + switch vrType := vr.Type(); vrType { + case bsontype.CodeWithScope: + cws, err = dvd.readCodeWithScope(dc, vr) + case bsontype.Null: + err = vr.ReadNull() + case bsontype.Undefined: + err = vr.ReadUndefined() + default: + return emptyValue, fmt.Errorf("cannot decode %v into a primitive.CodeWithScope", vrType) + } + if err != nil { + return emptyValue, err + } + + return reflect.ValueOf(cws), nil +} + +// CodeWithScopeDecodeValue is the ValueDecoderFunc for CodeWithScope. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value decoders registered. +func (dvd DefaultValueDecoders) CodeWithScopeDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tCodeWithScope { + return ValueDecoderError{Name: "CodeWithScopeDecodeValue", Types: []reflect.Type{tCodeWithScope}, Received: val} + } + + elem, err := dvd.codeWithScopeDecodeType(dc, vr, tCodeWithScope) + if err != nil { + return err + } + + val.Set(elem) + return nil +} + +func (dvd DefaultValueDecoders) decodeD(dc DecodeContext, vr bsonrw.ValueReader, _ reflect.Value) ([]reflect.Value, error) { + switch vr.Type() { + case bsontype.Type(0), bsontype.EmbeddedDocument: + default: + return nil, fmt.Errorf("cannot decode %v into a D", vr.Type()) + } + + dr, err := vr.ReadDocument() + if err != nil { + return nil, err + } + + return dvd.decodeElemsFromDocumentReader(dc, dr) +} + +func (DefaultValueDecoders) decodeElemsFromDocumentReader(dc DecodeContext, dr bsonrw.DocumentReader) ([]reflect.Value, error) { + decoder, err := dc.LookupDecoder(tEmpty) + if err != nil { + return nil, err + } + + elems := make([]reflect.Value, 0) + for { + key, vr, err := dr.ReadElement() + if err == bsonrw.ErrEOD { + break + } + if err != nil { + return nil, err + } + + val := reflect.New(tEmpty).Elem() + err = decoder.DecodeValue(dc, vr, val) + if err != nil { + return nil, newDecodeError(key, err) + } + + elems = append(elems, reflect.ValueOf(primitive.E{Key: key, Value: val.Interface()})) + } + + return elems, nil +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go new file mode 100644 index 0000000000..4ab14a668c --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go @@ -0,0 +1,856 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import ( + "encoding/json" + "errors" + "fmt" + "math" + "net/url" + "reflect" + "sync" + "time" + + "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" +) + +var defaultValueEncoders DefaultValueEncoders + +var bvwPool = bsonrw.NewBSONValueWriterPool() + +var errInvalidValue = errors.New("cannot encode invalid element") + +var sliceWriterPool = sync.Pool{ + New: func() interface{} { + sw := make(bsonrw.SliceWriter, 0) + return &sw + }, +} + +func encodeElement(ec EncodeContext, dw bsonrw.DocumentWriter, e primitive.E) error { + vw, err := dw.WriteDocumentElement(e.Key) + if err != nil { + return err + } + + if e.Value == nil { + return vw.WriteNull() + } + encoder, err := ec.LookupEncoder(reflect.TypeOf(e.Value)) + if err != nil { + return err + } + + err = encoder.EncodeValue(ec, vw, reflect.ValueOf(e.Value)) + if err != nil { + return err + } + return nil +} + +// DefaultValueEncoders is a namespace type for the default ValueEncoders used +// when creating a registry. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +type DefaultValueEncoders struct{} + +// RegisterDefaultEncoders will register the encoder methods attached to DefaultValueEncoders with +// the provided RegistryBuilder. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) RegisterDefaultEncoders(rb *RegistryBuilder) { + if rb == nil { + panic(errors.New("argument to RegisterDefaultEncoders must not be nil")) + } + rb. + RegisterTypeEncoder(tByteSlice, defaultByteSliceCodec). + RegisterTypeEncoder(tTime, defaultTimeCodec). + RegisterTypeEncoder(tEmpty, defaultEmptyInterfaceCodec). + RegisterTypeEncoder(tCoreArray, defaultArrayCodec). + RegisterTypeEncoder(tOID, ValueEncoderFunc(dve.ObjectIDEncodeValue)). + RegisterTypeEncoder(tDecimal, ValueEncoderFunc(dve.Decimal128EncodeValue)). + RegisterTypeEncoder(tJSONNumber, ValueEncoderFunc(dve.JSONNumberEncodeValue)). + RegisterTypeEncoder(tURL, ValueEncoderFunc(dve.URLEncodeValue)). + RegisterTypeEncoder(tJavaScript, ValueEncoderFunc(dve.JavaScriptEncodeValue)). + RegisterTypeEncoder(tSymbol, ValueEncoderFunc(dve.SymbolEncodeValue)). + RegisterTypeEncoder(tBinary, ValueEncoderFunc(dve.BinaryEncodeValue)). + RegisterTypeEncoder(tUndefined, ValueEncoderFunc(dve.UndefinedEncodeValue)). + RegisterTypeEncoder(tDateTime, ValueEncoderFunc(dve.DateTimeEncodeValue)). + RegisterTypeEncoder(tNull, ValueEncoderFunc(dve.NullEncodeValue)). + RegisterTypeEncoder(tRegex, ValueEncoderFunc(dve.RegexEncodeValue)). + RegisterTypeEncoder(tDBPointer, ValueEncoderFunc(dve.DBPointerEncodeValue)). + RegisterTypeEncoder(tTimestamp, ValueEncoderFunc(dve.TimestampEncodeValue)). + RegisterTypeEncoder(tMinKey, ValueEncoderFunc(dve.MinKeyEncodeValue)). + RegisterTypeEncoder(tMaxKey, ValueEncoderFunc(dve.MaxKeyEncodeValue)). + RegisterTypeEncoder(tCoreDocument, ValueEncoderFunc(dve.CoreDocumentEncodeValue)). + RegisterTypeEncoder(tCodeWithScope, ValueEncoderFunc(dve.CodeWithScopeEncodeValue)). + RegisterDefaultEncoder(reflect.Bool, ValueEncoderFunc(dve.BooleanEncodeValue)). + RegisterDefaultEncoder(reflect.Int, ValueEncoderFunc(dve.IntEncodeValue)). + RegisterDefaultEncoder(reflect.Int8, ValueEncoderFunc(dve.IntEncodeValue)). + RegisterDefaultEncoder(reflect.Int16, ValueEncoderFunc(dve.IntEncodeValue)). + RegisterDefaultEncoder(reflect.Int32, ValueEncoderFunc(dve.IntEncodeValue)). + RegisterDefaultEncoder(reflect.Int64, ValueEncoderFunc(dve.IntEncodeValue)). + RegisterDefaultEncoder(reflect.Uint, defaultUIntCodec). + RegisterDefaultEncoder(reflect.Uint8, defaultUIntCodec). + RegisterDefaultEncoder(reflect.Uint16, defaultUIntCodec). + RegisterDefaultEncoder(reflect.Uint32, defaultUIntCodec). + RegisterDefaultEncoder(reflect.Uint64, defaultUIntCodec). + RegisterDefaultEncoder(reflect.Float32, ValueEncoderFunc(dve.FloatEncodeValue)). + RegisterDefaultEncoder(reflect.Float64, ValueEncoderFunc(dve.FloatEncodeValue)). + RegisterDefaultEncoder(reflect.Array, ValueEncoderFunc(dve.ArrayEncodeValue)). + RegisterDefaultEncoder(reflect.Map, defaultMapCodec). + RegisterDefaultEncoder(reflect.Slice, defaultSliceCodec). + RegisterDefaultEncoder(reflect.String, defaultStringCodec). + RegisterDefaultEncoder(reflect.Struct, newDefaultStructCodec()). + RegisterDefaultEncoder(reflect.Ptr, NewPointerCodec()). + RegisterHookEncoder(tValueMarshaler, ValueEncoderFunc(dve.ValueMarshalerEncodeValue)). + RegisterHookEncoder(tMarshaler, ValueEncoderFunc(dve.MarshalerEncodeValue)). + RegisterHookEncoder(tProxy, ValueEncoderFunc(dve.ProxyEncodeValue)) +} + +// BooleanEncodeValue is the ValueEncoderFunc for bool types. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) BooleanEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Kind() != reflect.Bool { + return ValueEncoderError{Name: "BooleanEncodeValue", Kinds: []reflect.Kind{reflect.Bool}, Received: val} + } + return vw.WriteBoolean(val.Bool()) +} + +func fitsIn32Bits(i int64) bool { + return math.MinInt32 <= i && i <= math.MaxInt32 +} + +// IntEncodeValue is the ValueEncoderFunc for int types. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) IntEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + switch val.Kind() { + case reflect.Int8, reflect.Int16, reflect.Int32: + return vw.WriteInt32(int32(val.Int())) + case reflect.Int: + i64 := val.Int() + if fitsIn32Bits(i64) { + return vw.WriteInt32(int32(i64)) + } + return vw.WriteInt64(i64) + case reflect.Int64: + i64 := val.Int() + if ec.MinSize && fitsIn32Bits(i64) { + return vw.WriteInt32(int32(i64)) + } + return vw.WriteInt64(i64) + } + + return ValueEncoderError{ + Name: "IntEncodeValue", + Kinds: []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int}, + Received: val, + } +} + +// UintEncodeValue is the ValueEncoderFunc for uint types. +// +// Deprecated: UintEncodeValue is not registered by default. Use UintCodec.EncodeValue instead. +func (dve DefaultValueEncoders) UintEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + switch val.Kind() { + case reflect.Uint8, reflect.Uint16: + return vw.WriteInt32(int32(val.Uint())) + case reflect.Uint, reflect.Uint32, reflect.Uint64: + u64 := val.Uint() + if ec.MinSize && u64 <= math.MaxInt32 { + return vw.WriteInt32(int32(u64)) + } + if u64 > math.MaxInt64 { + return fmt.Errorf("%d overflows int64", u64) + } + return vw.WriteInt64(int64(u64)) + } + + return ValueEncoderError{ + Name: "UintEncodeValue", + Kinds: []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint}, + Received: val, + } +} + +// FloatEncodeValue is the ValueEncoderFunc for float types. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) FloatEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + switch val.Kind() { + case reflect.Float32, reflect.Float64: + return vw.WriteDouble(val.Float()) + } + + return ValueEncoderError{Name: "FloatEncodeValue", Kinds: []reflect.Kind{reflect.Float32, reflect.Float64}, Received: val} +} + +// StringEncodeValue is the ValueEncoderFunc for string types. +// +// Deprecated: StringEncodeValue is not registered by default. Use StringCodec.EncodeValue instead. +func (dve DefaultValueEncoders) StringEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if val.Kind() != reflect.String { + return ValueEncoderError{ + Name: "StringEncodeValue", + Kinds: []reflect.Kind{reflect.String}, + Received: val, + } + } + + return vw.WriteString(val.String()) +} + +// ObjectIDEncodeValue is the ValueEncoderFunc for primitive.ObjectID. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) ObjectIDEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tOID { + return ValueEncoderError{Name: "ObjectIDEncodeValue", Types: []reflect.Type{tOID}, Received: val} + } + return vw.WriteObjectID(val.Interface().(primitive.ObjectID)) +} + +// Decimal128EncodeValue is the ValueEncoderFunc for primitive.Decimal128. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) Decimal128EncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tDecimal { + return ValueEncoderError{Name: "Decimal128EncodeValue", Types: []reflect.Type{tDecimal}, Received: val} + } + return vw.WriteDecimal128(val.Interface().(primitive.Decimal128)) +} + +// JSONNumberEncodeValue is the ValueEncoderFunc for json.Number. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) JSONNumberEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tJSONNumber { + return ValueEncoderError{Name: "JSONNumberEncodeValue", Types: []reflect.Type{tJSONNumber}, Received: val} + } + jsnum := val.Interface().(json.Number) + + // Attempt int first, then float64 + if i64, err := jsnum.Int64(); err == nil { + return dve.IntEncodeValue(ec, vw, reflect.ValueOf(i64)) + } + + f64, err := jsnum.Float64() + if err != nil { + return err + } + + return dve.FloatEncodeValue(ec, vw, reflect.ValueOf(f64)) +} + +// URLEncodeValue is the ValueEncoderFunc for url.URL. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) URLEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tURL { + return ValueEncoderError{Name: "URLEncodeValue", Types: []reflect.Type{tURL}, Received: val} + } + u := val.Interface().(url.URL) + return vw.WriteString(u.String()) +} + +// TimeEncodeValue is the ValueEncoderFunc for time.TIme. +// +// Deprecated: TimeEncodeValue is not registered by default. Use TimeCodec.EncodeValue instead. +func (dve DefaultValueEncoders) TimeEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tTime { + return ValueEncoderError{Name: "TimeEncodeValue", Types: []reflect.Type{tTime}, Received: val} + } + tt := val.Interface().(time.Time) + dt := primitive.NewDateTimeFromTime(tt) + return vw.WriteDateTime(int64(dt)) +} + +// ByteSliceEncodeValue is the ValueEncoderFunc for []byte. +// +// Deprecated: ByteSliceEncodeValue is not registered by default. Use ByteSliceCodec.EncodeValue instead. +func (dve DefaultValueEncoders) ByteSliceEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tByteSlice { + return ValueEncoderError{Name: "ByteSliceEncodeValue", Types: []reflect.Type{tByteSlice}, Received: val} + } + if val.IsNil() { + return vw.WriteNull() + } + return vw.WriteBinary(val.Interface().([]byte)) +} + +// MapEncodeValue is the ValueEncoderFunc for map[string]* types. +// +// Deprecated: MapEncodeValue is not registered by default. Use MapCodec.EncodeValue instead. +func (dve DefaultValueEncoders) MapEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Kind() != reflect.Map || val.Type().Key().Kind() != reflect.String { + return ValueEncoderError{Name: "MapEncodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: val} + } + + if val.IsNil() { + // If we have a nill map but we can't WriteNull, that means we're probably trying to encode + // to a TopLevel document. We can't currently tell if this is what actually happened, but if + // there's a deeper underlying problem, the error will also be returned from WriteDocument, + // so just continue. The operations on a map reflection value are valid, so we can call + // MapKeys within mapEncodeValue without a problem. + err := vw.WriteNull() + if err == nil { + return nil + } + } + + dw, err := vw.WriteDocument() + if err != nil { + return err + } + + return dve.mapEncodeValue(ec, dw, val, nil) +} + +// mapEncodeValue handles encoding of the values of a map. The collisionFn returns +// true if the provided key exists, this is mainly used for inline maps in the +// struct codec. +func (dve DefaultValueEncoders) mapEncodeValue(ec EncodeContext, dw bsonrw.DocumentWriter, val reflect.Value, collisionFn func(string) bool) error { + + elemType := val.Type().Elem() + encoder, err := ec.LookupEncoder(elemType) + if err != nil && elemType.Kind() != reflect.Interface { + return err + } + + keys := val.MapKeys() + for _, key := range keys { + if collisionFn != nil && collisionFn(key.String()) { + return fmt.Errorf("Key %s of inlined map conflicts with a struct field name", key) + } + + currEncoder, currVal, lookupErr := dve.lookupElementEncoder(ec, encoder, val.MapIndex(key)) + if lookupErr != nil && lookupErr != errInvalidValue { + return lookupErr + } + + vw, err := dw.WriteDocumentElement(key.String()) + if err != nil { + return err + } + + if lookupErr == errInvalidValue { + err = vw.WriteNull() + if err != nil { + return err + } + continue + } + + err = currEncoder.EncodeValue(ec, vw, currVal) + if err != nil { + return err + } + } + + return dw.WriteDocumentEnd() +} + +// ArrayEncodeValue is the ValueEncoderFunc for array types. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) ArrayEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Kind() != reflect.Array { + return ValueEncoderError{Name: "ArrayEncodeValue", Kinds: []reflect.Kind{reflect.Array}, Received: val} + } + + // If we have a []primitive.E we want to treat it as a document instead of as an array. + if val.Type().Elem() == tE { + dw, err := vw.WriteDocument() + if err != nil { + return err + } + + for idx := 0; idx < val.Len(); idx++ { + e := val.Index(idx).Interface().(primitive.E) + err = encodeElement(ec, dw, e) + if err != nil { + return err + } + } + + return dw.WriteDocumentEnd() + } + + // If we have a []byte we want to treat it as a binary instead of as an array. + if val.Type().Elem() == tByte { + var byteSlice []byte + for idx := 0; idx < val.Len(); idx++ { + byteSlice = append(byteSlice, val.Index(idx).Interface().(byte)) + } + return vw.WriteBinary(byteSlice) + } + + aw, err := vw.WriteArray() + if err != nil { + return err + } + + elemType := val.Type().Elem() + encoder, err := ec.LookupEncoder(elemType) + if err != nil && elemType.Kind() != reflect.Interface { + return err + } + + for idx := 0; idx < val.Len(); idx++ { + currEncoder, currVal, lookupErr := dve.lookupElementEncoder(ec, encoder, val.Index(idx)) + if lookupErr != nil && lookupErr != errInvalidValue { + return lookupErr + } + + vw, err := aw.WriteArrayElement() + if err != nil { + return err + } + + if lookupErr == errInvalidValue { + err = vw.WriteNull() + if err != nil { + return err + } + continue + } + + err = currEncoder.EncodeValue(ec, vw, currVal) + if err != nil { + return err + } + } + return aw.WriteArrayEnd() +} + +// SliceEncodeValue is the ValueEncoderFunc for slice types. +// +// Deprecated: SliceEncodeValue is not registered by default. Use SliceCodec.EncodeValue instead. +func (dve DefaultValueEncoders) SliceEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Kind() != reflect.Slice { + return ValueEncoderError{Name: "SliceEncodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: val} + } + + if val.IsNil() { + return vw.WriteNull() + } + + // If we have a []primitive.E we want to treat it as a document instead of as an array. + if val.Type().ConvertibleTo(tD) { + d := val.Convert(tD).Interface().(primitive.D) + + dw, err := vw.WriteDocument() + if err != nil { + return err + } + + for _, e := range d { + err = encodeElement(ec, dw, e) + if err != nil { + return err + } + } + + return dw.WriteDocumentEnd() + } + + aw, err := vw.WriteArray() + if err != nil { + return err + } + + elemType := val.Type().Elem() + encoder, err := ec.LookupEncoder(elemType) + if err != nil && elemType.Kind() != reflect.Interface { + return err + } + + for idx := 0; idx < val.Len(); idx++ { + currEncoder, currVal, lookupErr := dve.lookupElementEncoder(ec, encoder, val.Index(idx)) + if lookupErr != nil && lookupErr != errInvalidValue { + return lookupErr + } + + vw, err := aw.WriteArrayElement() + if err != nil { + return err + } + + if lookupErr == errInvalidValue { + err = vw.WriteNull() + if err != nil { + return err + } + continue + } + + err = currEncoder.EncodeValue(ec, vw, currVal) + if err != nil { + return err + } + } + return aw.WriteArrayEnd() +} + +func (dve DefaultValueEncoders) lookupElementEncoder(ec EncodeContext, origEncoder ValueEncoder, currVal reflect.Value) (ValueEncoder, reflect.Value, error) { + if origEncoder != nil || (currVal.Kind() != reflect.Interface) { + return origEncoder, currVal, nil + } + currVal = currVal.Elem() + if !currVal.IsValid() { + return nil, currVal, errInvalidValue + } + currEncoder, err := ec.LookupEncoder(currVal.Type()) + + return currEncoder, currVal, err +} + +// EmptyInterfaceEncodeValue is the ValueEncoderFunc for interface{}. +// +// Deprecated: EmptyInterfaceEncodeValue is not registered by default. Use EmptyInterfaceCodec.EncodeValue instead. +func (dve DefaultValueEncoders) EmptyInterfaceEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tEmpty { + return ValueEncoderError{Name: "EmptyInterfaceEncodeValue", Types: []reflect.Type{tEmpty}, Received: val} + } + + if val.IsNil() { + return vw.WriteNull() + } + encoder, err := ec.LookupEncoder(val.Elem().Type()) + if err != nil { + return err + } + + return encoder.EncodeValue(ec, vw, val.Elem()) +} + +// ValueMarshalerEncodeValue is the ValueEncoderFunc for ValueMarshaler implementations. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) ValueMarshalerEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + // Either val or a pointer to val must implement ValueMarshaler + switch { + case !val.IsValid(): + return ValueEncoderError{Name: "ValueMarshalerEncodeValue", Types: []reflect.Type{tValueMarshaler}, Received: val} + case val.Type().Implements(tValueMarshaler): + // If ValueMarshaler is implemented on a concrete type, make sure that val isn't a nil pointer + if isImplementationNil(val, tValueMarshaler) { + return vw.WriteNull() + } + case reflect.PtrTo(val.Type()).Implements(tValueMarshaler) && val.CanAddr(): + val = val.Addr() + default: + return ValueEncoderError{Name: "ValueMarshalerEncodeValue", Types: []reflect.Type{tValueMarshaler}, Received: val} + } + + m, ok := val.Interface().(ValueMarshaler) + if !ok { + return vw.WriteNull() + } + t, data, err := m.MarshalBSONValue() + if err != nil { + return err + } + return bsonrw.Copier{}.CopyValueFromBytes(vw, t, data) +} + +// MarshalerEncodeValue is the ValueEncoderFunc for Marshaler implementations. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) MarshalerEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + // Either val or a pointer to val must implement Marshaler + switch { + case !val.IsValid(): + return ValueEncoderError{Name: "MarshalerEncodeValue", Types: []reflect.Type{tMarshaler}, Received: val} + case val.Type().Implements(tMarshaler): + // If Marshaler is implemented on a concrete type, make sure that val isn't a nil pointer + if isImplementationNil(val, tMarshaler) { + return vw.WriteNull() + } + case reflect.PtrTo(val.Type()).Implements(tMarshaler) && val.CanAddr(): + val = val.Addr() + default: + return ValueEncoderError{Name: "MarshalerEncodeValue", Types: []reflect.Type{tMarshaler}, Received: val} + } + + m, ok := val.Interface().(Marshaler) + if !ok { + return vw.WriteNull() + } + data, err := m.MarshalBSON() + if err != nil { + return err + } + return bsonrw.Copier{}.CopyValueFromBytes(vw, bsontype.EmbeddedDocument, data) +} + +// ProxyEncodeValue is the ValueEncoderFunc for Proxy implementations. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) ProxyEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + // Either val or a pointer to val must implement Proxy + switch { + case !val.IsValid(): + return ValueEncoderError{Name: "ProxyEncodeValue", Types: []reflect.Type{tProxy}, Received: val} + case val.Type().Implements(tProxy): + // If Proxy is implemented on a concrete type, make sure that val isn't a nil pointer + if isImplementationNil(val, tProxy) { + return vw.WriteNull() + } + case reflect.PtrTo(val.Type()).Implements(tProxy) && val.CanAddr(): + val = val.Addr() + default: + return ValueEncoderError{Name: "ProxyEncodeValue", Types: []reflect.Type{tProxy}, Received: val} + } + + m, ok := val.Interface().(Proxy) + if !ok { + return vw.WriteNull() + } + v, err := m.ProxyBSON() + if err != nil { + return err + } + if v == nil { + encoder, err := ec.LookupEncoder(nil) + if err != nil { + return err + } + return encoder.EncodeValue(ec, vw, reflect.ValueOf(nil)) + } + vv := reflect.ValueOf(v) + switch vv.Kind() { + case reflect.Ptr, reflect.Interface: + vv = vv.Elem() + } + encoder, err := ec.LookupEncoder(vv.Type()) + if err != nil { + return err + } + return encoder.EncodeValue(ec, vw, vv) +} + +// JavaScriptEncodeValue is the ValueEncoderFunc for the primitive.JavaScript type. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) JavaScriptEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tJavaScript { + return ValueEncoderError{Name: "JavaScriptEncodeValue", Types: []reflect.Type{tJavaScript}, Received: val} + } + + return vw.WriteJavascript(val.String()) +} + +// SymbolEncodeValue is the ValueEncoderFunc for the primitive.Symbol type. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) SymbolEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tSymbol { + return ValueEncoderError{Name: "SymbolEncodeValue", Types: []reflect.Type{tSymbol}, Received: val} + } + + return vw.WriteSymbol(val.String()) +} + +// BinaryEncodeValue is the ValueEncoderFunc for Binary. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) BinaryEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tBinary { + return ValueEncoderError{Name: "BinaryEncodeValue", Types: []reflect.Type{tBinary}, Received: val} + } + b := val.Interface().(primitive.Binary) + + return vw.WriteBinaryWithSubtype(b.Data, b.Subtype) +} + +// UndefinedEncodeValue is the ValueEncoderFunc for Undefined. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) UndefinedEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tUndefined { + return ValueEncoderError{Name: "UndefinedEncodeValue", Types: []reflect.Type{tUndefined}, Received: val} + } + + return vw.WriteUndefined() +} + +// DateTimeEncodeValue is the ValueEncoderFunc for DateTime. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) DateTimeEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tDateTime { + return ValueEncoderError{Name: "DateTimeEncodeValue", Types: []reflect.Type{tDateTime}, Received: val} + } + + return vw.WriteDateTime(val.Int()) +} + +// NullEncodeValue is the ValueEncoderFunc for Null. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) NullEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tNull { + return ValueEncoderError{Name: "NullEncodeValue", Types: []reflect.Type{tNull}, Received: val} + } + + return vw.WriteNull() +} + +// RegexEncodeValue is the ValueEncoderFunc for Regex. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) RegexEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tRegex { + return ValueEncoderError{Name: "RegexEncodeValue", Types: []reflect.Type{tRegex}, Received: val} + } + + regex := val.Interface().(primitive.Regex) + + return vw.WriteRegex(regex.Pattern, regex.Options) +} + +// DBPointerEncodeValue is the ValueEncoderFunc for DBPointer. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) DBPointerEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tDBPointer { + return ValueEncoderError{Name: "DBPointerEncodeValue", Types: []reflect.Type{tDBPointer}, Received: val} + } + + dbp := val.Interface().(primitive.DBPointer) + + return vw.WriteDBPointer(dbp.DB, dbp.Pointer) +} + +// TimestampEncodeValue is the ValueEncoderFunc for Timestamp. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) TimestampEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tTimestamp { + return ValueEncoderError{Name: "TimestampEncodeValue", Types: []reflect.Type{tTimestamp}, Received: val} + } + + ts := val.Interface().(primitive.Timestamp) + + return vw.WriteTimestamp(ts.T, ts.I) +} + +// MinKeyEncodeValue is the ValueEncoderFunc for MinKey. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) MinKeyEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tMinKey { + return ValueEncoderError{Name: "MinKeyEncodeValue", Types: []reflect.Type{tMinKey}, Received: val} + } + + return vw.WriteMinKey() +} + +// MaxKeyEncodeValue is the ValueEncoderFunc for MaxKey. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) MaxKeyEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tMaxKey { + return ValueEncoderError{Name: "MaxKeyEncodeValue", Types: []reflect.Type{tMaxKey}, Received: val} + } + + return vw.WriteMaxKey() +} + +// CoreDocumentEncodeValue is the ValueEncoderFunc for bsoncore.Document. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (DefaultValueEncoders) CoreDocumentEncodeValue(_ EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tCoreDocument { + return ValueEncoderError{Name: "CoreDocumentEncodeValue", Types: []reflect.Type{tCoreDocument}, Received: val} + } + + cdoc := val.Interface().(bsoncore.Document) + + return bsonrw.Copier{}.CopyDocumentFromBytes(vw, cdoc) +} + +// CodeWithScopeEncodeValue is the ValueEncoderFunc for CodeWithScope. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with all default +// value encoders registered. +func (dve DefaultValueEncoders) CodeWithScopeEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tCodeWithScope { + return ValueEncoderError{Name: "CodeWithScopeEncodeValue", Types: []reflect.Type{tCodeWithScope}, Received: val} + } + + cws := val.Interface().(primitive.CodeWithScope) + + dw, err := vw.WriteCodeWithScope(string(cws.Code)) + if err != nil { + return err + } + + sw := sliceWriterPool.Get().(*bsonrw.SliceWriter) + defer sliceWriterPool.Put(sw) + *sw = (*sw)[:0] + + scopeVW := bvwPool.Get(sw) + defer bvwPool.Put(scopeVW) + + encoder, err := ec.LookupEncoder(reflect.TypeOf(cws.Scope)) + if err != nil { + return err + } + + err = encoder.EncodeValue(ec, scopeVW, reflect.ValueOf(cws.Scope)) + if err != nil { + return err + } + + err = bsonrw.Copier{}.CopyBytesToDocumentWriter(dw, *sw) + if err != nil { + return err + } + return dw.WriteDocumentEnd() +} + +// isImplementationNil returns if val is a nil pointer and inter is implemented on a concrete type +func isImplementationNil(val reflect.Value, inter reflect.Type) bool { + vt := val.Type() + for vt.Kind() == reflect.Ptr { + vt = vt.Elem() + } + return vt.Implements(inter) && val.Kind() == reflect.Ptr && val.IsNil() +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/doc.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/doc.go new file mode 100644 index 0000000000..4613e5a1ec --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/doc.go @@ -0,0 +1,95 @@ +// Copyright (C) MongoDB, Inc. 2022-present. +// +// 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 + +// Package bsoncodec provides a system for encoding values to BSON representations and decoding +// values from BSON representations. This package considers both binary BSON and ExtendedJSON as +// BSON representations. The types in this package enable a flexible system for handling this +// encoding and decoding. +// +// The codec system is composed of two parts: +// +// 1) ValueEncoders and ValueDecoders that handle encoding and decoding Go values to and from BSON +// representations. +// +// 2) A Registry that holds these ValueEncoders and ValueDecoders and provides methods for +// retrieving them. +// +// # ValueEncoders and ValueDecoders +// +// The ValueEncoder interface is implemented by types that can encode a provided Go type to BSON. +// The value to encode is provided as a reflect.Value and a bsonrw.ValueWriter is used within the +// EncodeValue method to actually create the BSON representation. For convenience, ValueEncoderFunc +// is provided to allow use of a function with the correct signature as a ValueEncoder. An +// EncodeContext instance is provided to allow implementations to lookup further ValueEncoders and +// to provide configuration information. +// +// The ValueDecoder interface is the inverse of the ValueEncoder. Implementations should ensure that +// the value they receive is settable. Similar to ValueEncoderFunc, ValueDecoderFunc is provided to +// allow the use of a function with the correct signature as a ValueDecoder. A DecodeContext +// instance is provided and serves similar functionality to the EncodeContext. +// +// # Registry +// +// A Registry is a store for ValueEncoders, ValueDecoders, and a type map. See the Registry type +// documentation for examples of registering various custom encoders and decoders. A Registry can +// have three main types of codecs: +// +// 1. Type encoders/decoders - These can be registered using the RegisterTypeEncoder and +// RegisterTypeDecoder methods. The registered codec will be invoked when encoding/decoding a value +// whose type matches the registered type exactly. +// If the registered type is an interface, the codec will be invoked when encoding or decoding +// values whose type is the interface, but not for values with concrete types that implement the +// interface. +// +// 2. Hook encoders/decoders - These can be registered using the RegisterHookEncoder and +// RegisterHookDecoder methods. These methods only accept interface types and the registered codecs +// will be invoked when encoding or decoding values whose types implement the interface. An example +// of a hook defined by the driver is bson.Marshaler. The driver will call the MarshalBSON method +// for any value whose type implements bson.Marshaler, regardless of the value's concrete type. +// +// 3. Type map entries - This can be used to associate a BSON type with a Go type. These type +// associations are used when decoding into a bson.D/bson.M or a struct field of type interface{}. +// For example, by default, BSON int32 and int64 values decode as Go int32 and int64 instances, +// respectively, when decoding into a bson.D. The following code would change the behavior so these +// values decode as Go int instances instead: +// +// intType := reflect.TypeOf(int(0)) +// registry.RegisterTypeMapEntry(bsontype.Int32, intType).RegisterTypeMapEntry(bsontype.Int64, intType) +// +// 4. Kind encoder/decoders - These can be registered using the RegisterDefaultEncoder and +// RegisterDefaultDecoder methods. The registered codec will be invoked when encoding or decoding +// values whose reflect.Kind matches the registered reflect.Kind as long as the value's type doesn't +// match a registered type or hook encoder/decoder first. These methods should be used to change the +// behavior for all values for a specific kind. +// +// # Registry Lookup Procedure +// +// When looking up an encoder in a Registry, the precedence rules are as follows: +// +// 1. A type encoder registered for the exact type of the value. +// +// 2. A hook encoder registered for an interface that is implemented by the value or by a pointer to +// the value. If the value matches multiple hooks (e.g. the type implements bsoncodec.Marshaler and +// bsoncodec.ValueMarshaler), the first one registered will be selected. Note that registries +// constructed using bson.NewRegistry have driver-defined hooks registered for the +// bsoncodec.Marshaler, bsoncodec.ValueMarshaler, and bsoncodec.Proxy interfaces, so those will take +// precedence over any new hooks. +// +// 3. A kind encoder registered for the value's kind. +// +// If all of these lookups fail to find an encoder, an error of type ErrNoEncoder is returned. The +// same precedence rules apply for decoders, with the exception that an error of type ErrNoDecoder +// will be returned if no decoder is found. +// +// # DefaultValueEncoders and DefaultValueDecoders +// +// The DefaultValueEncoders and DefaultValueDecoders types provide a full set of ValueEncoders and +// ValueDecoders for handling a wide range of Go types, including all of the types within the +// primitive package. To make registering these codecs easier, a helper method on each type is +// provided. For the DefaultValueEncoders type the method is called RegisterDefaultEncoders and for +// the DefaultValueDecoders type the method is called RegisterDefaultDecoders, this method also +// handles registering type map entries for each BSON type. +package bsoncodec diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go new file mode 100644 index 0000000000..94f7dcf1eb --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go @@ -0,0 +1,159 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import ( + "reflect" + + "go.mongodb.org/mongo-driver/bson/bsonoptions" + "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/bson/bsontype" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +// EmptyInterfaceCodec is the Codec used for interface{} values. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// EmptyInterfaceCodec registered. +type EmptyInterfaceCodec struct { + // DecodeBinaryAsSlice causes DecodeValue to unmarshal BSON binary field values that are the + // "Generic" or "Old" BSON binary subtype as a Go byte slice instead of a primitive.Binary. + // + // Deprecated: Use bson.Decoder.BinaryAsSlice instead. + DecodeBinaryAsSlice bool +} + +var ( + defaultEmptyInterfaceCodec = NewEmptyInterfaceCodec() + + // Assert that defaultEmptyInterfaceCodec satisfies the typeDecoder interface, which allows it + // to be used by collection type decoders (e.g. map, slice, etc) to set individual values in a + // collection. + _ typeDecoder = defaultEmptyInterfaceCodec +) + +// NewEmptyInterfaceCodec returns a EmptyInterfaceCodec with options opts. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// EmptyInterfaceCodec registered. +func NewEmptyInterfaceCodec(opts ...*bsonoptions.EmptyInterfaceCodecOptions) *EmptyInterfaceCodec { + interfaceOpt := bsonoptions.MergeEmptyInterfaceCodecOptions(opts...) + + codec := EmptyInterfaceCodec{} + if interfaceOpt.DecodeBinaryAsSlice != nil { + codec.DecodeBinaryAsSlice = *interfaceOpt.DecodeBinaryAsSlice + } + return &codec +} + +// EncodeValue is the ValueEncoderFunc for interface{}. +func (eic EmptyInterfaceCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != tEmpty { + return ValueEncoderError{Name: "EmptyInterfaceEncodeValue", Types: []reflect.Type{tEmpty}, Received: val} + } + + if val.IsNil() { + return vw.WriteNull() + } + encoder, err := ec.LookupEncoder(val.Elem().Type()) + if err != nil { + return err + } + + return encoder.EncodeValue(ec, vw, val.Elem()) +} + +func (eic EmptyInterfaceCodec) getEmptyInterfaceDecodeType(dc DecodeContext, valueType bsontype.Type) (reflect.Type, error) { + isDocument := valueType == bsontype.Type(0) || valueType == bsontype.EmbeddedDocument + if isDocument { + if dc.defaultDocumentType != nil { + // If the bsontype is an embedded document and the DocumentType is set on the DecodeContext, then return + // that type. + return dc.defaultDocumentType, nil + } + if dc.Ancestor != nil { + // Using ancestor information rather than looking up the type map entry forces consistent decoding. + // If we're decoding into a bson.D, subdocuments should also be decoded as bson.D, even if a type map entry + // has been registered. + return dc.Ancestor, nil + } + } + + rtype, err := dc.LookupTypeMapEntry(valueType) + if err == nil { + return rtype, nil + } + + if isDocument { + // For documents, fallback to looking up a type map entry for bsontype.Type(0) or bsontype.EmbeddedDocument, + // depending on the original valueType. + var lookupType bsontype.Type + switch valueType { + case bsontype.Type(0): + lookupType = bsontype.EmbeddedDocument + case bsontype.EmbeddedDocument: + lookupType = bsontype.Type(0) + } + + rtype, err = dc.LookupTypeMapEntry(lookupType) + if err == nil { + return rtype, nil + } + } + + return nil, err +} + +func (eic EmptyInterfaceCodec) decodeType(dc DecodeContext, vr bsonrw.ValueReader, t reflect.Type) (reflect.Value, error) { + if t != tEmpty { + return emptyValue, ValueDecoderError{Name: "EmptyInterfaceDecodeValue", Types: []reflect.Type{tEmpty}, Received: reflect.Zero(t)} + } + + rtype, err := eic.getEmptyInterfaceDecodeType(dc, vr.Type()) + if err != nil { + switch vr.Type() { + case bsontype.Null: + return reflect.Zero(t), vr.ReadNull() + default: + return emptyValue, err + } + } + + decoder, err := dc.LookupDecoder(rtype) + if err != nil { + return emptyValue, err + } + + elem, err := decodeTypeOrValue(decoder, dc, vr, rtype) + if err != nil { + return emptyValue, err + } + + if (eic.DecodeBinaryAsSlice || dc.binaryAsSlice) && rtype == tBinary { + binElem := elem.Interface().(primitive.Binary) + if binElem.Subtype == bsontype.BinaryGeneric || binElem.Subtype == bsontype.BinaryBinaryOld { + elem = reflect.ValueOf(binElem.Data) + } + } + + return elem, nil +} + +// DecodeValue is the ValueDecoderFunc for interface{}. +func (eic EmptyInterfaceCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != tEmpty { + return ValueDecoderError{Name: "EmptyInterfaceDecodeValue", Types: []reflect.Type{tEmpty}, Received: val} + } + + elem, err := eic.decodeType(dc, vr, val.Type()) + if err != nil { + return err + } + + val.Set(elem) + return nil +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go new file mode 100644 index 0000000000..325c1738ab --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go @@ -0,0 +1,327 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import ( + "encoding" + "fmt" + "reflect" + "strconv" + + "go.mongodb.org/mongo-driver/bson/bsonoptions" + "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/bson/bsontype" +) + +var defaultMapCodec = NewMapCodec() + +// MapCodec is the Codec used for map values. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// MapCodec registered. +type MapCodec struct { + // DecodeZerosMap causes DecodeValue to delete any existing values from Go maps in the destination + // value passed to Decode before unmarshaling BSON documents into them. + // + // Deprecated: Use bson.Decoder.ZeroMaps instead. + DecodeZerosMap bool + + // EncodeNilAsEmpty causes EncodeValue to marshal nil Go maps as empty BSON documents instead of + // BSON null. + // + // Deprecated: Use bson.Encoder.NilMapAsEmpty instead. + EncodeNilAsEmpty bool + + // EncodeKeysWithStringer causes the Encoder to convert Go map keys to BSON document field name + // strings using fmt.Sprintf() instead of the default string conversion logic. + // + // Deprecated: Use bson.Encoder.StringifyMapKeysWithFmt instead. + EncodeKeysWithStringer bool +} + +// KeyMarshaler is the interface implemented by an object that can marshal itself into a string key. +// This applies to types used as map keys and is similar to encoding.TextMarshaler. +type KeyMarshaler interface { + MarshalKey() (key string, err error) +} + +// KeyUnmarshaler is the interface implemented by an object that can unmarshal a string representation +// of itself. This applies to types used as map keys and is similar to encoding.TextUnmarshaler. +// +// UnmarshalKey must be able to decode the form generated by MarshalKey. +// UnmarshalKey must copy the text if it wishes to retain the text +// after returning. +type KeyUnmarshaler interface { + UnmarshalKey(key string) error +} + +// NewMapCodec returns a MapCodec with options opts. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// MapCodec registered. +func NewMapCodec(opts ...*bsonoptions.MapCodecOptions) *MapCodec { + mapOpt := bsonoptions.MergeMapCodecOptions(opts...) + + codec := MapCodec{} + if mapOpt.DecodeZerosMap != nil { + codec.DecodeZerosMap = *mapOpt.DecodeZerosMap + } + if mapOpt.EncodeNilAsEmpty != nil { + codec.EncodeNilAsEmpty = *mapOpt.EncodeNilAsEmpty + } + if mapOpt.EncodeKeysWithStringer != nil { + codec.EncodeKeysWithStringer = *mapOpt.EncodeKeysWithStringer + } + return &codec +} + +// EncodeValue is the ValueEncoder for map[*]* types. +func (mc *MapCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Kind() != reflect.Map { + return ValueEncoderError{Name: "MapEncodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: val} + } + + if val.IsNil() && !mc.EncodeNilAsEmpty && !ec.nilMapAsEmpty { + // If we have a nil map but we can't WriteNull, that means we're probably trying to encode + // to a TopLevel document. We can't currently tell if this is what actually happened, but if + // there's a deeper underlying problem, the error will also be returned from WriteDocument, + // so just continue. The operations on a map reflection value are valid, so we can call + // MapKeys within mapEncodeValue without a problem. + err := vw.WriteNull() + if err == nil { + return nil + } + } + + dw, err := vw.WriteDocument() + if err != nil { + return err + } + + return mc.mapEncodeValue(ec, dw, val, nil) +} + +// mapEncodeValue handles encoding of the values of a map. The collisionFn returns +// true if the provided key exists, this is mainly used for inline maps in the +// struct codec. +func (mc *MapCodec) mapEncodeValue(ec EncodeContext, dw bsonrw.DocumentWriter, val reflect.Value, collisionFn func(string) bool) error { + + elemType := val.Type().Elem() + encoder, err := ec.LookupEncoder(elemType) + if err != nil && elemType.Kind() != reflect.Interface { + return err + } + + keys := val.MapKeys() + for _, key := range keys { + keyStr, err := mc.encodeKey(key, ec.stringifyMapKeysWithFmt) + if err != nil { + return err + } + + if collisionFn != nil && collisionFn(keyStr) { + return fmt.Errorf("Key %s of inlined map conflicts with a struct field name", key) + } + + currEncoder, currVal, lookupErr := defaultValueEncoders.lookupElementEncoder(ec, encoder, val.MapIndex(key)) + if lookupErr != nil && lookupErr != errInvalidValue { + return lookupErr + } + + vw, err := dw.WriteDocumentElement(keyStr) + if err != nil { + return err + } + + if lookupErr == errInvalidValue { + err = vw.WriteNull() + if err != nil { + return err + } + continue + } + + err = currEncoder.EncodeValue(ec, vw, currVal) + if err != nil { + return err + } + } + + return dw.WriteDocumentEnd() +} + +// DecodeValue is the ValueDecoder for map[string/decimal]* types. +func (mc *MapCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if val.Kind() != reflect.Map || (!val.CanSet() && val.IsNil()) { + return ValueDecoderError{Name: "MapDecodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: val} + } + + switch vrType := vr.Type(); vrType { + case bsontype.Type(0), bsontype.EmbeddedDocument: + case bsontype.Null: + val.Set(reflect.Zero(val.Type())) + return vr.ReadNull() + case bsontype.Undefined: + val.Set(reflect.Zero(val.Type())) + return vr.ReadUndefined() + default: + return fmt.Errorf("cannot decode %v into a %s", vrType, val.Type()) + } + + dr, err := vr.ReadDocument() + if err != nil { + return err + } + + if val.IsNil() { + val.Set(reflect.MakeMap(val.Type())) + } + + if val.Len() > 0 && (mc.DecodeZerosMap || dc.zeroMaps) { + clearMap(val) + } + + eType := val.Type().Elem() + decoder, err := dc.LookupDecoder(eType) + if err != nil { + return err + } + eTypeDecoder, _ := decoder.(typeDecoder) + + if eType == tEmpty { + dc.Ancestor = val.Type() + } + + keyType := val.Type().Key() + + for { + key, vr, err := dr.ReadElement() + if err == bsonrw.ErrEOD { + break + } + if err != nil { + return err + } + + k, err := mc.decodeKey(key, keyType) + if err != nil { + return err + } + + elem, err := decodeTypeOrValueWithInfo(decoder, eTypeDecoder, dc, vr, eType, true) + if err != nil { + return newDecodeError(key, err) + } + + val.SetMapIndex(k, elem) + } + return nil +} + +func clearMap(m reflect.Value) { + var none reflect.Value + for _, k := range m.MapKeys() { + m.SetMapIndex(k, none) + } +} + +func (mc *MapCodec) encodeKey(val reflect.Value, encodeKeysWithStringer bool) (string, error) { + if mc.EncodeKeysWithStringer || encodeKeysWithStringer { + return fmt.Sprint(val), nil + } + + // keys of any string type are used directly + if val.Kind() == reflect.String { + return val.String(), nil + } + // KeyMarshalers are marshaled + if km, ok := val.Interface().(KeyMarshaler); ok { + if val.Kind() == reflect.Ptr && val.IsNil() { + return "", nil + } + buf, err := km.MarshalKey() + if err == nil { + return buf, nil + } + return "", err + } + // keys implement encoding.TextMarshaler are marshaled. + if km, ok := val.Interface().(encoding.TextMarshaler); ok { + if val.Kind() == reflect.Ptr && val.IsNil() { + return "", nil + } + + buf, err := km.MarshalText() + if err != nil { + return "", err + } + + return string(buf), nil + } + + switch val.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return strconv.FormatInt(val.Int(), 10), nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return strconv.FormatUint(val.Uint(), 10), nil + } + return "", fmt.Errorf("unsupported key type: %v", val.Type()) +} + +var keyUnmarshalerType = reflect.TypeOf((*KeyUnmarshaler)(nil)).Elem() +var textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() + +func (mc *MapCodec) decodeKey(key string, keyType reflect.Type) (reflect.Value, error) { + keyVal := reflect.ValueOf(key) + var err error + switch { + // First, if EncodeKeysWithStringer is not enabled, try to decode withKeyUnmarshaler + case !mc.EncodeKeysWithStringer && reflect.PtrTo(keyType).Implements(keyUnmarshalerType): + keyVal = reflect.New(keyType) + v := keyVal.Interface().(KeyUnmarshaler) + err = v.UnmarshalKey(key) + keyVal = keyVal.Elem() + // Try to decode encoding.TextUnmarshalers. + case reflect.PtrTo(keyType).Implements(textUnmarshalerType): + keyVal = reflect.New(keyType) + v := keyVal.Interface().(encoding.TextUnmarshaler) + err = v.UnmarshalText([]byte(key)) + keyVal = keyVal.Elem() + // Otherwise, go to type specific behavior + default: + switch keyType.Kind() { + case reflect.String: + keyVal = reflect.ValueOf(key).Convert(keyType) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + n, parseErr := strconv.ParseInt(key, 10, 64) + if parseErr != nil || reflect.Zero(keyType).OverflowInt(n) { + err = fmt.Errorf("failed to unmarshal number key %v", key) + } + keyVal = reflect.ValueOf(n).Convert(keyType) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + n, parseErr := strconv.ParseUint(key, 10, 64) + if parseErr != nil || reflect.Zero(keyType).OverflowUint(n) { + err = fmt.Errorf("failed to unmarshal number key %v", key) + break + } + keyVal = reflect.ValueOf(n).Convert(keyType) + case reflect.Float32, reflect.Float64: + if mc.EncodeKeysWithStringer { + parsed, err := strconv.ParseFloat(key, 64) + if err != nil { + return keyVal, fmt.Errorf("Map key is defined to be a decimal type (%v) but got error %v", keyType.Kind(), err) + } + keyVal = reflect.ValueOf(parsed) + break + } + fallthrough + default: + return keyVal, fmt.Errorf("unsupported key type: %v", keyType) + } + } + return keyVal, err +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/mode.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/mode.go new file mode 100644 index 0000000000..fbd9f0a9e9 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/mode.go @@ -0,0 +1,65 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import "fmt" + +type mode int + +const ( + _ mode = iota + mTopLevel + mDocument + mArray + mValue + mElement + mCodeWithScope + mSpacer +) + +func (m mode) String() string { + var str string + + switch m { + case mTopLevel: + str = "TopLevel" + case mDocument: + str = "DocumentMode" + case mArray: + str = "ArrayMode" + case mValue: + str = "ValueMode" + case mElement: + str = "ElementMode" + case mCodeWithScope: + str = "CodeWithScopeMode" + case mSpacer: + str = "CodeWithScopeSpacerFrame" + default: + str = "UnknownMode" + } + + return str +} + +// TransitionError is an error returned when an invalid progressing a +// ValueReader or ValueWriter state machine occurs. +type TransitionError struct { + parent mode + current mode + destination mode +} + +func (te TransitionError) Error() string { + if te.destination == mode(0) { + return fmt.Sprintf("invalid state transition: cannot read/write value while in %s", te.current) + } + if te.parent == mode(0) { + return fmt.Sprintf("invalid state transition: %s -> %s", te.current, te.destination) + } + return fmt.Sprintf("invalid state transition: %s -> %s; parent %s", te.current, te.destination, te.parent) +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go new file mode 100644 index 0000000000..a1bf9c3e2b --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go @@ -0,0 +1,115 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import ( + "reflect" + "sync" + + "go.mongodb.org/mongo-driver/bson/bsonrw" + "go.mongodb.org/mongo-driver/bson/bsontype" +) + +var _ ValueEncoder = &PointerCodec{} +var _ ValueDecoder = &PointerCodec{} + +// PointerCodec is the Codec used for pointers. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// PointerCodec registered. +type PointerCodec struct { + ecache map[reflect.Type]ValueEncoder + dcache map[reflect.Type]ValueDecoder + l sync.RWMutex +} + +// NewPointerCodec returns a PointerCodec that has been initialized. +// +// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the +// PointerCodec registered. +func NewPointerCodec() *PointerCodec { + return &PointerCodec{ + ecache: make(map[reflect.Type]ValueEncoder), + dcache: make(map[reflect.Type]ValueDecoder), + } +} + +// EncodeValue handles encoding a pointer by either encoding it to BSON Null if the pointer is nil +// or looking up an encoder for the type of value the pointer points to. +func (pc *PointerCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if val.Kind() != reflect.Ptr { + if !val.IsValid() { + return vw.WriteNull() + } + return ValueEncoderError{Name: "PointerCodec.EncodeValue", Kinds: []reflect.Kind{reflect.Ptr}, Received: val} + } + + if val.IsNil() { + return vw.WriteNull() + } + + pc.l.RLock() + enc, ok := pc.ecache[val.Type()] + pc.l.RUnlock() + if ok { + if enc == nil { + return ErrNoEncoder{Type: val.Type()} + } + return enc.EncodeValue(ec, vw, val.Elem()) + } + + enc, err := ec.LookupEncoder(val.Type().Elem()) + pc.l.Lock() + pc.ecache[val.Type()] = enc + pc.l.Unlock() + if err != nil { + return err + } + + return enc.EncodeValue(ec, vw, val.Elem()) +} + +// DecodeValue handles decoding a pointer by looking up a decoder for the type it points to and +// using that to decode. If the BSON value is Null, this method will set the pointer to nil. +func (pc *PointerCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Kind() != reflect.Ptr { + return ValueDecoderError{Name: "PointerCodec.DecodeValue", Kinds: []reflect.Kind{reflect.Ptr}, Received: val} + } + + if vr.Type() == bsontype.Null { + val.Set(reflect.Zero(val.Type())) + return vr.ReadNull() + } + if vr.Type() == bsontype.Undefined { + val.Set(reflect.Zero(val.Type())) + return vr.ReadUndefined() + } + + if val.IsNil() { + val.Set(reflect.New(val.Type().Elem())) + } + + pc.l.RLock() + dec, ok := pc.dcache[val.Type()] + pc.l.RUnlock() + if ok { + if dec == nil { + return ErrNoDecoder{Type: val.Type()} + } + return dec.DecodeValue(dc, vr, val.Elem()) + } + + dec, err := dc.LookupDecoder(val.Type().Elem()) + pc.l.Lock() + pc.dcache[val.Type()] = dec + pc.l.Unlock() + if err != nil { + return err + } + + return dec.DecodeValue(dc, vr, val.Elem()) +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/proxy.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/proxy.go new file mode 100644 index 0000000000..4cf2b01ab4 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/proxy.go @@ -0,0 +1,14 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +// Proxy is an interface implemented by types that cannot themselves be directly encoded. Types +// that implement this interface with have ProxyBSON called during the encoding process and that +// value will be encoded in place for the implementer. +type Proxy interface { + ProxyBSON() (interface{}, error) +} diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go new file mode 100644 index 0000000000..930de28490 --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go @@ -0,0 +1,579 @@ +// Copyright (C) MongoDB, Inc. 2017-present. +// +// 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 + +package bsoncodec + +import ( + "errors" + "fmt" + "reflect" + "sync" + + "go.mongodb.org/mongo-driver/bson/bsontype" +) + +// ErrNilType is returned when nil is passed to either LookupEncoder or LookupDecoder. +// +// Deprecated: ErrNilType will not be supported in Go Driver 2.0. +var ErrNilType = errors.New("cannot perform a decoder lookup on