简体   繁体   中英

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
    }

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

To: []getstream.Feed{UserFeed}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM