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: mock.go
    path of file: ./repos/beego/core/bean
    
    the code of the file until where you have to start completion: package bean

import (
	"fmt"
	"reflect"
	"strconv"
	"strings"
)

// Mock have a mock object ,it must be pointer of struct
// the element in mock object can be slices, structures, basic data types, pointers and interface
func Mock(v interface{}) (err error) {
	pv := reflect.ValueOf(v)
	// the input must be pointer of struct
	if pv.Kind() != reflect.Ptr || pv.IsNil() {
		err = fmt.Errorf("not a pointer of struct")
		return
	}
	err = mock(pv)
	return
}

func mock(pv reflect.Value) (err error) {
	pt := pv.Type()
	for i := 0; i < pt.Elem().NumField(); i++ {
		ptt := pt.Elem().Field(i)
		pvv := pv.Elem().FieldByName(ptt.Name)
		if !pvv.CanSet() {
			continue
		}
		kt := ptt.Type.Kind()
		tagValue := ptt.Tag.Get("mock")
		switch kt {
		case reflect.Map:
			continue
		case reflect.Interface:
			if pvv.IsNil() { // when interface is nil,can not sure the type
				continue
			}
			pvv.Set(reflect.New(pvv.Elem().Type().Elem()))
			err = mock(pvv.Elem())
		cas
    
func mockSlice(tagValue string, pvv reflect.Value) (err error) {
	if tagValue == "" {
		return
	}
	sliceMetas := strings.Split(tagValue, ":")
	if len(sliceMetas) != 2 || sliceMetas[0] != "length" {
		err = fmt.Errorf("the value:%s is invalid", tagValue)
		return
	}
	length, e := strconv.Atoi(sliceMetas[1])
	if e != nil {
		return e
	}

	sliceType := reflect.SliceOf(pvv.Type().Elem()) // get slice type
	itemType := sliceType.Elem()                    // get the type of item in slice
	value := reflect.MakeSlice(sliceType, 0, length)
	newSliceValue := make([]reflect.Value, 0, length)
	for k := 0; k < length; k++ {
		itemValue := reflect.New(itemType).Elem()
		// if item in slice is struct or pointer,must set zero value
		switch itemType.Kind() {
		case reflect.Struct:
			err = mock(itemValue.Addr())
		case reflect.Ptr:
			if itemValue.IsNil() {
				itemValue.Set(reflect.New(itemType.Elem()))
				if e := mock(itemValue); e != nil {
					return e
				}
			}
		}
		newSliceValue = append(newSliceValue, itemValue)
		if err != nil {
			return
		}
	}
	value = reflect.Append(value, newSliceValue...)
	pvv.Set(value)
	return
}