diff options
author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 00:38:48 +0300 |
---|---|---|
committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 00:38:48 +0300 |
commit | 99bb487fefcba22903aceb63f128886a74efc420 (patch) | |
tree | eb96dcc558f1729e344c15759c1e5f68500bdec2 /main.go | |
parent | 18daf268e2e334649c0e07f9c2117b91dab4bae5 (diff) | |
download | radiorus-rss-99bb487fefcba22903aceb63f128886a74efc420.tar.gz radiorus-rss-99bb487fefcba22903aceb63f128886a74efc420.zip |
decouple file write
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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) } |