File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 8080// be returned if the format is invalid.
8181func Parse (s string ) (Digest , error ) {
8282 d := Digest (s )
83- return d , d .Validate ()
83+ if err := d .Validate (); err != nil {
84+ return "" , err
85+ }
86+ return d , nil
8487}
8588
8689// FromReader consumes the content of rd until io.EOF, returning canonical digest.
@@ -137,7 +140,7 @@ func (d Digest) Encoded() string {
137140 return string (d [d .sepIndex ()+ 1 :])
138141}
139142
140- // Hex is deprecated. Please use Digest.Encoded.
143+ // Deprecated: Hex has been deprecated in favor of Digest.Encoded
141144func (d Digest ) Hex () string {
142145 return d .Encoded ()
143146}
Original file line number Diff line number Diff line change @@ -91,15 +91,17 @@ func (dst *Set) Lookup(d string) (digest.Digest, error) {
9191 searchFunc func (int ) bool
9292 alg digest.Algorithm
9393 hex string
94+ dgst digest.Digest
9495 )
95- dgst , err := digest .Parse (d )
96- if err == digest .ErrDigestInvalidFormat {
96+
97+ dgst = digest .Digest (d )
98+ if err := dgst .Validate (); err == digest .ErrDigestInvalidFormat {
9799 hex = d
98100 searchFunc = func (i int ) bool {
99101 return dst .entries [i ].val >= d
100102 }
101- } else {
102- hex = dgst .Hex ()
103+ } else { // Note: `err` is not necessarily `nil` here
104+ hex = dgst .Encoded ()
103105 alg = dgst .Algorithm ()
104106 searchFunc = func (i int ) bool {
105107 if dst .entries [i ].val == hex {
You can’t perform that action at this time.
0 commit comments