Details
-
Bug
-
Resolution: Fixed
-
Test Blocker
-
None
-
None
-
None
-
DOC-2020-S16-Aug23
Description
Can we please have a full paste-and-run code in the documentation (with package and import parts), like the one below? Maybe even start it with "go mod init couchbase.com/main" instruction.
package main
import (
"fmt"
"github.com/couchbase/gocb/v2"
)
func main() {
cluster, err := gocb.Connect(
"localhost",
gocb.ClusterOptions
)
if err != nil
{ panic(err) }// get a bucket reference
bucket := cluster.Bucket("travel-sample")
// get a collection reference
collection := bucket.DefaultCollection()
// 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.Cas())
// Get Document
getResult, err := collection.Get("my-document", &gocb.GetOptions{})
if err != nil
var myContent interface{}
if err := getResult.Content(&myContent); err != nil { panic(err) }
fmt.Println(myContent)
}