From 70b6261e3403b9769f81b939851df0143ea8d3d4 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sun, 16 Apr 2017 23:38:53 +0900 Subject: [PATCH] golint & go vet --- accounts.go | 2 +- cmd/mstdn/cmd_stream.go | 1 + cmd/mstdn/main.go | 6 +++--- mastodon.go | 1 + notification.go | 2 +- status.go | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/accounts.go b/accounts.go index 0dd7fa3..ee9cec3 100644 --- a/accounts.go +++ b/accounts.go @@ -219,7 +219,7 @@ func (c *Client) AccountsSearch(q string, limit int64) ([]*Account, error) { return accounts, nil } -// Follow send follow-request. +// FollowRemoteUser send follow-request. func (c *Client) FollowRemoteUser(uri string) (*Account, error) { params := url.Values{} params.Set("uri", uri) diff --git a/cmd/mstdn/cmd_stream.go b/cmd/mstdn/cmd_stream.go index 6105896..50aba7d 100644 --- a/cmd/mstdn/cmd_stream.go +++ b/cmd/mstdn/cmd_stream.go @@ -14,6 +14,7 @@ import ( func cmdStream(c *cli.Context) error { client := c.App.Metadata["client"].(*mastodon.Client) ctx, cancel := context.WithCancel(context.Background()) + defer cancel() sc := make(chan os.Signal, 1) signal.Notify(sc, os.Interrupt) q, err := client.StreamingPublic(ctx) diff --git a/cmd/mstdn/main.go b/cmd/mstdn/main.go index a8a6349..1903c34 100644 --- a/cmd/mstdn/main.go +++ b/cmd/mstdn/main.go @@ -54,7 +54,7 @@ func textContent(s string) string { } var ( - readUsername func() (string, error) = func() (string, error) { + readUsername = func() (string, error) { b, _, err := bufio.NewReader(os.Stdin).ReadLine() if err != nil { return "", err @@ -134,11 +134,11 @@ func authenticate(client *mastodon.Client, config *mastodon.Config, file string) } b, err := json.MarshalIndent(config, "", " ") if err != nil { - return fmt.Errorf("failed to store file:", err) + return fmt.Errorf("failed to store file: %v", err) } err = ioutil.WriteFile(file, b, 0700) if err != nil { - return fmt.Errorf("failed to store file:", err) + return fmt.Errorf("failed to store file: %v", err) } return nil } diff --git a/mastodon.go b/mastodon.go index e3fbb88..3cdf902 100644 --- a/mastodon.go +++ b/mastodon.go @@ -139,6 +139,7 @@ type Attachment struct { TextURL string `json:"text_url"` } +// Results hold information for search result. type Results struct { Accounts []*Account `json:"accounts"` Statuses []*Status `json:"statuses"` diff --git a/notification.go b/notification.go index 6fa2436..b8762c0 100644 --- a/notification.go +++ b/notification.go @@ -25,7 +25,7 @@ func (c *Client) GetNotifications() ([]*Notification, error) { return notifications, nil } -// GetNotifications return notifications. +// GetNotification return notifications. func (c *Client) GetNotification(id int64) (*Notification, error) { var notification Notification err := c.doAPI(http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, ¬ification) diff --git a/status.go b/status.go index 4536aae..ae20794 100644 --- a/status.go +++ b/status.go @@ -33,8 +33,8 @@ type Status struct { // Context hold information for mastodon context. type Context struct { - Ancestors []*Status `ancestors` - Descendants []*Status `descendants` + Ancestors []*Status `json:"ancestors"` + Descendants []*Status `json:"descendants"` } // Card hold information for mastodon card.