You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: message.go
    path of file: ./repos/podman/vendor/github.com/sigstore/sigstore/pkg/signature
    
    the code of the file until where you have to start completion: //
// Copyright 2021 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "L
    
func hashMessage(rawMessage io.Reader, hashFunc crypto.Hash) ([]byte, error) {
	if rawMessage == nil {
		return nil, errors.New("message cannot be nil")
	}
	if hashFunc == crypto.Hash(0) {
		return io.ReadAll(rawMessage)
	}
	hasher := hashFunc.New()
	// avoids reading entire message into memory
	if _, err := io.Copy(hasher, rawMessage); err != nil {
		return nil, fmt.Errorf("hashing message: %w", err)
	}
	return hasher.Sum(nil), nil
}