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: arshal_default.go
    path of file: ./repos/agones/vendor/k8s.io/kube-openapi/pkg/internal/third_party/go-json-experiment/json
    
    the code of the file until where you have to start completion: // Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package json

import (
	"bytes"
	"encoding/base32"
	"encoding/base64"
	"encoding/hex"
	"errors"
	"fmt"
	"math"
	"reflect"
	"sort"
	"strconv"
	"sync"
)

// optimizeCommon specifies whether to use optimizations targeted for certain
// common patterns, rather than using the slower, but more general logic.
// All tests should pass regardless of whether this is true or not.
const optimizeCommon = true

var (
	// Most natural Go type that correspond with each JSON type.
	anyType          = reflect.TypeOf((*any)(nil)).Elem()            // JSON value
	boolType         = reflect.TypeOf((*bool)(nil)).Elem()           // JSON bool
	stringType       = reflect.TypeOf((*string)(nil)).Elem()         // JSON string
	float64Type      = reflect.TypeOf((*float64)(nil)).Elem()        // JSON number
	mapStringAnyType = reflect.TypeOf((*map[string]any)(nil)).Elem() // JSON object
	sliceAnyType     = reflect.TypeOf((*[]any)(nil)).Elem()          // JSON array

	bytesType       = reflect.TypeOf((*[]byte)(nil)).Elem()
	emptyStructType = reflect.TypeOf((*struct{})(nil)).Elem()
)

const startDetectingCyclesAfter = 1000

type seenPointers map[typedPointer]struct{}

type typedPointer struct {
	typ reflect.Type
	ptr any // always stores unsafe.Pointer, but avoids depending on unsafe
}

// visit visits pointer p of type t, reporting an error if seen before.
// If successfully visited, then the caller must eventually call leave.
func (m *seenPointers) visit(v reflect.Value) error {
	p := typedPointer{v.Type(), v.UnsafePointer()}
	if _, ok := (*m)[p]; ok {
		return &SemanticError{action: "marshal", GoType: p.typ, Err: errors.New("encountered a cycle")}
	}
	if *m == nil {
		*m = make(map[typedPointer]struct{})
	}
	(*m)[p] = struct{}{}
	return nil
}
func (m *seenPointers) leave(v reflect.Value) {
	p := typedPointer{v.Type(), v.UnsafePointer()}
	delete(*m
    
func makeFloatArshaler(t reflect.Type) *arshaler {
	var fncs arshaler
	bits := t.Bits()
	fncs.marshal = func(mo MarshalOptions, enc *Encoder, va addressableValue) error {
		var allowNonFinite bool
		if mo.format != "" && mo.formatDepth == enc.tokens.depth() {
			if mo.format == "nonfinite" {
				allowNonFinite = true
			} else {
				return newInvalidFormatError("marshal", t, mo.format)
			}
		}

		fv := va.Float()
		if math.IsNaN(fv) || math.IsInf(fv, 0) {
			if !allowNonFinite {
				err := fmt.Errorf("invalid value: %v", fv)
				return &SemanticError{action: "marshal", GoType: t, Err: err}
			}
			return enc.WriteToken(Float(fv))
		}

		// Optimize for marshaling without preceding whitespace or string escaping.
		if optimizeCommon && !enc.options.multiline && !mo.StringifyNumbers && !enc.tokens.last.needObjectName() {
			enc.buf = enc.tokens.mayAppendDelim(enc.buf, '0')
			enc.buf = appendNumber(enc.buf, fv, bits)
			enc.tokens.last.increment()
			if enc.needFlush() {
				return enc.flush()
			}
			return nil
		}

		return enc.writeNumber(fv, bits, mo.StringifyNumbers)
	}
	fncs.unmarshal = func(uo UnmarshalOptions, dec *Decoder, va addressableValue) error {
		var allowNonFinite bool
		if uo.format != "" && uo.formatDepth == dec.tokens.depth() {
			if uo.format == "nonfinite" {
				allowNonFinite = true
			} else {
				return newInvalidFormatError("unmarshal", t, uo.format)
			}
		}
		var flags valueFlags
		val, err := dec.readValue(&flags)
		if err != nil {
			return err
		}
		k := val.Kind()
		switch k {
		case 'n':
			va.SetFloat(0)
			return nil
		case '"':
			val = unescapeStringMayCopy(val, flags.isVerbatim())
			if allowNonFinite {
				switch string(val) {
				case "NaN":
					va.SetFloat(math.NaN())
					return nil
				case "Infinity":
					va.SetFloat(math.Inf(+1))
					return nil
				case "-Infinity":
					va.SetFloat(math.Inf(-1))
					return nil
				}
			}
			if !uo.StringifyNumbers {
				break
			}
			if n, err := consumeNumber(val); n != len(val) || err != nil {
				err := fmt.Errorf("cannot parse %q as JSON number: %w", val, strconv.ErrSyntax)
				return &SemanticError{action: "unmarshal", JSONKind: k, GoType: t, Err: err}
			}
			fallthrough
		case '0':
			// NOTE: Floating-point parsing is by nature a lossy operation.
			// We never report an overflow condition since we can always
			// round the input to the closest representable finite value.
			// For extremely large numbers, the closest value is Â±MaxFloat.
			fv, _ := parseFloat(val, bits)
			va.SetFloat(fv)
			return nil
		}
		return &SemanticError{action: "unmarshal", JSONKind: k, GoType: t}
	}
	return &fncs
}