Skip to content

Instantly share code, notes, and snippets.

@pedrobertao
Created August 26, 2023 10:39
Show Gist options
  • Save pedrobertao/6ec6f4942744036afeb1e05b6d76d177 to your computer and use it in GitHub Desktop.
Save pedrobertao/6ec6f4942744036afeb1e05b6d76d177 to your computer and use it in GitHub Desktop.
Example of Clear in Go
package main
import "fmt"
func main() {
intSlice := []int{1, 2, 3}
floatSlice := []float64{1.0, 2.0, 3.0}
stringSlice := []string{"a", "b", "c"}
mapString := map[string]string{
"Name": "Pedro",
"Age": "20",
}
fmt.Println("Int Slice", intSlice)
fmt.Println("Float Slice", floatSlice)
fmt.Println("String Slice", stringSlice)
fmt.Println("Map", mapString)
clear(intSlice)
clear(floatSlice)
clear(stringSlice)
clear(mapString)
fmt.Println("")
fmt.Println("===================Clear")
fmt.Println("")
fmt.Println("Int Slice", intSlice)
fmt.Println("Float Slice", floatSlice)
fmt.Println("String Slice", stringSlice)
fmt.Println("Map", mapString)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment