<commit_before>package mc

// Handles SASL authentication.

import (
	"fmt"
	"strings"
)

func (cn *Conn) Auth(user, pass string) *MCError {
	s, err := cn.authList()
	if err != nil {
		return err
	}

	switch {
	case strings.Index(s, "PLAIN") != -1:
		return cn.authPlain(user, pass)
	}

	return &MCError{0xffff, fmt.Sprintf("mc: unknown auth types %q", s)}
}

func (cn *Conn) authList() (s string, err *MCError) {
	m := &msg{
		header: header{
			Op: OpAuthList,
		},
	}

	err = cn.sendRecv(m)
	return m.val, err
}

func (cn *Conn) authPlain(user, pass string) *MCError {
	m := &msg{
		header: header{
			Op: OpAuthStart,
		},<commit_msg>document functions in auth.go<commit_after>package mc

// Handles SASL authentication.

import (
	"fmt"
	"strings"
)

// Auth performs SASL authentication (using the PLAIN method) with the server.
func (cn *Conn) Auth(user, pass string) *MCError {
	s, err := cn.authList()
	if err != nil {
		return err
	}

	switch {
	case strings.Index(s, "PLAIN") != -1:
		return cn.authPlain(user, pass)
	}

	return &MCError{0xffff, fmt.Sprintf("mc: unknown auth types %q", s)}
}

// authList runs the SASL authentication list command with the server to
// retrieve the list of support authentication mechansims.
func (cn *Conn) authList() (s string, err *MCError) {
	m := &msg{
		header: header{
			Op: OpAuthList,
		},
	}

	err = cn.sendRecv(m)
	return m.val, err
}

// authPlain performs SASL authentication using the PLAIN method.
func (cn *Conn) authPlain(user, pass string) *MCError {
	m := &msg{
		header: header{
			Op: OpAuthStart,
		},
{'fraction_non_alphanumeric': 0.14276609305289995, 'fraction_numerical': 0.0025493945188017845, 'mean_word_length': 3.631268436578171, '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': '7609417', 'n_tokens_mistral': 622, 'n_tokens_neox': 588, 'n_words': 182}