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: extjson_wrappers.go
    path of file: ./repos/learning/golang/practice/go-crontab/gopath/src/github.com/mongodb/mongo-go-driver/bson
    
    the code of the file until where you have to start completion: // Copyright (C) MongoDB, Inc. 2017-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package bson

import (
	"encoding/base64"
	"encoding/hex"
	"fmt"
	"math"
	"strconv"
	"time"

	"github.com/buger/jsonparser"
	"github.com/mongodb/mongo-go-driver/bson/builder"
	"github.com/mongodb/mongo-go-driver/bson/decimal"
)

type wrapperType byte

const (
	none     wrapperType = 0
	objectID             = iota
	symbol
	int32Type
	int64Type
	double
	decimalType
	binaryData
	code
	timestamp
	regex
	dbPointer
	dateTime
	dbRef
	minKey
	maxKey
	undefined
)

func (w wrapperType) String() string {
	switch w {
	case objectID:
		return "objectID"
	case int32Type:
		return "int32Type"
	case int64Type:
		return "int64"
	case double:
		return "double"
	case decimalType:
		return "decimalType"
	case binaryData:
		return "binary"
	case code:
		return "JavaScript code"
	case timestamp:
		return "timestamp"
	case regex:
		return "regex"
	case dbPointer:
		return "dbpointer"
	case dateTime:
		return "datetime"
	case dbRef:
		return "dbref"
	case minKey:
		return "minkey"
	case maxKey:
		return "maxkey"
	case undefin
    
func parseBinary(data []byte, dataType jsonparser.ValueType) ([]byte, byte, error) {
	if dataType != jsonparser.Object {
		return nil, 0, fmt.Errorf("$binary value should be object, but instead is %s", dataType.String())
	}

	var b []byte
	var subType *int64

	err := jsonparser.ObjectEach(data, func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error {
		switch string(key) {
		case "base64":
			if b != nil {
				return fmt.Errorf("duplicate base64 key in $binary: %s", string(data))
			}

			if dataType != jsonparser.String {
				return fmt.Errorf("$binary base64 value should be string, but instead is %s", dataType.String())
			}

			base64Bytes, err := base64.StdEncoding.DecodeString(string(value))
			if err != nil {
				return fmt.Errorf("invalid $binary base64 string: %s", string(value))
			}

			b = base64Bytes
		case "subType":
			if subType != nil {
				return fmt.Errorf("duplicate subType key in $binary: %s", string(data))
			}

			if dataType != jsonparser.String {
				return fmt.Errorf("$binary subType value should be string, but instead is %s", dataType.String())
			}

			i, err := strconv.ParseInt(string(value), 16, 64)
			if err != nil {
				return fmt.Errorf("invalid $binary subtype string: %s", string(value))
			}

			subType = &i
		default:
			return fmt.Errorf("invalid key in $binary object: %s", string(key))
		}

		return nil
	})

	if err != nil {
		return nil, 0, err
	}

	if b == nil {
		return nil, 0, fmt.Errorf("missing base64 field in $binary object: %s", string(data))
	}

	if subType == nil {
		return nil, 0, fmt.Errorf("missing subType field in $binary object: %s", string(data))

	}

	return b, byte(*subType), nil
}