docutil

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package docutil has the small operations on JSON-shaped documents (nested map[string]any and []any) that several packages need: copying, merge patches and dot paths. It imports only the standard library, so any package may use it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyPath

func CopyPath(dst, src map[string]any, path []string)

CopyPath copies the value at path (the parts of a dot path) from src into dst, keeping the nesting. A missing path adds nothing, and no empty object is left behind.

func DeepCopy

func DeepCopy(v any) any

DeepCopy copies the maps and slices of a JSON-shaped value; other values are shared.

func DeepCopyMap

func DeepCopyMap(m map[string]any) map[string]any

DeepCopyMap is DeepCopy for a document.

func Get

func Get(doc map[string]any, path string) any

Get is GetPath for callers that treat a missing path as nil.

func GetPath

func GetPath(doc map[string]any, path string) (v any, ok bool)

GetPath reads a dot path ("a.b.c") of a document; ok is false when a member on the way is missing or is not an object.

func MergePatch

func MergePatch(target, patch map[string]any) map[string]any

MergePatch applies an RFC 7396 JSON Merge Patch object to target, which is modified in place and returned. A null value removes the member.

func RemovePath

func RemovePath(doc map[string]any, path string)

RemovePath deletes the value at a dot path of a document, if it is there.

func SetPath

func SetPath(doc map[string]any, path string, v any)

SetPath puts v at a dot path of a document, making the objects on the way.

func SetPathExisting

func SetPathExisting(doc map[string]any, path string, v any)

SetPathExisting puts v at a dot path of a document in place; when an object on the way is missing it does nothing.

Types

This section is empty.

Jump to

Keyboard shortcuts

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