Add a HashInt helper/schema function

This commit is contained in:
kt 2018-04-27 00:04:08 -07:00
parent c1bc0be7b2
commit a182a53108
No known key found for this signature in database
GPG Key ID: F6893EA8EA295272
1 changed files with 6 additions and 0 deletions

View File

@ -17,6 +17,12 @@ func HashString(v interface{}) int {
return hashcode.String(v.(string)) return hashcode.String(v.(string))
} }
// HashInt hashes integers. If you want a Set of integers, this is the
// SchemaSetFunc you want.
func HashInt(v interface{}) int {
return hashcode.String(strconv.Itoa(v.(int)))
}
// HashResource hashes complex structures that are described using // HashResource hashes complex structures that are described using
// a *Resource. This is the default set implementation used when a set's // a *Resource. This is the default set implementation used when a set's
// element type is a full resource. // element type is a full resource.