-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
suggestion: Refactor Library Encoder/Decoder to use github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute #28
Comments
@KingofSouth I currently have a fork which I am refactoring to use dynamodbattribute. I plan on submitting a PR when it is finished. |
I think it's a great idea to support the official The reason this library has a custom implementation is because that package simply didn't exist when I made this. There was no other way to easily (un)marshal DynamoDB AV stuff. Later they added an extremely limited version, essentially a thin wrapper around json.Marshal along with its weird inconsistencies, providing no way to add sets, turning []byte into string instead of binary typed values, etc., so I stopped paying attention to it. I hadn't looked at until now but it seems like they've addressed most of those shortcomings. I need to take a closer look but looking at the tests in @MattAitchison's fork it seems like it's basically equivalent, which is great. Thank you for putting in the work. This library might have some philosophical differences compared to the official one, though. For example, you cannot set a DynamoDB attribute to an empty string. It'll give you an error if you try. Empty strings are super common in Go so this library automatically omits them instead of erroring out. There are a number of types where this library will automatically omit them instead of producing invalid input. Ultimately they are arbitrary decisions I made a long time ago to help me avoid common mistakes. I think our options are:
Apologies for the wall of text, but I hope it helps explain why I'm not immediately pulling the plug on all of my crappy encoding code. There's a lot of real world software I don't want to break by suddenly dropping support for the |
one other thought that I had thought about encoding that I have had on this library is to add a These to methods in the interface:
Then you could have two implementations of that interface one with all of the marshaling code that exists and one that uses the aws default. Would also allow clients to make a single marshaller for handling things like for instance encryption and use it with every struct that they persist. That way every struct in the package doesn't have some boilerplate Just an idea for a potential alternate approach |
Aws sdk has their own implementation of the struct tags contained in this library suggest refactoring this library to make use of their struct tags to stay more inline with the official release
See:
https://godoc.org/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute
The text was updated successfully, but these errors were encountered: