prometheus/vendor/google.golang.org/protobuf/internal/detectknown/detect.go
Bartlomiej Plotka 86ff4a1717 Updated all deps.
Pinned github.com/googleapis/gnostic as they introduced braking change.


Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2020-04-23 13:43:59 +01:00

48 lines
1.5 KiB
Go

// 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 detectknown provides functionality for detecting well-known types
// and identifying them by name.
package detectknown
import "google.golang.org/protobuf/reflect/protoreflect"
type ProtoFile int
const (
Unknown ProtoFile = iota
AnyProto
TimestampProto
DurationProto
WrappersProto
StructProto
FieldMaskProto
EmptyProto
)
var wellKnownTypes = map[protoreflect.FullName]ProtoFile{
"google.protobuf.Any": AnyProto,
"google.protobuf.Timestamp": TimestampProto,
"google.protobuf.Duration": DurationProto,
"google.protobuf.BoolValue": WrappersProto,
"google.protobuf.Int32Value": WrappersProto,
"google.protobuf.Int64Value": WrappersProto,
"google.protobuf.UInt32Value": WrappersProto,
"google.protobuf.UInt64Value": WrappersProto,
"google.protobuf.FloatValue": WrappersProto,
"google.protobuf.DoubleValue": WrappersProto,
"google.protobuf.BytesValue": WrappersProto,
"google.protobuf.StringValue": WrappersProto,
"google.protobuf.Struct": StructProto,
"google.protobuf.ListValue": StructProto,
"google.protobuf.Value": StructProto,
"google.protobuf.FieldMask": FieldMaskProto,
"google.protobuf.Empty": EmptyProto,
}
// Which identifies the proto file that a well-known type belongs to.
func Which(s protoreflect.FullName) ProtoFile {
return wellKnownTypes[s]
}