Skip to content
Branch: master
Commits on Sep 10, 2019
  1. internal/impl: fix race ExtensionInfo.lazyInitSlow

    dsnet committed Sep 9, 2019
    The xi.init flag should not be set until after we have truly
    initialized everything.
    Change-Id: I43dcb300917145ce19a7199fa871acd0df325c6c
    Reviewed-by: Damien Neil <>
  2. internal/impl: fix panic calling XXX_MessageName on aberrant messages

    dsnet committed Sep 10, 2019
    Call XXX_MessageName with best-effort. If it panics, oh-well.
    Change-Id: I605ea074470b0c90b0bea8b36fa7d4a69368692d
    Reviewed-by: Damien Neil <>
Commits on Sep 9, 2019
  1. compiler/protogen: deprecate certain ways to derive Go package inform…

    dsnet committed Sep 7, 2019
    There are currently at least 5 ways to derive Go package information:
    * From the 'M' command-line flag.
    * From the 'import_path' command-line flag.
    * From the 'go_package' proto file option.
    * From the proto package name in proto source file.
    * From the path of the proto source file.
    Technically, there are more than 5 ways since information can be derived
    from a convoluted combination of all the methods.
    We should move towards a sensible and consistent world where each
    Go package information for each proto source file is:
    * only derived from the command-line OR
    * only derived from the proto source file itself.
    It should never be derived from a mixture of methods.
    In the future, all .proto source files will be required to have a
    "go_package" option specified, unless the "M" command-line argument is
    specified. If the "M" flag is given it takes precedence over 'go_package'.
    This CL prints warnings if the user is generating proto files without
    a "M" flag or "go_package" option specified. It suggests to the user
    a "go_package" option that preserves the current semantics.
    Change-Id: I5cf8d40a245146bb145b3b610d42f1bcd140b449
    Reviewed-by: Damien Neil <>
  2. internal/impl: fix SetLazyValue

    dsnet committed Sep 6, 2019
    Since the internal body calls ExtensionType.ValueOf, it seems that the
    intent is for lazyExtensionValue.value to store a:
    	func() protoreflect.Value
    instead of a:
    	func() interface{}
    This seems more apparent given that GetValue returns a pref.Value.
    Change-Id: I1679fe56088c20d5c8d36360e75dd773850da4c2
    Reviewed-by: Damien Neil <>
  3. internal/impl: preserve nil in ProtoMessageVXOf

    dsnet committed Sep 6, 2019
    ProtoMessageV1(nil) now returns nil.
    ProtoMessageV2(nil) now returns nil.
    Note that the following continue to panic:
    It may be reasonable for them to also return nil in the future.
    Change-Id: Icc14857252d844eb6d4dbfe0c248cef22023e930
    Reviewed-by: Damien Neil <>
  4. internal: improve use of detrand in descfmt and errors

    dsnet committed Sep 7, 2019
    Use a non-breaking space instead of two spaces to vary the output.
    This keeps the mutated version aesthetically similar to the normal one.
    Change-Id: Ib4ade2795004fe5b30e454e7e533e5a0e3a9ffa2
    Reviewed-by: Herbie Ong <>
Commits on Sep 7, 2019
  1. all: make error messages unstable

    dsnet committed Sep 6, 2019
    Use internal/detrand in the construction of our error messages.
    This alters whether there is one or two spaces following the "proto:" prefix.
    While it is easy for users to still work around this mutation,
    sit at least forces them to write test infrastructure to more fuzzily
    match on error strings.
    Change-Id: I4ddca717526ee3fc4dbb1e0b36cfca8c6e0df36d
    Reviewed-by: Herbie Ong <>
Commits on Sep 6, 2019
  1. encoding: verify that the target message is extendable

    dsnet committed Sep 6, 2019
    After resolving a FieldDescriptor from the resolver, verify that the
    returned descriptor truly does extend the target message.
    This will never happen with the global registry, since it checks this
    but can happen with poorly written custom resolvers.
    Change-Id: I2de5b9d2fb9d32e076ec4e82adda98d672891444
    Reviewed-by: Herbie Ong <>
Commits on Sep 5, 2019
  1. internal/mapsort: use explicit kind for strings

    dsnet committed Aug 23, 2019
    Rather than handle the string kind in the default case,
    explicitly check for the string kind.
    Instead, panic with a more useful message for unknown kinds.
    Change-Id: I7e205a19658edd62a03f47f5b50a556dd942bf52
    Reviewed-by: Herbie Ong <>
  2. reflect/protoreflect: emit valid Go from GoString

    dsnet committed Aug 23, 2019
    Rather than using the <unknown:%d> syntax for GoString,
    emit something similar to TypeName(%d),
    which is functionally equivalent to casting the integer
    to the specified type.
    Change-Id: Ibf4bd680d1672fcaba9022fb6bd03bbfe249b8b7
    Reviewed-by: Herbie Ong <>
  3. reflect/protoregistry: add Num methods for every Range method

    dsnet committed Sep 5, 2019
    The Num methods provide an O(1) lookup for the number of entries that Range
    would return. This is needed to implement efficient cache invalidation logic
    for caches that wrap the global registry.
    Change-Id: I7c4ff97f674c4e9e4caae291f017cfad7294856c
    Reviewed-by: Damien Neil <>
  4. internal/impl: support legacy message names

    dsnet committed Sep 5, 2019
    This change:
    * Adds aberrant support for the undocumented XXX_MessageName method.
    * Adds LegacyMessageTypeOf so that v1 registration can suggest a
    fullname to use with a legacy message with no Descriptor support.
    Change-Id: I0265bd3cf67f4d4815358148f5817695c1122dc8
    Reviewed-by: Damien Neil <>
  5. release.bash: support reproducible builds

    dsnet committed Sep 5, 2019
    Manually specifying the "-buildid" removes the last source of variability
    when the release binaries is built on one system or another.
    See golang/go#33772 (comment)
    Change-Id: Ibc9b8e99b5b76719735942a510570bcbf96dfea6
    Reviewed-by: Damien Neil <>
  6. internal/impl: unexport Unwrapper

    dsnet committed Sep 3, 2019
    This interface is only ever used within the impl package.
    Unexport it to avoid potential abuse by users.
    Change-Id: I58d0cc2e8cb01c8c9d36cdec469c8d2196c4f836
    Reviewed-by: Damien Neil <>
Commits on Sep 3, 2019
  1. internal/impl: add ProtoMessageV1Of and ProtoMessageV2Of

    dsnet committed Sep 3, 2019
    These functions are used by v1 code to switch between
    protoV1.Message and protoV2.Message.
    Wrappers over them may be exposed in a hypothetical protoadapt package.
    Change-Id: Ib5265420e34e9888b540307962c70189625d663c
    Reviewed-by: Damien Neil <>
  2. internal/filedesc: fix dependency on legacy generated enums

    dsnet committed Aug 30, 2019
    Suppose you have a generated message with an enum field that
    has a default value, where the enum is declared in another proto file
    that does not register its descriptors.
    In such a situation, the enum dependency cannot be resolved and will
    be left as a placeholder.
    When unmarshalDefault is called, it will attempt to parse the enum
    name stored as the default value, but panic since the placeholder enum
    has no enum values known to it.
    Instead of panicking, use a placeholder enum value that preserves the
    name of default enum value and just use the enum number of 0.
    This is not ideal, but is a better alternative than panicking.
    Change-Id: I5ff6c351adbdd6fe7b41f2d4f215be4aa09e751f
    Reviewed-by: Damien Neil <>
You can’t perform that action at this time.