blob: c74650721d7d1c9a479550e6e759a3f82aac273d (
plain) (
blame)
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
|
package main
import "fmt"
type Fooer interface {
Foo() int
}
type SomeFooer struct {
val int
}
func (s SomeFooer) Foo() int {
return s.val
}
type mystruct struct {
myInt int
myPointer *mystruct
}
func main() {
theBool := true
theInt := -7
theComplex := 1 + 2i
pointee := -10
thePointer := &pointee
theStruct := &mystruct { myInt: 7}
theStruct.myPointer = theStruct
theArray := [5]byte{1, 2, 3, 4, 5}
theSlice := theArray[1:2]
theString := "abc"
f := SomeFooer {9}
var theEface interface{} = f
var theFooer Fooer = f
theChan := make(chan int)
theMap := make(map[int]string)
theMap[1] = "1"
fmt.Println(theBool) // Set breakpoint here.
// Reference all the variables so the compiler is happy.
fmt.Println(theInt, theComplex, thePointer, theStruct.myInt)
fmt.Println(theArray[0], theSlice[0], theString)
fmt.Println(theEface, theFooer, theChan, theMap)
}
|