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

Function ExamplePointer_Set

examples_test.go:104–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102}
103
104func ExamplePointer_Set() {
105 var doc exampleDocument
106
107 if err := json.Unmarshal(testDocumentJSONBytes, &doc); err != nil { // populates doc
108 fmt.Println(err)
109
110 return
111 }
112
113 pointer, err := New("/foo/1")
114 if err != nil {
115 fmt.Println(err)
116
117 return
118 }
119
120 result, err := pointer.Set(&doc, "hey my")
121 if err != nil {
122 fmt.Println(err)
123
124 return
125 }
126
127 fmt.Printf("result: %#v\n", result)
128 fmt.Printf("doc: %#v\n", doc)
129
130 // Output:
131 // result: &jsonpointer.exampleDocument{Foo:[]string{"bar", "hey my"}}
132 // doc: jsonpointer.exampleDocument{Foo:[]string{"bar", "hey my"}}
133}
134
135// ExamplePointer_Set_append demonstrates the RFC 6901 "-" token as an append operation on a slice.
136//

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…