github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/google.golang.org/protobuf/reflect/protoreflect/value_pure.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build purego || appengine 6 // +build purego appengine 7 8 package protoreflect 9 10 import "google.golang.org/protobuf/internal/pragma" 11 12 type valueType int 13 14 const ( 15 nilType valueType = iota 16 boolType 17 int32Type 18 int64Type 19 uint32Type 20 uint64Type 21 float32Type 22 float64Type 23 stringType 24 bytesType 25 enumType 26 ifaceType 27 ) 28 29 // value is a union where only one type can be represented at a time. 30 // This uses a distinct field for each type. This is type safe in Go, but 31 // occupies more memory than necessary (72B). 32 type value struct { 33 pragma.DoNotCompare // 0B 34 35 typ valueType // 8B 36 num uint64 // 8B 37 str string // 16B 38 bin []byte // 24B 39 iface interface{} // 16B 40 } 41 42 func valueOfString(v string) Value { 43 return Value{typ: stringType, str: v} 44 } 45 func valueOfBytes(v []byte) Value { 46 return Value{typ: bytesType, bin: v} 47 } 48 func valueOfIface(v interface{}) Value { 49 return Value{typ: ifaceType, iface: v} 50 } 51 52 func (v Value) getString() string { 53 return v.str 54 } 55 func (v Value) getBytes() []byte { 56 return v.bin 57 } 58 func (v Value) getIface() interface{} { 59 return v.iface 60 }