1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00
goreleaser/sha256sum/sha256.go
Carlos Alexandro Becker b4b69ddb25
fixed tests and linters
2017-01-11 14:08:29 -02:00

26 lines
358 B
Go

package sha256sum
import (
"crypto/sha256"
"encoding/hex"
"io"
"os"
)
func For(path string) (result string, err error) {
file, err := os.Open(path)
if err != nil {
return
}
defer func() { _ = file.Close() }()
hash := sha256.New()
_, err = io.Copy(hash, file)
if err != nil {
return
}
result = hex.EncodeToString(hash.Sum(nil))
return
}