-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello.go
49 lines (37 loc) · 1 KB
/
hello.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
package main
import (
"fmt"
"reflect"
"rsc.io/quote"
)
func main() {
fmt.Printf("hello, world\n")
fmt.Println(quote.Go())
// float
var3 := 1.55
// boolean
var4 := true
// shorthand string array declaration
var5 := []string{"foo", "bar", "baz"}
// map is reference datatype
var6 := map[int]string{100: "Ana", 101: "Lisa", 102: "Rob"}
// complex64 and complex128
// is basic datatype
var7 := complex(9, 15)
fmt.Printf("var3 = %T\n", var3)
fmt.Printf("var4 = %T\n", var4)
fmt.Printf("var5 = %T\n", var5)
fmt.Printf("var6 = %T\n", var6)
fmt.Printf("var7 = %T\n", var7)
// using TypeOf() method of reflect package
// to determine the datatype of the variables
fmt.Println()
fmt.Println("Using reflect.TypeOf Function")
fmt.Println()
fmt.Println("var3 = ", reflect.TypeOf(var3))
fmt.Println("var4 = ", reflect.TypeOf(var4))
fmt.Println("var5 = ", reflect.TypeOf(var5))
fmt.Println("var6 = ", reflect.TypeOf(var6))
fmt.Println("var7 = ", reflect.TypeOf(var7))
fmt.Println("var3 = ", var3)
}