Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

65 lines
751 B

package main
import "fmt"
type name string
type location struct {
x int
y int
}
type size struct {
width int
height int
}
type dot struct {
name
location
size
}
func getDots() []dot {
var dot1 dot
dot2 := dot{}
dot2.name = "A"
dot2.x = 5
dot2.y = 6
dot2.width = 10
dot2.height = 20
dot3 := dot{
name: "B",
location: location{
x: 13,
y: 27,
},
size: size{
width: 5,
height: 7,
},
}
dot4 := dot{}
dot4.name = "C"
dot4.x = 101
dot4.location.y = 209
dot4.width = 87
dot4.size.height = 43
return []dot{dot1, dot2, dot3, dot4}
}
func main() {
dots := getDots()
for i := 0; i < len(dots); i++ {
fmt.Printf("dot%v: %#v\n", i+1, dots[i])
}
}