Rpc error: code = Unknown desc = Empty query

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 ???!

You might have a version mismatch, take a look at: Mutate: rpc error: code = Unknown desc = Empty query · Issue #82 · dgraph-io/dgo · GitHub

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?

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

Now i use dgraph latest in docker compose and dgo v1
it’s work !!!

This is certainly v1.1.0 so you should use Dgo v2.