I tried using go-mastodon against the https://chaos.social instance, which uses version 2.6.5 according to https://chaos.social/api/v1/instance, with following code:
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/mattn/go-mastodon"
)
func main() {
ctx := context.Background()
c := mastodon.NewClient(&mastodon.Config{
Server: "https://chaos.social",
})
pg := mastodon.Pagination{}
for {
timeline, err := c.GetTimelinePublic(ctx, false, &pg)
if err != nil {
log.Println(err)
}
for _, item := range timeline {
fmt.Printf("%#v\n", item)
}
if pg.MaxID == "" {
break
}
time.Sleep(10 * time.Second)
}
}
This quits with the output
2018/12/21 07:25:04 strconv.ParseInt: parsing "": invalid syntax
which is coming from
|
id, err := strconv.ParseInt(val, 10, 64) |
I have an experimental fix that works for me here for the simple purpose of the above code: https://github.com/marians/go-mastodon/pull/1/files
My understanding of the Mastodon API version differences is not deep enough to tell when min_id has been introduced, where it is used, whether since_id is still in use etc. So I can't provide a PR currently that makes pagination work in all cases. Hopefully the description is enough for others to do so. Thanks!
I tried using go-mastodon against the
https://chaos.socialinstance, which uses version 2.6.5 according to https://chaos.social/api/v1/instance, with following code:This quits with the output
which is coming from
go-mastodon/mastodon.go
Line 296 in 4def10a
I have an experimental fix that works for me here for the simple purpose of the above code: https://github.com/marians/go-mastodon/pull/1/files
My understanding of the Mastodon API version differences is not deep enough to tell when
min_idhas been introduced, where it is used, whethersince_idis still in use etc. So I can't provide a PR currently that makes pagination work in all cases. Hopefully the description is enough for others to do so. Thanks!