func GrabOk(s interface{}, path string) (interface{}, bool) {
	t := reflect.TypeOf(s)
	if t.Kind() != reflect.Struct {
		return nil, false
	}

	dotIndex := strings.Index(path, ".")
	if dotIndex == -1 {
		dotIndex = len(path)
	}

	fieldName := path[0:dotIndex]
	val := reflect.ValueOf(s)
	fieldVal := val.FieldByName(fieldName)
	if fieldVal.Kind() == reflect.Ptr {
		if fieldVal.IsNil() {
			return reflect.Zero(fieldVal.Type().Elem()).Interface(), false
		}

		fieldVal = reflect.Indirect(fieldVal)
	}

	result, ok := GetOk(fieldVal.Interface())
	if !ok {
		return result, ok
	}

	if dotIndex == len(path) {
		return result, ok
	}

	return GrabOk(result, path[dotIndex+1:len(path)])
}
// GrabOk returns the value specified by the path given,
// starting from the struct s.
// If at any point in the path the lookup falls short
// (i.e. a field is not found), or if the last field in the path is nil
// itself, a type-appropriate zero-value is returned.
// It returns a second value, a boolean, which will be false if it failed
// to lookup the value, including if the last field in the path was nil.
//
// This is useful for getting values our of deeply nested structures
// Example: val, ok := sl.GrabOk(virtualGuest, "Datacenter.Name")
GrabOk returns the value specified by the path given,
starting from the struct s.
If at any point in the path the lookup falls short
, or if the last field in the path is nil
itself, a type-appropriate zero-value is returned.
It returns a second value, a boolean, which will be false if it failed
to lookup the value, including if the last field in the path was nil.

This is useful for getting values our of deeply nested structures
Example: val, ok := sl.GrabOk(virtualGuest, "Datacenter.Name")
// GrabOk returns the value specified by the path given // starting from the struct s . // If at any point in the path the lookup falls short // ( i . e . a field is not found ) or if the last field in the path is nil // itself a type - appropriate zero - value is returned . // It returns a second value a boolean which will be false if it failed // to lookup the value including if the last field in the path was nil . // // This is useful for getting values our of deeply nested structures // Example : val ok : = sl . GrabOk ( virtualGuest " Datacenter . Name " )
func GrabOk(s interface{}, path string) (interface{}, bool) {
	t := reflect.TypeOf(s)
	if t.Kind() != reflect.Struct {
		return nil, false
	}
	dotIndex := strings.Index(path, ".")
	if dotIndex == -1 {
		dotIndex = len(path)
	}
	fieldName := path[0:dotIndex]
	val := reflect.ValueOf(s)
	fieldVal := val.FieldByName(fieldName)
	if fieldVal.Kind() == reflect.Ptr {
		if fieldVal.IsNil() {
			return reflect.Zero(fieldVal.Type().Elem()).Interface(), false
		}
		fieldVal = reflect.Indirect(fieldVal)
	}
	result, ok := GetOk(fieldVal.Interface())
	if !ok {
		return result, ok
	}
	if dotIndex == len(path) {
		return result, ok
	}
	return GrabOk(result, path[dotIndex+1:len(path)])
}
func GrabOk ( s interface { } , path string ) ( interface { } , bool ) { t := reflect . TypeOf ( s ) if t . Kind ( ) != reflect . Struct { return nil , false } dotIndex := strings . Index ( path , " " ) if dotIndex == - 1 { dotIndex = len ( path ) } fieldName := path [ 0 : dotIndex ] val := reflect . ValueOf ( s ) fieldVal := val . FieldByName ( fieldName ) if fieldVal . Kind ( ) == reflect . Ptr { if fieldVal . IsNil ( ) { return reflect . Zero ( fieldVal . Type ( ) . Elem ( ) ) . Interface ( ) , false } fieldVal = reflect . Indirect ( fieldVal ) } result , ok := GetOk ( fieldVal . Interface ( ) ) if ! ok { return result , ok } if dotIndex == len ( path ) { return result , ok } return GrabOk ( result , path [ dotIndex + 1 : len ( path ) ] ) }
GrabOk returns the value specified by the path given,
starting from the struct s.
If at any point in the path the lookup falls short
, or if the last field in the path is nil
itself, a type-appropriate zero-value is returned.
GrabOk returns the value specified by the path given starting from the struct s . If at any point in the path the lookup falls short or if the last field in the path is nil itself a type - appropriate zero - value is returned .