Different ways of defining variables in google’s golang

If you are reading this then probably you already know atleast little bit about golang. Coding in golang is fun and productive. Golang is simple and precise.

There are many ways of defining a variable in golang and sometimes it’s get really confusing what is the best way to define a variable. The best way is really subject. So I will define here some of the ways in which you can define a variable in google’s golang and will leave up to you to decide which way is the best way.

1. var name string = “Prakash”
2. var name = “Prakash”
3. name string = “Prakash”
4. name := “Prakash”

I use style 1 & 2 to define global variables and style 3 & 4 to define block or function variables.

You can use any of the above styles to define a variable. The best among them is the one you like the most.

Like what you read? Give Prakash Pandey a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.