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: helpers.go
    path of file: ./repos/chai/internal/encoding
    
    the code of the file until where you have to start completion: package encoding

import (
	"bytes"
	"encoding/binary"
	"fmt"
	"math"
)

func write1(dst []byte, code byte, n uint8) []byte {
	return append(dst, code, n)
}

func write2(dst []byte, code byte, n uint16) []byte {
	return append(dst, code, byte(n>>8), byte(n))
}

func write4(dst []byte, code byte, n uint32) []byte {
	return append(
		dst,
		code,
		byte(n>>24),
		byte(n>>16),
		byte(n>>8),
		byte(n),
	)
}

func write8(dst []byte, code byte, n uint64) []byte {
	return append(
		dst,
		code,
		byte(n>>56),
		byte(n>>48),
		byte(n>>40),
		byte(n>>32),
		byte(n>>24),
		byte(n>>16),
		byte(n>>8),
		byte(n),
	)
}

func Skip(b []byte) int {
	if b[0] >= IntSmallValue && b[0] < Uint8Value {
		return 1
	}

	switch b[0] {
	case NullValue, FalseValue, TrueValue, DESC_NullValue, DESC_FalseValue, DESC_TrueValue:
		re
    
func compareNextValue(a, b []byte) (cmp int, n int) {
	if len(a) == 0 || len(b) == 0 {
		if len(a) == 0 && len(b) == 0 {
			return 0, 0
		}

		if len(a) == 0 {
			return -1, 0
		}

		return 1, 0
	}

	// compare the type first
	cmp = int(a[0]) - int(b[0])
	if cmp != 0 {
		return cmp, 1
	}

	if a[0] >= IntSmallValue && a[0] < Uint8Value {
		return 0, 1
	}
	if a[0] <= DESC_IntSmallValue && a[0] > DESC_Uint8Value {
		return 0, 1
	}

	// then compare values
	switch a[0] {
	case TombstoneValue, NullValue, FalseValue, TrueValue,
		DESC_NullValue, DESC_FalseValue, DESC_TrueValue:
		return 0, 1
	}

	// deal with empty values
	if len(a) == 1 || len(b) == 1 {
		if len(a) == 1 && len(b) > 1 {
			return -1, 1
		}

		if len(a) > 1 && len(b) == 1 {
			return 1, 1
		}

		return 0, 1
	}

	// compare non empty values

	t := a[0]
	// if DESC_*, invert the comparison
	if a[0] > 128 {
		t = 255 - t
	}

	cmp, n = compareNonEmptyValues(t, a, b)
	if a[0] > 128 {
		return -cmp, n
	}

	return cmp, n
}