File tree 2 files changed +11
-6
lines changed 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 80
80
// be returned if the format is invalid.
81
81
func Parse (s string ) (Digest , error ) {
82
82
d := Digest (s )
83
- return d , d .Validate ()
83
+ if err := d .Validate (); err != nil {
84
+ return "" , err
85
+ }
86
+ return d , nil
84
87
}
85
88
86
89
// FromReader consumes the content of rd until io.EOF, returning canonical digest.
@@ -137,7 +140,7 @@ func (d Digest) Encoded() string {
137
140
return string (d [d .sepIndex ()+ 1 :])
138
141
}
139
142
140
- // Hex is deprecated. Please use Digest.Encoded.
143
+ // Deprecated: Hex has been deprecated in favor of Digest.Encoded
141
144
func (d Digest ) Hex () string {
142
145
return d .Encoded ()
143
146
}
Original file line number Diff line number Diff line change @@ -91,15 +91,17 @@ func (dst *Set) Lookup(d string) (digest.Digest, error) {
91
91
searchFunc func (int ) bool
92
92
alg digest.Algorithm
93
93
hex string
94
+ dgst digest.Digest
94
95
)
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 {
97
99
hex = d
98
100
searchFunc = func (i int ) bool {
99
101
return dst .entries [i ].val >= d
100
102
}
101
- } else {
102
- hex = dgst .Hex ()
103
+ } else { // Note: `err` is not necessarily `nil` here
104
+ hex = dgst .Encoded ()
103
105
alg = dgst .Algorithm ()
104
106
searchFunc = func (i int ) bool {
105
107
if dst .entries [i ].val == hex {
You can’t perform that action at this time.
0 commit comments