abstract

package
v0.0.0-...-eb36113 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryUser

func QueryUser(doer Doer) error

Types

type Doer

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

We define a Doer interface, that has the method signature of the `http.Client` structs `Do` method

func NewHTTPClient

func NewHTTPClient() Doer

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

func NewMockHTTPClient

func NewMockHTTPClient() Doer

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

type PersonA

type PersonA interface {
	Greet()
}

抽象工厂模式,它和简单工厂模式的唯一区别,就是它返回的是接口而不是结构体。 通过返回接口,可以在你不公开内部实现的情况下,让调用者使用你提供的各种功能。

func NewPerson

func NewPerson(name string, age int) PersonA

Jump to

Keyboard shortcuts

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