-
Notifications
You must be signed in to change notification settings - Fork 0
/
pokemon.go
73 lines (68 loc) · 845 Bytes
/
pokemon.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
package main
import (
"embed"
"fmt"
"path"
"strings"
)
//go:embed pokemons
var fs embed.FS
type Pokemon struct {
id int
name string
}
func (p Pokemon) Picture() string {
fileName := fmt.Sprintf("%s.txt", strings.ToLower(p.name))
filePath := path.Join("pokemons", fileName)
imageBytes, err := fs.ReadFile(filePath)
if err != nil {
return ""
}
return string(imageBytes)
}
var pokemons = []Pokemon{
{
id: 1,
name: "Bulbasaur",
},
{
id: 2,
name: "Ivysaur",
},
{
id: 3,
name: "Venusaur",
},
{
id: 4,
name: "Charmander",
},
{
id: 5,
name: "Charmeleon",
},
{
id: 6,
name: "Charizard",
},
{
id: 7,
name: "Squirtle",
},
{
id: 8,
name: "Wartortle",
},
{
id: 9,
name: "Blastoise",
},
{
id: 10,
name: "Caterpie",
},
{
id: 25,
name: "Pikachu",
},
}