tpl/transform: Add transform.Unmarshal func

Fixes #5428
This commit is contained in:
Bjørn Erik Pedersen 2018-12-21 16:21:13 +01:00
parent 43f9df0194
commit 822dc627a1
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
20 changed files with 633 additions and 74 deletions

View file

@ -394,11 +394,10 @@ func MD5FromFileFast(r io.ReadSeeker) (string, error) {
return hex.EncodeToString(h.Sum(nil)), nil
}
// MD5FromFile creates a MD5 hash from the given file.
// It will not close the file.
func MD5FromFile(f afero.File) (string, error) {
// MD5FromReader creates a MD5 hash from the given reader.
func MD5FromReader(r io.Reader) (string, error) {
h := md5.New()
if _, err := io.Copy(h, f); err != nil {
if _, err := io.Copy(h, r); err != nil {
return "", nil
}
return hex.EncodeToString(h.Sum(nil)), nil