谷歌数据存储全球连接

时间:2017-11-20 20:57:40

标签: google-app-engine go google-cloud-datastore

您如何为数据存储客户端声明全局?

到目前为止,我有:

var (
    db     driver.Conn
    ctx    context.Context
    client datastore.Client
)

忽略数据库。这是我的全球数据库连接。

func bootstrap() {
    ctx = context.Background()
    pId := ProjectId
    var err error
    client, err = datastore.NewClient(ctx, pId)
    if err != nil {
        fmt.Printf("caught error:%v\n", err)
    }

}

我的错误是: 无法将*“cloud.google.com/go/datastore”.Client分配给客户(在多次转让中输入“cloud.google.com/go/datastore".Client”)

1 个答案:

答案 0 :(得分:3)

df.groupby(['id','year']).entr.transform('sum') 更改为client datastore.Client

您的错误消息说明了一切:

client *datastore.Client

稍微冷凝一下......

cannot assign *"cloud.google.com/go/datastore".Client to client (type "cloud.google.com/go/datastore".Client) in multiple assignment

请注意,第一种类型是指针,由cannot assign *ds.Client to client (type ds.Client)... pointer ━━━━┷━━━━━━━━┙ │ │ plain type ━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━┙ 字符表示,第二种类型是普通类型(没有星号)。

相关问题