Hi , i use this code for connect and run query with go .
but show this error :
2019/09/03 17:33:47 rpc error: code = Unknown desc = Empty query
exit status 1
code :
package main
import (
"context"
"fmt"
"log"
"github.com/dgraph-io/dgo"
"github.com/dgraph-io/dgo/protos/api"
"google.golang.org/grpc"
)
func main() {
conn, err := grpc.Dial("127.0.0.1:8080", grpc.WithInsecure())
if err != nil {
log.Fatal(err)
}
defer conn.Close()
dgraphClient := dgo.NewDgraphClient(api.NewDgraphClient(conn))
ctx := context.Background()
txn := dgraphClient.NewTxn()
defer txn.Discard(ctx)
variables := map[string]string{
"$name": "mhb8898",
}
q := `query name($name: string)
{
name(func : allofterms(UrlName , $name)){
UrlName
}
}`
resp, err := txn.QueryWithVars(ctx, q, variables)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(resp.Json))
}
Can you help me ???!