Dear all,
I’m starting to look at Couchbase and tried to create and Bucket and insert documents into it.
Unfortunattely I do not get any error and no documents are inserted. Any idea where I should start from?
This is my Go Sample Code:
package main
import (
“github.com/couchbase/gocb”
“log”
“github.com/google/uuid”
“fmt”
)
var globalCluster *gocb.Cluster = nil
var globalBucket *gocb.Bucket = nil
func main() {
globalCluster, err := gocb.Connect(“couchbase://localhost”)
if err!=nil{
log.Panic(err)
}
err = globalCluster.Authenticate(gocb.PasswordAuthenticator{“admin”,“password”})
if err!=nil{
log.Panic(err)
}
globalBucket,err = globalCluster.OpenBucket(“property”,"")
if err!=nil{
log.Panic(err)
}
propertyID := uuid.New().String()
property := &Property{“This is my name”}
globalBucket.Insert(propertyID,property,0)
var newProperty Property
globalBucket.Get(propertyID,&newProperty)
fmt.Print(newProperty)
}
type Property struct {
Name string json:"name"
}
Thanks for any help.
Regards,