package main import ( "fmt" "gopkg.in/yaml.v2" ) type PokemonInspectOutput struct { Name string Height int Weight int Stats map[string]int Types []string } func commandInspect(p *PokedexConfig, a *string) error { found := false for _, pokemon := range p.CaughtPokemon { if pokemon.Name == *a { found = true stats := map[string]int{} types := []string{} for _, pokeStat := range pokemon.PokeStats { stats[pokeStat.PokeStat.Name] = pokeStat.BaseStat } for _, pokeType := range pokemon.PokeTypes { types = append(types, pokeType.PokeType.Name) } pokemonInspectOutput := PokemonInspectOutput{ Name: pokemon.Name, Height: pokemon.Height, Weight: pokemon.Weight, Stats: stats, Types: types, } data, _ := yaml.Marshal(pokemonInspectOutput) fmt.Println(string(data)) } } if !found { fmt.Println("you have not caught that pokemon") } return nil }