Skip to content
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

fix golint, go vet and go fmt #44

Merged
merged 1 commit into from
Oct 6, 2017
Merged

fix golint, go vet and go fmt #44

merged 1 commit into from
Oct 6, 2017

Conversation

feliixx
Copy link

@feliixx feliixx commented Sep 28, 2017

WIP - Do not merge

This PR is an attempt to fix golint, go vet and gofmt warning of all files in the project ( see #43 for details)

A few warnings are still raised by go vet:

session.go:661: assignment copies lock value to scopy: mgo.Session contains sync.RWMutex

-> not sure how to handle this one

internal/json/decode_test.go:1350: struct field m has json tag but is not exported
internal/json/decode_test.go:1351: struct field m2 has json tag but is not exported
internal/json/tagkey_test.go:56: struct field tag `:"BadFormat"` not compatible with reflect.StructTag.Get: bad syntax for struct tag key

-> part of the tests and intended to be badly formatted.

I was able to fix all golint warnings, but bad news is that it currently breaks backward compatibility...
golint raise warnings about Id not being ID, and theres many occurence of this in mgo (ObjectId, FindId() ...)

This might be fixed with type alias to preserve backward compatibility ?

Waiting for any feedback on this,

Feliixx

@domodwyer
Copy link

Hey @feliixx

I just had a quick look at the mutex thing - copySession() is creating a shallow copy of the struct (so same pointers, etc but fields referenced by value are copied). Essentially it's a lazy way of doing:

scopy := Session{
    defaultdb: session.defaultdb,
    sourcedb: session.sourcedb,
    ...
    m: sync.Mutex{},
    ...
}

So long as this is the only place a session is copied (and it looks like it is, otherwise you'd have more mutex copy errors) the above change should be fine.

I'm aware of the other two - and I really don't like what I'm about to suggest...

  • For the struct tags, I think in this case disabling vet's struct tag checks might be best - we could do some fancy stuff with build tags but it's a bit hard to reason about.

If the tags are malformed the code won't work, and this should be caught by any unit tests added alongside any new structs with tags.

  • For the Id => ID conversion - again, sorry! - I'd rather keep backwards compatibility and not run golint as part of the CI - apparently it's not really supposed to be used for this purpose anyway (see here).

I don't think type aliasing will be able to help us with the ID thing but I'm definitely open to ideas - we'd have to do it when 1.9 is a little "older" - a lot of people will currently still be using 1.8 and earlier.

As always, genuinely grateful for the time you've put in contributing - thanks!

Dom

@feliixx
Copy link
Author

feliixx commented Sep 28, 2017

Hey @domodwyer,

Totally understand that keeping backward compatibility is more important.

I removed all Id/ID related changes, and fixed the warning in copySession()

So here is a solution :

  • run golint ./... | grep -v 'ID' | cat so warnings about Id/ID aren't printed, but all other are. If some warnings are found, the build does not fail

  • run go vet on exported packages only (mgo, mgo/bson and mgo/txn). Content of internal would not be tested . If warnings are found, the build fails

Feliixx

@domodwyer
Copy link

Hey @feliixx

Both are good solutions for me :) Any idea why tests on 3.0.X always fail? I've retried them a bunch of times.

Dom

@feliixx
Copy link
Author

feliixx commented Oct 2, 2017

Hi @domodwyer,

tests on 3.0.x were failing because the command drop doesn't return the same error as 2.6, 3.2 & 3.4 when trying to delete a collection that doesn't exist.
It might be a bug, couldn' test this with 3.0.15 (last release for the 3.0.x serie).
I updated the test TestRepairCursor, everything should be fine now!

@domodwyer
Copy link

Thanks @feliixx!

Copy link

@domodwyer domodwyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A slightly enthusiastic search and replace has had a few collateral changes! :)

Really appreciate taking the time to add the references to the Mongo documentation in the godoc comments, a brilliant idea 👍

@globalsign/hv the breaking change in GridFS?

