Skip to content

Commit 5762c6a

Browse files
benjirewisBenji Rewis
authored andcommitted
GODRIVER-2543 Run make fmt with the latest Go version. #1065
1 parent 2855941 commit 5762c6a

File tree

22 files changed

+262
-254
lines changed

22 files changed

+262
-254
lines changed

bson/bson.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Zeroer interface {
2727
//
2828
// Example usage:
2929
//
30-
// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
30+
// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
3131
type D = primitive.D
3232

3333
// E represents a BSON element for a D. It is usually used inside a D.
@@ -39,12 +39,12 @@ type E = primitive.E
3939
//
4040
// Example usage:
4141
//
42-
// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
42+
// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
4343
type M = primitive.M
4444

4545
// An A is an ordered representation of a BSON array.
4646
//
4747
// Example usage:
4848
//
49-
// bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
49+
// bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
5050
type A = primitive.A

bson/bsoncodec/doc.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// 2) A Registry that holds these ValueEncoders and ValueDecoders and provides methods for
1818
// retrieving them.
1919
//
20-
// ValueEncoders and ValueDecoders
20+
// # ValueEncoders and ValueDecoders
2121
//
2222
// The ValueEncoder interface is implemented by types that can encode a provided Go type to BSON.
2323
// The value to encode is provided as a reflect.Value and a bsonrw.ValueWriter is used within the
@@ -31,7 +31,7 @@
3131
// allow the use of a function with the correct signature as a ValueDecoder. A DecodeContext
3232
// instance is provided and serves similar functionality to the EncodeContext.
3333
//
34-
// Registry and RegistryBuilder
34+
// # Registry and RegistryBuilder
3535
//
3636
// A Registry is an immutable store for ValueEncoders, ValueDecoders, and a type map. See the Registry type
3737
// documentation for examples of registering various custom encoders and decoders. A Registry can be constructed using a
@@ -53,15 +53,15 @@
5353
// values decode as Go int32 and int64 instances, respectively, when decoding into a bson.D. The following code would
5454
// change the behavior so these values decode as Go int instances instead:
5555
//
56-
// intType := reflect.TypeOf(int(0))
57-
// registryBuilder.RegisterTypeMapEntry(bsontype.Int32, intType).RegisterTypeMapEntry(bsontype.Int64, intType)
56+
// intType := reflect.TypeOf(int(0))
57+
// registryBuilder.RegisterTypeMapEntry(bsontype.Int32, intType).RegisterTypeMapEntry(bsontype.Int64, intType)
5858
//
5959
// 4. Kind encoder/decoders - These can be registered using the RegisterDefaultEncoder and RegisterDefaultDecoder
6060
// methods. The registered codec will be invoked when encoding or decoding values whose reflect.Kind matches the
6161
// registered reflect.Kind as long as the value's type doesn't match a registered type or hook encoder/decoder first.
6262
// These methods should be used to change the behavior for all values for a specific kind.
6363
//
64-
// Registry Lookup Procedure
64+
// # Registry Lookup Procedure
6565
//
6666
// When looking up an encoder in a Registry, the precedence rules are as follows:
6767
//
@@ -79,7 +79,7 @@
7979
// rules apply for decoders, with the exception that an error of type ErrNoDecoder will be returned if no decoder is
8080
// found.
8181
//
82-
// DefaultValueEncoders and DefaultValueDecoders
82+
// # DefaultValueEncoders and DefaultValueDecoders
8383
//
8484
// The DefaultValueEncoders and DefaultValueDecoders types provide a full set of ValueEncoders and
8585
// ValueDecoders for handling a wide range of Go types, including all of the types within the

bson/bsoncodec/registry.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ func (rb *RegistryBuilder) RegisterDefaultDecoder(kind reflect.Kind, dec ValueDe
254254
// By default, BSON documents will decode into interface{} values as bson.D. To change the default type for BSON
255255
// documents, a type map entry for bsontype.EmbeddedDocument should be registered. For example, to force BSON documents
256256
// to decode to bson.Raw, use the following code:
257+
//
257258
// rb.RegisterTypeMapEntry(bsontype.EmbeddedDocument, reflect.TypeOf(bson.Raw{}))
258259
func (rb *RegistryBuilder) RegisterTypeMapEntry(bt bsontype.Type, rt reflect.Type) *RegistryBuilder {
259260
rb.typeMap[bt] = rt

bson/bsoncodec/struct_tag_parser.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ func (stpf StructTagParserFunc) ParseStructTags(sf reflect.StructField) (StructT
3434
//
3535
// The properties are defined below:
3636
//
37-
// OmitEmpty Only include the field if it's not set to the zero value for the type or to
38-
// empty slices or maps.
37+
// OmitEmpty Only include the field if it's not set to the zero value for the type or to
38+
// empty slices or maps.
3939
//
40-
// MinSize Marshal an integer of a type larger than 32 bits value as an int32, if that's
41-
// feasible while preserving the numeric value.
40+
// MinSize Marshal an integer of a type larger than 32 bits value as an int32, if that's
41+
// feasible while preserving the numeric value.
4242
//
43-
// Truncate When unmarshaling a BSON double, it is permitted to lose precision to fit within
44-
// a float32.
43+
// Truncate When unmarshaling a BSON double, it is permitted to lose precision to fit within
44+
// a float32.
4545
//
46-
// Inline Inline the field, which must be a struct or a map, causing all of its fields
47-
// or keys to be processed as if they were part of the outer struct. For maps,
48-
// keys must not conflict with the bson keys of other struct fields.
46+
// Inline Inline the field, which must be a struct or a map, causing all of its fields
47+
// or keys to be processed as if they were part of the outer struct. For maps,
48+
// keys must not conflict with the bson keys of other struct fields.
4949
//
50-
// Skip This struct field should be skipped. This is usually denoted by parsing a "-"
51-
// for the name.
50+
// Skip This struct field should be skipped. This is usually denoted by parsing a "-"
51+
// for the name.
5252
//
5353
// TODO(skriptble): Add tags for undefined as nil and for null as nil.
5454
type StructTags struct {
@@ -67,20 +67,20 @@ type StructTags struct {
6767
// If there is no name in the struct tag fields, the struct field name is lowercased.
6868
// The tag formats accepted are:
6969
//
70-
// "[<key>][,<flag1>[,<flag2>]]"
70+
// "[<key>][,<flag1>[,<flag2>]]"
7171
//
72-
// `(...) bson:"[<key>][,<flag1>[,<flag2>]]" (...)`
72+
// `(...) bson:"[<key>][,<flag1>[,<flag2>]]" (...)`
7373
//
7474
// An example:
7575
//
76-
// type T struct {
77-
// A bool
78-
// B int "myb"
79-
// C string "myc,omitempty"
80-
// D string `bson:",omitempty" json:"jsonkey"`
81-
// E int64 ",minsize"
82-
// F int64 "myf,omitempty,minsize"
83-
// }
76+
// type T struct {
77+
// A bool
78+
// B int "myb"
79+
// C string "myc,omitempty"
80+
// D string `bson:",omitempty" json:"jsonkey"`
81+
// E int64 ",minsize"
82+
// F int64 "myf,omitempty,minsize"
83+
// }
8484
//
8585
// A struct tag either consisting entirely of '-' or with a bson key with a
8686
// value consisting entirely of '-' will return a StructTags with Skip true and

bson/doc.go

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@
99
// The BSON library handles marshalling and unmarshalling of values through a configurable codec system. For a description
1010
// of the codec system and examples of registering custom codecs, see the bsoncodec package.
1111
//
12-
// Raw BSON
12+
// # Raw BSON
1313
//
1414
// The Raw family of types is used to validate and retrieve elements from a slice of bytes. This
1515
// type is most useful when you want do lookups on BSON bytes without unmarshaling it into another
1616
// type.
1717
//
1818
// Example:
19-
// var raw bson.Raw = ... // bytes from somewhere
20-
// err := raw.Validate()
21-
// if err != nil { return err }
22-
// val := raw.Lookup("foo")
23-
// i32, ok := val.Int32OK()
24-
// // do something with i32...
2519
//
26-
// Native Go Types
20+
// var raw bson.Raw = ... // bytes from somewhere
21+
// err := raw.Validate()
22+
// if err != nil { return err }
23+
// val := raw.Lookup("foo")
24+
// i32, ok := val.Int32OK()
25+
// // do something with i32...
26+
//
27+
// # Native Go Types
2728
//
2829
// The D and M types defined in this package can be used to build representations of BSON using native Go types. D is a
2930
// slice and M is a map. For more information about the use cases for these types, see the documentation on the type
@@ -32,63 +33,64 @@
3233
// Note that a D should not be constructed with duplicate key names, as that can cause undefined server behavior.
3334
//
3435
// Example:
35-
// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
36-
// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
36+
//
37+
// bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
38+
// bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
3739
//
3840
// When decoding BSON to a D or M, the following type mappings apply when unmarshalling:
3941
//
40-
// 1. BSON int32 unmarshals to an int32.
41-
// 2. BSON int64 unmarshals to an int64.
42-
// 3. BSON double unmarshals to a float64.
43-
// 4. BSON string unmarshals to a string.
44-
// 5. BSON boolean unmarshals to a bool.
45-
// 6. BSON embedded document unmarshals to the parent type (i.e. D for a D, M for an M).
46-
// 7. BSON array unmarshals to a bson.A.
47-
// 8. BSON ObjectId unmarshals to a primitive.ObjectID.
48-
// 9. BSON datetime unmarshals to a primitive.DateTime.
49-
// 10. BSON binary unmarshals to a primitive.Binary.
50-
// 11. BSON regular expression unmarshals to a primitive.Regex.
51-
// 12. BSON JavaScript unmarshals to a primitive.JavaScript.
52-
// 13. BSON code with scope unmarshals to a primitive.CodeWithScope.
53-
// 14. BSON timestamp unmarshals to an primitive.Timestamp.
54-
// 15. BSON 128-bit decimal unmarshals to an primitive.Decimal128.
55-
// 16. BSON min key unmarshals to an primitive.MinKey.
56-
// 17. BSON max key unmarshals to an primitive.MaxKey.
57-
// 18. BSON undefined unmarshals to a primitive.Undefined.
58-
// 19. BSON null unmarshals to nil.
59-
// 20. BSON DBPointer unmarshals to a primitive.DBPointer.
60-
// 21. BSON symbol unmarshals to a primitive.Symbol.
42+
// 1. BSON int32 unmarshals to an int32.
43+
// 2. BSON int64 unmarshals to an int64.
44+
// 3. BSON double unmarshals to a float64.
45+
// 4. BSON string unmarshals to a string.
46+
// 5. BSON boolean unmarshals to a bool.
47+
// 6. BSON embedded document unmarshals to the parent type (i.e. D for a D, M for an M).
48+
// 7. BSON array unmarshals to a bson.A.
49+
// 8. BSON ObjectId unmarshals to a primitive.ObjectID.
50+
// 9. BSON datetime unmarshals to a primitive.DateTime.
51+
// 10. BSON binary unmarshals to a primitive.Binary.
52+
// 11. BSON regular expression unmarshals to a primitive.Regex.
53+
// 12. BSON JavaScript unmarshals to a primitive.JavaScript.
54+
// 13. BSON code with scope unmarshals to a primitive.CodeWithScope.
55+
// 14. BSON timestamp unmarshals to an primitive.Timestamp.
56+
// 15. BSON 128-bit decimal unmarshals to an primitive.Decimal128.
57+
// 16. BSON min key unmarshals to an primitive.MinKey.
58+
// 17. BSON max key unmarshals to an primitive.MaxKey.
59+
// 18. BSON undefined unmarshals to a primitive.Undefined.
60+
// 19. BSON null unmarshals to nil.
61+
// 20. BSON DBPointer unmarshals to a primitive.DBPointer.
62+
// 21. BSON symbol unmarshals to a primitive.Symbol.
6163
//
6264
// The above mappings also apply when marshalling a D or M to BSON. Some other useful marshalling mappings are:
6365
//
64-
// 1. time.Time marshals to a BSON datetime.
65-
// 2. int8, int16, and int32 marshal to a BSON int32.
66-
// 3. int marshals to a BSON int32 if the value is between math.MinInt32 and math.MaxInt32, inclusive, and a BSON int64
67-
// otherwise.
68-
// 4. int64 marshals to BSON int64.
69-
// 5. uint8 and uint16 marshal to a BSON int32.
70-
// 6. uint, uint32, and uint64 marshal to a BSON int32 if the value is between math.MinInt32 and math.MaxInt32,
71-
// inclusive, and BSON int64 otherwise.
72-
// 7. BSON null and undefined values will unmarshal into the zero value of a field (e.g. unmarshalling a BSON null or
73-
// undefined value into a string will yield the empty string.).
66+
// 1. time.Time marshals to a BSON datetime.
67+
// 2. int8, int16, and int32 marshal to a BSON int32.
68+
// 3. int marshals to a BSON int32 if the value is between math.MinInt32 and math.MaxInt32, inclusive, and a BSON int64
69+
// otherwise.
70+
// 4. int64 marshals to BSON int64.
71+
// 5. uint8 and uint16 marshal to a BSON int32.
72+
// 6. uint, uint32, and uint64 marshal to a BSON int32 if the value is between math.MinInt32 and math.MaxInt32,
73+
// inclusive, and BSON int64 otherwise.
74+
// 7. BSON null and undefined values will unmarshal into the zero value of a field (e.g. unmarshalling a BSON null or
75+
// undefined value into a string will yield the empty string.).
7476
//
75-
// Structs
77+
// # Structs
7678
//
7779
// Structs can be marshalled/unmarshalled to/from BSON or Extended JSON. When transforming structs to/from BSON or Extended
7880
// JSON, the following rules apply:
7981
//
80-
// 1. Only exported fields in structs will be marshalled or unmarshalled.
82+
// 1. Only exported fields in structs will be marshalled or unmarshalled.
8183
//
82-
// 2. When marshalling a struct, each field will be lowercased to generate the key for the corresponding BSON element.
84+
// 2. When marshalling a struct, each field will be lowercased to generate the key for the corresponding BSON element.
8385
// For example, a struct field named "Foo" will generate key "foo". This can be overridden via a struct tag (e.g.
8486
// `bson:"fooField"` to generate key "fooField" instead).
8587
//
86-
// 3. An embedded struct field is marshalled as a subdocument. The key will be the lowercased name of the field's type.
88+
// 3. An embedded struct field is marshalled as a subdocument. The key will be the lowercased name of the field's type.
8789
//
88-
// 4. A pointer field is marshalled as the underlying type if the pointer is non-nil. If the pointer is nil, it is
90+
// 4. A pointer field is marshalled as the underlying type if the pointer is non-nil. If the pointer is nil, it is
8991
// marshalled as a BSON null value.
9092
//
91-
// 5. When unmarshalling, a field of type interface{} will follow the D/M type mappings listed above. BSON documents
93+
// 5. When unmarshalling, a field of type interface{} will follow the D/M type mappings listed above. BSON documents
9294
// unmarshalled into an interface{} field will be unmarshalled as a D.
9395
//
9496
// The encoding of each struct field can be customized by the "bson" struct tag.
@@ -98,13 +100,14 @@
98100
// are not honored, but that can be enabled by creating a StructCodec with JSONFallbackStructTagParser, like below:
99101
//
100102
// Example:
101-
// structcodec, _ := bsoncodec.NewStructCodec(bsoncodec.JSONFallbackStructTagParser)
103+
//
104+
// structcodec, _ := bsoncodec.NewStructCodec(bsoncodec.JSONFallbackStructTagParser)
102105
//
103106
// The bson tag gives the name of the field, possibly followed by a comma-separated list of options.
104107
// The name may be empty in order to specify options without overriding the default field name. The following options can be used
105108
// to configure behavior:
106109
//
107-
// 1. omitempty: If the omitempty struct tag is specified on a field, the field will not be marshalled if it is set to
110+
// 1. omitempty: If the omitempty struct tag is specified on a field, the field will not be marshalled if it is set to
108111
// the zero value. Fields with language primitive types such as integers, booleans, and strings are considered empty if
109112
// their value is equal to the zero value for the type (i.e. 0 for integers, false for booleans, and "" for strings).
110113
// Slices, maps, and arrays are considered empty if they are of length zero. Interfaces and pointers are considered
@@ -113,16 +116,16 @@
113116
// never considered empty and will be marshalled as embedded documents.
114117
// NOTE: It is recommended that this tag be used for all slice and map fields.
115118
//
116-
// 2. minsize: If the minsize struct tag is specified on a field of type int64, uint, uint32, or uint64 and the value of
119+
// 2. minsize: If the minsize struct tag is specified on a field of type int64, uint, uint32, or uint64 and the value of
117120
// the field can fit in a signed int32, the field will be serialized as a BSON int32 rather than a BSON int64. For other
118121
// types, this tag is ignored.
119122
//
120-
// 3. truncate: If the truncate struct tag is specified on a field with a non-float numeric type, BSON doubles unmarshalled
123+
// 3. truncate: If the truncate struct tag is specified on a field with a non-float numeric type, BSON doubles unmarshalled
121124
// into that field will be truncated at the decimal point. For example, if 3.14 is unmarshalled into a field of type int,
122125
// it will be unmarshalled as 3. If this tag is not specified, the decoder will throw an error if the value cannot be
123126
// decoded without losing precision. For float64 or non-numeric types, this tag is ignored.
124127
//
125-
// 4. inline: If the inline struct tag is specified for a struct or map field, the field will be "flattened" when
128+
// 4. inline: If the inline struct tag is specified for a struct or map field, the field will be "flattened" when
126129
// marshalling and "un-flattened" when unmarshalling. This means that all of the fields in that struct/map will be
127130
// pulled up one level and will become top-level fields rather than being fields in a nested document. For example, if a
128131
// map field named "Map" with value map[string]interface{}{"foo": "bar"} is inlined, the resulting document will be
@@ -132,7 +135,7 @@
132135
// This tag can be used with fields that are pointers to structs. If an inlined pointer field is nil, it will not be
133136
// marshalled. For fields that are not maps or structs, this tag is ignored.
134137
//
135-
// Marshalling and Unmarshalling
138+
// # Marshalling and Unmarshalling
136139
//
137140
// Manually marshalling and unmarshalling can be done with the Marshal and Unmarshal family of functions.
138141
package bson

0 commit comments

Comments
 (0)