import ( "github.com/conformal/btcutil" ) func main() { block := btcutil.NewBlock(bytes) hash := block.BlockSha() fmt.Println(hash) }
import ( "github.com/conformal/btcutil" ) func main() { blocks := []*btcutil.Block{block1, block2, block3} hashes := make([]btcutil.Hash, len(blocks)) for i, block := range blocks { hashes[i] = block.BlockSha() } fmt.Println(hashes) }In this example, we create a slice of blocks and iterate over them, calling the BlockSha method on each block to get its SHA-256 hash. We store the hashes in a slice of btcutil.Hash objects, which can easily be printed to the console using fmt.Println. Based on its import path and name, the package library that these examples use is github.com/conformal/btcutil.