- what is the effect of appending to the slice
s[:0]instead ofnil? I'm guessing it overwrites parts of the existing slice, by sort of passing a pointer to just the beginning of the slice (length of 0) instead of the entire slice?
sum := sha.Sum(s[:0]) // internal behavior of Sum: append(param, otherSlice...)
example: https://cs.opensource.google/go/x/crypto/+/refs/tags/v0.5.0:nacl/box/box.go;l=179
- what is the effect of spreading a slice of a slice out? (difference between these two options)
s = append(s, other...)
s = append(s, other[:]...) // extra allocation for the sub-slice, yes, but why?
example: https://cs.opensource.google/go/go/+/refs/tags/go1.19.4:src/crypto/sha256/sha256.go;l=223