Hi i'm trying to use IBM cloudant DB in go I copied codes from IBM official document
productsDoc := cloudantv1.Document{
ID: core.StringPtr("small-appliances:1000042"),
}
productsDoc.SetProperty("type", "product")
productsDoc.SetProperty("productid", "1000042")
productsDoc.SetProperty("brand", "Salter")
productsDoc.SetProperty("name", "Digital Kitchen Scales")
productsDoc.SetProperty("description", "Slim Colourful Design Electronic Cooking Appliance for Home / Kitchen, Weigh up to 5kg + Aquatronic for Liquids ml + fl. oz. 15Yr Guarantee - Green")
productsDoc.SetProperty("price", 14.99)
productsDoc.SetProperty("image", "assets/img/0gmsnghhew.jpg")
postDocumentOptions := service.NewPostDocumentOptions(
"users",
)
postDocumentOptions.SetDocument(&productsDoc)
service.PostDocument(postDocumentOptions)
Then i ran the code But i got this error runtime error: invalid memory address or nil pointer dereference it says this code is the problem service.PostDocument(postDocumentOptions)
But i don't know why it is a problem please help me thank you
Aucun commentaire:
Enregistrer un commentaire