Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckWellKnownType ¶
CheckWellKnownType checks if a value is one of the proto library's well-known types. The ok return value reports whether the value is a well-known type or not, while the name return value reports the name provided by the proto library for this type.
This is done by checking if the proto message has a XXX_WellKnownType method defined on it.
Types ¶
type Option ¶
Option modifies how ObjectHashes for protobufs is calculated.
func EnumsAsStrings ¶
func EnumsAsStrings() Option
EnumsAsStrings returns an Option to specify that enum values should be hashed as strings instead of being hashed as integers.
This can be useful for compatibility with non-protobuf formats that represent enums as strings, but will have backward-compatiblity consequences for the proto message itself.
func FieldNamesAsKeys ¶
func FieldNamesAsKeys() Option
FieldNamesAsKeys returns an Option to specify that field names should be used as their keys instead of using their tag number.
This can be useful for compatibility with non-protobuf formats that primarily use strings (rather than integers) as keys, but will have backward-compatiblity consequences for the proto message itself.
func MessageIdentifier ¶
MessageIdentifier returns an Option to specify that proto messages should use the supplied argument as their type identifier. This will make messages have a different hash from maps with equivalent contents.
This can be useful for stricter type checking when comparing hashes, but will have consequences for the compatiblity with non-protobuf formats, in particular those that do not provide a container type for messages/structs distinct from that for maps/dictionaries.
type ProtoHasher ¶
ProtoHasher is an interface for hashers that are capable of returning an ObjectHash for protobufs.
func NewHasher ¶
func NewHasher(opts ...Option) ProtoHasher
NewHasher creates a new ProtoHasher with the options specified in the argument.