User not found for id groot

Hi, i installed the local version for linux following the steps of the duocumentation, but, i have a problem, when i try to connect with Golang, all actions request me a password, but, when i put this, the console say: “User not found for id groot”, and i can’t make anything, anyone can help me please?

Hi,
Welcome to the Dgraph community!

if you mean when you write the grpc.Dial function? If that’s the case, it should be noted that ACL is a feature for the enterprise edition. Chances are you are using the Community Edition of Dgraph. In that case, search your code for code that looks like dg.Login(...). You ain’t gonna need that line.

2 Likes

Hello, thanks for the welcome. i appreciate it
Now… i delete the dg.Login, but the console now say: rpc error code = unknown desc = Line 3 column 7: Missing colon exit status 1, mi code is…

func getDgraphClient() (*dgo.Dgraph, CancelFunc) {
	conn, err := grpc.Dial("localhost:9080", grpc.WithInsecure())
	if err != nil {
		log.Fatal("While trying to dial gRPC")
	}

	dc := api.NewDgraphClient(conn)
	dg := dgo.NewDgraphClient(dc)

	return dg, func() {
		if err := conn.Close(); err != nil {
			log.Printf("Error while closing connection:%v", err)
		}
	}
}

What is Line 3 of your code?

1 Like

Literally… it’s de import of “fmt”

Here, all of my code, in the first method y try the connection, in the main, i try mutate to insert a register in the Graph @chewxy

package main
import (
"fmt"
"context"
"encoding/json"
"log"
dgo "github.com/dgraph-io/dgo/v2"
api "github.com/dgraph-io/dgo/v2/protos/api"
grpc "google.golang.org/grpc"
)

type Person struct {
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Age string `json:"lastname,omitempty"`
}

type CancelFunc func()

func getDgraphClient() (*dgo.Dgraph, CancelFunc) {
conn, err := grpc.Dial("localhost:9080", grpc.WithInsecure())
if err != nil {
	log.Fatal("While trying to dial gRPC")
}

dc := api.NewDgraphClient(conn)
dg := dgo.NewDgraphClient(dc)

return dg, func() {
	if err := conn.Close(); err != nil {
		log.Printf("Error while closing connection:%v", err)
	}
}
}

func main() {
type Person struct {
	Uid      string   `json:"uid,omitempty"`
	Name     string   `json:"name,omitempty"`
	Age      int      `json:"age,omitempty"`
	ID       string     `json:"id,omitempty"`
}

dg, cancel := getDgraphClient()
defer cancel()

p := Person{
	Uid:     "_:alice",
	Name:    "Alice",
	Age:     26,
	ID:      "4cfc265d",
}

op := &api.Operation{}
op.Schema = `
	id: string @index(exact) .
	name string .
	age: int .
	type Person {
		name
		age
		id
	  }
`

ctx := context.Background()
if err := dg.Alter(ctx, op); err != nil {
	log.Fatal(err)
}

mu := &api.Mutation{
	CommitNow: true,
}
pb, err := json.Marshal(p)
if err != nil {
	log.Fatal(err)
}

mu.SetJson = pb
response, err := dg.NewTxn().Mutate(ctx, mu)
if err != nil {
	log.Fatal(err)
}

puid := response.Uids["alice"]
const q = `
	query Me($id: string){
		me(func: uid($id)) {
			name
			age
			loc
			raw_bytes
			dgraph.type
		}
	}
`

variables := make(map[string]string)
variables["$id"] = puid
resp, err := dg.NewTxn().QueryWithVars(ctx, q, variables)
if err != nil {
	log.Fatal(err)
}

type Root struct {
	Me []Person `json:"me"`
}

var r Root
err = json.Unmarshal(resp.Json, &r)
if err != nil {
	log.Fatal(err)
}

out, _ := json.MarshalIndent(r, "", "\t")
fmt.Printf("%s\n", out)
}

See, you are actually missing a colon in line 3 column 7 of input schema.
It should be name: string .

2 Likes

Thanks @abhimanyusinghgaur now my code works, i’m grateful from the help

1 Like