Update dependencies
This commit is contained in:
parent
e97c7f2ada
commit
71b2136a9e
138 changed files with 7864 additions and 968 deletions
78
vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go
generated
vendored
78
vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go
generated
vendored
|
@ -7,7 +7,6 @@ package protoreflect
|
|||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// Value is a union where only one Go type may be set at a time.
|
||||
|
@ -87,7 +86,7 @@ func ValueOf(v interface{}) Value {
|
|||
case Message, List, Map:
|
||||
return valueOfIface(v)
|
||||
default:
|
||||
panic(fmt.Sprintf("invalid type: %v", reflect.TypeOf(v)))
|
||||
panic(fmt.Sprintf("invalid type: %T", v))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,13 +196,55 @@ func (v Value) Interface() interface{} {
|
|||
}
|
||||
}
|
||||
|
||||
func (v Value) typeName() string {
|
||||
switch v.typ {
|
||||
case nilType:
|
||||
return "nil"
|
||||
case boolType:
|
||||
return "bool"
|
||||
case int32Type:
|
||||
return "int32"
|
||||
case int64Type:
|
||||
return "int64"
|
||||
case uint32Type:
|
||||
return "uint32"
|
||||
case uint64Type:
|
||||
return "uint64"
|
||||
case float32Type:
|
||||
return "float32"
|
||||
case float64Type:
|
||||
return "float64"
|
||||
case stringType:
|
||||
return "string"
|
||||
case bytesType:
|
||||
return "bytes"
|
||||
case enumType:
|
||||
return "enum"
|
||||
default:
|
||||
switch v := v.getIface().(type) {
|
||||
case Message:
|
||||
return "message"
|
||||
case List:
|
||||
return "list"
|
||||
case Map:
|
||||
return "map"
|
||||
default:
|
||||
return fmt.Sprintf("<unknown: %T>", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (v Value) panicMessage(what string) string {
|
||||
return fmt.Sprintf("type mismatch: cannot convert %v to %s", v.typeName(), what)
|
||||
}
|
||||
|
||||
// Bool returns v as a bool and panics if the type is not a bool.
|
||||
func (v Value) Bool() bool {
|
||||
switch v.typ {
|
||||
case boolType:
|
||||
return v.num > 0
|
||||
default:
|
||||
panic("proto: value type mismatch")
|
||||
panic(v.panicMessage("bool"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,7 +254,7 @@ func (v Value) Int() int64 {
|
|||
case int32Type, int64Type:
|
||||
return int64(v.num)
|
||||
default:
|
||||
panic("proto: value type mismatch")
|
||||
panic(v.panicMessage("int"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,7 +264,7 @@ func (v Value) Uint() uint64 {
|
|||
case uint32Type, uint64Type:
|
||||
return uint64(v.num)
|
||||
default:
|
||||
panic("proto: value type mismatch")
|
||||
panic(v.panicMessage("uint"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +274,7 @@ func (v Value) Float() float64 {
|
|||
case float32Type, float64Type:
|
||||
return math.Float64frombits(uint64(v.num))
|
||||
default:
|
||||
panic("proto: value type mismatch")
|
||||
panic(v.panicMessage("float"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +295,7 @@ func (v Value) Bytes() []byte {
|
|||
case bytesType:
|
||||
return v.getBytes()
|
||||
default:
|
||||
panic("proto: value type mismatch")
|
||||
panic(v.panicMessage("bytes"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,37 +305,37 @@ func (v Value) Enum() EnumNumber {
|
|||
case enumType:
|
||||
return EnumNumber(v.num)
|
||||
default:
|
||||
panic("proto: value type mismatch")
|
||||
panic(v.panicMessage("enum"))
|
||||
}
|
||||
}
|
||||
|
||||
// Message returns v as a Message and panics if the type is not a Message.
|
||||
func (v Value) Message() Message {
|
||||
switch v := v.getIface().(type) {
|
||||
switch vi := v.getIface().(type) {
|
||||
case Message:
|
||||
return v
|
||||
return vi
|
||||
default:
|
||||
panic("proto: value type mismatch")
|
||||
panic(v.panicMessage("message"))
|
||||
}
|
||||
}
|
||||
|
||||
// List returns v as a List and panics if the type is not a List.
|
||||
func (v Value) List() List {
|
||||
switch v := v.getIface().(type) {
|
||||
switch vi := v.getIface().(type) {
|
||||
case List:
|
||||
return v
|
||||
return vi
|
||||
default:
|
||||
panic("proto: value type mismatch")
|
||||
panic(v.panicMessage("list"))
|
||||
}
|
||||
}
|
||||
|
||||
// Map returns v as a Map and panics if the type is not a Map.
|
||||
func (v Value) Map() Map {
|
||||
switch v := v.getIface().(type) {
|
||||
switch vi := v.getIface().(type) {
|
||||
case Map:
|
||||
return v
|
||||
return vi
|
||||
default:
|
||||
panic("proto: value type mismatch")
|
||||
panic(v.panicMessage("map"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,8 +344,9 @@ func (v Value) MapKey() MapKey {
|
|||
switch v.typ {
|
||||
case boolType, int32Type, int64Type, uint32Type, uint64Type, stringType:
|
||||
return MapKey(v)
|
||||
default:
|
||||
panic(v.panicMessage("map key"))
|
||||
}
|
||||
panic("proto: invalid map key type")
|
||||
}
|
||||
|
||||
// MapKey is used to index maps, where the Go type of the MapKey must match
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue