<commit_before>package websocket

import "golang.org/x/net/websocket"

// Connection represents a connected websocket.
type connection struct {
	id        string
	websocket *websocket.Conn
}

// Close terminates the web socket.
func (c connection) Close() {
	c.websocket.Close()
}

// ID returns the ID associated with the websocket.
func (c connection) ID() string {
	return c.id
}

// Send a payload over the websocket.
func (c connection) Send(payload []byte) (err error) {
	// Force it to be a TextFrame by wrapping in string
	err = websocket.Message.Send(c.websocket, string(payload))
	return
}

// Receive a payload from the websocket.
func (c connection) Receive() (payload []byte, err error) {
	err = websocket.Message.Receive(c.websocket, &payload)
	return
}
<commit_msg>Always return the same error if something goes wrong<commit_after>package websocket

import "golang.org/x/net/websocket"

// Connection represents a connected websocket.
type connection struct {
	id        string
	websocket *websocket.Conn
	err       error
}

// Close terminates the web socket.
func (c connection) Close() {
	c.websocket.Close()
}

// ID returns the ID associated with the websocket.
func (c connection) ID() string {
	return c.id
}

// Send a payload over the websocket.
func (c connection) Send(payload []byte) (err error) {
	if c.err != nil {
		return c.err
	}

	// Force it to be a TextFrame by wrapping in string
	err = websocket.Message.Send(c.websocket, string(payload))
	if err != nil {
		c.err = err
	}
	return
}

// Receive a payload from the websocket.
func (c connection) Receive() (payload []byte, err error) {
	if c.err != nil {
		return nil, c.err
	}

	err = websocket.Message.Receive(c.websocket, &payload)
	if err != nil {
		c.err = err
	}
	return
}

{'fraction_non_alphanumeric': 0.11048158640226628, 'fraction_numerical': 0.0, 'mean_word_length': 3.516624040920716, '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': '3360170', 'n_tokens_mistral': 593, 'n_tokens_neox': 565, 'n_words': 203}