diff options
Diffstat (limited to 'exercises')
-rw-r--r-- | exercises/structs/structs1/main.go | 15 | ||||
-rw-r--r-- | exercises/structs/structs2/main.go | 19 |
2 files changed, 34 insertions, 0 deletions
diff --git a/exercises/structs/structs1/main.go b/exercises/structs/structs1/main.go new file mode 100644 index 0000000..77090b3 --- /dev/null +++ b/exercises/structs/structs1/main.go @@ -0,0 +1,15 @@ +// structs1 +// Make me compile! +// +// I AM NOT DONE +package main + +import "fmt" + +type Person struct { + +} + +func main() { + fmt.Printf("Person %s and age %d", person.name, person.age) +} diff --git a/exercises/structs/structs2/main.go b/exercises/structs/structs2/main.go new file mode 100644 index 0000000..80e7dce --- /dev/null +++ b/exercises/structs/structs2/main.go @@ -0,0 +1,19 @@ +// structs2 +// Make me compile! +// +// I AM NOT DONE +package main + +import "fmt" + +type Person struct { + // don't just create the phone field here. embed a new struct + name string + age int +} + +func main() { + // contactDetails := ContactDetails{} + person := Person{name: "John", age: 32} + fmt.Printf("%s is %d years old and his phone is %s\n", person.name, person.age, person.phone) +} |