-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.go
47 lines (38 loc) · 864 Bytes
/
map.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
package main
import (
"errors"
"fmt"
)
type Config struct {
Previous string
Next string
}
func commandMap(cfg *config, params []string) error {
locations, err := cfg.pokeApiClient.ListLocations(cfg.nextLocation)
if err != nil {
return err
}
cfg.nextLocation = locations.Next
cfg.prevLocation = locations.Previous
fmt.Println()
for _, location := range locations.Results {
fmt.Println(location.Name)
fmt.Println()
}
return nil
}
func commandMap2(cfg *config, params []string) error {
if cfg.prevLocation == nil {
return errors.New("you're on the first page")
}
locations, err := cfg.pokeApiClient.ListLocations(cfg.prevLocation)
if err != nil {
return err
}
cfg.nextLocation = locations.Next
cfg.prevLocation = locations.Previous
for _, location := range locations.Results {
fmt.Println(location.Name)
}
return nil
}