<commit_before>package drum

import (
	"bytes"
	"encoding/binary"
	"errors"
	"io"
	"os"
)

var (
	MAGIC_NUM = []byte{0x53, 0x50, 0x4c, 0x49, 0x43, 0x45}
)

var (
	ErrMagicNumberInvalid = errors.New("pattern: magic number invalid")
)

// StickyErrorReader remembers the first error encountered. Any Read()
// operations following the first error are effectively no-ops.
type StickyErrorReader struct {
	r   io.Reader
	err error
}

// Read implements the io.Reader interface on StickyErrorReader. If an error
// has already occurred it returns that error, otherwise it performs the read.
func (er *StickyErrorReader) Read(p []byte) (n int, err error) {
	if er.err != nil {
		return 0, er.err
	}

	n, err = er.r.Read(p)
	er.err = err

	return
}

// Err returns the first error the StickyErrorReader encountered, if any.
func (er *StickyErrorReader) Err() error {
	return er.err
}

// DecodeFile decodes the drum machine file found at the provided path<commit_msg>go vet and golint<commit_after>package drum

import (
	"bytes"
	"encoding/binary"
	"errors"
	"io"
	"os"
)

// Error when a pattern file's magic number is incorrect
var (
	ErrMagicNumberInvalid = errors.New("pattern: magic number invalid")
)

// StickyErrorReader remembers the first error encountered. Any Read()
// operations following the first error are effectively no-ops.
type StickyErrorReader struct {
	r   io.Reader
	err error
}

// Read implements the io.Reader interface on StickyErrorReader. If an error
// has already occurred it returns that error, otherwise it performs the read.
func (er *StickyErrorReader) Read(p []byte) (n int, err error) {
	if er.err != nil {
		return 0, er.err
	}

	n, err = er.r.Read(p)
	er.err = err

	return
}

// Err returns the first error the StickyErrorReader encountered, if any.
func (er *StickyErrorReader) Err() error {
	return er.err
}

// DecodeFile decodes the drum machine file found at the provided path
{'fraction_non_alphanumeric': 0.0975991649269311, 'fraction_numerical': 0.009916492693110648, 'mean_word_length': 3.8531645569620254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3648835', 'n_tokens_mistral': 637, 'n_tokens_neox': 613, 'n_words': 235}