Last active
August 29, 2015 13:57
-
-
Save goinggo/9567247 to your computer and use it in GitHub Desktop.
Exported_Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package counters | |
// AlertCounter is an exported type that | |
// contains an integer counter for alerts. | |
type AlertCounter int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"test/counters" | |
) | |
func main() { | |
// Create a variable of the exported type and | |
// initialize the value to 10. | |
counter := counters.AlertCounter(10) | |
fmt.Printf("Counter: %d\n", counter) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package counters | |
// alertCounter is an unexported type that | |
// contains an integer counter for alerts. | |
type alertCounter int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"test/counters" | |
) | |
func main() { | |
// Attempt to create a variable of the unexported type | |
// and initialize the value to 10. This will NOT compile. | |
counter := counters.alertCounter(10) | |
fmt.Printf("Counter: %d\n", counter) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package counters | |
// alertCounter is an unexported type that | |
// contains an integer counter for alerts. | |
type alertCounter int | |
// NewAlertCounter creates and returns objects of | |
// the unexported type alertCounter. | |
func NewAlertCounter(value int) alertCounter { | |
return alertCounter(value) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"test/counters" | |
) | |
func main() { | |
// Create a variable of the unexported type using the | |
// exported NewAlertCounter function from the package counters. | |
counter := counters.NewAlertCounter(10) | |
fmt.Printf("Counter: %d\n", counter) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package animals | |
// Dog represents information about dogs. | |
type Dog struct { | |
Name string | |
BarkStrength int | |
age int | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"test/animals" | |
) | |
func main() { | |
// Create an object of type Dog from the animals package. | |
// This will NOT compile. | |
dog := animals.Dog{ | |
Name: "Chole", | |
BarkStrength: 10, | |
age: 5, | |
} | |
fmt.Printf("Counter: %#v\n", dog) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package animals | |
// Animal represents information about all animals. | |
type Animal struct { | |
Name string | |
Age int | |
} | |
// Dog represents information about dogs. | |
type Dog struct { | |
Animal | |
BarkStrength int | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"test/animals" | |
) | |
func main() { | |
// Create an object of type Dog from the animals package. | |
dog := animals.Dog{ | |
Animal: animals.Animal{ | |
Name: "Chole", | |
Age: 1, | |
}, | |
BarkStrength: 10, | |
} | |
fmt.Printf("Counter: %#v\n", dog) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package animals | |
// animal represents information about all animals. | |
type animal struct { | |
Name string | |
Age int | |
} | |
// Dog represents information about dogs. | |
type Dog struct { | |
animal | |
BarkStrength int | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"test/animals" | |
) | |
func main() { | |
// Create an object of type Dog from the animals package. | |
// This will NOT compile. | |
dog := animals.Dog{ | |
animal: animals.animal{ | |
Name: "Chole", | |
Age: 1, | |
}, | |
BarkStrength: 10, | |
} | |
fmt.Printf("Counter: %#v\n", dog) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"test/animals" | |
) | |
func main() { | |
// Create an object of type Dog from the animals package. | |
dog := animals.Dog{ | |
BarkStrength: 10, | |
} | |
dog.Name = "Chole" | |
dog.Age = 1 | |
fmt.Printf("Counter: %#v\n", dog) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Time struct { | |
// sec gives the number of seconds elapsed since | |
// January 1, year 1 00:00:00 UTC. | |
sec int64 | |
// nsec specifies a non-negative nanosecond | |
// offset within the second named by Seconds. | |
// It must be in the range [0, 999999999]. | |
// | |
// It is declared as uintptr instead of int32 or uint32 | |
// to avoid garbage collector aliasing in the case where | |
// on a 64-bit system the int32 or uint32 field is written | |
// over the low half of a pointer, creating another pointer. | |
// TODO(rsc): When the garbage collector is completely | |
// precise, change back to int32. | |
nsec uintptr | |
// loc specifies the Location that should be used to | |
// determine the minute, hour, month, day, and year | |
// that correspond to this Time. | |
// Only the zero Time has a nil Location. | |
// In that case it is interpreted to mean UTC. | |
loc *Location | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment