examples/subscribe-go/main.go
raw| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "bufio" |
| 5 | "log" |
| 6 | "net/http" |
| 7 | ) |
| 8 | |
| 9 | func main() { |
| 10 | resp, err := http.Get("https://ntfy.sh/phil_alerts/json") |
| 11 | if err != nil { |
| 12 | log.Fatal(err) |
| 13 | } |
| 14 | defer resp.Body.Close() |
| 15 | scanner := bufio.NewScanner(resp.Body) |
| 16 | for scanner.Scan() { |
| 17 | println(scanner.Text()) |
| 18 | } |
| 19 | } |