fieldmaskmagic

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromFields

func FromFields(msg proto.Message, fields ...proto.Message) (*fieldmaskpb.FieldMask, error)

FromFields returns a new FieldMask with given fields. It determines the paths by finding the fields with the same type in the message. So it works only when:

  1. The specified fields are all message types.
  2. The msg does not contain more than one field with the same type.

func Patch

func Patch[T proto.Message](mask *fieldmaskpb.FieldMask, msg, patch T) (T, error)

Patch returns a copy of origin with all fields in patch applied. If the mask is empty, it returns a copy of the origin message. Please note that it does check recursively.

func Prune

func Prune[T proto.Message](mask *fieldmaskpb.FieldMask, msg T) (T, error)

Prune returns a copy of msg with all fields not in mask removed. If the mask is empty, it returns a copy of msg. Please note that it does check recursively.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL