dongyan5815 2016-05-19 05:17
浏览 87

Couchbase GoLang客户端找不到存储桶

I have a TCP server that tries to connect to a Couchbase database using the go-couchbase client library but I get an error saying that the bucket that I'm trying to access, named "events", doesn't exist.

When I use the official Couchbase client library for Go everything works fine.

The difference that I noticed between these two clients is the concept of "pool". I have set this pool to be "default".

What could lead to this Go client not seeing my bucket?

cb, err := couchbase.Connect("http://address:port")
if err != nil {
        log.Fatalf("Error connecting:  %v", err)
}

cbPool, err := cb.GetPool("default")
if err != nil {
    log.Fatalf("Error getting pool: %v", err)
}

cbBucket, err := cbPool.GetBucketWithAuth("events", "username", "password")
if err != nil {
    log.Fatalf("Error getting bucket: %v", err)
}
  • 写回答

1条回答

  • dongyanjing5975 2016-05-20 03:58
    关注

    I'm assuming you're getting some kind of an authentication error. The API is a little bit confusing. GetBucketWithAuth should be called like this:

    GetBucketWithAuth("events", "events", "password")

    The reason is that the client wants the bucket user name and the bucket password. The bucket username is the same as the bucket name.

    With that said I would highly recommend that you use gocb and not go-couchbase. gocb is the official Couchbase go client and go-couchbase is only used internally inside Couchbase. In fact many of the components that use go-couchbase will start using gocb instead since this library is much easier to use and is better organized.

    https://github.com/couchbase/gocb

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办