-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.go
76 lines (57 loc) · 1.39 KB
/
index.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"log"
"fmt"
"time"
"net/http"
"io/ioutil"
//"github.com/gorilla/mux"
)
type Microphone struct {
ID int
Name string
ProductionDate time.Time
}
func Index(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("Hello from web server!\n\n\n" + time.Now().String() + "\n\n\n"))
URL := "https://api.github.com/users"
res, err := http.Get(URL)
if err != nil {
log.Println(err)
return
}
defer res.Body.Close()
responseBodyBytes, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Println(err)
return
}
w.Write(responseBodyBytes)
}
func Serve(port string) {
http.HandleFunc("/", Index)
if err := http.ListenAndServe(port, nil); err != nil {
panic(err)
}
}
func main () {
fmt.Println (`SHIT THIS WORKS!!!`)
microphone := map[string]string{
"name": "Sennheiser MKH416",
"polar-pattern": "Figure 8 Cardioid",
}
//Microphone := map[string]interface{}{
m := Microphone{
ID: 416,
Name: "Sennheiser MKH416",
// https://github.com/fxtlabs/date/blob/master/date.go#L93
ProductionDate: time.Date(1979, time.November, 13, 23, 45, 2, 0, time.UTC),
}
for key, value := range microphone {
fmt.Println(key, value)
}
fmt.Println("Microphone ID", m.ID)
fmt.Println("Microphone Name", m.Name)
fmt.Println("Microphone Production Date", m.ProductionDate)
Serve(":8080")
}