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

No Fix.library panics when trying to marshal a nil *time.Time struct member #101

Closed
Nazozen opened this issue Jul 18, 2019 · 3 comments
Closed

Comments

@Nazozen
Copy link

Nazozen commented Jul 18, 2019

Thank you for creating the Dynamo library !!!
I would not have been able to create an application using DynamoDB without this library.

However, this problem has been partially resolved, but not yet resolved.

I defined such a structure.

type Test structure {
ID int64
Timestamp * time.Time
}

In this case, no error occurs, but add an annotation

type Test structure {
ID int64
Timestamp *time.Time dynamo:"onothername,omitempty"
}

I receive a nil pointer reference error as before.

You can also prevent the error by removing the omitempty option.

Copy stack trace when an error occurs.

testing.tRunner.func1 (0xc4201e80f0)
/usr/local/Cellar/go/1.9.3/libexec/src/testing/testing.go: 711 + 0x2d2
Panic (0x1514cc0, 0xc42004f920)
/usr/local/Cellar/go/1.9.3/libexec/src/runtime/panic.go: 491 + 0x283
time. (* Time) .IsZero (0x0, 0x1597b20)
: 1 + 0xa9
github.com/guregu/dynamo.isZero (0x1597b20, 0xc4200ecf18, 0x96, 0x1897901)
/Users/makoto/go/src/github.com/guregu/dynamo/encode.go: 433 + 0x4f3
github.com/guregu/dynamo.marshalStruct (0x1543200, 0xc4200ecf00, 0x99, 0x18979c0, 0x1543200, 0x1543200)
/Users/makoto/go/src/github.com/guregu/dynamo/encode.go: 70 + 0x31e
github.com/guregu/dynamo.marshalItem (0x1543200, 0xc4200ecf00, 0x1525b40, 0xc42010fee8, 0x1010414)
/Users/makoto/go/src/github.com/guregu/dynamo/encode.go: 33 + 0xd6
github.com/guregu/dynamo.Table.Put (0x15a174c, 0xc, 0xc42004f8e0, 0x1543200, 0xc4200ecf00, 0xc42004f8e0)
/Users/makoto/go/src/github.com/guregu/dynamo/put.go: 24 + 0x3c

@guregu
Copy link
Owner

guregu commented Jul 18, 2019

Oh no! Thanks for the report.
I should be able to fix this soon.
In the meantime, feel free to remove omitempty, since it gets omitted automatically anyway.

@guregu guregu closed this as completed in 019aa7b Jul 18, 2019
@guregu
Copy link
Owner

guregu commented Jul 18, 2019

I've fixed this issue and released v1.3.1. Let me know if you have any problems.

@Nazozen
Copy link
Author

Nazozen commented Jul 18, 2019

Thank you!!

I was able to confirm the correction.

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

No branches or pull requests

2 participants