MCPcopy Index your code
hub / github.com/go-openapi/jsonpointer / ExamplePointer_Set_appendTopLevelSlice

Function ExamplePointer_Set_appendTopLevelSlice

examples_test.go:165–188  ·  view source on GitHub ↗

ExamplePointer_Set_appendTopLevelSlice shows the one case where the returned document is load-bearing: appending to a top-level slice passed by value. The library cannot rebind the slice header in the caller's variable, so callers must use the returned document (or pass *[]T to get in-place rebind)

()

Source from the content-addressed store, hash-verified

163// The library cannot rebind the slice header in the caller's variable, so callers must use the
164// returned document (or pass *[]T to get in-place rebind).
165func ExamplePointer_Set_appendTopLevelSlice() {
166 doc := []int{1, 2}
167
168 pointer, err := New("/-")
169 if err != nil {
170 fmt.Println(err)
171
172 return
173 }
174
175 out, err := pointer.Set(doc, 3)
176 if err != nil {
177 fmt.Println(err)
178
179 return
180 }
181
182 fmt.Printf("original: %v\n", doc)
183 fmt.Printf("returned: %v\n", out)
184
185 // Output:
186 // original: [1 2]
187 // returned: [1 2 3]
188}
189
190// ExampleUseGoNameProvider contrasts the two [NameProvider] implementations shipped by
191// [github.com/go-openapi/jsonpointer/jsonname]:

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
SetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…