Skip to content

Instantly share code, notes, and snippets.

@kicool
Created March 31, 2013 10:33
Show Gist options
  • Save kicool/5280237 to your computer and use it in GitHub Desktop.
Save kicool/5280237 to your computer and use it in GitHub Desktop.

Revisions

  1. kicool created this gist Mar 31, 2013.
    18 changes: 18 additions & 0 deletions sam-append.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    package main

    import "fmt"

    func main() {
    a := make([]int, 1, 100)
    a[0] = 10
    fmt.Printf("a:%v, &a[0] %p, &a %p\n\n", a, &a[0], &a)

    b := append(a, 20)
    fmt.Printf("a:%v, &a[0] %p, &a %p\n", a, &a[0], &a)
    fmt.Printf("b:%v, &b[0] %p, &b %p\n\n", b, &b[0], &b)

    c := append(a, 30)
    fmt.Printf("a:%v, &a[0] %p, &a %p\n", a, &a[0], &a)
    fmt.Printf("b:%v, &b[0] %p, &b %p\n", b, &b[0], &b)
    fmt.Printf("c:%v, &c[0] %p, &c %p\n", c, &c[0], &c)
    }