1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/sha256sum/sha256.go
Carlos Alexandro Becker 4aa098052d
golint comments
2017-01-15 08:48:27 -02:00

27 lines
410 B
Go

package sha256sum
import (
"crypto/sha256"
"encoding/hex"
"io"
"os"
)
// For calculates the SHA256 sum for the given file
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
}