-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
70 lines (55 loc) · 1.7 KB
/
main.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"fmt"
)
// Not allowed outside of method
// tokenExpiry := 24353
// Allowed
// var tokenExpiry uint32 = 24353
const SuccessToken string = "A super secret token" // public and can't be reassigned
func main() {
var username string = "saheemshafi"
fmt.Println(username)
fmt.Printf("Variable is of type: %T \n", username)
fmt.Println("")
var isLoggedIn bool = false
fmt.Println(isLoggedIn)
fmt.Printf("Variable is of type: %T \n", isLoggedIn)
fmt.Println("")
var smallVal uint8 = 255
fmt.Println(smallVal)
fmt.Printf("Variable is of type: %T \n", smallVal)
fmt.Println("")
var smallFloatVal float64 = 255.32425255
fmt.Println(smallFloatVal)
fmt.Printf("Variable is of type: %T \n", smallFloatVal)
fmt.Println("")
// The default values and aliases
var someVariable int
fmt.Println(someVariable)
fmt.Printf("Variable is of type: %T \n", someVariable)
fmt.Println("")
// implicitly declare variables
var url = "portfolio-saheem.vercel.app"
fmt.Println(url)
fmt.Println("")
// no var style to declare variables
numberOfClicks := 1200
fmt.Println(numberOfClicks)
fmt.Println("")
fmt.Println(SuccessToken)
fmt.Printf("Variable is of type: %T \n", SuccessToken)
fmt.Println("")
var array = [5]int{1, 2, 3, 4, 5} // An fixed size array
fmt.Println(array)
fmt.Printf("Variable is of type: %T \n", array)
fmt.Println("")
var slice = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} // A variable size array also called as slice
fmt.Println(slice)
fmt.Printf("Variable is of type: %T \n", slice)
fmt.Println("")
var keyValuePairs = make(map[string]string)
keyValuePairs["key"] = "Store key value pairs"
fmt.Println(keyValuePairs)
fmt.Printf("Variables is of type: %T \n", keyValuePairs)
}