Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for FieldByIndexErr (0.31 sec)

  1. src/text/template/exec.go

    	// It's not a method; must be a field of a struct or an element of a map.
    	switch receiver.Kind() {
    	case reflect.Struct:
    		tField, ok := receiver.Type().FieldByName(fieldName)
    		if ok {
    			field, err := receiver.FieldByIndexErr(tField.Index)
    			if !tField.IsExported() {
    				s.errorf("%s is an unexported field of struct type %s", fieldName, typ)
    			}
    			if err != nil {
    				s.errorf("%v", err)
    			}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri May 24 21:22:24 UTC 2024
    - 32K bytes
    - Viewed (0)
  2. src/reflect/value.go

    				v = v.Elem()
    			}
    		}
    		v = v.Field(x)
    	}
    	return v
    }
    
    // FieldByIndexErr returns the nested field corresponding to index.
    // It returns an error if evaluation requires stepping through a nil
    // pointer, but panics if it must step through a field that
    // is not a struct.
    func (v Value) FieldByIndexErr(index []int) (Value, error) {
    	if len(index) == 1 {
    		return v.Field(index[0]), nil
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 22 21:17:41 UTC 2024
    - 119.9K bytes
    - Viewed (0)
  3. src/text/template/exec_test.go

    				if err != nil {
    					t.Error(err)
    				}
    			}
    		}()
    	}
    
    	wg.Wait()
    }
    
    // Issue 48215: embedded nil pointer causes panic.
    // Fixed by adding FieldByIndexErr to the reflect package.
    func TestIssue48215(t *testing.T) {
    	type A struct {
    		S string
    	}
    	type B struct {
    		*A
    	}
    	tmpl, err := New("").Parse(`{{ .S }}`)
    	if err != nil {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri May 24 22:23:55 UTC 2024
    - 60.1K bytes
    - Viewed (0)
Back to top