Lambda defer

func main() {
  var d = int64(0)
  defer func(d \*int64) {
    fmt.Printf("& %v Unix Sec\n", *d)
  }(&d)
  fmt.Print("Done ")
  d = time.Now().Unix()
}

The defer func uses current value of d, unless we use a pointer to get final value at end of main.

Comments