March 2019
Beginner to intermediate
324 pages
7h 17m
English
A variable is another basic building block of the Go language. In Go, to declare a variable, you can simply use the var keyword. Here is what this looks like:
var s string
Obviously, string is the data type. Let's say we would like to declare more than one variable of type string on the same statement. Here is what this would look like:
var s1,s2,s3 string
To initialize a variable with an initial value, Go offers a number of options. One option is to initialize the variable while also specifying the variable type. Here is what this looks like:
var s1,s2,s3 string = "first-string", "second-string", "third-string"
Another option is to initialize the variables without specifying the data type. Here is what this would ...
Read now
Unlock full access