utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffObject added in v0.2.0

func DiffObject(old interface{}, new interface{}, option UpdateJsonOption) interface{}

DiffObject computes a minimal patch that transforms old -> new. It returns: - nil if there are no changes - a map[string]interface{} with only changed fields for objects - a full new array for arrays when they differ - the new primitive value for scalars when they differ

Special handling: OData metadata fields (keys starting with "@odata.") are always included in the result when they exist in the new object and there are other changes. This is required for Microsoft Graph API endpoints that use polymorphic types and need the discriminator field (@odata.type) to be present in PATCH requests.

func ExtractObjectJMES

func ExtractObjectJMES(old interface{}, pathKey, path string) interface{}

ExtractObjectJMES is used to extract object from old using JMES path

func LastSegment added in v0.2.0

func LastSegment(input string) string

func MergeObject

func MergeObject(old interface{}, new interface{}) interface{}

MergeObject is used to merge object old and new, if overlaps, use new value

func NormalizeJson

func NormalizeJson(input interface{}) string

func ResponseErrorWasNotFound

func ResponseErrorWasNotFound(err error) bool

func ResponseErrorWasStatusCode

func ResponseErrorWasStatusCode(err error, statusCode int) bool

func UpdateObject added in v0.2.0

func UpdateObject(old interface{}, new interface{}, option UpdateJsonOption) interface{}

UpdateObject is used to get an updated object which has same schema as old, but with new value

Types

type UpdateJsonOption added in v0.2.0

type UpdateJsonOption struct {
	IgnoreCasing          bool
	IgnoreMissingProperty bool
	IgnoreNullProperty    bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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