Search code examples
gogetstream-io

Golang example not working for adding Activity


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
    }

Solution

  • The TO field should look like this. Hope this helps someone:

    To: []getstream.Feed{UserFeed}