[]interface{}怎么遍历转化值


var list []interface{}
		if reflect.TypeOf(delayRunResult).Kind() == reflect.Slice {
			s := reflect.ValueOf(delayRunResult)
			for i := 0; i < s.Len(); i++ {
				ele := s.Index(i)
				list = append(list, ele.Interface())
			}
		}
func (cd *commandDefinition) tableOutputForGetCommands(obj interface{}) {
  var list []common.TableOutput
  if reflect.TypeOf(obj).Kind() == reflect.Slice {
		s := reflect.ValueOf(obj)
		for i := 0; i < s.Len(); i++ {
			ele := s.Index(i)
			list = append(list, ele.Interface().(common.TableOutput))
		}
	} 
}

你可能感兴趣的:(go-Q&A)