Hello World ๐
So , Today I learned about Golang Variables and found it amazing ๐ฅณ
Welcome to my blog!
Let Learn about this ๐
What is Variable ? ๐ง A variable is a storage location, with a specific type and an associated name. Let's change the program we wrote in chapter 2 so that it uses a variable:
We can decalare variable in 2 ways ๐
First Way ๐ฑ
package main
import "fmt"
func main() {
var x string = "Hello World"
fmt.Println(x)
}
Second Way๐คฉ
package main
import "fmt"
func main() {
x := "Hello World"
fmt.Println(x)
}
Done ! ๐
Okay , So now take a look here ๐
How to Name a Variable ? ๐ง
Naming a variable properly is an important part of software development. Names must start with a letter and may contain letters, numbers or the _ (underscore) symbol. The Go compiler doesn't care what you name a variable so the name is meant for your (and others) benefit. ๐ฅฑ
name := "Max"
fmt.Println("My dog's name is", name)
I will explain the scopes in next blog . Find me on Twitter ๐
Stay Tuned ! ๐คญ