<commit_before>package main

import (
	"github.com/andybons/hipchat"
	"log"
	"time"
)

const (
	timeout time.Duration = 2
)

func SendMessage(msg string, config Config) {
	c := hipchat.Client{AuthToken: config.Token}
	request := hipchat.MessageRequest{
		RoomId:        config.Room,
		From:          config.From,
		Message:       msg,
		Color:         hipchat.ColorPurple,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}

	errc := make(chan error, 1)
	okc := make(chan bool, 1)
	go func() {
		err := c.PostMessage(request)
		if err != nil {
			errc <- err
		}
		okc <- true
	}()

	select {
	case <-okc:
	case err := <-errc:
		log.Printf("Cannot send message: %s %q", msg, err)
	case <-time.After(time.Second * timeout):
		log.Printf("Timout after %d seconds", timeout)
	}
}
<commit_msg>Better error handling with else for ok channel<commit_after>package main

import (
	"log"
	"time"

	"github.com/andybons/hipchat"
)

const (
	timeout time.Duration = 2
)

func SendMessage(msg string, config Config) {
	c := hipchat.Client{AuthToken: config.Token}
	request := hipchat.MessageRequest{
		RoomId:        config.Room,
		From:          config.From,
		Message:       msg,
		Color:         hipchat.ColorPurple,
		MessageFormat: hipchat.FormatText,
		Notify:        true,
	}

	errc := make(chan error, 1)
	okc := make(chan bool, 1)
	go func() {
		err := c.PostMessage(request)
		if err != nil {
			errc <- err
		} else {
			okc <- true
		}
	}()

	select {
	case <-okc:
	case err := <-errc:
		log.Printf("Cannot send message: %s %q", msg, err)
	case <-time.After(time.Second * timeout):
		log.Printf("Timout after %d seconds", timeout)
	}
}

{'fraction_non_alphanumeric': 0.1407766990291262, 'fraction_numerical': 0.0036407766990291263, 'mean_word_length': 2.935560859188544, 'pattern_counts': {'":': 0, '<': 13, '<?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': '1279881', 'n_tokens_mistral': 653, 'n_tokens_neox': 600, 'n_words': 152}