<commit_before>package nntp

import (
    "crypto/tls"
    "fmt"
    "net/textproto"
)

// Interface implementation check
var _ Conn = (*conn)(nil)

// Conn represent(s) a single connection to a NNTP Server
type Conn interface {
    Connect() bool
    Close() error

    SwitchGroup(group string) error
    ArticleExists(id string) (bool, error)
    FetchArticle(id string) ([]byte, error)
}

// Conn represents a NNTP Connection
type conn struct {
    Info        *ServerInfo

    id          int
    conn        *textproto.Conn
    group       string
}

// NewConn create a new NNTP connection based on provided ServerInfo
func NewConn(id int, i *ServerInfo) Conn {
    return &conn {
        id: id,
        Info: i,
    }
}

func (c *conn) String() string {
    return fmt.Sprintf("%s:%d", c.Info.Host, c.id)
}

// Connect to NNTP server
func (c *conn) Connect() bool {
    // (Re)connect
    // Try to connect to newsgroup server
    // if unable to connect start auto-reconnect timer
    if c.Info.TLS {
        // Secured connection is requested
        err := c.dialTLS()
        if err != nil {
            return false
        }

        return true
    }

    err := c.dial()
    if err != nil {
        return false
    }

    return true
}
<commit_msg>fix Connect() include connection error in return<commit_after>package nntp

import (
    "crypto/tls"
    "fmt"
    "net/textproto"
)

// Interface implementation check
var _ Conn = (*conn)(nil)

// Conn represent(s) a single connection to a NNTP Server
type Conn interface {
    Connect() (bool, error)
    Close() error

    SwitchGroup(group string) error
    ArticleExists(id string) (bool, error)
    FetchArticle(id string) ([]byte, error)
}

// Conn represents a NNTP Connection
type conn struct {
    Info        *ServerInfo

    id          int
    conn        *textproto.Conn
    group       string
}

// NewConn create a new NNTP connection based on provided ServerInfo
func NewConn(id int, i *ServerInfo) Conn {
    return &conn {
        id: id,
        Info: i,
    }
}

func (c *conn) String() string {
    return fmt.Sprintf("%s:%d", c.Info.Host, c.id)
}

// Connect to NNTP server
func (c *conn) Connect() (bool, error) {
    // (Re)connect
    // Try to connect to newsgroup server
    // if unable to connect start auto-reconnect timer
    if c.Info.TLS {
        // Secured connection is requested
        err := c.dialTLS()
        if err != nil {
            return false, err
        }

        return true, nil
    }

    err := c.dial()
    if err != nil {
        return false, err
    }

    return true, nil
}

{'fraction_non_alphanumeric': 0.10372646945831733, 'fraction_numerical': 0.0, 'mean_word_length': 2.118562874251497, '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': '1279162', 'n_tokens_mistral': 820, 'n_tokens_neox': 789, 'n_words': 278}