go-ml.dev/pkg/base@v0.0.0-20200610162856-60c38abac71b/fu/copy.go (about)

     1  package fu
     2  
     3  import (
     4  	"reflect"
     5  )
     6  
     7  /*
     8  CopySlice returns copy of given slice
     9  */
    10  func CopySlice(a interface{}) interface{} {
    11  	v := reflect.ValueOf(a)
    12  	r := reflect.MakeSlice(v.Type(), v.Len(), v.Len())
    13  	reflect.Copy(r, v)
    14  	return r.Interface()
    15  }