You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: reader.go
    path of file: ./repos/go-astilectron
    
    the code of the file until where you have to start completion: package astilectron

import (
	"bufio"
	"bytes"
	"context"
	"encoding/json"
	"io"
	"strings"

	"github.com/asticode/go-astikit"
)

// reader represents an object capable of reading in the TCP server
type reader struct {
	ctx context.Con
    
func (r *reader) read() {
	var reader = bufio.NewReader(r.r)
	for {
		// Check context error
		if r.ctx.Err() != nil {
			return
		}

		// Read next line
		var b []byte
		var err error
		if b, err = reader.ReadBytes('\n'); err != nil {
			if !r.isEOFErr(err) {
				r.l.Errorf("%s while reading", err)
				continue
			}
			return
		}
		b = bytes.TrimSpace(b)
		r.l.Debugf("Astilectron says: %s", b)

		// Unmarshal
		var e Event
		if err = json.Unmarshal(b, &e); err != nil {
			r.l.Errorf("%s while unmarshaling %s", err, b)
			continue
		}

		// Dispatch
		r.d.dispatch(e)
	}
}