Directories ¶
Path | Synopsis |
---|---|
composition
|
|
assertions/example1
Sample program demonstrating when implicit interface conversions are provided by the compiler.
|
Sample program demonstrating when implicit interface conversions are provided by the compiler. |
assertions/example2
Sample program demonstrating that type assertions are a runtime and not compile time construct.
|
Sample program demonstrating that type assertions are a runtime and not compile time construct. |
decoupling/example1
Sample program demonstrating struct composition.
|
Sample program demonstrating struct composition. |
decoupling/example2
Sample program demonstrating decoupling with interfaces.
|
Sample program demonstrating decoupling with interfaces. |
decoupling/example3
Sample program demonstrating interface composition.
|
Sample program demonstrating interface composition. |
decoupling/example4
Sample program demonstrating decoupling with interface composition.
|
Sample program demonstrating decoupling with interface composition. |
exercises/exercise1
Using the template, declare a set of concrete types that implement the set of predefined interface types.
|
Using the template, declare a set of concrete types that implement the set of predefined interface types. |
grouping/example1
This is an example of using type hierarchies with a OOP pattern.
|
This is an example of using type hierarchies with a OOP pattern. |
grouping/example2
This is an example of using composition and interfaces.
|
This is an example of using composition and interfaces. |
mocking/example1
Sample program to show how you can personally mock concrete types when you need to for your own packages or tests.
|
Sample program to show how you can personally mock concrete types when you need to for your own packages or tests. |
mocking/example1/pubsub
Package pubsub simulates a package that provides publication/subscription type services.
|
Package pubsub simulates a package that provides publication/subscription type services. |
pollution/example1
This is an example that creates interface pollution by improperly using an interface when one is not needed.
|
This is an example that creates interface pollution by improperly using an interface when one is not needed. |
pollution/example2
This is an example that removes the interface pollution by removing the interface and using the concrete type directly.
|
This is an example that removes the interface pollution by removing the interface and using the concrete type directly. |
error_handling
|
|
example1
Sample program to show how the default error type is implemented.
|
Sample program to show how the default error type is implemented. |
example2
Sample program to show how to use error variables to help the caller determine the exact error being returned.
|
Sample program to show how to use error variables to help the caller determine the exact error being returned. |
example3
http://golang.org/src/pkg/encoding/json/decode.go Sample program to show how to implement a custom error type based on the json package in the standard library.
|
http://golang.org/src/pkg/encoding/json/decode.go Sample program to show how to implement a custom error type based on the json package in the standard library. |
example4
Package example5 provides code to show how to implement behavior as context.
|
Package example5 provides code to show how to implement behavior as context. |
example5
Sample program to show see if the class can find the bug.
|
Sample program to show see if the class can find the bug. |
example5/reason
Sample program to show see if the class can find the bug.
|
Sample program to show see if the class can find the bug. |
example6
Sample program to show how wrapping errors work.
|
Sample program to show how wrapping errors work. |
exercises/exercise1
Create two error variables, one called ErrInvalidValue and the other called ErrAmountTooLarge.
|
Create two error variables, one called ErrInvalidValue and the other called ErrAmountTooLarge. |
exercises/exercise2
Create a custom error type called appError that contains three fields, err error, message string and code int.
|
Create a custom error type called appError that contains three fields, err error, message string and code int. |
exercises/template1
Create two error variables, one called ErrInvalidValue and the other called ErrAmountTooLarge.
|
Create two error variables, one called ErrInvalidValue and the other called ErrAmountTooLarge. |
exercises/template2
Create a custom error type called appError that contains three fields, err error, message string and code int.
|
Create a custom error type called appError that contains three fields, err error, message string and code int. |
Click to show internal directories.
Click to hide internal directories.