Translate

Wednesday, 20 August 2014

Variable declaration and assigning values in Go Lang

   There are various ways to declare and assign values to variables in GoLang.
  • Declaring variables using var keyword
  • Declaring  variables and assigning values with a special assignment operator :=
Below images depict various ways of declaring and assigning values to variables


Variable declaration using var keyword and assigning values



Download above code from Variable declaration example-1

As mentioned earlier there is another way of declaring variables at the time of assigning values to them. It can be called as ad-hoc declaration . The below image explains how to do that
Variable declaration and assign value in an ad-hoc way
 Download above code from Variable declaration example-2

Thanks for reading, please do write your comments and correct me if some thing is wrong or some thing to be added to it. I will write advanced techniques in Go Lang in my upcoming posts..

No comments:

Post a Comment