Skip to content

Commit 4dcada6

Browse files
author
Divjot Arora
committed
GODRIVER-1736 Fix deprecation notice formats (#503)
1 parent c3326fd commit 4dcada6

File tree

9 files changed

+139
-68
lines changed

9 files changed

+139
-68
lines changed

bson/bsoncodec/default_value_decoders.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ func (dvd DefaultValueDecoders) IntDecodeValue(dc DecodeContext, vr bsonrw.Value
238238
}
239239

240240
// UintDecodeValue is the ValueDecoderFunc for uint types.
241-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
242-
// future. Use UIntCodec.DecodeValue instead.
241+
//
242+
// Deprecated: UintDecodeValue is not registered by default. Use UintCodec.DecodeValue instead.
243243
func (dvd DefaultValueDecoders) UintDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
244244
var i64 int64
245245
var err error
@@ -385,8 +385,8 @@ func (dvd DefaultValueDecoders) FloatDecodeValue(ec DecodeContext, vr bsonrw.Val
385385
}
386386

387387
// StringDecodeValue is the ValueDecoderFunc for string types.
388-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
389-
// future. Use StringCodec.DecodeValue instead.
388+
//
389+
// Deprecated: StringDecodeValue is not registered by default. Use StringCodec.DecodeValue instead.
390390
func (dvd DefaultValueDecoders) StringDecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
391391
var str string
392392
var err error
@@ -851,8 +851,8 @@ func (dvd DefaultValueDecoders) URLDecodeValue(dc DecodeContext, vr bsonrw.Value
851851
}
852852

853853
// TimeDecodeValue is the ValueDecoderFunc for time.Time.
854-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
855-
// future. Use Time.DecodeValue instead.
854+
//
855+
// Deprecated: TimeDecodeValue is not registered by default. Use TimeCodec.DecodeValue instead.
856856
func (dvd DefaultValueDecoders) TimeDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
857857
if vr.Type() != bsontype.DateTime {
858858
return fmt.Errorf("cannot decode %v into a time.Time", vr.Type())
@@ -872,8 +872,8 @@ func (dvd DefaultValueDecoders) TimeDecodeValue(dc DecodeContext, vr bsonrw.Valu
872872
}
873873

874874
// ByteSliceDecodeValue is the ValueDecoderFunc for []byte.
875-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
876-
// future. Use ByteSliceCodec.DecodeValue instead.
875+
//
876+
// Deprecated: ByteSliceDecodeValue is not registered by default. Use ByteSliceCodec.DecodeValue instead.
877877
func (dvd DefaultValueDecoders) ByteSliceDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
878878
if vr.Type() != bsontype.Binary && vr.Type() != bsontype.Null {
879879
return fmt.Errorf("cannot decode %v into a []byte", vr.Type())
@@ -901,8 +901,8 @@ func (dvd DefaultValueDecoders) ByteSliceDecodeValue(dc DecodeContext, vr bsonrw
901901
}
902902

903903
// MapDecodeValue is the ValueDecoderFunc for map[string]* types.
904-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
905-
// future. Use Map.DecodeValue instead.
904+
//
905+
// Deprecated: MapDecodeValue is not registered by default. Use MapCodec.DecodeValue instead.
906906
func (dvd DefaultValueDecoders) MapDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
907907
if !val.CanSet() || val.Kind() != reflect.Map || val.Type().Key().Kind() != reflect.String {
908908
return ValueDecoderError{Name: "MapDecodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: val}
@@ -1025,8 +1025,8 @@ func (dvd DefaultValueDecoders) ArrayDecodeValue(dc DecodeContext, vr bsonrw.Val
10251025
}
10261026

10271027
// SliceDecodeValue is the ValueDecoderFunc for slice types.
1028-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
1029-
// future. Use SliceCodec.DecodeValue instead.
1028+
//
1029+
// Deprecated: SliceDecodeValue is not registered by default. Use SliceCodec.DecodeValue instead.
10301030
func (dvd DefaultValueDecoders) SliceDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
10311031
if !val.CanSet() || val.Kind() != reflect.Slice {
10321032
return ValueDecoderError{Name: "SliceDecodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: val}
@@ -1136,8 +1136,8 @@ func (dvd DefaultValueDecoders) UnmarshalerDecodeValue(dc DecodeContext, vr bson
11361136
}
11371137

11381138
// EmptyInterfaceDecodeValue is the ValueDecoderFunc for interface{}.
1139-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
1140-
// future. Use EmptyInterfaceCodec.DecodeValue instead.
1139+
//
1140+
// Deprecated: EmptyInterfaceDecodeValue is not registered by default. Use EmptyInterfaceCodec.DecodeValue instead.
11411141
func (dvd DefaultValueDecoders) EmptyInterfaceDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
11421142
if !val.CanSet() || val.Type() != tEmpty {
11431143
return ValueDecoderError{Name: "EmptyInterfaceDecodeValue", Types: []reflect.Type{tEmpty}, Received: val}

bson/bsoncodec/default_value_encoders.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ func (dve DefaultValueEncoders) IntEncodeValue(ec EncodeContext, vw bsonrw.Value
150150
}
151151

152152
// UintEncodeValue is the ValueEncoderFunc for uint types.
153-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
154-
// future. Use UIntCodec.EncodeValue instead.
153+
//
154+
// Deprecated: UintEncodeValue is not registered by default. Use UintCodec.EncodeValue instead.
155155
func (dve DefaultValueEncoders) UintEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
156156
switch val.Kind() {
157157
case reflect.Uint8, reflect.Uint16:
@@ -185,8 +185,8 @@ func (dve DefaultValueEncoders) FloatEncodeValue(ec EncodeContext, vw bsonrw.Val
185185
}
186186

187187
// StringEncodeValue is the ValueEncoderFunc for string types.
188-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
189-
// future. Use StringCodec.EncodeValue instead.
188+
//
189+
// Deprecated: StringEncodeValue is not registered by default. Use StringCodec.EncodeValue instead.
190190
func (dve DefaultValueEncoders) StringEncodeValue(ectx EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
191191
if val.Kind() != reflect.String {
192192
return ValueEncoderError{
@@ -245,8 +245,8 @@ func (dve DefaultValueEncoders) URLEncodeValue(ec EncodeContext, vw bsonrw.Value
245245
}
246246

247247
// TimeEncodeValue is the ValueEncoderFunc for time.TIme.
248-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
249-
// future. Use TimeCodec.EncodeValue instead.
248+
//
249+
// Deprecated: TimeEncodeValue is not registered by default. Use TimeCodec.EncodeValue instead.
250250
func (dve DefaultValueEncoders) TimeEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
251251
if !val.IsValid() || val.Type() != tTime {
252252
return ValueEncoderError{Name: "TimeEncodeValue", Types: []reflect.Type{tTime}, Received: val}
@@ -257,8 +257,8 @@ func (dve DefaultValueEncoders) TimeEncodeValue(ec EncodeContext, vw bsonrw.Valu
257257
}
258258

259259
// ByteSliceEncodeValue is the ValueEncoderFunc for []byte.
260-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
261-
// future. Use ByteSliceCodec.EncodeValue instead.
260+
//
261+
// Deprecated: ByteSliceEncodeValue is not registered by default. Use ByteSliceCodec.EncodeValue instead.
262262
func (dve DefaultValueEncoders) ByteSliceEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
263263
if !val.IsValid() || val.Type() != tByteSlice {
264264
return ValueEncoderError{Name: "ByteSliceEncodeValue", Types: []reflect.Type{tByteSlice}, Received: val}
@@ -270,8 +270,8 @@ func (dve DefaultValueEncoders) ByteSliceEncodeValue(ec EncodeContext, vw bsonrw
270270
}
271271

272272
// MapEncodeValue is the ValueEncoderFunc for map[string]* types.
273-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
274-
// future. Use MapCodec.EncodeValue instead.
273+
//
274+
// Deprecated: MapEncodeValue is not registered by default. Use MapCodec.EncodeValue instead.
275275
func (dve DefaultValueEncoders) MapEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
276276
if !val.IsValid() || val.Kind() != reflect.Map || val.Type().Key().Kind() != reflect.String {
277277
return ValueEncoderError{Name: "MapEncodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: val}
@@ -420,8 +420,8 @@ func (dve DefaultValueEncoders) ArrayEncodeValue(ec EncodeContext, vw bsonrw.Val
420420
}
421421

422422
// SliceEncodeValue is the ValueEncoderFunc for slice types.
423-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
424-
// future. Use SliceCodec.EncodeValue instead.
423+
//
424+
// Deprecated: SliceEncodeValue is not registered by default. Use SliceCodec.EncodeValue instead.
425425
func (dve DefaultValueEncoders) SliceEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
426426
if !val.IsValid() || val.Kind() != reflect.Slice {
427427
return ValueEncoderError{Name: "SliceEncodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: val}
@@ -502,8 +502,8 @@ func (dve DefaultValueEncoders) lookupElementEncoder(ec EncodeContext, origEncod
502502
}
503503

504504
// EmptyInterfaceEncodeValue is the ValueEncoderFunc for interface{}.
505-
// This method is deprecated and does not have any stability guarantees. It may be removed in the
506-
// future. Use EmptyInterfaceCodec.EncodeValue instead.
505+
//
506+
// Deprecated: EmptyInterfaceEncodeValue is not registered by default. Use EmptyInterfaceCodec.EncodeValue instead.
507507
func (dve DefaultValueEncoders) EmptyInterfaceEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
508508
if !val.IsValid() || val.Type() != tEmpty {
509509
return ValueEncoderError{Name: "EmptyInterfaceEncodeValue", Types: []reflect.Type{tEmpty}, Received: val}

bson/bsoncodec/registry.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@ func (rb *RegistryBuilder) RegisterHookDecoder(t reflect.Type, dec ValueDecoder)
187187
return rb
188188
}
189189

190-
// RegisterEncoder has been deprecated and will be removed in a future major version release. Use RegisterTypeEncoder
191-
// or RegisterHookEncoder instead.
190+
// RegisterEncoder registers the provided type and encoder pair.
191+
//
192+
// Deprecated: Use RegisterTypeEncoder or RegisterHookEncoder instead.
192193
func (rb *RegistryBuilder) RegisterEncoder(t reflect.Type, enc ValueEncoder) *RegistryBuilder {
193194
if t == tEmpty {
194195
rb.typeEncoders[t] = enc
@@ -210,8 +211,9 @@ func (rb *RegistryBuilder) RegisterEncoder(t reflect.Type, enc ValueEncoder) *Re
210211
return rb
211212
}
212213

213-
// RegisterDecoder has been deprecated and will be removed in a future major version release. Use RegisterTypeDecoder
214-
// or RegisterHookDecoder instead.
214+
// RegisterDecoder registers the provided type and decoder pair.
215+
//
216+
// Deprecated: Use RegisterTypeDecoder or RegisterHookDecoder instead.
215217
func (rb *RegistryBuilder) RegisterDecoder(t reflect.Type, dec ValueDecoder) *RegistryBuilder {
216218
if t == nil {
217219
rb.typeDecoders[nil] = dec

mongo/cursor.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,10 @@ func (c *Cursor) closeImplicitSession() {
269269
}
270270

271271
// BatchCursorFromCursor returns a driver.BatchCursor for the given Cursor. If there is no underlying
272-
// driver.BatchCursor, nil is returned. This method is deprecated and does not have any stability guarantees. It may be
273-
// removed in the future.
272+
// driver.BatchCursor, nil is returned.
273+
//
274+
// Deprecated: This is an unstable function because the driver.BatchCursor type exists in the "x" package. Neither this
275+
// function nor the driver.BatchCursor type should be used by applications and may be changed or removed in any release.
274276
func BatchCursorFromCursor(c *Cursor) *driver.BatchCursor {
275277
bc, _ := c.bc.(*driver.BatchCursor)
276278
return bc

mongo/index_options_builder.go

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,125 +10,167 @@ import (
1010
"go.mongodb.org/mongo-driver/bson"
1111
)
1212

13-
// IndexOptionsBuilder is deprecated and unused. Use mongo/options.IndexOptions instead.
13+
// IndexOptionsBuilder specifies options for a new index.
14+
//
15+
// Deprecated: Use the IndexOptions type in the mongo/options package instead.
1416
type IndexOptionsBuilder struct {
1517
document bson.D
1618
}
1719

18-
// NewIndexOptionsBuilder is deprecated.
20+
// NewIndexOptionsBuilder creates a new IndexOptionsBuilder.
21+
//
22+
// Deprecated: Use the Index function in mongo/options instead.
1923
func NewIndexOptionsBuilder() *IndexOptionsBuilder {
2024
return &IndexOptionsBuilder{}
2125
}
2226

23-
// Background is deprecated.
27+
// Background specifies a value for the background option.
28+
//
29+
// Deprecated: Use the IndexOptions.SetBackground function in mongo/options instead.
2430
func (iob *IndexOptionsBuilder) Background(background bool) *IndexOptionsBuilder {
2531
iob.document = append(iob.document, bson.E{"background", background})
2632
return iob
2733
}
2834

29-
// ExpireAfterSeconds is deprecated.
35+
// ExpireAfterSeconds specifies a value for the expireAfterSeconds option.
36+
//
37+
// Deprecated: Use the IndexOptions.SetExpireAfterSeconds function in mongo/options instead.
3038
func (iob *IndexOptionsBuilder) ExpireAfterSeconds(expireAfterSeconds int32) *IndexOptionsBuilder {
3139
iob.document = append(iob.document, bson.E{"expireAfterSeconds", expireAfterSeconds})
3240
return iob
3341
}
3442

35-
// Name is deprecated.
43+
// Name specifies a value for the name option.
44+
//
45+
// Deprecated: Use the IndexOptions.SetName function in mongo/options instead.
3646
func (iob *IndexOptionsBuilder) Name(name string) *IndexOptionsBuilder {
3747
iob.document = append(iob.document, bson.E{"name", name})
3848
return iob
3949
}
4050

41-
// Sparse is deprecated.
51+
// Sparse specifies a value for the sparse option.
52+
//
53+
// Deprecated: Use the IndexOptions.SetSparse function in mongo/options instead.
4254
func (iob *IndexOptionsBuilder) Sparse(sparse bool) *IndexOptionsBuilder {
4355
iob.document = append(iob.document, bson.E{"sparse", sparse})
4456
return iob
4557
}
4658

47-
// StorageEngine is deprecated.
59+
// StorageEngine specifies a value for the storageEngine option.
60+
//
61+
// Deprecated: Use the IndexOptions.SetStorageEngine function in mongo/options instead.
4862
func (iob *IndexOptionsBuilder) StorageEngine(storageEngine interface{}) *IndexOptionsBuilder {
4963
iob.document = append(iob.document, bson.E{"storageEngine", storageEngine})
5064
return iob
5165
}
5266

53-
// Unique is deprecated.
67+
// Unique specifies a value for the unique option.
68+
//
69+
// Deprecated: Use the IndexOptions.SetUnique function in mongo/options instead.
5470
func (iob *IndexOptionsBuilder) Unique(unique bool) *IndexOptionsBuilder {
5571
iob.document = append(iob.document, bson.E{"unique", unique})
5672
return iob
5773
}
5874

59-
// Version is deprecated.
75+
// Version specifies a value for the version option.
76+
//
77+
// Deprecated: Use the IndexOptions.SetVersion function in mongo/options instead.
6078
func (iob *IndexOptionsBuilder) Version(version int32) *IndexOptionsBuilder {
6179
iob.document = append(iob.document, bson.E{"v", version})
6280
return iob
6381
}
6482

65-
// DefaultLanguage is deprecated.
83+
// DefaultLanguage specifies a value for the default_language option.
84+
//
85+
// Deprecated: Use the IndexOptions.SetDefaultLanguage function in mongo/options instead.
6686
func (iob *IndexOptionsBuilder) DefaultLanguage(defaultLanguage string) *IndexOptionsBuilder {
6787
iob.document = append(iob.document, bson.E{"default_language", defaultLanguage})
6888
return iob
6989
}
7090

71-
// LanguageOverride is deprecated.
91+
// LanguageOverride specifies a value for the language_override option.
92+
//
93+
// Deprecated: Use the IndexOptions.SetLanguageOverride function in mongo/options instead.
7294
func (iob *IndexOptionsBuilder) LanguageOverride(languageOverride string) *IndexOptionsBuilder {
7395
iob.document = append(iob.document, bson.E{"language_override", languageOverride})
7496
return iob
7597
}
7698

77-
// TextVersion is deprecated.
99+
// TextVersion specifies a value for the textIndexVersion option.
100+
//
101+
// Deprecated: Use the IndexOptions.SetTextVersion function in mongo/options instead.
78102
func (iob *IndexOptionsBuilder) TextVersion(textVersion int32) *IndexOptionsBuilder {
79103
iob.document = append(iob.document, bson.E{"textIndexVersion", textVersion})
80104
return iob
81105
}
82106

83-
// Weights is deprecated.
107+
// Weights specifies a value for the weights option.
108+
//
109+
// Deprecated: Use the IndexOptions.SetWeights function in mongo/options instead.
84110
func (iob *IndexOptionsBuilder) Weights(weights interface{}) *IndexOptionsBuilder {
85111
iob.document = append(iob.document, bson.E{"weights", weights})
86112
return iob
87113
}
88114

89-
// SphereVersion is deprecated.
115+
// SphereVersion specifies a value for the 2dsphereIndexVersion option.
116+
//
117+
// Deprecated: Use the IndexOptions.SetSphereVersion function in mongo/options instead.
90118
func (iob *IndexOptionsBuilder) SphereVersion(sphereVersion int32) *IndexOptionsBuilder {
91119
iob.document = append(iob.document, bson.E{"2dsphereIndexVersion", sphereVersion})
92120
return iob
93121
}
94122

95-
// Bits is deprecated.
123+
// Bits specifies a value for the bits option.
124+
//
125+
// Deprecated: Use the IndexOptions.SetBits function in mongo/options instead.
96126
func (iob *IndexOptionsBuilder) Bits(bits int32) *IndexOptionsBuilder {
97127
iob.document = append(iob.document, bson.E{"bits", bits})
98128
return iob
99129
}
100130

101-
// Max is deprecated.
131+
// Max specifies a value for the max option.
132+
//
133+
// Deprecated: Use the IndexOptions.SetMax function in mongo/options instead.
102134
func (iob *IndexOptionsBuilder) Max(max float64) *IndexOptionsBuilder {
103135
iob.document = append(iob.document, bson.E{"max", max})
104136
return iob
105137
}
106138

107-
// Min is deprecated.
139+
// Min specifies a value for the min option.
140+
//
141+
// Deprecated: Use the IndexOptions.SetMin function in mongo/options instead.
108142
func (iob *IndexOptionsBuilder) Min(min float64) *IndexOptionsBuilder {
109143
iob.document = append(iob.document, bson.E{"min", min})
110144
return iob
111145
}
112146

113-
// BucketSize is deprecated.
147+
// BucketSize specifies a value for the bucketSize option.
148+
//
149+
// Deprecated: Use the IndexOptions.SetBucketSize function in mongo/options instead.
114150
func (iob *IndexOptionsBuilder) BucketSize(bucketSize int32) *IndexOptionsBuilder {
115151
iob.document = append(iob.document, bson.E{"bucketSize", bucketSize})
116152
return iob
117153
}
118154

119-
// PartialFilterExpression is deprecated.
155+
// PartialFilterExpression specifies a value for the partialFilterExpression option.
156+
//
157+
// Deprecated: Use the IndexOptions.SetPartialFilterExpression function in mongo/options instead.
120158
func (iob *IndexOptionsBuilder) PartialFilterExpression(partialFilterExpression interface{}) *IndexOptionsBuilder {
121159
iob.document = append(iob.document, bson.E{"partialFilterExpression", partialFilterExpression})
122160
return iob
123161
}
124162

125-
// Collation is deprecated.
163+
// Collation specifies a value for the collation option.
164+
//
165+
// Deprecated: Use the IndexOptions.SetCollation function in mongo/options instead.
126166
func (iob *IndexOptionsBuilder) Collation(collation interface{}) *IndexOptionsBuilder {
127167
iob.document = append(iob.document, bson.E{"collation", collation})
128168
return iob
129169
}
130170

131-
// Build is deprecated.
171+
// Build finishes constructing an the builder.
172+
//
173+
// Deprecated: Use the IndexOptions type in the mongo/options package instead.
132174
func (iob *IndexOptionsBuilder) Build() bson.D {
133175
return iob.document
134176
}

0 commit comments

Comments
 (0)