Set
Overview
Set writes value at dot-separated path, creating intermediate maps (lodash set).
If you are coming from Node.js, the closest pattern is _.set(obj, "a.b", v).
Signature
go
func Set(m map[string]any, path string, value any)Compare: Node.js · Standard Go · gox
js
_.set(obj, "a.b", v)go
// Use the underlying stdlib or driver directly.
// See package overview for escape hatches.go
import "github.com/sahilkhaire/gox/maputil"
maputil.Set(obj, "a.b", v)Example
go
import "github.com/sahilkhaire/gox/maputil"
maputil.Set(obj, "a.b", v)Tips
Import github.com/sahilkhaire/gox/maputil and call Set directly. See the comparison below for the standard library equivalent.
Standard library alternative
gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.