Skip to main content

Posts

Showing posts from November 19, 2017

GoLang from Programming Template

About Memory: 1. How do I get memory, i.e how are variables declared. Any specific facts and constrains about variables ? Basic data types are here .Declare the variables which you'll need outside the entry point of main function. Something like : var ( ToBe   bool       = false MaxInt uint64     = 1<<64 - 1 z      complex128 = cmplx.Sqrt(-5 + 12i) ) local variables can be declared as shown as example in explanation of FOR loop. 2. How do we get the entry point for the program execution ? [ Example : main() in the C program ] func main() --> is the entry point of the program execution. 3. How does dynamic memory handled ? Is it supported in first place ? Yes dynamic memory is supported.  new  allocates zeroed storage for a new item or type whatever and then returns a pointer to it. Go has garbage collection. This means the Go runtime checks in the background if an object or any other variable is not used anymore and if this is the case, frees the memory