From a182a53108acd89e0b733a80c54960f0b0abea7d Mon Sep 17 00:00:00 2001 From: kt Date: Fri, 27 Apr 2018 00:04:08 -0700 Subject: [PATCH] Add a HashInt helper/schema function --- helper/schema/set.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helper/schema/set.go b/helper/schema/set.go index bb194ee65..cba289035 100644 --- a/helper/schema/set.go +++ b/helper/schema/set.go @@ -17,6 +17,12 @@ func HashString(v interface{}) int { 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 // a *Resource. This is the default set implementation used when a set's // element type is a full resource.