title: Getting value from yaml object in file
body: <p>I'm getting time to learn Go, and I'm having a problem dealing with yaml file.</p>
  <p>this is my yaml file</p>
  <pre><code>--- 
  endpoints: 
    service1: 
      url: &quot;https://service1.com&quot;
      frequency: 2
      interval: 1
    service2: 
      url: &quot;https://service2.com&quot;
      frequency: 3
      interval: 2 
  </code></pre>
  <p>My go code</p>
  <pre><code>package main
  
  import (
      &quot;fmt&quot;
      &quot;io/ioutil&quot;
      &quot;reflect&quot;
  
      &quot;gopkg.in/yaml.v3&quot;
  )
  
  // Config define estrutura do arquivo de configuração
  type Config struct {
      Endpoint map[string]interface{} `yaml:&quot;endpoints&quot;`
  }
  
  func main() {
      yamlFile, err := ioutil.ReadFile(&quot;config.yml&quot;)
      if err != nil {
          fmt.Printf(&quot;Error reading YAML file: %s\n&quot;, err)
          return
      }
  
      var yamlConfig Config
      err = yaml.Unmarshal(yamlFile, &amp;yamlConfig)
      if err != nil {
          fmt.Printf(&quot;Error parsing YAML file: %s\n&quot;, err)
      }
  
      for k := range yamlConfig.Endpoint {
          nm := reflect.ValueOf(yamlConfig.Endpoint[k])
          for _, key := range nm.MapKeys() {
              strct := nm.MapIndex(key)
              fmt.Println(key.Interface(), strct.Interface())
          }
      }
  
  }
  
  // PingEndpoint acessa os endpoint informados
  func PingEndpoint(url string, frequency, interval int) {
      // do something
  
  }
  </code></pre>
  <p>Is there a better way to define the Config structure without using interface? And is really necessary use reflect do get properties of a <code>service1</code> or exist a better whey to do that?</p>