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: to_event.go
    path of file: ./repos/plumber/vendor/github.com/cloudevents/sdk-go/v2/binding
    
    the code of the file until where you have to start completion: /*
 Copyright 2021 The CloudEvents Authors
 SPDX-License-Identifier: Apache-2.0
*/

package binding

import (
	"bytes"
	"context"
	"errors"
	"fmt"
	"io"

	"github.com/cloudevents/sdk-go/v2/binding/format"
	"github.com/cloudevents/sdk-go/v2/binding/spec"
	"github.com/cloudevents/sdk-go/v2/event"
	"github.com/cloudevents/sdk-go/v2/types"
)

// 
    
func (b *messageToEventBuilder) SetAttribute(attribute spec.Attribute, value interface{}) error {
	if value == nil {
		_ = attribute.Delete(b.Context)
		return nil
	}
	// If spec version we need to change to right context struct
	if attribute.Kind() == spec.SpecVersion {
		str, err := types.ToString(value)
		if err != nil {
			return err
		}
		switch str {
		case event.CloudEventsVersionV03:
			b.Context = b.Context.AsV03()
		case event.CloudEventsVersionV1:
			b.Context = b.Context.AsV1()
		default:
			return fmt.Errorf("unrecognized event version %s", str)
		}
		return nil
	}
	return attribute.Set(b.Context, value)
}