Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/bsonutil/bsonutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ func RawArrayToDocuments(arr bson.RawArray) []bson.Raw {
return out
}

// RawToInterfaces takes one or many bson.Raw documents and returns them as a []interface{}.
func RawToInterfaces(docs ...bson.Raw) []interface{} {
out := make([]interface{}, len(docs))
// RawToInterfaces takes one or many bson.Raw documents and returns them as a []any.
func RawToInterfaces(docs ...bson.Raw) []any {
out := make([]any, len(docs))
for i := range docs {
out[i] = docs[i]
}
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/benchmark/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ type poplarTestArtifact struct {
// poplarTestMetrics was copied from
// https://github.com/evergreen-ci/poplar/blob/8d03d2bacde0897cedd73ed79ddc167ed1ed4c77/report.go#L124
type poplarTestMetrics struct {
Name string `bson:"name" json:"name" yaml:"name"`
Version int `bson:"version,omitempty" json:"version,omitempty" yaml:"version,omitempty"`
Type string `bson:"type" json:"type" yaml:"type"`
Value interface{} `bson:"value" json:"value" yaml:"value"`
Name string `bson:"name" json:"name" yaml:"name"`
Version int `bson:"version,omitempty" json:"version,omitempty" yaml:"version,omitempty"`
Type string `bson:"type" json:"type" yaml:"type"`
Value any `bson:"value" json:"value" yaml:"value"`
}
2 changes: 1 addition & 1 deletion internal/cmd/testkms/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {
}
defer func() { _ = keyVaultClient.Disconnect(context.Background()) }()

kmsProvidersMap := map[string]map[string]interface{}{
kmsProvidersMap := map[string]map[string]any{
provider: {},
}
ceOpts := options.ClientEncryption().SetKmsProviders(kmsProvidersMap).SetKeyVaultNamespace("keyvault.datakeys")
Expand Down
4 changes: 2 additions & 2 deletions internal/codecutil/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var ErrNilValue = errors.New("value is nil")
// MarshalError is returned when attempting to transform a value into a document
// results in an error.
type MarshalError struct {
Value interface{}
Value any
Err error
}

Expand All @@ -39,7 +39,7 @@ type EncoderFn func(io.Writer) *bson.Encoder

// MarshalValue will attempt to encode the value with the encoder returned by
// the encoder function.
func MarshalValue(val interface{}, encFn EncoderFn) (bsoncore.Value, error) {
func MarshalValue(val any, encFn EncoderFn) (bsoncore.Value, error) {
// If the val is already a bsoncore.Value, then do nothing.
if bval, ok := val.(bsoncore.Value); ok {
return bval, nil
Expand Down
4 changes: 2 additions & 2 deletions internal/codecutil/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestMarshalValue(t *testing.T) {

tests := []struct {
name string
val interface{}
val any
registry *bson.Registry
encFn EncoderFn
want string
Expand All @@ -49,7 +49,7 @@ func TestMarshalValue(t *testing.T) {
},
{
name: "map",
val: map[string]interface{}{"foo": "bar"},
val: map[string]any{"foo": "bar"},
want: `{"foo": "bar"}`,
encFn: testEncFn(t),
},
Expand Down
16 changes: 8 additions & 8 deletions internal/csot/csot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,55 +157,55 @@ func TestWithTimeout(t *testing.T) {
timeout *time.Duration
wantTimeout time.Duration
wantDeadline bool
wantValues []interface{}
wantValues []any
}{
{
name: "deadline set with non-zero timeout",
parent: newTestContext(t, 1),
timeout: ptrutil.Ptr(time.Duration(2)),
wantTimeout: 1,
wantDeadline: true,
wantValues: []interface{}{},
wantValues: []any{},
},
{
name: "deadline set with zero timeout",
parent: newTestContext(t, 1),
timeout: ptrutil.Ptr(time.Duration(0)),
wantTimeout: 1,
wantDeadline: true,
wantValues: []interface{}{},
wantValues: []any{},
},
{
name: "deadline set with nil timeout",
parent: newTestContext(t, 1),
timeout: nil,
wantTimeout: 1,
wantDeadline: true,
wantValues: []interface{}{},
wantValues: []any{},
},
{
name: "deadline unset with non-zero timeout",
parent: context.Background(),
timeout: ptrutil.Ptr(time.Duration(1)),
wantTimeout: 1,
wantDeadline: true,
wantValues: []interface{}{},
wantValues: []any{},
},
{
name: "deadline unset with zero timeout",
parent: context.Background(),
timeout: ptrutil.Ptr(time.Duration(0)),
wantTimeout: 0,
wantDeadline: false,
wantValues: []interface{}{clientLevel{}},
wantValues: []any{clientLevel{}},
},
{
name: "deadline unset with nil timeout",
parent: context.Background(),
timeout: nil,
wantTimeout: 0,
wantDeadline: false,
wantValues: []interface{}{},
wantValues: []any{},
},
{
// If "clientLevel" has been set, but a new timeout is applied
Expand All @@ -216,7 +216,7 @@ func TestWithTimeout(t *testing.T) {
timeout: ptrutil.Ptr(time.Duration(1)),
wantTimeout: 0,
wantDeadline: false,
wantValues: []interface{}{},
wantValues: []any{},
},
}

Expand Down
38 changes: 19 additions & 19 deletions internal/docexamples/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func InsertExamples(t *testing.T, db *mongo.Database) {

result, err := coll.InsertMany(
context.TODO(),
[]interface{}{
[]any{
bson.D{
{"item", "journal"},
{"qty", int32(25)},
Expand Down Expand Up @@ -149,7 +149,7 @@ func QueryToplevelFieldsExamples(t *testing.T, db *mongo.Database) {
{
// Start Example 6

docs := []interface{}{
docs := []any{
bson.D{
{"item", "journal"},
{"qty", 25},
Expand Down Expand Up @@ -318,7 +318,7 @@ func QueryEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
{
// Start Example 14

docs := []interface{}{
docs := []any{
bson.D{
{"item", "journal"},
{"qty", 25},
Expand Down Expand Up @@ -480,7 +480,7 @@ func QueryArraysExamples(t *testing.T, db *mongo.Database) {
{
// Start Example 20

docs := []interface{}{
docs := []any{
bson.D{
{"item", "journal"},
{"qty", 25},
Expand Down Expand Up @@ -667,7 +667,7 @@ func QueryArrayEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
{
// Start Example 29

docs := []interface{}{
docs := []any{
bson.D{
{"item", "journal"},
{"instock", bson.A{
Expand Down Expand Up @@ -897,7 +897,7 @@ func QueryNullMissingFieldsExamples(t *testing.T, db *mongo.Database) {
{
// Start Example 38

docs := []interface{}{
docs := []any{
bson.D{
{"_id", 1},
{"item", nil},
Expand Down Expand Up @@ -976,7 +976,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
{
// Start Example 42

docs := []interface{}{
docs := []any{
bson.D{
{"item", "journal"},
{"status", "A"},
Expand Down Expand Up @@ -1361,7 +1361,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
{
// Start Example 51

docs := []interface{}{
docs := []any{
bson.D{
{"item", "canvas"},
{"qty", 100},
Expand Down Expand Up @@ -1641,7 +1641,7 @@ func DeleteExamples(t *testing.T, db *mongo.Database) {

{
// Start Example 55
docs := []interface{}{
docs := []any{
bson.D{
{"item", "journal"},
{"qty", 25},
Expand Down Expand Up @@ -1985,7 +1985,7 @@ func WithTransactionExample(ctx context.Context) error {
barColl := client.Database("mydb1").Collection("bar", wcMajorityCollectionOpts)

// Step 1: Define the callback that specifies the sequence of operations to perform inside the transaction.
callback := func(sesctx context.Context) (interface{}, error) {
callback := func(sesctx context.Context) (any, error) {
// Important: You must pass sesctx as the Context parameter to the operations for them to be executed in the
// transaction.
if _, err := fooColl.InsertOne(sesctx, bson.D{{"abc", 1}}); err != nil {
Expand Down Expand Up @@ -2145,7 +2145,7 @@ func AggregationExamples(t *testing.T, db *mongo.Database) {
date20180205 := parseDate(t, "2018-02-05T06:03:00.000Z")
date20180111 := parseDate(t, "2018-01-11T07:15:00.000Z")

sales := []interface{}{
sales := []any{
bson.D{
{"date", date20180208},
{"items", bson.A{
Expand Down Expand Up @@ -2242,7 +2242,7 @@ func AggregationExamples(t *testing.T, db *mongo.Database) {
}},
},
}
airlines := []interface{}{
airlines := []any{
bson.D{
{"airline", 17},
{"name", "Air Canada"},
Expand Down Expand Up @@ -2314,7 +2314,7 @@ func AggregationExamples(t *testing.T, db *mongo.Database) {
{"base", "CYS"},
},
}
airAlliances := []interface{}{
airAlliances := []any{
bson.D{
{"name", "Star Alliance"},
{"airlines", bson.A{
Expand Down Expand Up @@ -2670,7 +2670,7 @@ func IndexExamples(t *testing.T, db *mongo.Database) {
err = restaurantsColl.Drop(ctx)
assert.NoError(t, err)

records := []interface{}{
records := []any{
bson.D{
{"student", "Marty McFly"},
{"classYear", 1986},
Expand All @@ -2691,7 +2691,7 @@ func IndexExamples(t *testing.T, db *mongo.Database) {
{"score", 99.9},
},
}
restaurants := []interface{}{
restaurants := []any{
bson.D{
{"name", "Chez Panisse"},
{"cuisine", "American/French"},
Expand Down Expand Up @@ -2884,7 +2884,7 @@ func StableAPIStrictCountExample(t *testing.T) {
// Start Versioned API Example 5

coll := client.Database("db").Collection("sales")
docs := []interface{}{
docs := []any{
bson.D{{"_id", 1}, {"item", "abc"}, {"price", 10}, {"quantity", 2}, {"date", "2021-01-01T08:00:00Z"}},
bson.D{{"_id", 2}, {"item", "jkl"}, {"price", 20}, {"quantity", 1}, {"date", "2021-02-03T09:00:00Z"}},
bson.D{{"_id", 3}, {"item", "xyz"}, {"price", 5}, {"quantity", 5}, {"date", "2021-02-03T09:05:00Z"}},
Expand Down Expand Up @@ -2938,7 +2938,7 @@ func StableAPIExamples() {

func insertSnapshotQueryTestData(mt *mtest.T) {
catColl := mt.CreateCollection(mtest.Collection{Name: "cats"}, true)
_, err := catColl.InsertMany(context.Background(), []interface{}{
_, err := catColl.InsertMany(context.Background(), []any{
bson.D{
{"adoptable", false},
{"name", "Miyagi"},
Expand All @@ -2955,7 +2955,7 @@ func insertSnapshotQueryTestData(mt *mtest.T) {
assert.NoError(mt, err)

dogColl := mt.CreateCollection(mtest.Collection{Name: "dogs"}, true)
_, err = dogColl.InsertMany(context.Background(), []interface{}{
_, err = dogColl.InsertMany(context.Background(), []any{
bson.D{
{"adoptable", true},
{"name", "Cormac"},
Expand All @@ -2972,7 +2972,7 @@ func insertSnapshotQueryTestData(mt *mtest.T) {
assert.NoError(mt, err)

salesColl := mt.CreateCollection(mtest.Collection{Name: "sales"}, true)
_, err = salesColl.InsertMany(context.Background(), []interface{}{
_, err = salesColl.InsertMany(context.Background(), []any{
bson.D{
{"shoeType", "hiking boot"},
{"price", 30.0},
Expand Down
2 changes: 1 addition & 1 deletion internal/errutil/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (e *joinError) Is(target error) bool {
}

// As calls [errors.As] with the first error in the slice.
func (e *joinError) As(target interface{}) bool {
func (e *joinError) As(target any) bool {
if len(e.errs) == 0 {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion internal/errutil/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func TestJoin_ErrorsAs(t *testing.T) {
tests := []struct {
desc string
errs []error
target interface{}
target any
}{{
desc: "one error with a matching target",
errs: []error{err1},
Expand Down
6 changes: 3 additions & 3 deletions internal/failpoint/failpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const (
// https://github.com/mongodb/specifications/tree/HEAD/source/transactions/tests#server-fail-point
type FailPoint struct {
ConfigureFailPoint string `bson:"configureFailPoint"`
// Mode should be a string, FailPointMode, or map[string]interface{}
Mode interface{} `bson:"mode"`
Data Data `bson:"data"`
// Mode should be a string, FailPointMode, or map[string]any
Mode any `bson:"mode"`
Data Data `bson:"data"`
}

// Mode configures when a fail point will be enabled. It is used to set the
Expand Down
Loading
Loading