abstract_factory

package
v0.0.0-...-5ca63f1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

实现多个工厂函数,返回不同的接口实现

func NewHttpClient

func NewHttpClient() Doer

NewHttpClient gives us a regular HTTP client from the `net/http` package

func NewMockHTTPClient

func NewMockHTTPClient() Doer

NewMockHTTPClient gives us a mock HTTP client, which returns an empty response for any request sent to it

type Person

type Person interface {
	Greet()
}

func NewPerson

func NewPerson(name string, age int) Person

NewPerson returns an interface, and not the person struct itself

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL