takin' care of business
this is an adapter library for couchbase client gocb i made gocbadapter for that before, i want refactor and refine by recreating.
it's just same as traditional style
go get github.com/deadcheat/tcb
package main
import (
"fmt"
"github.com/deadcheat/tcb"
)
type Data struct {
Text string
}
func main() {
config := tcb.Configure{
ConnectString: "couchbase://localhost",
BucketConfigs: []tcb.BucketConfig{
tcb.BucketConfig{
Name: "default",
Password: "",
},
},
User: "Administrator",
Password: "password",
}
c := tcb.NewCluster(config)
if err := c.Open(); err != nil {
panic(err)
}
defer c.CloseAll()
o, _ := c.Operator("default")
data := Data{
Text: "TestData",
}
if _, err := o.Insert("key", &data, 0); err != nil {
panic(err)
}
var m Data
if _, err := o.Get("key", &m); err != nil {
panic(err)
}
fmt.Println("data : ", m)
if _, err := o.Remove("key"); err != nil {
panic(err)
}
}