From 08026ddca3e47b3c8d8a3976c21d2b1c65323343 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 14 Feb 2020 21:46:15 +0800 Subject: [PATCH 1/4] chore: support go module --- go.mod | 8 ++++++++ go.sum | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 go.mod create mode 100644 go.sum diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..fc4b2c8 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/n0madic/twitter-scraper + +go 1.13 + +require ( + github.com/PuerkitoBio/goquery v1.5.1 + github.com/google/go-cmp v0.4.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5fc056f --- /dev/null +++ b/go.sum @@ -0,0 +1,14 @@ +github.com/PuerkitoBio/goquery v1.5.1 h1:PSPBGne8NIUWw+/7vFBV+kG2J/5MOjbzc7154OaKCSE= +github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= +github.com/andybalholm/cascadia v1.1.0 h1:BuuO6sSfQNFRu1LppgbD25Hr2vLYW25JvxHs5zzsLTo= +github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From bf5b9db7d6417226add8c260c36445252bcfed9a Mon Sep 17 00:00:00 2001 From: Alexander Sheiko Date: Fri, 14 Feb 2020 16:10:29 +0200 Subject: [PATCH 2/4] Improve error msg --- trends_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trends_test.go b/trends_test.go index 9f61445..ad0db70 100644 --- a/trends_test.go +++ b/trends_test.go @@ -11,6 +11,6 @@ func TestGetTrends(t *testing.T) { } if len(trends) != 10 { - t.Error("Expected 10 trends") + t.Errorf("Expected 10 trends, got %d: %#v", len(trends), trends) } } From b6c9f13be2ecde1b2f43bb19af657cee8268fa01 Mon Sep 17 00:00:00 2001 From: Alexander Sheiko Date: Fri, 14 Feb 2020 16:21:05 +0200 Subject: [PATCH 3/4] misspell --- util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util.go b/util.go index 70d06a3..1d8bd26 100644 --- a/util.go +++ b/util.go @@ -26,7 +26,7 @@ func getHTMLFromJSON(req *http.Request, field string) (*strings.Reader, error) { htm, ok := ajaxJSON[field].(string) if !ok { - return nil, fmt.Errorf("filed not found in JSON") + return nil, fmt.Errorf("field not found in JSON") } return strings.NewReader(htm), nil From ca155dc0183a245ba613449cf4f5726f1376c5be Mon Sep 17 00:00:00 2001 From: Alexander Sheiko Date: Fri, 14 Feb 2020 16:21:20 +0200 Subject: [PATCH 4/4] minor fix --- tweets.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tweets.go b/tweets.go index c50705e..99e1012 100644 --- a/tweets.go +++ b/tweets.go @@ -45,7 +45,7 @@ type Result struct { // GetTweets returns channel with tweets for a given user func GetTweets(user string, pages int) <-chan *Result { - channel := make(chan *Result, 0) + channel := make(chan *Result) go func(user string) { defer close(channel) var lastTweetID string