Does Go SDK support memcached buckets?


I’m trying to use the Go SDK with a Memcached bucket.


package main

import (



const (
mcurl = "http://localhost:8091"
bucketName = "mc"
saslpassword = "saslpassword"
ttl = uint32(3600)

func main() {
cluster, err := gocb.Connect(mcurl)
if err != nil {
fmt.Errorf("%v\n", err)

bucket, err := cluster.OpenBucket(bucketName, saslpassword)
if err != nil {
	fmt.Errorf("%v\n", err)

rndkey := make([]byte, 16)
if _, err := rand.Read(rndkey); err != nil {
	fmt.Errorf("%#v\n", err)
key := hex.EncodeToString(rndkey)
payload := fmt.Sprintf("value-%s", key)

fmt.Printf("Insert {%s, %d, \"%s\"}\n", key, ttl, payload)

cas, err := bucket.Insert(key, payload, ttl)
if err != nil {
	fmt.Errorf("%v\n", err)

fmt.Printf("%v\n", cas)


Works okay with a Couchbase bucket, but with a Memcached bucket it panics with a divide by zero:

$ go run main.go
Insert {973f73381b3d9126c39be7b2144be095, 3600, “value-973f73381b3d9126c39be7b2144be095”}
panic: runtime error: integer divide by zero
[signal 0x8 code=0x7 addr=0xe39bc pc=0xe39bc]

goroutine 1 [running]:*Agent).routeRequest(0xc208052730, 0xc2080642d0, 0xc20800b220)
$(GOCODE)/src/ +0x19c*Agent).dispatchDirect(0xc208052730, 0xc2080642d0, 0x0, 0x0)
$(GOCODE)/src/ +0x44*Agent).dispatchOp(0xc208052730, 0xc2080642d0, 0x0, 0x0, 0x0, 0x0)
$(GOCODE)/src/ +0x56*Agent).store(0xc208052730, 0x2, 0xc20801ee80, 0x20, 0x20, 0xc20803b440, 0x26, 0x30, 0xc204000
$(GOCODE)/src/ +0x376*Agent).Add(0xc208052730, 0xc20801ee80, 0x20, 0x20, 0xc20803b440, 0x26, 0x30, 0xe1004000000, 0
$(GOCODE)/src/ +0xdd·012(0xc20801ee60, 0x0, 0x0, 0x0, 0x0)
$(GOCODE)/src/ +0xee*Bucket).hlpCasExec(0xc208052370, 0xc208079e08, 0x0, 0x0, 0x0)
$(GOCODE)/src/ +0x175*Bucket).Insert(0xc208052370, 0xc20801ee40, 0x20, 0x260a20, 0xc20800b1f0, 0xe10, 0x0, 0x0, 0x0)
$(GOCODE)/src/ +0x156
$(GOCODE)/go-sdk-validation/main.go:38 +0x75c


Hey @jmcgill_public,

Unfortunately the Go SDK does not currently support connecting to a memcached bucket. While support for this is something we will be including in the future, it is not yet available.

Cheers, Brett