From d5cc235c4827e6c2f488415e41ef08fa9985094b Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Thu, 15 Dec 2016 14:58:54 -0800 Subject: [PATCH] digest: remove stuttering ParseDigest function Signed-off-by: Stephen J Day --- digest/digest.go | 8 ++++++-- digest/digest_test.go | 4 ++-- digest/set.go | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/digest/digest.go b/digest/digest.go index 65c6f7f0..67f3c875 100644 --- a/digest/digest.go +++ b/digest/digest.go @@ -63,12 +63,16 @@ var ( // ParseDigest parses s and returns the validated digest object. An error will // be returned if the format is invalid. -func ParseDigest(s string) (Digest, error) { +func Parse(s string) (Digest, error) { d := Digest(s) - return d, d.Validate() } +// ParseDigest is deprecated. Use Parse. +func ParseDigest(s string) (Digest, error) { + return Parse(s) +} + // FromReader returns the most valid digest for the underlying content using // the canonical digest algorithm. func FromReader(rd io.Reader) (Digest, error) { diff --git a/digest/digest_test.go b/digest/digest_test.go index afb4ebf6..75151e08 100644 --- a/digest/digest_test.go +++ b/digest/digest_test.go @@ -51,7 +51,7 @@ func TestParseDigest(t *testing.T) { err: ErrDigestUnsupported, }, } { - digest, err := ParseDigest(testcase.input) + digest, err := Parse(testcase.input) if err != testcase.err { t.Fatalf("error differed from expected while parsing %q: %v != %v", testcase.input, err, testcase.err) } @@ -69,7 +69,7 @@ func TestParseDigest(t *testing.T) { } // Parse string return value and check equality - newParsed, err := ParseDigest(digest.String()) + newParsed, err := Parse(digest.String()) if err != nil { t.Fatalf("unexpected error parsing input %q: %v", testcase.input, err) diff --git a/digest/set.go b/digest/set.go index 4b9313c1..6074080f 100644 --- a/digest/set.go +++ b/digest/set.go @@ -75,7 +75,7 @@ func (dst *Set) Lookup(d string) (Digest, error) { alg Algorithm hex string ) - dgst, err := ParseDigest(d) + dgst, err := Parse(d) if err == ErrDigestInvalidFormat { hex = d searchFunc = func(i int) bool {