Skip to content

Commit b1866ab

Browse files
authored
Improve readme (#8)
* beef up the readme * beef up the readme
1 parent ca6ab99 commit b1866ab

File tree

2 files changed

+108
-49
lines changed

2 files changed

+108
-49
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GOCMD=go
2-
VERSION=0.1.4
2+
VERSION=0.1.5
33

44
# First target for travis ci
55
test:

README.md

Lines changed: 107 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,70 +9,129 @@ Fetch what's new from AWS
99
[![Go Report Card](https://goreportcard.com/badge/github.com/circa10a/go-aws-news)](https://goreportcard.com/report/github.com/circa10a/go-aws-news)
1010
![GitHub release (latest by date)](https://img.shields.io/github/v/release/circa10a/go-aws-news?style=plastic)
1111

12+
[go-aws-news](#go-aws-news)
13+
* [Install](#install)
14+
* [Usage](#usage)
15+
- [Get Today's news](#get-today-s-news)
16+
- [Get Yesterday's news](#get-yesterday-s-news)
17+
- [Get all news for the month](#get-all-news-for-the-month)
18+
- [Gets from a previous month](#gets-from-a-previous-month)
19+
- [Print out announcements](#print-out-announcements)
20+
- [Loop over news data](#loop-over-news-data)
21+
- [Get news as JSON](#get-news-as-json)
22+
- [Get news about a specific product](#get-news-about-a-specific-product)
23+
* [Development](#development)
24+
+ [Test](#test)
25+
1226
## Install
1327

1428
```shell
15-
go get "github.com/circa10a/go-aws-news"
29+
go get -u "github.com/circa10a/go-aws-news"
1630
```
1731

1832
## Usage
1933

2034
Methods return a slice of structs which include the announcement title, a link, and the date it was posted as well an error. This allows you to manipulate the data in whichever way you please, or simply use `Print()` to print a nice ASCII table to the console.
2135

36+
#### Get Today's news
37+
38+
```go
39+
news, err := awsnews.Today()
40+
if err != nil {
41+
// Handle error
42+
}
43+
```
44+
45+
#### Get Yesterday's news
46+
47+
```go
48+
news, _= awsnews.Yesterday()
49+
```
50+
51+
#### Get all news for the month
52+
53+
```go
54+
news, _ = awsnews.ThisMonth()
55+
```
56+
57+
#### Gets from a previous month
58+
59+
```go
60+
// Custom timeframe(June 2019)
61+
news, err = awsnews.Fetch(2019, 06)
62+
```
63+
64+
#### Print out announcements
65+
66+
```go
67+
news, _ = awsnews.ThisMonth()
68+
news.Print()
69+
// Console output
70+
// +--------------------------------+--------------+
71+
// | ANNOUNCEMENT | DATE |
72+
// +--------------------------------+--------------+
73+
// | Amazon Cognito now supports | Jan 10, 2020 |
74+
// | CloudWatch Usage Metrics | |
75+
// +--------------------------------+--------------+
76+
// | Introducing Workload Shares in | Jan 10, 2020 |
77+
// | AWS Well-Architected Tool | |
78+
// +--------------------------------+--------------+
79+
//
80+
```
81+
82+
#### Loop over news data
83+
84+
```go
85+
// Loop slice of stucts of announcements
86+
// For your own data manipulation
87+
news, _ = awsnews.Fetch(time.Now().Year(), int(time.Now().Month()))
88+
for _, v := range news {
89+
fmt.Printf("Title: %v\n", v.Title)
90+
fmt.Printf("Link: %v\n", v.Link)
91+
fmt.Printf("Date: %v\n", v.PostDate)
92+
}
93+
```
94+
95+
#### Get news as JSON
96+
97+
```go
98+
news, _ = awsnews.ThisMonth()
99+
json, jsonErr := news.JSON()
100+
if jsonErr != nil {
101+
log.Fatal(err)
102+
}
103+
fmt.Println(string(json))
104+
```
105+
106+
#### Get news about a specific product
107+
22108
```go
23109
package main
24110

25111
import (
26-
"fmt"
27-
"log"
28-
"time"
29-
awsNews "github.com/circa10a/go-aws-news"
112+
"fmt"
113+
"strings"
114+
115+
awsnews "github.com/circa10a/go-aws-news"
30116
)
31117

118+
func getEKSAnnouncements(n awsnews.Announcements) awsnews.Announcements {
119+
var myEKSAnnouncements awsnews.Announcements
120+
for _, v := range n {
121+
if strings.Contains(v.Title, "EKS") {
122+
myEKSAnnouncements = append(myEKSAnnouncements, v)
123+
}
124+
}
125+
return myEKSAnnouncements
126+
}
127+
32128
func main() {
33-
// Today's news
34-
news, _ := awsNews.Today()
35-
news.Print()
36-
// Yesterday's news
37-
news, _= awsNews.Yesterday()
38-
news.Print()
39-
// Current news
40-
news, _ = awsNews.ThisMonth()
41-
news.Print()
42-
// Custom timeframe(June 2019)
43-
var err error
44-
news, err = awsNews.Fetch(2019, 06)
45-
// Handle errors as well
46-
if err != nil {
47-
log.Fatal(err)
48-
}
49-
news.Print()
50-
// Console output
51-
// +--------------------------------+--------------+
52-
// | ANNOUNCEMENT | DATE |
53-
// +--------------------------------+--------------+
54-
// | Amazon Cognito now supports | Jan 10, 2020 |
55-
// | CloudWatch Usage Metrics | |
56-
// +--------------------------------+--------------+
57-
// | Introducing Workload Shares in | Jan 10, 2020 |
58-
// | AWS Well-Architected Tool | |
59-
// +--------------------------------+--------------+
60-
//
61-
// Loop slice of stucts of announcements
62-
// For your own data manipulation
63-
news, _ = awsNews.Fetch(time.Now().Year(), int(time.Now().Month()))
64-
for _, v := range news {
65-
fmt.Printf("Title: %v\n", v.Title)
66-
fmt.Printf("Link: %v\n", v.Link)
67-
fmt.Printf("Date: %v\n", v.PostDate)
68-
}
69-
// Even get all the Announcements as JSON
70-
news, err = awsNews.Fetch(2019, 12)
71-
json, jsonErr := news.JSON()
72-
if jsonErr != nil {
73-
log.Fatal(err)
74-
}
75-
fmt.Println(string(json))
129+
news, err := awsnews.Fetch(2019, 12)
130+
if err != nil {
131+
fmt.Println(err)
132+
} else {
133+
getEKSAnnouncements(news).Print()
134+
}
76135
}
77136
```
78137

0 commit comments

Comments
 (0)