code: func (hr *Resolver) CNAMEFlatten(host string) (string, string) {
  	if hr.cache == nil {
  		hr.cache = cache.New(30*time.Minute, 5*time.Minute)
  	}
  
  	result := []string{host}
  	request := host
  
  	value, found := hr.cache.Get(host)
  	if found {
  		result = strings.Split(value.(string), ",")
  	} else {
  		var cacheDuration = 0 * time.Second
  
  		for depth := 0; depth < hr.ResolvDepth; depth++ {
  			resolv, err := cnameResolve(request, hr.ResolvConfig)
  			if err != nil {
  				log.Error(err)
  				break
  			}
  			if resolv == nil {
  				break
  			}
  
  			result = append(result, resolv.Record)
  			if depth == 0 {
  				cacheDuration = resolv.TTL
  			}
  			request = resolv.Record
  		}
  
  		if err := hr.cache.Add(host, strings.Join(result, ","), cacheDuration); err != nil {
  			log.Error(err)
  		}
  	}
  
  	return result[0], result[len(result)-1]
  }
docs: // CNAMEFlatten check if CNAME record exists, flatten if possible