|
|
@@ -13,10 +13,7 @@ import (
|
|
|
|
|
|
defval "github.com/golang/protobuf/v2/internal/encoding/defval"
|
|
|
ptype "github.com/golang/protobuf/v2/internal/prototype"
|
|
|
- scalar "github.com/golang/protobuf/v2/internal/scalar"
|
|
|
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
|
|
|
-
|
|
|
- descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
|
|
|
)
|
|
|
|
|
|
var byteType = reflect.TypeOf(byte(0))
|
|
|
@@ -31,8 +28,7 @@ var byteType = reflect.TypeOf(byte(0))
|
|
|
//
|
|
|
// This function is a best effort attempt; parsing errors are ignored.
|
|
|
func Unmarshal(tag string, goType reflect.Type) ptype.Field {
|
|
|
- opts := new(descriptorpb.FieldOptions)
|
|
|
- f := ptype.Field{Options: opts}
|
|
|
+ f := ptype.Field{}
|
|
|
for len(tag) > 0 {
|
|
|
i := strings.IndexByte(tag, ',')
|
|
|
if i < 0 {
|
|
|
@@ -105,9 +101,9 @@ func Unmarshal(tag string, goType reflect.Type) ptype.Field {
|
|
|
case strings.HasPrefix(s, "json="):
|
|
|
f.JSONName = s[len("json="):]
|
|
|
case s == "packed":
|
|
|
- opts.Packed = scalar.Bool(true)
|
|
|
+ f.IsPacked = ptype.True
|
|
|
case strings.HasPrefix(s, "weak="):
|
|
|
- opts.Weak = scalar.Bool(true)
|
|
|
+ f.IsWeak = true
|
|
|
f.MessageType = ptype.PlaceholderMessage(pref.FullName(s[len("weak="):]))
|
|
|
case strings.HasPrefix(s, "def="):
|
|
|
// The default tag is special in that everything afterwards is the
|