[GODRIVER-605] bson codec is not supporting pointers for inline tags Created: 19/Oct/18  Updated: 27/Oct/23  Resolved: 19/Nov/18

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Mihai B Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Currently if the inline field is a pointer to a struct it returns an error. Pointers to structs are quite common if not idiomatic in Go.

https://github.com/mongodb/mongo-go-driver/blob/44d349d1886bcc181046312daee15bb2533a2d10/bson/bsoncodec/struct_codec.go#L342



 Comments   
Comment by Mihai B [ 10/Nov/18 ]

Sorry for the delay. This is really something that I can't understand. Can you please let me know why you would not support pointers? What harm it makes ? You just need to check if it's a pointer and if so dereference it(like any other encoder from the Go community).

Pointers are part of the language and one good reason why people should use pointers to structs is to reduce the memory usage. The language designers gave us pointers so that we can use them. Structs, being of the value data types are the main candidates for the use of pointers.  Every single struct encoder  supports pointers. 

Comment by Kristofer Brandow (Inactive) [ 05/Nov/18 ]

Closing due to inactivity.

Comment by Kristofer Brandow (Inactive) [ 22/Oct/18 ]

Hi themihai,

This follows the current behavior of the community Go driver's BSON library, which only support value structs and not pointers to structs. Can you elaborate on your use case for inlining a pointer to a struct?

Thanks,

Kris

Generated at Thu Feb 08 08:34:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.