From 82ee148846ab6bd16bb3de716352f2e5d06b19f6 Mon Sep 17 00:00:00 2001 From: Jun Hiroe Date: Thu, 27 Apr 2017 01:46:18 +0900 Subject: [PATCH] Fix usage code in README.md skip ci --- README.md | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 374c212..a3fd959 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,32 @@ ## Usage ```go -c := mastodon.NewClient(&mastodon.Config{ - Server: "https://mstdn.jp", - ClientID: "client-id", - ClientSecret: "client-secret", -}) -err := c.Authenticate("your-username", "your-password") -if err != nil { - log.Fatal(err) -} -timeline, err := c.GetTimelineHome(context.Background()) -if err != nil { - log.Fatal(err) +package main + +import ( + "context" + "fmt" + "github.com/mattn/go-mastodon" + "log" +) + +func main() { + c := mastodon.NewClient(&mastodon.Config{ + Server: "https://mstdn.jp", + ClientID: "client-id", + ClientSecret: "client-secret", + }) + err := c.Authenticate(context.Background(), "your-email", "your-password") + if err != nil { + log.Fatal(err) + } + timeline, err := c.GetTimelineHome(context.Background()) + if err != nil { + log.Fatal(err) + } + for i := len(timeline) - 1; i >= 0; i-- { + fmt.Println(timeline[i]) + } } ``` ## Status of implementations