hash applies the provided hash algorithm h with ComputeHash.
(h hash.Hash)
| 115 | |
| 116 | // hash applies the provided hash algorithm h with ComputeHash. |
| 117 | func (p *FormatParams) hash(h hash.Hash) (interface{}, error) { |
| 118 | var ( |
| 119 | err error |
| 120 | n int |
| 121 | result interface{} |
| 122 | ) |
| 123 | |
| 124 | if len(p.Args) == 0 || p.Args[0] == "" { |
| 125 | n = defaultHashLength |
| 126 | } else if strings.ToUpper(p.Args[0]) == "FULL" { |
| 127 | n = -1 |
| 128 | } else if n, err = strconv.Atoi(p.Args[0]); err != nil { |
| 129 | return nil, err |
| 130 | } |
| 131 | |
| 132 | if result, err = ComputeHash(p.Info, p.Path, h); err != nil { |
| 133 | return nil, err |
| 134 | } |
| 135 | |
| 136 | return truncate(result.(string), n), nil |
| 137 | } |
| 138 | |
| 139 | // DefaultFormatValue returns the default format value for the provided |
| 140 | // attribute attr based on path and info. |
no test coverage detected