merge

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

This file contains the implementation of proto.Merge, with new merge options. It also differentiates between null and zero values of Duration and Timestamp.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge

func Merge(dst, src proto.Message)

Merge merges src into dst, which must be a message with the same descriptor.

Populated scalar fields in src are copied to dst, while populated singular messages in src are merged into dst by recursively calling Merge. The elements of every list field in src is appended to the corresponded list fields in dst, unless the ReplaceLists option is true, in which case the list fields in dst are replaced entirely. The entries of every map field in src is copied into the corresponding map field in dst, possibly replacing existing entries. The unknown fields of src are appended to the unknown fields of dst.

It is semantically equivalent to unmarshaling the encoded form of src into dst with the UnmarshalOptions.Merge option specified.

func MergeWithReplace

func MergeWithReplace[T proto.Message](dst, src T)

MergeWithReplace is like Merge, but replaces lists and maps instead of appending to them.

Types

type MergeOptions

type MergeOptions struct {
	// If true, slices are replaced instead of appended to.
	ReplaceLists bool

	// If true, maps are replaced instead of merged.
	ReplaceMaps bool
}

MergeOptions provides a namespace for merge functions, and can be exported in the future if we add user-visible merge options.

func (MergeOptions) Merge

func (o MergeOptions) Merge(dst, src proto.Message)

Jump to

Keyboard shortcuts

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