Golang示例无法添加活动。

huangapple go评论87阅读模式
英文:

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}

huangapple
  • 本文由 发表于 2016年11月15日 04:33:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/40597344.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定