daily pastebin goal
91%
SHARE
TWEET

Untitled

a guest Jun 6th, 2018 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top