On Fri, May 3, 2019 at 7:25 PM <lgod...@gmail.com> wrote: > Example: > var kk int; > > func main() { > kk= 22 > { kkk := 10 > println ( kkk, kk) > } > println ( kk) > //println (kkk) //compiler error bec at this point kkk has been > destroyed by GC >
No. Wrong. The compiler issues an error because `kkk` is no longer in scope. That has nothing whatsoever to do with the GC. > } // But what happens to kk at this point ?? > You should assume nothing happens to `kk` as a consequence of the Go GC. It is true that the operating system will invalidate the page of memory containing that var and ensure the page is zeroed before giving it to another process. But that has nothing to do with the Go GC. -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.