Variables
package main
import "fmt"
func main() {
// Declare and initialize a variable 'a' with the string value "initial"
var a = "initial"
fmt.Println(a)
// Declare and initialize two variables 'b' and 'c' with integer values 1 and 2
var b, c int = 1, 2
fmt.Println(b, c)
// Declare and initialize a variable 'd' with a boolean value true
var d = true
fmt.Println(d)
// Declare a variable 'e' without initializing it, defaults to the zero value for its type (int in this case)
var e int
fmt.Println(e)
// Short declaration and initialization of a variable 'f' with the string value "apple"
f := "apple"
fmt.Println(f)
}Output
Explanation:
Last updated