<commit_before>// to test the panic use go build -race
package main

import "fmt"

type test struct {
	ch  chan string
	foo bool
}

func (t *test) run() {
	for {
		select {
		case v := <-t.ch:
			fmt.Printf("%+v, foo=%+v\n", v, t.foo)
			t.foo = false
		default:
		}
	}
}

func (self *test) Ping() {
	self.ch <- "ping"
}

func New() *test {
	t := &test{
		ch: make(chan string),
	}
	go t.run()
	return t
}

func main() {
	t := New()
	for i := 0; i <= 10; i++ {
		if t.foo {
			t.Ping()
		}
		//	time.Sleep(time.Second)
		if i%3 == 0 {
			t.foo = true
		}
	}
}<commit_msg>fixed panic with atomic.Value<commit_after>// to test the panic use go build -race
package main

import (
	"fmt"
	"sync/atomic"
)

type test struct {
	ch chan string
	atomic.Value
}

func (t *test) run() {
	for {
		select {
		case v := <-t.ch:
			fmt.Printf("%+v, foo=%+v\n", v, t.Load())
			t.Store(false)
		default:
		}
	}
}

func (t *test) Ping() {
	t.ch <- "ping"
}

func New() *test {
	t := &test{
		ch: make(chan string),
	}
	go t.run()
	return t
}

func main() {
	t := New()
	for i := 0; i <= 10; i++ {
		if x, _ := t.Load().(bool); x {
			t.Ping()
		}
		//	time.Sleep(time.Second)
		if i%3 == 0 {
			t.Store(true)
		}
	}
}
{'fraction_non_alphanumeric': 0.20149875104079934, 'fraction_numerical': 0.00832639467110741, 'mean_word_length': 2.348189415041783, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5381514', 'n_tokens_mistral': 597, 'n_tokens_neox': 543, 'n_words': 151}