Closed thecodekitchen closed 1 year ago
I am running into the same issue following the example.
type User struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
}
user:= User{
Name: "Test",
}
data, err := handler.db.Create("user", user)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// Unmarshal data
createdUser:= make([]User, 1)
err = surrealdb.Unmarshal(data, &createdUser)
Although from testing it the following will work. I am not sure if the document version using make([]User, 1) is attended or this updated example is the intended solution.
type User struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
}
user:= User{
Name: "Test",
}
data, err := handler.db.Create("user", user)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// Unmarshal data
createdUser:= User{}
err = surrealdb.Unmarshal(data, &createdUser)
Hi @lukasbowen and @thecodekitchen.
I'm sorry for your bad experience with the driver.
the problem you are facing is caused by RPC data response to change with beta 8 to 9.
The driver has been updated but there is no release at the moment.
You can use go get ithub.com/surrealdb/surrealdb.go@0316f40
If it is not working please let me know I can look into out.
also if docs are not enough you can look into unit tests and tests the lib yourself.
@phughk I think we need to make a release. for beta v9 fix.
Thanks ElecTwix! Will do that now
I started a local in-memory database according to the installation instructions, ran go mod init, ran go get github.com/surrealdb/surrealdb.go, created a main.go file in the project root, copied and pasted the example code into it, and ran it with 'go run main.go'. I received the following error:
What's going wrong here?