예제 #1
0
func assertFetch(lookup string, expected interface{}, root interface{}, t *testing.T) {
	if val, err := reflect.Fetch(lookup, root); err != nil {
		t.Errorf("expected no error (got %v)", err)
	} else if val != expected {
		t.Errorf("expected value to equal \"%v\" (got \"%v\")", expected, val)
	}
}
예제 #2
0
func (c *Configuration) get(lookup string) (interface{}, error) {
	i, err := reflect.Fetch(lookup, c.root)

	if err != nil {
		if c.parent != nil {
			return c.parent.get(lookup)
		}

		return nil, err
	}

	return i, nil
}