Details
-
Bug
-
Resolution: Fixed
-
None
-
None
-
None
-
1
Description
The sample code in the web site reads:
import (
"fmt"
gocb "github.com/couchbase/gocb/v2"
)
func main() {
cluster, err := gocb.Connect(
"localhost",
gocb.ClusterOptions
)
if err != nil
// get a bucket reference
bucket := cluster.Bucket("bucket-name")
// get a bucket reference
bucket := cluster.Bucket("travel-sample")
// get a collection reference
collection := bucket.DefaultCollection()
// for a named collection and scope
// scope := bucket.Scope("my-scope")
// collection := scope.Collection("my-collection")
// Upsert Document
upsertData := map[string]string{"name": "mike"}
upsertResult, err := collection.Upsert("my-document", upsertData, &gocb.UpsertOptions{})
if err != nil { panic(err) }
fmt.Println(upsertResult)
// Get Document
getResult, err := collection.Get("my-document", &gocb.GetOptions{})
if err != nil
fmt.Println(getResult)
}
It should be this:
package main
import (
"fmt"
gocb "github.com/couchbase/gocb/v2"
)
func main() {
cluster, err := gocb.Connect(
"localhost",
gocb.ClusterOptions{ Username: "Administrator", Password: "password", })
if err != nil { panic(err) }
// get a bucket reference
bucket := cluster.Bucket("travel-sample")
// get a collection reference
collection := bucket.DefaultCollection()
// for a named collection and scope
// scope := bucket.Scope("my-scope")
// collection := scope.Collection("my-collection")
// Upsert Document
upsertData := map[string]string
upsertResult, err := collection.Upsert("my-document", upsertData, &gocb.UpsertOptions{})
if err != nil
fmt.Println(upsertResult)
// Get Document
getResult, err := collection.Get("my-document", &gocb.GetOptions{})
if err != nil { panic(err) }
fmt.Println(getResult)
}
Attachments
Issue Links
- relates to
-
DOC-6799 Paste-and-run Go SDK example
- Resolved