Golang: Clear Slice
Clear Slice
To clear slice, set it to nil
or set it to a slice of 0 length.
mySlice = nil
or
mySlice = mySlice[0:0]
The recommended way is to set to nil
.
Golang, array and slice
- Golang: Array
- Golang: Slice
- Golang: Slice of Slice
- Golang: Append to Slice
- Golang: Cut Slice (Delete Elements)
- Golang: Copy Slice
- Golang: Clear Slice
- Golang: Nested Slice
- Golang: Slice of Strings to String
- Golang: Iterate Slice
- Golang: Convert Value to String
- Golang: Convert Array to Slice
- Golang: Print Slice, Array