Advertisement
Guest User

Untitled

a guest
Jun 6th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.41 KB | None | 0 0
  1. func Remove(s interface{}, index int) interface{}{
  2.     arrV := reflect.ValueOf(s)
  3.     counter := 0
  4.     if arrV.Kind() == reflect.Slice {
  5.         var interfaceSlice []interface{} = make([]interface{}, arrV.Len() - 1)
  6.         for i := 0; i<arrV.Len(); i++ {
  7.             if i == index {
  8.                 continue
  9.             }
  10.             interfaceSlice[counter] = arrV.Index(i).Interface()
  11.             counter ++
  12.         }
  13.         return interfaceSlice
  14.     }
  15.     panic("Argument is not a slice")
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement