I have been trying to learn to use dgraph Go client. I tried to use the “complete example” from https://dgraph.io/docs/clients/go/#complete-example . But this does not have a main() function. After I added that myself, I kept getting the following error:
$ go run main.go
2020/08/12 06:04:25 rpc error: code = Unknown desc = Schema does not contain a matching predicate for field raw in type Person
Then I tried to use https://godoc.org/github.com/dgraph-io/dgo#example-package--SetObject example. But the
getDgraphClient() is missing. I was able to get it working.
I wish that you would address these issues for future users. Thanks.
Thanks @tamalsaha for the feedback. We apologise for the inconvenience. I have created the task internally for improving documentation regarding this.
I just wanted to echo @tamalsaha’s comments above. I went thru the same process, adding main, getting things running in a debugger and have (only in the debugger) hit the same error ("Schema does not contain a matching predicate for field raw in type Person) finally. I’ve definitely spent too much time on getting this example to work only to hit this. I’m not annoyed but more disappointed. I was hoping to have something working to launch from to continue to make some headway on a proof-of-concept but now having to go back to “the basics”.
I’d just “+1” here in hopes that your task of documentation improvement has already happened. Any chance you have something new to give “the masses” as we attempt to learn how to use the dgo client?
In addition, I’ve attempted to run the tests that come with the client code and those do not work either (out of the box). I’ve run the dgraph server in a couple different ways (as a locally hosted process and as a containerized set of services running in docker) but neither has allowed the dgo tests to pass. Just some additional info here for you. At this point, I’d be happy with just some tests that run succesfully.
Thank you for your comment and welcome to the community.
We are in the process of over-hauling all our docs and this is one of the items in the list. We will address this soon.
Regarding the tests failing, please open a Dgraph dgo issue and we can look into it separately as well. Please provide the steps you followed. I will try to run the tests locally on my end as well.
I tried running the tests in the dgo repo using the
test.sh script. All tests pass for me on my local setup out of the box.
Rebuilding dgraph ...
Commit SHA256: 1252f8aa2b03d4ab85a661306d17e9c5305a08b6
Old SHA256: 0e996cebeecc426cd12efbf1e935fdd76622efe02e5683578289e3ecb53a4392
New SHA256: 0e996cebeecc426cd12efbf1e935fdd76622efe02e5683578289e3ecb53a4392
Creating alpha1 ... done
Creating minio1 ... done
Creating zero1 ... done
Creating alpha2 ... done
Creating zero2 ... done
Creating alpha3 ... done
Creating zero3 ... done
Creating alpha4 ... done
Creating alpha5 ... done
Creating alpha6 ... done
wait-for-it.sh: waiting 60 seconds for localhost:6180
wait-for-it.sh: localhost:6180 is available after 0 seconds
wait-for-it.sh: waiting 60 seconds for localhost:9180
wait-for-it.sh: localhost:9180 is available after 0 seconds
Running tests. Ignoring vendor folder.
Running test for github.com/dgraph-io/dgo/v200
=== RUN TestACLs
--- PASS: TestACLs (31.35s)
=== RUN TestTxnErrFinished
--- PASS: TestTxnErrFinished (2.39s)
=== RUN TestTxnErrReadOnly
--- PASS: TestTxnErrReadOnly (2.69s)
=== RUN TestTxnErrAborted
--- PASS: TestTxnErrAborted (2.53s)
=== RUN TestQueryNoDiscardTxn
--- PASS: TestQueryNoDiscardTxn (0.12s)
=== RUN TestNoType
--- PASS: TestNoType (3.40s)
=== RUN TestSingleType
--- PASS: TestSingleType (3.12s)
=== RUN TestMultipleType
--- PASS: TestMultipleType (2.72s)
=== RUN TestCondUpsertCorrectingName
--- PASS: TestCondUpsertCorrectingName (2.60s)
=== RUN TestUpsertMultiValueEdge
--- PASS: TestUpsertMultiValueEdge (2.61s)
=== RUN TestUpsertEdgeWithBlankNode
--- PASS: TestUpsertEdgeWithBlankNode (2.56s)
=== RUN TestUpsertDeleteOnlyYourPost
--- PASS: TestUpsertDeleteOnlyYourPost (3.42s)
=== RUN TestUpsertBulkUpdateBranch
--- PASS: TestUpsertBulkUpdateBranch (2.60s)
=== RUN TestBulkDelete
--- PASS: TestBulkDelete (2.46s)
=== RUN Example_getSchema
--- PASS: Example_getSchema (0.11s)
=== RUN Example_setObject
--- PASS: Example_setObject (1.75s)
=== RUN ExampleDgraph_Alter_dropAll
--- PASS: ExampleDgraph_Alter_dropAll (0.26s)
=== RUN ExampleTxn_Query_variables
--- PASS: ExampleTxn_Query_variables (2.23s)
=== RUN ExampleTxn_Mutate
--- PASS: ExampleTxn_Mutate (0.54s)
=== RUN ExampleTxn_Mutate_bytes
--- PASS: ExampleTxn_Mutate_bytes (0.95s)
=== RUN ExampleTxn_Query_unmarshal
--- PASS: ExampleTxn_Query_unmarshal (0.10s)
=== RUN ExampleTxn_Query_besteffort
--- PASS: ExampleTxn_Query_besteffort (0.07s)
=== RUN ExampleTxn_Mutate_facets
--- PASS: ExampleTxn_Mutate_facets (2.57s)
=== RUN ExampleDeleteEdges
--- PASS: ExampleDeleteEdges (1.31s)
=== RUN ExampleTxn_Mutate_deleteNode
--- PASS: ExampleTxn_Mutate_deleteNode (0.12s)
=== RUN ExampleTxn_Mutate_deletePredicate
--- PASS: ExampleTxn_Mutate_deletePredicate (0.33s)
=== RUN ExampleTxn_Discard
--- PASS: ExampleTxn_Discard (2.43s)
=== RUN ExampleTxn_Mutate_upsert
--- PASS: ExampleTxn_Mutate_upsert (2.40s)
=== RUN ExampleTxn_Mutate_upsertJSON
--- PASS: ExampleTxn_Mutate_upsertJSON (2.39s)
ok github.com/dgraph-io/dgo/v200 82.124s
Running test for github.com/dgraph-io/dgo/v200/protos/api
? github.com/dgraph-io/dgo/v200/protos/api [no test files]