GetAll finds all values in the Include statement matching the alias and the given key.
(alias, key string)
| 748 | // GetAll finds all values in the Include statement matching the alias and the |
| 749 | // given key. |
| 750 | func (inc *Include) GetAll(alias, key string) ([]string, error) { |
| 751 | inc.mu.Lock() |
| 752 | defer inc.mu.Unlock() |
| 753 | var vals []string |
| 754 | |
| 755 | // TODO: we search files in any order which is not correct |
| 756 | for i := range inc.matches { |
| 757 | cfg := inc.files[inc.matches[i]] |
| 758 | if cfg == nil { |
| 759 | panic("nil cfg") |
| 760 | } |
| 761 | val, err := cfg.GetAll(alias, key) |
| 762 | if err == nil && len(val) != 0 { |
| 763 | // In theory if SupportsMultiple was false for this key we could |
| 764 | // stop looking here. But the caller has asked us to find all |
| 765 | // instances of the keyword (and could use Get() if they wanted) so |
| 766 | // let's keep looking. |
| 767 | vals = append(vals, val...) |
| 768 | } |
| 769 | } |
| 770 | return vals, nil |
| 771 | } |
| 772 | |
| 773 | // String prints out a string representation of this Include directive. Note |
| 774 | // included Config files are not printed as part of this representation. |