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: replication_slave.go
    path of file: ./repos/godis/database
    
    the code of the file until where you have to start completion: package database

import (
	"bytes"
	"context"
	"errors"
	"fmt"
	"io/ioutil"
	"net"
	"os"
	"strconv"
	"strings"
	"sync"
	"sync/atomic"
	"time"

	"github.com/hdt3213/godis/aof"
	"github.com/hdt3213/godis/config"
	"github.com/hdt3213/godis/interface/redis"
    
func (server *Server) receiveAOF(ctx context.Context, configVersion int32) error {
	conn := connection.NewConn(server.slaveStatus.masterConn)
	conn.SetMaster()
	server.slaveStatus.running.Add(1)
	defer server.slaveStatus.running.Done()
	for {
		select {
		case payload, open := <-server.slaveStatus.masterChan:
			if !open {
				return errors.New("master channel unexpected close")
			}
			if payload.Err != nil {
				return payload.Err
			}
			cmdLine, ok := payload.Data.(*protocol.MultiBulkReply)
			if !ok {
				return errors.New("unexpected payload: " + string(payload.Data.ToBytes()))
			}
			server.slaveStatus.mutex.Lock()
			if server.slaveStatus.configVersion != configVersion {
				// slaveStatus conf changed during connecting and waiting mutex
				return configChangedErr
			}
			server.Exec(conn, cmdLine.Args)
			n := len(cmdLine.ToBytes()) // todo: directly get size from socket
			server.slaveStatus.replOffset += int64(n)
			server.slaveStatus.lastRecvTime = time.Now()
			logger.Info(fmt.Sprintf("receive %d bytes from master, current offset %d, %s",
				n, server.slaveStatus.replOffset, strconv.Quote(string(cmdLine.ToBytes()))))
			server.slaveStatus.mutex.Unlock()
		case <-ctx.Done():
			_ = conn.Close()
			return nil
		}
	}
}