Skip to content

Instantly share code, notes, and snippets.

@afucher
Created July 17, 2018 14:37
Show Gist options
  • Save afucher/e8e95a4c9c8625c040ccae962782172b to your computer and use it in GitHub Desktop.
Save afucher/e8e95a4c9c8625c040ccae962782172b to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func main() {
tstSlice2()
}
func tstSlice2() {
var meuSlice = make([]int, 1, 2)
meuSlice[0] = 1
printSlice(meuSlice, "meuSlice")
meuSlice[0] = 2
printSlice(meuSlice, "meuSlice")
meuSlice[0] = 3
printSlice(meuSlice, "meuSlice")
}
func printSlice(meuSlice []int, sliceName string) {
fmt.Printf("%v> %v - %v - %v - %p \n", sliceName, len(meuSlice), cap(meuSlice), meuSlice, &meuSlice)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment