-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
50 lines (41 loc) · 733 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
49
50
package main
import (
"bytes"
"fmt"
"image"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"io/ioutil"
"log"
"net/http"
"os"
"github.com/Doarakko/go-yugioh/yugioh"
"github.com/mattn/go-sixel"
)
func main() {
client := yugioh.NewClient()
card, _, err := client.RandomCards.One()
if err != nil {
log.Fatal(err)
}
resp, err := http.Get(card.Images[0].URL)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
img, _, err := image.Decode(bytes.NewReader(b))
if err != nil {
log.Fatal(err)
}
err = sixel.NewEncoder(os.Stdout).Encode(img)
if err != nil {
log.Fatal(err)
}
fmt.Println()
fmt.Println(card.Images[0].URL)
}