Comment Comment by voidlogic This code should just call sha1.New(). If for some reason these allocations are a performance issue it is very simple to fix that will a little pooling: package main import ( "crypto/sha1" "hash" "sync" ) func main() { hasher := getHasher() defer poolHasher(hasher) } var hasherPool sync.Pool = sync.Pool{ New: func() interface{} { return sha1.New() }, } func getHasher() hash.Hash { return hasherPool.Get().(hash.Hash) } func poolHasher(hasher hash.Hash) { hasher.Reset() hasherPool.Put(hasher) } parent voidlogic 6 years ago