Remove element of slice
examples/remove-element-from-slice/remove_element_from_slice.go
package main import ( "fmt" ) func main() { celestialObjects := []string{"Moon", "Gas", "Asteroid", "Dwarf", "Star", "Commet"} fmt.Println(celestialObjects) celestialObjects = append(celestialObjects[:3], celestialObjects[4:]...) fmt.Println(celestialObjects) }
[Moon Gas Asteroid Dwarf Star Commet] [Moon Gas Asteroid Star Commet]