From ef310d11263ab79053cea9df19308ddf346fb3b7 Mon Sep 17 00:00:00 2001 From: Nima Talebi Date: Thu, 25 Aug 2022 17:49:28 -0700 Subject: [PATCH 1/2] feat: Add two abstraction helper methods These methods are `IsIdenticalTo` and `IsEmpty`. Signed-off-by: Nima Talebi --- digest.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/digest.go b/digest.go index 518b5e7..38aa223 100644 --- a/digest.go +++ b/digest.go @@ -30,7 +30,7 @@ import ( // // The following is an example of the contents of Digest types: // -// sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc +// sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc // // This allows to abstract the digest behind this type and work only in those // terms. @@ -146,6 +146,16 @@ func (d Digest) String() string { return string(d) } +// IsIdenticalTo compares this digest to any other, inclusive of the hashing algorithm used +func (d Digest) IsIdenticalTo(o Digest) bool { + return string(d) == string(o) +} + +// IsEmpty does what it says (an empty digest is an empty string) +func (d Digest) IsEmpty() bool { + return len(d) == 0 +} + func (d Digest) sepIndex() int { i := strings.Index(string(d), ":") From e11a02ca9a949be90df86d8f4c097ec9430471ab Mon Sep 17 00:00:00 2001 From: Nima Talebi Date: Thu, 25 Aug 2022 18:53:50 -0700 Subject: [PATCH 2/2] fix: Ignore IDE cache Signed-off-by: Nima Talebi --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/