Skip to content

GODRIVER-2612 Docs updates. #1607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2024
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
14 changes: 7 additions & 7 deletions bson/raw_array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestReadArray(t *testing.T) {
t.Parallel()

arr, err := ReadArray(tc.ioReader)
if !compareErrors(err, tc.err) {
if !assert.CompareErrors(err, tc.err) {
t.Errorf("errors do not match. got %v; want %v", err, tc.err)
}
if !bytes.Equal(tc.arr, arr) {
Expand All @@ -102,7 +102,7 @@ func TestArray_Validate(t *testing.T) {

want := bsoncore.NewInsufficientBytesError(nil, nil)
got := RawArray{'\x00', '\x00'}.Validate()
if !compareErrors(got, want) {
if !assert.CompareErrors(got, want) {
t.Errorf("Did not get expected error. got %v; want %v", got, want)
}
})
Expand All @@ -114,7 +114,7 @@ func TestArray_Validate(t *testing.T) {
r := make(RawArray, 5)
binary.LittleEndian.PutUint32(r[0:4], 200)
got := r.Validate()
if !compareErrors(got, want) {
if !assert.CompareErrors(got, want) {
t.Errorf("Did not get expected error. got %v; want %v", got, want)
}
})
Expand All @@ -127,7 +127,7 @@ func TestArray_Validate(t *testing.T) {
binary.LittleEndian.PutUint32(r[0:4], 7)
r[4], r[5], r[6] = 0x02, 'f', 0x00
got := r.Validate()
if !compareErrors(got, want) {
if !assert.CompareErrors(got, want) {
t.Errorf("Did not get expected error. got %v; want %v", got, want)
}
})
Expand All @@ -140,7 +140,7 @@ func TestArray_Validate(t *testing.T) {
binary.LittleEndian.PutUint32(r[0:4], 6)
r[4], r[5] = 0x0A, '0'
got := r.Validate()
if !compareErrors(got, want) {
if !assert.CompareErrors(got, want) {
t.Errorf("Did not get expected error. got %v; want %v", got, want)
}
})
Expand Down Expand Up @@ -199,7 +199,7 @@ func TestArray_Validate(t *testing.T) {
t.Parallel()

got := tc.r.Validate()
if !compareErrors(got, tc.want) {
if !assert.CompareErrors(got, tc.want) {
t.Errorf("Returned error does not match. got %v; want %v", got, tc.want)
}
})
Expand All @@ -226,7 +226,7 @@ func TestArray_Index(t *testing.T) {
rdr := RawArray{0x07, 0x00, 0x00, 0x00, 0x00}
_, got := rdr.IndexErr(1)
want := bsoncore.NewInsufficientBytesError(nil, nil)
if !compareErrors(got, want) {
if !assert.CompareErrors(got, want) {
t.Errorf("Did not receive expected error. got %v; want %v", got, want)
}
})
Expand Down
4 changes: 2 additions & 2 deletions docs/common-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/bson#Marshal) function requires a parameter that can be decoded into a BSON Document, i.e. a [`bson.D`](https://pkg.go.dev/go.mongodb.org/mongo-driver/bson#D). Therefore the error message

> `WriteXXX` can only write while positioned on a Element or Value but is positioned on a TopLevel

Expand Down Expand Up @@ -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/go.mongodb.org/mongo-driver/bson#MarshalExtJSON):

```go
doc := bson.D{{"x", 1}}
Expand Down