Pick a hash by name
h := crypto.SHA256.New() // requires import of crypto/sha256
io.Copy(h, f)
fmt.Printf("%x\n", h.Sum(nil))
cryptoThe root crypto package. Defines Hash (an enum of registered hash funcs), the Signer and Decrypter interfaces, and little else. Real work happens in subpackages.
Subpackages (crypto/sha256, crypto/sha512, crypto/md5...) register themselves on import. crypto.Hash lets generic code name them.
h := crypto.SHA256.New() // requires import of crypto/sha256
io.Copy(h, f)
fmt.Printf("%x\n", h.Sum(nil))
crypto.Signer is the abstraction used by TLS, ssh, and PKI code: anything with a private key you can sign with. *rsa.PrivateKey, *ecdsa.PrivateKey, ed25519.PrivateKey all implement it.