key is used to turn a name, such as a repository url, into a filesystem safe name that is unique for querying. To accomplish this a unique hash of the string is used.
(name string)
| 913 | // safe name that is unique for querying. To accomplish this a unique hash of |
| 914 | // the string is used. |
| 915 | func key(name string) (string, error) { |
| 916 | in := strings.NewReader(name) |
| 917 | hash := crypto.SHA256.New() |
| 918 | if _, err := io.Copy(hash, in); err != nil { |
| 919 | return "", nil |
| 920 | } |
| 921 | return hex.EncodeToString(hash.Sum(nil)), nil |
| 922 | } |