Skip to content

Instantly share code, notes, and snippets.

@178inaba
Last active August 29, 2015 14:27
Show Gist options
  • Save 178inaba/7a9834505f17af1c9671 to your computer and use it in GitHub Desktop.
Save 178inaba/7a9834505f17af1c9671 to your computer and use it in GitHub Desktop.
delete element of slice of go
package main
import "fmt"
func main() {
s := []string{"abc"}
s = append(s, "def")
// delete
s = append(s[:1], s[1+1:]...)
fmt.Println("len:", len(s), "cap:", cap(s))
}
$ go run del_slice.go
len: 1 cap: 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment