aboutsummaryrefslogtreecommitdiff
path: root/pkg/utils/utils.go
diff options
context:
space:
mode:
authorgithub-classroom[bot] <66690702+github-classroom[bot]@users.noreply.github.com>2022-02-28 19:36:23 +0000
committergithub-classroom[bot] <66690702+github-classroom[bot]@users.noreply.github.com>2022-02-28 19:36:23 +0000
commit1dd0508d5d3c737f1ee9c723f580baf73b1cfd70 (patch)
tree6adcc5ef85f9cf0bbb205c577da0bac9148114dd /pkg/utils/utils.go
Initial commit
Diffstat (limited to 'pkg/utils/utils.go')
-rw-r--r--pkg/utils/utils.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go
new file mode 100644
index 0000000..5055723
--- /dev/null
+++ b/pkg/utils/utils.go
@@ -0,0 +1,13 @@
+package utils
+
+import (
+ "crypto/sha256"
+ "fmt"
+)
+
+// Hash Adapted from: https://blog.8bitzen.com/posts/22-08-2019-how-to-hash-a-struct-in-go
+func Hash(o interface{}) string {
+ h := sha256.New()
+ h.Write([]byte(fmt.Sprintf("%v", o)))
+ return fmt.Sprintf("%x", h.Sum(nil))
+}