英文:
Golang example not working for adding Activity
问题
我已经尝试过让这个工作,并且越来越沮丧。我使用了文档中的示例,但是它们抛出了错误。
具体来说,是这个字段:
To: [&UserFeed]
抛出了这个错误:
does not compile: expected type, found ','
以下是代码片段:
getstream_client, err := getstream.New(&getstream.Config{
APIKey: os.Getenv("STREAM_API_KEY"),
APISecret: os.Getenv("STREAM_API_SECRET"),
AppID: os.Getenv("STREAM_APP_ID"),
Location: "us-west",
})
if err != nil {
log.Println("ERR :", err)
}
UserFeed, err := getstream_client.FlatFeed("user", u.StreamId)
if err != nil {
return err
}
GlobalFeed, err := getstream_client.FlatFeed("user", "global")
if err != nil {
return err
}
activity := &getstream.Activity{
Actor: UserFeed.FeedID(),
ForeignID: uuid.New(),
To: [&UserFeed],
Verb: "attempt",
};
activity, err = GlobalFeed.AddActivity(activity);
if err != nil {
return err
}
英文:
I have tried to get this to work and am growing more and more frustrated. I have used the examples in the docs but they are throwing errors.
Specifically this field:
To: [&UserFeed]
Throws this error:
does not compile: expected type, found ','
Here is code snippet:
getstream_client, err := getstream.New(&getstream.Config{
APIKey: os.Getenv("STREAM_API_KEY"),
APISecret: os.Getenv("STREAM_API_SECRET"),
AppID: os.Getenv("STREAM_APP_ID"),
Location: "us-west",
})
if err != nil {
log.Println("ERR :", err)
}
UserFeed, err := getstream_client.FlatFeed("user", u.StreamId)
if err != nil {
return err
}
GlobalFeed, err := getstream_client.FlatFeed("user", "global")
if err != nil {
return err
}
activity := &getstream.Activity{
Actor: UserFeed.FeedID(),
ForeignID: uuid.New(),
To: [&UserFeed],
Verb: "attempt",
};
activity, err = GlobalFeed.AddActivity(activity);
if err != nil {
return err
}
答案1
得分: 2
收到,以下是翻译好的内容:
收件人(TO)字段应该如下所示。希望对某人有所帮助:
To: []getstream.Feed{UserFeed}
英文:
The TO field should look like this. Hope this helps someone:
To: []getstream.Feed{UserFeed}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论