Skip to content

Commit 10b945e

Browse files
Removed the original number 5 because it was not necessary
1 parent 242344c commit 10b945e

File tree

5 files changed

+10
-55
lines changed

5 files changed

+10
-55
lines changed

04-packaging_exporting/example5/animals/animals.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
// Package animals provides support for animals.
55
package animals
66

7-
// Animal represents information about all animals.
8-
type Animal struct {
7+
// animal represents information about all animals.
8+
type animal struct {
99
Name string
1010
Age int
1111
}
1212

1313
// Dog represents information about dogs.
1414
type Dog struct {
15-
Animal
15+
animal // The embedded type is unexported.
1616
BarkStrength int
1717
}

04-packaging_exporting/example5/example5.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// https://github.com/ArdanStudios/gotraining/blob/master/LICENSE
33

44
// Sample program to show how to create values from exported types with
5-
// embedded types.
5+
// embedded unexported types.
66
package main
77

88
import (
@@ -13,14 +13,14 @@ import (
1313

1414
// main is the entry point for the application.
1515
func main() {
16-
// Create a value of type Dog from the animals package.
16+
/// Create a value of type Dog from the animals package.
1717
dog := animals.Dog{
18-
Animal: animals.Animal{
19-
Name: "Chole",
20-
Age: 1,
21-
},
2218
BarkStrength: 10,
2319
}
2420

21+
// Set the exported fields from the unexported animal inner type.
22+
dog.Name = "Chole"
23+
dog.Age = 1
24+
2525
fmt.Printf("Dog: %#v\n", dog)
2626
}

04-packaging_exporting/example6/animals/animals.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

04-packaging_exporting/example6/example6.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

04-packaging_exporting/readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ http://www.goinggo.net/2013/08/organizing-code-to-support-go-get.html
2727

2828
[Unexported struct type fields](example4/example4.go)
2929

30-
[Exported embedded types](example5/example5.go)
31-
32-
[Unexported embedded types](example6/example6.go)
30+
[Unexported embedded types](example5/example5.go)
3331

3432
## Exercises
3533

0 commit comments

Comments
 (0)