mehrdad.dev
(mehrdad mohammadian)
September 3, 2019, 1:16pm
1
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 ???!
jawr
(Jess Lawrence)
September 3, 2019, 1:23pm
2
mehrdad.dev
(mehrdad mohammadian)
September 3, 2019, 1:32pm
3
How to install dgo v1 ??
in this issues write this link : github.com/dgraph-io/dgo
and i install this dgo and my version dgraph v1.0.17
and in github dgo :
Note, dgo 1.0.0 works with dgraph 1.0.x only
Note, dgo 2.0.0 works with dgraph 1.1.x only
go get -u -v github.com/dgraph-io/dgo
i use this go get for install …
is it v1?
MichelDiz
(Michel Diz)
September 7, 2019, 2:43am
4
mehrdad.dev:
How to install dgo v1 ??
Run
go get -u -v github.com/dgraph-io/dgo/v1
or go to
~/go/src/github.com/dgraph-io/dgo
And do a git checkout to V1
git checkout dgraph/release/v1.0
mehrdad.dev
(mehrdad mohammadian)
September 14, 2019, 7:53am
5
Now i use dgraph latest in docker compose and dgo v1
it’s work !!!
MichelDiz
(Michel Diz)
September 14, 2019, 3:35pm
6
mehrdad.dev:
dgraph latest in docker
This is certainly v1.1.0 so you should use Dgo v2.