From 866bcf91b02151ba05f68b486632ecadcfddeeb4 Mon Sep 17 00:00:00 2001 From: Marcin Wyszynski Date: Thu, 27 Feb 2014 23:15:37 +0000 Subject: [PATCH] use an interface for client, not a concrete implementation --- rss.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rss.go b/rss.go index 916d335..83ac8b4 100644 --- a/rss.go +++ b/rss.go @@ -12,6 +12,10 @@ import ( _ "code.google.com/p/go-charset/data" ) +type Fetcher interface { + Get(url string) (resp *http.Response, err error) +} + type Channel struct { Title string `xml:"title"` Link string `xml:"link"` @@ -76,7 +80,7 @@ func Read(url string) (*Channel, error) { return ReadWithClient(url, http.DefaultClient) } -func ReadWithClient(url string, client *http.Client) (*Channel, error) { +func ReadWithClient(url string, client Fetcher) (*Channel, error) { response, err := client.Get(url) if err != nil { return nil, err