From fe87b5a44aed0b2e50e28bb51e26b31e1be66843 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Tue, 10 Jan 2017 15:28:23 +0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=99=82=20Fix=20codestyle=20and=20some=20t?= =?UTF-8?q?hings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- account.go | 3 ++- content.go | 3 ++- page.go | 3 ++- telegraph.go | 5 +++-- valid_test.go | 14 ++++++-------- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index f53dda7..b2a93f5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Build Status](https://travis-ci.org/toby3d/telegraph.svg)](https://travis-ci.org/toby3d/telegraph) [![GoDoc](https://godoc.org/github.com/toby3d/telegraph?status.svg)](https://godoc.org/github.com/toby3d/telegraph) [![Go Report](https://goreportcard.com/badge/github.com/toby3d/telegraph)](https://goreportcard.com/report/github.com/toby3d/telegraph) -[![Patreon](https://img.shields.io/badge/support-patreon-E66500.svg?maxAge=2592000)](https://www.patreon.com/toby3d) +[![Patreon](https://img.shields.io/badge/support-patreon-E6461A.svg?maxAge=2592000)](https://www.patreon.com/toby3d) All [methods](http://telegra.ph/api#Available-methods) and [types](http://telegra.ph/api#Available-types) available! Yaay! diff --git a/account.go b/account.go index 6f9d991..3306c52 100644 --- a/account.go +++ b/account.go @@ -3,8 +3,9 @@ package telegraph import ( "encoding/json" "fmt" - "github.com/valyala/fasthttp" "strings" + + "github.com/valyala/fasthttp" ) // CreateAccount create a new Telegraph account. Most users only need one diff --git a/content.go b/content.go index 5272367..602ee2c 100644 --- a/content.go +++ b/content.go @@ -4,8 +4,9 @@ import ( "bytes" "errors" "fmt" - "golang.org/x/net/html" "strings" + + "golang.org/x/net/html" ) var availableTags = map[string]bool{ diff --git a/page.go b/page.go index f5d1521..fe5b810 100644 --- a/page.go +++ b/page.go @@ -3,8 +3,9 @@ package telegraph import ( "encoding/json" "fmt" - "github.com/valyala/fasthttp" "strconv" + + "github.com/valyala/fasthttp" ) // CreatePage create a new Telegraph page. On success, returns a Page object. diff --git a/telegraph.go b/telegraph.go index 3156f0d..ab6d73d 100644 --- a/telegraph.go +++ b/telegraph.go @@ -5,6 +5,7 @@ package telegraph import ( "encoding/json" "errors" + "github.com/valyala/fasthttp" ) @@ -132,13 +133,13 @@ type ( ) func request(url string, args *fasthttp.Args) (*Response, error) { - _, res, err := fasthttp.Post(nil, url, args) + _, resp, err := fasthttp.Post(nil, url, args) if err != nil { return nil, err } var tResp Response - if err := json.Unmarshal(res, &tResp); err != nil { + if err := json.Unmarshal(resp, &tResp); err != nil { return nil, err } diff --git a/valid_test.go b/valid_test.go index 642c438..fad7de4 100644 --- a/valid_test.go +++ b/valid_test.go @@ -29,7 +29,7 @@ func TestCreateValidAccount(t *testing.T) { } demoAccount = *account - t.Logf("New account created!\n%#v", *account) + t.Logf("New account created!") } func TestCreateValidPage(t *testing.T) { @@ -61,12 +61,12 @@ func TestEditValidAccountInfo(t *testing.T) { AuthorURL: "https://telegram.me/telegraph", } - info, err := demoAccount.EditAccountInfo(update) + _, err := demoAccount.EditAccountInfo(update) if err != nil { t.Error(err) } - t.Logf("Account updated!\n%#v", *info) + t.Logf("Account updated!") } func TestEditValidPage(t *testing.T) { @@ -96,7 +96,7 @@ func TestGetValidAccountInfo(t *testing.T) { t.Error(err) } - t.Logf("Account info:\n%#v", *account) + t.Logf("%s create %d pages", account.ShortName, account.PageCount) } func TestGetValidPageList(t *testing.T) { @@ -127,12 +127,10 @@ func TestGetValidViews(t *testing.T) { } func TestRevokeAccessToken(t *testing.T) { - t.Logf("Old Access Token: %s", demoAccount.AccessToken) - - token, err := demoAccount.RevokeAccessToken() + _, err := demoAccount.RevokeAccessToken() if err != nil { t.Error(err) } - t.Logf("New Access Token: %s", token.AccessToken) + t.Logf("New Access Token set!") }