[GODRIVER-890] Error on Marshal method of a struct Created: 20/Mar/19 Updated: 11/Sep/19 Resolved: 02/Apr/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | 1.0.0 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Rafael Souza | Assignee: | Kristofer Brandow (Inactive) |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux Ubuntu 16.4 |
||
| Description |
|
I've made some tests implementing the `Marshaler` and `ValueMarshaler` interfaces, but any of then I was able to make it work. I always get a error similar to this:
Is there any problem with my implementation or is actually a bug? |
| Comments |
| Comment by Kristofer Brandow (Inactive) [ 02/Apr/19 ] | |||||||||||||
|
Hi souzasrafael, that's the correct solution. --Kris | |||||||||||||
| Comment by Rafael Souza [ 01/Apr/19 ] | |||||||||||||
|
I figured out how to make it works:
Thanks! | |||||||||||||
| Comment by Rafael Souza [ 21/Mar/19 ] | |||||||||||||
|
Ian, I did a test using the value marshaler, too:
And get the same error:
So, how can I use the value marshaler correctly? Also, I did a test trying to create a byte array instead of using the bson.Marshal function:
Got the error:
| |||||||||||||
| Comment by Ian Whalen (Inactive) [ 21/Mar/19 ] | |||||||||||||
|
Hey souzasrafael - as per your line here: {{ return bson.Marshal(`fixed value`)}} You can't actually marshal a string, you'll need to use a value marshaler instead. | |||||||||||||
| Comment by Diego Marangoni [ 20/Mar/19 ] | |||||||||||||
|
I'm having the same issue. I can decode normally, but can't encode it |