-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (40 loc) · 973 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import "fmt"
import "net/http"
import "io/ioutil"
import "encoding/json"
const Meetupurl = "http://api.meetup.com/%s/events"
var communities = []string{
"PHP-MG",
"GDG-BH"}
type Event struct {
Id string `json:"id"`
Name string `json:"name"`
Link string `json:"link"`
Description string `json:"description"`
WaitlistCount int64 `json:"waitlist_count"`
YesCount int64 `json:"yes_rsvp_count"`
Limit int64 `json:"rsvp_limit"`
}
func getEvents(community string) *[]Event {
var eventsUrl = fmt.Sprintf(Meetupurl, community)
resp, err := http.Get(eventsUrl)
if err != nil {
panic(err.Error())
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var s = new([]Event)
err = json.Unmarshal(body, &s)
if(err != nil){
fmt.Println("whoops:", err)
}
return s
}
func main() {
var length, i int
length = len(communities)
for i = 0; i < length; i++ {
fmt.Println(getEvents(communities[i]))
}
}