mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +02:00
26 lines
358 B
Go
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
|
|
}
|