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

Options to always attempt fmt.Stringer and to always assume hash:"set" #1

Merged
merged 2 commits into from
Aug 28, 2019

Conversation

adamhassel
Copy link
Owner

For large structs and legacy code, it's nice to be able to create a checksum without first having to go through all the code and set tags on many fields.

This change introduces options to always assume that a slice is a set, and to always use the fmt.Stringer interface for a struct, if it is present.

The SlicesAsSets option overrides the tag (since it will no longer have any effect).
The UseStringer option is overridden by the tag, in the sense that if the tag is set, it is an error if the type does not implement fmt.Stringer. Using the option alone, we fall back to the default hashing, with the caveat that this means that structs with unexported fields will not be hashed if they don't implement fmt.Stringer.

@adamhassel adamhassel merged commit 6b70a69 into master Aug 28, 2019
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

Successfully merging this pull request may close these issues.

1 participant