Skip to content

Instantly share code, notes, and snippets.

@narenaryan
Last active June 15, 2016 17:25
Show Gist options
  • Select an option

  • Save narenaryan/01fab2bcc31efab65a33315d5404861e to your computer and use it in GitHub Desktop.

Select an option

Save narenaryan/01fab2bcc31efab65a33315d5404861e to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main(){
s := []string{"Naren", "Saikiran"}
// appending an element at the end of slice
s = append(s, "Manoj", "Harish")
fmt.Println(s)
// removing element at the end
s = s[:len(s)-1]
fmt.Println(s)
index := 1
// removing element at the nth index
s = append(s[:index], s[index+1:]...)
fmt.Println(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment