-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable.go
More file actions
37 lines (32 loc) · 857 Bytes
/
variable.go
File metadata and controls
37 lines (32 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
func main() {
// variable is a container for storing data values
var name string = "Muhammad Luthfi"
var age int = 21
var isStudent bool = true
// we can also create variables without specifying the type
var country = "Indonesia"
var height = 170.5
// or we can use the shorthand syntax (only inside functions)
city := "Bandung"
weight := 60
isAlive := false
// we can also create a group of variables
var (
campus string = "Wageningen University"
semester int = 5
)
grade := 3.75
// print the variables
println("Name:", name)
println("Age:", age)
println("Is Student:", isStudent)
println("Country:", country)
println("Height:", height)
println("City:", city)
println("Weight:", weight)
println("Is Alive:", isAlive)
println("Campus:", campus)
println("Semester:", semester)
println("Grade:", grade)
}