Set implemented to allow use of Algorithm as a command line flag.
(value string)
| 89 | |
| 90 | // Set implemented to allow use of Algorithm as a command line flag. |
| 91 | func (a *Algorithm) Set(value string) error { |
| 92 | if value == "" { |
| 93 | *a = Canonical |
| 94 | } else { |
| 95 | // just do a type conversion, support is queried with Available. |
| 96 | *a = Algorithm(value) |
| 97 | } |
| 98 | |
| 99 | if !a.Available() { |
| 100 | return ErrDigestUnsupported |
| 101 | } |
| 102 | |
| 103 | return nil |
| 104 | } |
| 105 | |
| 106 | // Digester returns a new digester for the specified algorithm. If the algorithm |
| 107 | // does not have a digester implementation, nil will be returned. This can be |