I would like to understand how the stack variables are deallocated. Is it garbage collected as variables located on heap, or like C languages which after leaving the variable scope it will be deallocated internally ?
A variable allocated on the stack will be removed once the function allocating that variable returns because the stack pointer will be restored to its state before the function call. There is no GC involvement there.
In Go, if the stack variable is a pointer to an object on the heap, then once the function returns, the pointer will be removed, and then the GC can remove the object it was pointing to provided no other references exist.