<commit_before>package barcode

import (
	"gobarcode/reader"
	"log"
	"os/exec"
	"strings"
)

var OUTCHAN chan string

func init() {
	OUTCHAN = make(chan string, 1)
}

func Run(doneChan chan string) {
	log.Println("Starting")

	options := []string{
		"--nodisplay",
		"/dev/video0",
	}
	cmd := exec.Command("zbarcam", options...)

	// get the stdout
	processor := reader.New()
	processor.SetOutChannel(OUTCHAN)
	cmd.Stdout = processor

	// run the listener
	go listenAndPipe(OUTCHAN, doneChan)

	// run
	err := cmd.Run()
	if err != nil {
		log.Fatal("zbarcam process failed: ", err)
	}

	log.Println("Exit")
}

func listenAndPipe(outCh <-chan string, doneCh chan<- string) {
	for {
		data := <-outCh
		splitted := strings.Split(strings.TrimSpace(data), ":")
		doneCh <- strings.Join(splitted[1:], ":")
	}
}<commit_msg>small trimming<commit_after>package barcode

import (
	"gobarcode/reader"
	"log"
	"os/exec"
	"strings"
)

var OUTCHAN chan string

func init() {
	OUTCHAN = make(chan string, 1)
}

func Run(doneChan chan string) {
	options := []string{
		"--nodisplay",
		"/dev/video0",
	}
	cmd := exec.Command("zbarcam", options...)

	// get the stdout
	processor := reader.New()
	processor.SetOutChannel(OUTCHAN)
	cmd.Stdout = processor

	// run the listener
	go listenAndPipe(OUTCHAN, doneChan)

	// run
	err := cmd.Run()
	if err != nil {
		log.Fatal("zbarcam process failed: ", err)
	}
}

func listenAndPipe(outCh <-chan string, doneCh chan<- string) {
	for {
		data := <-outCh
		splitted := strings.Split(strings.TrimSpace(data), ":")
		doneCh <- strings.Join(splitted[1:], ":")
	}
}
{'fraction_non_alphanumeric': 0.16761184625078765, 'fraction_numerical': 0.003780718336483932, 'mean_word_length': 3.754491017964072, 'pattern_counts': {'":': 4, '<': 11, '<?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': '7500600', 'n_tokens_mistral': 642, 'n_tokens_neox': 599, 'n_words': 135}