From 68843f4dd029fdd92bcca50053ffa601ae3d103d Mon Sep 17 00:00:00 2001 From: 178inaba <178inaba@users.noreply.github.com> Date: Thu, 20 Apr 2017 21:20:40 +0900 Subject: [PATCH 1/2] Fix for golint ./... --- cmd/mstdn/cmd_stream.go | 1 + notification.go | 2 +- report.go | 6 +++--- status.go | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/mstdn/cmd_stream.go b/cmd/mstdn/cmd_stream.go index c922667..80747c4 100644 --- a/cmd/mstdn/cmd_stream.go +++ b/cmd/mstdn/cmd_stream.go @@ -13,6 +13,7 @@ import ( "github.com/urfave/cli" ) +// SimpleJSON is a struct for output JSON for data to be simple used type SimpleJSON struct { ID int64 `json:"id"` Username string `json:"username"` diff --git a/notification.go b/notification.go index 475b1b4..a25f3f0 100644 --- a/notification.go +++ b/notification.go @@ -26,7 +26,7 @@ func (c *Client) GetNotifications(ctx context.Context) ([]*Notification, error) return notifications, nil } -// GetNotifications return notification. +// GetNotification return notification. func (c *Client) GetNotification(ctx context.Context, id int64) (*Notification, error) { var notification Notification err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, ¬ification, nil) diff --git a/report.go b/report.go index c4b32ef..1e6debf 100644 --- a/report.go +++ b/report.go @@ -23,10 +23,10 @@ func (c *Client) GetReports(ctx context.Context) ([]*Report, error) { return reports, nil } -// Report reports the report -func (c *Client) Report(ctx context.Context, accountId int64, ids []int64, comment string) (*Report, error) { +// Report reports the report +func (c *Client) Report(ctx context.Context, accountID int64, ids []int64, comment string) (*Report, error) { params := url.Values{} - params.Set("account_id", fmt.Sprint(accountId)) + params.Set("account_id", fmt.Sprint(accountID)) for _, id := range ids { params.Add("status_ids[]", fmt.Sprint(id)) } diff --git a/status.go b/status.go index 0b7c8a0..c23c731 100644 --- a/status.go +++ b/status.go @@ -202,7 +202,7 @@ func (c *Client) Search(ctx context.Context, q string, resolve bool) (*Results, return &results, nil } -// PostMedia upload a media attachment. +// UploadMedia upload a media attachment. func (c *Client) UploadMedia(ctx context.Context, file string) (*Attachment, error) { var attachment Attachment err := c.doAPI(ctx, http.MethodPost, "/api/v1/media", file, &attachment, nil) From d1b5f4b1fb5262121e5286b0547406c2e1224d52 Mon Sep 17 00:00:00 2001 From: 178inaba <178inaba@users.noreply.github.com> Date: Thu, 20 Apr 2017 21:29:10 +0900 Subject: [PATCH 2/2] Fix for ineffassign . --- accounts_test.go | 4 ++-- cmd/mstdn/main.go | 3 ++- mastodon.go | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/accounts_test.go b/accounts_test.go index d764000..1e3a0a7 100644 --- a/accounts_test.go +++ b/accounts_test.go @@ -193,11 +193,11 @@ func TestGetAccountFollowing(t *testing.T) { ClientSecret: "bar", AccessToken: "zoo", }) - fl, err := client.GetAccountFollowing(context.Background(), 123) + _, err := client.GetAccountFollowing(context.Background(), 123) if err == nil { t.Fatalf("should be fail: %v", err) } - fl, err = client.GetAccountFollowing(context.Background(), 1234567) + fl, err := client.GetAccountFollowing(context.Background(), 1234567) if err != nil { t.Fatalf("should not be fail: %v", err) } diff --git a/cmd/mstdn/main.go b/cmd/mstdn/main.go index ca268c6..4226be3 100644 --- a/cmd/mstdn/main.go +++ b/cmd/mstdn/main.go @@ -78,7 +78,8 @@ func prompt() (string, string, error) { fmt.Print("Password: ") var password string if readPassword == nil { - t, err := tty.Open() + var t *tty.TTY + t, err = tty.Open() if err != nil { return "", "", err } diff --git a/mastodon.go b/mastodon.go index df97f22..16ccb08 100644 --- a/mastodon.go +++ b/mastodon.go @@ -128,6 +128,9 @@ func (c *Client) doAPI(ctx context.Context, method string, uri string, params in ct = mw.FormDataContentType() } else { req, err = http.NewRequest(method, u.String(), nil) + if err != nil { + return err + } } req = req.WithContext(ctx) req.Header.Set("Authorization", "Bearer "+c.config.AccessToken)