# README
Go Patterns
Examples for common patterns in Go.
Table of Contents
config.go
- Adding configuration.http_client.go
- Making HTTP requests via an HTTP client.http_server.go
- Handling HTTP requests via an HTTP server.
# Functions
This method demonstrates how a function might be passed a value that implements the FooAPI interface.
NewMockFooAPI creates a new mock instance.
# Variables
Instead of initializing the configuration in main(), it is useful to define a global variable that can be accessed anywhere in the package and overridden during testing.
# Structs
FooAPIClient is an application-specific HTTP client.
In almost all cases, an external API will return a response as JSON:
>The MIME media type for JSON text is application/json.
MockFooAPI is a mock of FooAPI interface.
MockFooAPIMockRecorder is the mock recorder for MockFooAPI.
No description provided by the author
A Handler responds to an HTTP request.
# Interfaces
Though requests made by an HTTP client can be tested using the standard library httptest package, more often than not, applications making HTTP requests will do more than simply return the response from the server.
HTTPClient is a common interface that specifies the method signatures on the http.Client struct that are to be mocked.