---
title: "Discussion on \"Go cheatsheet - Slice Utilities\" | Hashnode"
description: "Discussion on \"Go cheatsheet - Slice Utilities\". Slice\nEmpty a slice\na := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}\na = a[:0]\n// or\na = nil\n\nPrepend\nb := []int{2, 3, 4}\nb = append([]int{1}, b...)\n\nRemove\na = append(a[:i], a[i+1:]...)\n\nInsert at index\ns = append(s, 0)\ncopy(s[i+1:], s[i:])\ns[i] = x\n\nIndex..."
url: "https://hashnode.com/posts/go-cheatsheet-slice-utilities/6080e2cac99e200d08f83c13"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Go cheatsheet - Slice Utilities](https://hn.0xbf.me/go-cheatsheet-slice-utilities?utm_source=hashnode&utm_medium=feed)

Slice Empty a slice a := \[\]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} a = a\[:0\] // or a = nil Prepend b := \[\]int{2, 3, 4} b = append(\[\]int{1}, b...) Remove a = append(a\[:i\], a\[i+1:\]...) Insert at index s = append(s, 0) copy(s\[i+1:\], s\[i:\]) s\[i\] = x Index...

Apr 19, 2021 · 2 min read · hn.0xbf.me  
Read the article

-   [#go](https://hashnode.com/tag/go)

## Written by

[0xBF](https://hashnode.com/@0xbf)

@0xbf

  
[View profile](https://hashnode.com/@0xbf)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
