func formatToken(t Token, source, multi bool) (s string) {
	switch v := t.(type) {
	case Message:
		s = v.format(source, multi)
	case LengthPrefix:
		s = formatPacked(v, source, multi)
		if s == "" {
			ms := Message(v).format(source, multi)
			s = fmt.Sprintf("%T(%s)", v, ms)
		}
	case Tag:
		s = fmt.Sprintf("%T{%d, %s}", v, v.Number, formatType(v.Type, source))
	case Bool, Varint, Svarint, Uvarint, Int32, Uint32, Float32, Int64, Uint64, Float64:
		if source {
			// Print floats in a way that preserves exact precision.
			if f, _ := v.(Float32); math.IsNaN(float64(f)) || math.IsInf(float64(f), 0) {
				switch {
				case f > 0:
					s = fmt.Sprintf("%T(math.Inf(+1))", v)
				case f < 0:
					s = fmt.Sprintf("%T(math.Inf(-1))", v)
				case math.Float32bits(float32(math.NaN())) == math.Float32bits(float32(f)):
					s = fmt.Sprintf("%T(math.NaN())", v)
				default:
					s = fmt.Sprintf("%T(math.Float32frombits(0x%08x))", v, math.Float32bits(float32(f)))
				}
				break
			}
			if f, _ := v.(Float64); math.IsNaN(float64(f)) || math.IsInf(float64(f), 0) {
				switch {
				case f > 0:
					s = fmt.Sprintf("%T(math.Inf(+1))", v)
				case f < 0:
					s = fmt.Sprintf("%T(math.Inf(-1))", v)
				case math.Float64bits(float64(math.NaN())) == math.Float64bits(float64(f)):
					s = fmt.Sprintf("%T(math.NaN())", v)
				default:
					s = fmt.Sprintf("%T(math.Float64frombits(0x%016x))", v, math.Float64bits(float64(f)))
				}
				break
			}
		}
		s = fmt.Sprintf("%T(%v)", v, v)
	case String, Bytes, Raw:
		s = fmt.Sprintf("%s", v)
		s = fmt.Sprintf("%T(%s)", v, formatString(s))
	case Denormalized:
		s = fmt.Sprintf("%T{+%d, %v}", v, v.Count, formatToken(v.Value, source, multi))
	default:
		panic(fmt.Sprintf("unknown type: %T", v))
	}
	if !source {
		s = trimPackage(s)
	}
	return s
}
// formatToken formats a single token.
formatToken formats a single token.
// formatToken formats a single token .
func formatToken(t Token, source, multi bool) (s string) {
	switch v := t.(type) {
	case Message:
		s = v.format(source, multi)
	case LengthPrefix:
		s = formatPacked(v, source, multi)
		if s == "" {
			ms := Message(v).format(source, multi)
			s = fmt.Sprintf("%T(%s)", v, ms)
		}
	case Tag:
		s = fmt.Sprintf("%T{%d, %s}", v, v.Number, formatType(v.Type, source))
	case Bool, Varint, Svarint, Uvarint, Int32, Uint32, Float32, Int64, Uint64, Float64:
		if source {
			if f, _ := v.(Float32); math.IsNaN(float64(f)) || math.IsInf(float64(f), 0) {
				switch {
				case f > 0:
					s = fmt.Sprintf("%T(math.Inf(+1))", v)
				case f < 0:
					s = fmt.Sprintf("%T(math.Inf(-1))", v)
				case math.Float32bits(float32(math.NaN())) == math.Float32bits(float32(f)):
					s = fmt.Sprintf("%T(math.NaN())", v)
				default:
					s = fmt.Sprintf("%T(math.Float32frombits(0x%08x))", v, math.Float32bits(float32(f)))
				}
				break
			}
			if f, _ := v.(Float64); math.IsNaN(float64(f)) || math.IsInf(float64(f), 0) {
				switch {
				case f > 0:
					s = fmt.Sprintf("%T(math.Inf(+1))", v)
				case f < 0:
					s = fmt.Sprintf("%T(math.Inf(-1))", v)
				case math.Float64bits(float64(math.NaN())) == math.Float64bits(float64(f)):
					s = fmt.Sprintf("%T(math.NaN())", v)
				default:
					s = fmt.Sprintf("%T(math.Float64frombits(0x%016x))", v, math.Float64bits(float64(f)))
				}
				break
			}
		}
		s = fmt.Sprintf("%T(%v)", v, v)
	case String, Bytes, Raw:
		s = fmt.Sprintf("%s", v)
		s = fmt.Sprintf("%T(%s)", v, formatString(s))
	case Denormalized:
		s = fmt.Sprintf("%T{+%d, %v}", v, v.Count, formatToken(v.Value, source, multi))
	default:
		panic(fmt.Sprintf("unknown type: %T", v))
	}
	if !source {
		s = trimPackage(s)
	}
	return s
}
func formatToken ( t Token , source , multi bool ) ( s string ) { switch v := t . ( type ) { case Message : s = v . format ( source , multi ) case LengthPrefix : s = formatPacked ( v , source , multi ) if s == " " { ms := Message ( v ) . format ( source , multi ) s = fmt . Sprintf ( " " , v , ms ) } case Tag : s = fmt . Sprintf ( " " , v , v . Number , formatType ( v . Type , source ) ) case Bool , Varint , Svarint , Uvarint , Int32 , Uint32 , Float32 , Int64 , Uint64 , Float64 : if source { if f , _ := v . ( Float32 ) ; math . IsNaN ( float64 ( f ) ) || math . IsInf ( float64 ( f ) , 0 ) { switch { case f > 0 : s = fmt . Sprintf ( " " , v ) case f < 0 : s = fmt . Sprintf ( " " , v ) case math . Float32bits ( float32 ( math . NaN ( ) ) ) == math . Float32bits ( float32 ( f ) ) : s = fmt . Sprintf ( " " , v ) default : s = fmt . Sprintf ( " " , v , math . Float32bits ( float32 ( f ) ) ) } break } if f , _ := v . ( Float64 ) ; math . IsNaN ( float64 ( f ) ) || math . IsInf ( float64 ( f ) , 0 ) { switch { case f > 0 : s = fmt . Sprintf ( " " , v ) case f < 0 : s = fmt . Sprintf ( " " , v ) case math . Float64bits ( float64 ( math . NaN ( ) ) ) == math . Float64bits ( float64 ( f ) ) : s = fmt . Sprintf ( " " , v ) default : s = fmt . Sprintf ( " " , v , math . Float64bits ( float64 ( f ) ) ) } break } } s = fmt . Sprintf ( " " , v , v ) case String , Bytes , Raw : s = fmt . Sprintf ( " " , v ) s = fmt . Sprintf ( " " , v , formatString ( s ) ) case Denormalized : s = fmt . Sprintf ( " " , v , v . Count , formatToken ( v . Value , source , multi ) ) default : panic ( fmt . Sprintf ( " " , v ) ) } if ! source { s = trimPackage ( s ) } return s }
formatToken formats a single token.
formatToken formats a single token .
// Print floats in a way that preserves exact precision.