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 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置