Merge pull request #46 from suzukaze/fix-usage-code-in-readme.md

Fix usage code in README
pull/47/head
mattn 2017-04-27 09:19:16 +09:00 committed by GitHub
commit e2631e1815
1 changed files with 26 additions and 12 deletions

View File

@ -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