aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-01-28 00:38:48 +0300
committerEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-01-28 00:38:48 +0300
commit99bb487fefcba22903aceb63f128886a74efc420 (patch)
treeeb96dcc558f1729e344c15759c1e5f68500bdec2 /main.go
parent18daf268e2e334649c0e07f9c2117b91dab4bae5 (diff)
downloadradiorus-rss-99bb487fefcba22903aceb63f128886a74efc420.tar.gz
radiorus-rss-99bb487fefcba22903aceb63f128886a74efc420.zip
decouple file write
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 9 insertions, 4 deletions
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)
}