Categorygithub.com/NickolasHKraus/go-patterns
modulepackage
0.0.0-20240322191214-96dc7f1f4863
Repository: https://github.com/nickolashkraus/go-patterns.git
Documentation: pkg.go.dev

# README

Go Patterns

MIT License Go Report Card

Examples for common patterns in Go.

Table of Contents

# 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.