make it so it doesnt crash but just logs output
This commit is contained in:
parent
0dfbeea8d3
commit
96cff5792c
5
main.go
5
main.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/mmcdole/gofeed"
|
"github.com/mmcdole/gofeed"
|
||||||
)
|
)
|
||||||
|
@ -23,9 +24,9 @@ func main () {
|
||||||
s := bufio.NewScanner(os.Stdin)
|
s := bufio.NewScanner(os.Stdin)
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
fp := gofeed.NewParser()
|
fp := gofeed.NewParser()
|
||||||
feed, err := fp.ParseURLWithContext(s.Text(), ctx)
|
feed, err := fp.ParseURLWithContext(strings.TrimSpace(s.Text()), ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Println(err)
|
||||||
} else {
|
} else {
|
||||||
for _, item := range feed.Items {
|
for _, item := range feed.Items {
|
||||||
fmt.Printf("<li><a href=\"%s\">%s</a><p>%s</p></li>\n", item.Link, item.Title, item.Description)
|
fmt.Printf("<li><a href=\"%s\">%s</a><p>%s</p></li>\n", item.Link, item.Title, item.Description)
|
||||||
|
|
Loading…
Reference in New Issue