package main
import (
"fmt"
"log"
"github.com/gopherjs/gopherjs/js" // line added for JS *****
"github.com/cayleygraph/cayley"
"github.com/cayleygraph/cayley/quad"
)
func main() {
// Create a brand new graph
store, err := cayley.NewMemoryGraph()
if err != nil {
log.Fatalln(err)
}
store.AddQuad(quad.Make("phrase of the day", "is of course", "Hello World!", nil))
// Now we create the path, to get to our data
p := cayley.StartPath(store, quad.String("phrase of the day")).Out(quad.String("is of course"))
// Now we iterate over results. Arguments:
// 1. Optional context used for cancellation.
// 2. Flag to optimize query before execution.
// 3. Quad store, but we can omit it because we have already built path with it.
err = p.Iterate(nil).EachValue(nil, func(value quad.Value) {
nativeValue := quad.NativeOf(value) // this converts RDF values to normal Go types
fmt.Println(nativeValue) // Look in the javascript console to see this output *****
js.Global.Call("alert", nativeValue) // line added for JS *****
})
if err != nil {
log.Fatalln(err)
}
}