import ( "github.com/robertkrimen/otto" ) func main() { vm := otto.New() obj, err := vm.Object(`({name:"John", age:30, city:"New York"})`) if err != nil { fmt.Println(err) } fmt.Println(obj) }
import ( "github.com/robertkrimen/otto" ) func main() { vm := otto.New() obj, err := vm.Object(`({name:"John", age:30, city:"New York"})`) if err != nil { fmt.Println(err) } obj.Set("name", "Mike") obj.Set("age", 40) name, _ := obj.Get("name") age, _ := obj.Get("age") city, _ := obj.Get("city") fmt.Println(name) fmt.Println(age) fmt.Println(city) }In this example, we create a new object and set its properties. We then modify the `name` and `age` properties using the `obj.Set()` function. Finally, we retrieve the values of all three properties using the `obj.Get()` function and print them to the console. Overall, the `github.com/robertkrimen/otto` package provides a useful set of functions for working with JavaScript objects in Go.