Structure Go error messages in lowercase without terminal punctuation to match the standard library convention. Use errors.New with a plain string or fmt.Errorf with a format string, ensuring the message starts with the package name if it aids identification.
import "errors"
var ErrNotFound = errors.New("archive/tar: file not found")
func writeHeader(hdr *Header) error {
if hdr.Size < 0 {
return fmt.Errorf("archive/tar: negative file size %d", hdr.Size)
}
return nil
}