Merge pull request #34 from 178inaba/lint

Fix for golint ./... and ineffassign .
This commit is contained in:
mattn 2017-04-21 00:20:51 +09:00 committed by GitHub
commit f90053da77
7 changed files with 13 additions and 8 deletions

View File

@ -193,11 +193,11 @@ func TestGetAccountFollowing(t *testing.T) {
ClientSecret: "bar", ClientSecret: "bar",
AccessToken: "zoo", AccessToken: "zoo",
}) })
fl, err := client.GetAccountFollowing(context.Background(), 123) _, err := client.GetAccountFollowing(context.Background(), 123)
if err == nil { if err == nil {
t.Fatalf("should be fail: %v", err) t.Fatalf("should be fail: %v", err)
} }
fl, err = client.GetAccountFollowing(context.Background(), 1234567) fl, err := client.GetAccountFollowing(context.Background(), 1234567)
if err != nil { if err != nil {
t.Fatalf("should not be fail: %v", err) t.Fatalf("should not be fail: %v", err)
} }

View File

@ -13,6 +13,7 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
) )
// SimpleJSON is a struct for output JSON for data to be simple used
type SimpleJSON struct { type SimpleJSON struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Username string `json:"username"` Username string `json:"username"`

View File

@ -78,7 +78,8 @@ func prompt() (string, string, error) {
fmt.Print("Password: ") fmt.Print("Password: ")
var password string var password string
if readPassword == nil { if readPassword == nil {
t, err := tty.Open() var t *tty.TTY
t, err = tty.Open()
if err != nil { if err != nil {
return "", "", err return "", "", err
} }

View File

@ -128,6 +128,9 @@ func (c *Client) doAPI(ctx context.Context, method string, uri string, params in
ct = mw.FormDataContentType() ct = mw.FormDataContentType()
} else { } else {
req, err = http.NewRequest(method, u.String(), nil) req, err = http.NewRequest(method, u.String(), nil)
if err != nil {
return err
}
} }
req = req.WithContext(ctx) req = req.WithContext(ctx)
req.Header.Set("Authorization", "Bearer "+c.config.AccessToken) req.Header.Set("Authorization", "Bearer "+c.config.AccessToken)

View File

@ -26,7 +26,7 @@ func (c *Client) GetNotifications(ctx context.Context) ([]*Notification, error)
return notifications, nil return notifications, nil
} }
// GetNotifications return notification. // GetNotification return notification.
func (c *Client) GetNotification(ctx context.Context, id int64) (*Notification, error) { func (c *Client) GetNotification(ctx context.Context, id int64) (*Notification, error) {
var notification Notification var notification Notification
err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, &notification, nil) err := c.doAPI(ctx, http.MethodGet, fmt.Sprintf("/api/v1/notifications/%d", id), nil, &notification, nil)

View File

@ -23,10 +23,10 @@ func (c *Client) GetReports(ctx context.Context) ([]*Report, error) {
return reports, nil return reports, nil
} }
// Report reports the report // Report reports the report
func (c *Client) Report(ctx context.Context, accountId int64, ids []int64, comment string) (*Report, error) { func (c *Client) Report(ctx context.Context, accountID int64, ids []int64, comment string) (*Report, error) {
params := url.Values{} params := url.Values{}
params.Set("account_id", fmt.Sprint(accountId)) params.Set("account_id", fmt.Sprint(accountID))
for _, id := range ids { for _, id := range ids {
params.Add("status_ids[]", fmt.Sprint(id)) params.Add("status_ids[]", fmt.Sprint(id))
} }

View File

@ -202,7 +202,7 @@ func (c *Client) Search(ctx context.Context, q string, resolve bool) (*Results,
return &results, nil return &results, nil
} }
// PostMedia upload a media attachment. // UploadMedia upload a media attachment.
func (c *Client) UploadMedia(ctx context.Context, file string) (*Attachment, error) { func (c *Client) UploadMedia(ctx context.Context, file string) (*Attachment, error) {
var attachment Attachment var attachment Attachment
err := c.doAPI(ctx, http.MethodPost, "/api/v1/media", file, &attachment, nil) err := c.doAPI(ctx, http.MethodPost, "/api/v1/media", file, &attachment, nil)