-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
40 lines (29 loc) · 795 Bytes
/
client.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
package main
import (
"encoding/base64"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.github.com/users/huangjiasingle"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("authorization", "Basic aHVhbmdqaWFzaW5nbGU6aGxoajUyNTExNQ==")
req.Header.Add("cache-control", "no-cache")
req.Header.Add("postman-token", "5fd45ac5-4049-21f6-89de-e6cda8342670")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
sDec := base64.StdEncoding.EncodeToString([]byte("huangjiasingle:hlhj525115"))
fmt.Println(string(sDec))
queue := make(chan string, 5)
queue <- "one"
queue <- "two"
close(queue)
for elem, i := range queue {
fmt.Println(elem)
fmt.Println(i)
}
}