bson/bson.go Outdated
@@ -83,13 +83,13 @@ const (
BinaryGeneric byte = 0x00
BinaryFunction byte = 0x01
BinaryBinaryOld byte = 0x02
BinaryUUIDOld byte = 0x03
BinaryUUID byte = 0x04
BinaryUUIdOld byte = 0x03

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these got swept up in a find-and-replace - should still be ID

bson/bson.go Outdated
type RawDocElem struct {
Name string
Value Raw
}

// ObjectId is a unique ID identifying a BSON value. It must be exactly 12 bytes
// ObjectId is a unique Id identifying a BSON value. It must be exactly 12 bytes
// long. MongoDB objects by default have such a property set in their "_id"
// property.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental ID/Id replace (url broken)

bson/bson.go Outdated
@@ -447,7 +447,7 @@ var Undefined undefined
// 0x00 - Generic. This is decoded as []byte(data), not Binary{0x00, data}.
// 0x01 - Function (!?)
// 0x02 - Obsolete generic.
// 0x03 - UUID
// 0x03 - UUId

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UUID

@@ -740,15 +740,15 @@ func (s *S) TestDBPointer_type__deprecated__String_not_null_terminated(c *C) {
testDecodeError(c, b, &resultD)
}

func (s *S) TestDBPointer_type__deprecated__short_OID__less_than_minimum_length_for_field_(c *C) {
func (s *S) TestDBPointer_type__deprecated__short_OId__less_than_minimum_length_for_field_(c *C) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OID

b, err := hex.DecodeString("160000000C61000300000061620056E1FC72E0C91700")
c.Assert(err, IsNil)

var resultD bson.D
testDecodeError(c, b, &resultD)
}

func (s *S) TestDBPointer_type__deprecated__short_OID__greater_than_minimum__but_truncated_(c *C) {
func (s *S) TestDBPointer_type__deprecated__short_OId__greater_than_minimum__but_truncated_(c *C) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OID

txn/txn.go Outdated
@@ -394,7 +399,7 @@ func (r *Runner) Resume(id bson.ObjectId) (err error) {
//
// Saved documents are in the format:
//
// {"_id": <txn id>, <collection>: {"d": [<doc id>, ...], "r": [<doc revno>, ...]}}
// {"_id": <txn Id>, <collection>: {"d": [<doc Id>, ...], "r": [<doc revno>, ...]}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental capitalisation

txn/txn.go Outdated
@@ -481,11 +486,11 @@ func (r *Runner) PurgeMissing(collections ...string) error {
return nil
}

func (r *Runner) load(id bson.ObjectId) (*transaction, error) {
func (r *Runner) load(Id bson.ObjectId) (*transaction, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental capitalisation

txn/txn.go Outdated
@@ -438,7 +443,7 @@ func (r *Runner) PurgeMissing(collections ...string) error {
found[txnId] = true
continue
}
logf("WARNING: purging from document %s/%v the missing transaction id %s", collection, tdoc.Id, txnId)
logf("WARNING: purging from document %s/%v the missing transaction Id %s", collection, tdoc.Id, txnId)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental capitalisation

txn/txn.go Outdated
@@ -467,7 +472,7 @@ func (r *Runner) PurgeMissing(collections ...string) error {
found[txnId] = true
continue
}
logf("WARNING: purging from stash document %s/%v the missing transaction id %s", stdoc.Id.C, stdoc.Id.Id, txnId)
logf("WARNING: purging from stash document %s/%v the missing transaction Id %s", stdoc.Id.C, stdoc.Id.Id, txnId)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental capitalisation

txn/txn.go Outdated
@@ -542,7 +546,7 @@ func valueNature(v interface{}) (value interface{}, nature typeNature) {
case reflect.Struct:
return v, natureStruct
}
panic("document id type unsupported by txn: " + rv.Kind().String())
panic("document Id type unsupported by txn: " + rv.Kind().String())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental capitalisation

bson/bson.go Outdated
@@ -99,12 +99,12 @@ type Getter interface {
GetBSON() (interface{}, error)
}

// A value implementing the bson.Setter interface will receive the BSON
// Setter interface : a value implementing the bson.Setter interface will receive the BSON

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The space between "interface :" should be removed for consistency with the Getter comment. Very nitpicky this.

// its respective zero value. When used in pointer values, this will set the
// field to nil rather than to the pre-allocated value.
var SetZero = errors.New("set to zero")
var ErrSetZero = errors.New("set to zero")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially breaks backwards compat for little gain I'd say. @domodwyer, not sure how likely is this to be used?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is much of an issue, it's unlikely to be used by 99% of people.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I am one of the 1% that's affected by this change. Add reactions here for "me too".

@@ -411,7 +432,7 @@ func (file *GridFile) ContentType() string {
return file.doc.ContentType
}

// ContentType changes the optional file content type. An empty string may be
// SetContentType changes the optional file content type. An empty string may be

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like an issue

gridfs_test.go Outdated
@@ -141,12 +141,12 @@ func (s *S) TestGridFSFileDetails(c *C) {
c.Assert(err, IsNil)
c.Assert(info, IsNil)

file.SetId("myid")
// file.setId("myid")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to keep this around?

@@ -26,7 +26,8 @@ import (
"unsafe"
)

type saslStepper interface {
// Stepper interface for saslSession
type Stepper interface {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree the interface should be exported if returned from New.

domodwyer
domodwyer previously approved these changes Oct 4, 2017
  see #43 for details

ignore warning on Id/ID to keep fix backward compatible
@domodwyer domodwyer merged commit 97bd0cd into globalsign:development Oct 6, 2017
This was referenced Oct 6, 2017
domodwyer added a commit that referenced this pull request Oct 11, 2017
* development:
  readme: credit @bozaro (#47)
  Fix GetBSON() method usage (#40)
  readme: credit @feliixx (#46)
  fix golint, go vet and gofmt warnings (#44)
  readme: add missing features / credit
  bson.Unmarshal returns time in UTC (#42)
  Introduce constants for BSON element types (#41)
  Test against MongoDB 3.4.x (#35)
  Add collation option to collection.Create() (#37)
  Don't panic on indexed int64 fields (#23)
  readme: credit @feliixx in the README (#36)
  add method CreateView() (#33)
  Update README to add appName (#32)
  send metadata during handshake (#28)
  readme: credit @feliixx for #25 (#26)
  add DropAllIndexes() method (#25)

# Conflicts:
#	README.md
#	cluster.go
#	session.go
#	session_test.go
@domodwyer domodwyer mentioned this pull request Oct 11, 2017
domodwyer added a commit that referenced this pull request Oct 11, 2017
* add DropAllIndexes() method (#25)

Create a new method to drop all the indexes of a collection
in a single call

* readme: credit @feliixx for #25 (#26)

* send metadata during handshake (#28)

fix [#484](https://github.com/go-mgo/mgo/issues/484)

Annotate connections with metadata provided by the
connecting client.

informations send:

{
 "aplication": {         // optional
   "name": "myAppName"
 }
 "driver": {
    "name": "mgo",
    "version": "v2"
  },
  "os": {
    "type": runtime.GOOS,
    "architecture": runtime.GOARCH
  }
}

to set "application.name", add `appname` param in options
of string connection URI,
for example : "mongodb://localhost:27017?appname=myAppName"

* Update README to add appName (#32)

* docs: elaborate on what appName does

* readme: add appName to changes

* add method CreateView() (#33)

Fix #30.

Thanks to @feliixx for the time and effort.

* readme: credit @feliixx in the README (#36)

* Don't panic on indexed int64 fields (#23)

* Stop all db instances after tests (go-mgo#462)

If all tests pass, the builds for mongo earlier than 2.6 are still failing.
Running a clean up fixes the issue.

* fixing int64 type failing when getting indexes and trying to type them

* requested changes relating to case statement and panic

* Update README.md to credit @mapete94.

* tests: ensure indexed int64 fields do not cause a panic in Indexes()

See:
* #23
* https://github.com/go-mgo/mgo/issues/475
* go-mgo#476

* Add collation option to collection.Create() (#37)

- Allow specifying the default collation for the collection when creating it.
- Add some documentation to query.Collation() method.

fix #29

* Test against MongoDB 3.4.x (#35)

* test against MongoDB 3.4.x

* tests: use listIndexes to assert index state for 3.4+

* make test pass against v3.4.x

  - skip `TestViewWithCollation` because of SERVER-31049,
    cf: https://jira.mongodb.org/browse/SERVER-31049

  - add versionAtLeast() method in init.js script to better
    detect server version

fixes #31

* Introduce constants for BSON element types (#41)

* bson.Unmarshal returns time in UTC (#42)

* readme: add missing features / credit

* Adds missing collation feature description (by @feliixx).
* Adds missing 3.4 tests description (by @feliixx).
* Adds BSON constants description (by @bozaro).
* Adds UTC time.Time unmarshalling (by @gazoon).

* fix golint, go vet and gofmt warnings (#44)

Fixes #43

* readme: credit @feliixx (#46)

* Fix GetBSON() method usage (#40)

* Fix GetBSON() method usage

Original issue
---

You can't use type with custom GetBSON() method mixed with structure field type and structure field reference type.

For example, you can't create custom GetBSON() for Bar type:

```
struct Foo {
	a  Bar
	b *Bar
}
```

Type implementation (`func (t Bar) GetBSON()` ) would crash on `Foo.b = nil` value encoding.

Reference implementation (`func (t *Bar) GetBSON()` ) would not call on `Foo.a` value encoding.

After this change
---

For type implementation  `func (t Bar) GetBSON()` would not call on `Foo.b = nil` value encoding.
In this case `nil` value would be seariazied as `nil` BSON value.

For reference implementation `func (t *Bar) GetBSON()` would call even on `Foo.a` value encoding.

* Minor refactoring

* readme: credit @bozaro (#47)
domodwyer added a commit that referenced this pull request Oct 22, 2017
* commit '0454966c021aa1737c9680aceef7e2ba26952fe3':
  do not lock while writing to a socket (#52) (#54)
  readme: credit @bozaro and @idy (#53)
  Improve cursorData struct unmarshaling speed (#49)
  readme: credit @bozaro (#47)
  Fix GetBSON() method usage (#40)
  readme: credit @feliixx (#46)
  fix golint, go vet and gofmt warnings (#44)
  readme: add missing features / credit
  bson.Unmarshal returns time in UTC (#42)
  Introduce constants for BSON element types (#41)
  Test against MongoDB 3.4.x (#35)
  Add collation option to collection.Create() (#37)
  Don't panic on indexed int64 fields (#23)
  readme: credit @feliixx in the README (#36)
  add method CreateView() (#33)
  Update README to add appName (#32)
  send metadata during handshake (#28)
  readme: credit @feliixx for #25 (#26)
  add DropAllIndexes() method (#25)

# Conflicts:
#	README.md
#	bson/decode.go
domodwyer added a commit that referenced this pull request Nov 6, 2017
* add DropAllIndexes() method (#25)

Create a new method to drop all the indexes of a collection
in a single call

* readme: credit @feliixx for #25 (#26)

* send metadata during handshake (#28)

fix [#484](https://github.com/go-mgo/mgo/issues/484)

Annotate connections with metadata provided by the
connecting client.

informations send:

{
 "aplication": {         // optional
   "name": "myAppName"
 }
 "driver": {
    "name": "mgo",
    "version": "v2"
  },
  "os": {
    "type": runtime.GOOS,
    "architecture": runtime.GOARCH
  }
}

to set "application.name", add `appname` param in options
of string connection URI,
for example : "mongodb://localhost:27017?appname=myAppName"

* Update README to add appName (#32)

* docs: elaborate on what appName does

* readme: add appName to changes

* add method CreateView() (#33)

Fix #30.

Thanks to @feliixx for the time and effort.

* readme: credit @feliixx in the README (#36)

* Don't panic on indexed int64 fields (#23)

* Stop all db instances after tests (go-mgo#462)

If all tests pass, the builds for mongo earlier than 2.6 are still failing.
Running a clean up fixes the issue.

* fixing int64 type failing when getting indexes and trying to type them

* requested changes relating to case statement and panic

* Update README.md to credit @mapete94.

* tests: ensure indexed int64 fields do not cause a panic in Indexes()

See:
* #23
* https://github.com/go-mgo/mgo/issues/475
* go-mgo#476

* Add collation option to collection.Create() (#37)

- Allow specifying the default collation for the collection when creating it.
- Add some documentation to query.Collation() method.

fix #29

* Test against MongoDB 3.4.x (#35)

* test against MongoDB 3.4.x

* tests: use listIndexes to assert index state for 3.4+

* make test pass against v3.4.x

  - skip `TestViewWithCollation` because of SERVER-31049,
    cf: https://jira.mongodb.org/browse/SERVER-31049

  - add versionAtLeast() method in init.js script to better
    detect server version

fixes #31

* Introduce constants for BSON element types (#41)

* bson.Unmarshal returns time in UTC (#42)

* readme: add missing features / credit

* Adds missing collation feature description (by @feliixx).
* Adds missing 3.4 tests description (by @feliixx).
* Adds BSON constants description (by @bozaro).
* Adds UTC time.Time unmarshalling (by @gazoon).

* fix golint, go vet and gofmt warnings (#44)

Fixes #43

* readme: credit @feliixx (#46)

* Fix GetBSON() method usage (#40)

* Fix GetBSON() method usage

Original issue
---

You can't use type with custom GetBSON() method mixed with structure field type and structure field reference type.

For example, you can't create custom GetBSON() for Bar type:

```
struct Foo {
	a  Bar
	b *Bar
}
```

Type implementation (`func (t Bar) GetBSON()` ) would crash on `Foo.b = nil` value encoding.

Reference implementation (`func (t *Bar) GetBSON()` ) would not call on `Foo.a` value encoding.

After this change
---

For type implementation  `func (t Bar) GetBSON()` would not call on `Foo.b = nil` value encoding.
In this case `nil` value would be seariazied as `nil` BSON value.

For reference implementation `func (t *Bar) GetBSON()` would call even on `Foo.a` value encoding.

* Minor refactoring

* readme: credit @bozaro (#47)

* Improve cursorData struct unmarshaling speed (#49)

This change remove full BSON decoding on:

 - parsing to `bson.Raw` and `bson.DocElem` fields;
 - skipping unused BSON fields.

* readme: credit @bozaro and @idy (#53)

* readme: credit @bozaro and @idy

* readme: add @idy to contributor list

* do not lock while writing to a socket (#52) (#54)

fix #51
libi pushed a commit to libi/mgo that referenced this pull request Dec 1, 2022
* add DropAllIndexes() method (globalsign#25)

Create a new method to drop all the indexes of a collection
in a single call

* readme: credit @feliixx for globalsign#25 (globalsign#26)

* send metadata during handshake (globalsign#28)

fix [#484](https://github.com/go-mgo/mgo/issues/484)

Annotate connections with metadata provided by the
connecting client.

informations send:

{
 "aplication": {         // optional
   "name": "myAppName"
 }
 "driver": {
    "name": "mgo",
    "version": "v2"
  },
  "os": {
    "type": runtime.GOOS,
    "architecture": runtime.GOARCH
  }
}

to set "application.name", add `appname` param in options
of string connection URI,
for example : "mongodb://localhost:27017?appname=myAppName"

* Update README to add appName (globalsign#32)

* docs: elaborate on what appName does

* readme: add appName to changes

* add method CreateView() (globalsign#33)

Fix globalsign#30.

Thanks to @feliixx for the time and effort.

* readme: credit @feliixx in the README (globalsign#36)

* Don't panic on indexed int64 fields (globalsign#23)

* Stop all db instances after tests (go-mgo#462)

If all tests pass, the builds for mongo earlier than 2.6 are still failing.
Running a clean up fixes the issue.

* fixing int64 type failing when getting indexes and trying to type them

* requested changes relating to case statement and panic

* Update README.md to credit @mapete94.

* tests: ensure indexed int64 fields do not cause a panic in Indexes()

See:
* globalsign#23
* https://github.com/go-mgo/mgo/issues/475
* go-mgo#476

* Add collation option to collection.Create() (globalsign#37)

- Allow specifying the default collation for the collection when creating it.
- Add some documentation to query.Collation() method.

fix globalsign#29

* Test against MongoDB 3.4.x (globalsign#35)

* test against MongoDB 3.4.x

* tests: use listIndexes to assert index state for 3.4+

* make test pass against v3.4.x

  - skip `TestViewWithCollation` because of SERVER-31049,
    cf: https://jira.mongodb.org/browse/SERVER-31049

  - add versionAtLeast() method in init.js script to better
    detect server version

fixes globalsign#31

* Introduce constants for BSON element types (globalsign#41)

* bson.Unmarshal returns time in UTC (globalsign#42)

* readme: add missing features / credit

* Adds missing collation feature description (by @feliixx).
* Adds missing 3.4 tests description (by @feliixx).
* Adds BSON constants description (by @bozaro).
* Adds UTC time.Time unmarshalling (by @gazoon).

* fix golint, go vet and gofmt warnings (globalsign#44)

Fixes globalsign#43

* readme: credit @feliixx (globalsign#46)

* Fix GetBSON() method usage (globalsign#40)

* Fix GetBSON() method usage

Original issue
---

You can't use type with custom GetBSON() method mixed with structure field type and structure field reference type.

For example, you can't create custom GetBSON() for Bar type:

```
struct Foo {
	a  Bar
	b *Bar
}
```

Type implementation (`func (t Bar) GetBSON()` ) would crash on `Foo.b = nil` value encoding.

Reference implementation (`func (t *Bar) GetBSON()` ) would not call on `Foo.a` value encoding.

After this change
---

For type implementation  `func (t Bar) GetBSON()` would not call on `Foo.b = nil` value encoding.
In this case `nil` value would be seariazied as `nil` BSON value.

For reference implementation `func (t *Bar) GetBSON()` would call even on `Foo.a` value encoding.

* Minor refactoring

* readme: credit @bozaro (globalsign#47)
libi pushed a commit to libi/mgo that referenced this pull request Dec 1, 2022
* add DropAllIndexes() method (globalsign#25)

Create a new method to drop all the indexes of a collection
in a single call

* readme: credit @feliixx for globalsign#25 (globalsign#26)

* send metadata during handshake (globalsign#28)

fix [#484](https://github.com/go-mgo/mgo/issues/484)

Annotate connections with metadata provided by the
connecting client.

informations send:

{
 "aplication": {         // optional
   "name": "myAppName"
 }
 "driver": {
    "name": "mgo",
    "version": "v2"
  },
  "os": {
    "type": runtime.GOOS,
    "architecture": runtime.GOARCH
  }
}

to set "application.name", add `appname` param in options
of string connection URI,
for example : "mongodb://localhost:27017?appname=myAppName"

* Update README to add appName (globalsign#32)

* docs: elaborate on what appName does

* readme: add appName to changes

* add method CreateView() (globalsign#33)

Fix globalsign#30.

Thanks to @feliixx for the time and effort.

* readme: credit @feliixx in the README (globalsign#36)

* Don't panic on indexed int64 fields (globalsign#23)

* Stop all db instances after tests (go-mgo#462)

If all tests pass, the builds for mongo earlier than 2.6 are still failing.
Running a clean up fixes the issue.

* fixing int64 type failing when getting indexes and trying to type them

* requested changes relating to case statement and panic

* Update README.md to credit @mapete94.

* tests: ensure indexed int64 fields do not cause a panic in Indexes()

See:
* globalsign#23
* https://github.com/go-mgo/mgo/issues/475
* go-mgo#476

* Add collation option to collection.Create() (globalsign#37)

- Allow specifying the default collation for the collection when creating it.
- Add some documentation to query.Collation() method.

fix globalsign#29

* Test against MongoDB 3.4.x (globalsign#35)

* test against MongoDB 3.4.x

* tests: use listIndexes to assert index state for 3.4+

* make test pass against v3.4.x

  - skip `TestViewWithCollation` because of SERVER-31049,
    cf: https://jira.mongodb.org/browse/SERVER-31049

  - add versionAtLeast() method in init.js script to better
    detect server version

fixes globalsign#31

* Introduce constants for BSON element types (globalsign#41)

* bson.Unmarshal returns time in UTC (globalsign#42)

* readme: add missing features / credit

* Adds missing collation feature description (by @feliixx).
* Adds missing 3.4 tests description (by @feliixx).
* Adds BSON constants description (by @bozaro).
* Adds UTC time.Time unmarshalling (by @gazoon).

* fix golint, go vet and gofmt warnings (globalsign#44)

Fixes globalsign#43

* readme: credit @feliixx (globalsign#46)

* Fix GetBSON() method usage (globalsign#40)

* Fix GetBSON() method usage

Original issue
---

You can't use type with custom GetBSON() method mixed with structure field type and structure field reference type.

For example, you can't create custom GetBSON() for Bar type:

```
struct Foo {
	a  Bar
	b *Bar
}
```

Type implementation (`func (t Bar) GetBSON()` ) would crash on `Foo.b = nil` value encoding.

Reference implementation (`func (t *Bar) GetBSON()` ) would not call on `Foo.a` value encoding.

After this change
---

For type implementation  `func (t Bar) GetBSON()` would not call on `Foo.b = nil` value encoding.
In this case `nil` value would be seariazied as `nil` BSON value.

For reference implementation `func (t *Bar) GetBSON()` would call even on `Foo.a` value encoding.

* Minor refactoring

* readme: credit @bozaro (globalsign#47)

* Improve cursorData struct unmarshaling speed (globalsign#49)

This change remove full BSON decoding on:

 - parsing to `bson.Raw` and `bson.DocElem` fields;
 - skipping unused BSON fields.

* readme: credit @bozaro and @idy (globalsign#53)

* readme: credit @bozaro and @idy

* readme: add @idy to contributor list

* do not lock while writing to a socket (globalsign#52) (globalsign#54)

fix globalsign#51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants