From 99bb487fefcba22903aceb63f128886a74efc420 Mon Sep 17 00:00:00 2001 From: Evgeny Kuznetsov Date: Tue, 28 Jan 2020 00:38:48 +0300 Subject: decouple file write --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 75750aa..599a02d 100644 --- a/main.go +++ b/main.go @@ -69,17 +69,22 @@ func main() { describeEpisodes(feed) feed.Created = time.Now() - outputFile := outputPath + "radiorus-" + programNumber + ".rss" - writeFeed(feed, outputFile) + output := createFeed(feed) + + outputFile := outputPath + "radiorus-" + programNumber + ".rss" + writeFile(output, outputFile) } -func writeFeed(feed *feeds.Feed, filename string) { +func createFeed(feed *feeds.Feed) []byte { rss, err := feed.ToRss() if err != nil { log.Fatal(err) } - output := []byte(rss) + return []byte(rss) +} + +func writeFile(output []byte, filename string) { if err := ioutil.WriteFile(filename, output, 0644); err != nil { log.Fatal(err) } -- cgit v1.2.3