pattern

package
v0.0.0-...-0158116 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SizeBig    PhoneSize = "大尺寸"
	SizeMiddle           = "中等尺寸"
	SizeSmall            = "小尺寸"
)
View Source
const (
	ColorRed   PhoneColor = "红色"
	ColorGreen            = "绿色"
	ColorBlue             = "蓝色"
)
View Source
const (
	SimYiDong   PhoneSim = "移动"
	SimLianTong          = "联通"
	SimDianXin           = "电信"
)
View Source
const (
	TypeLenovo PcType = "lenovo"
	TypeDell          = "dell"
	TypeHp            = "hp"
)

Variables

This section is empty.

Functions

func NewCommand

func NewCommand() *cobra.Command

Types

type Addition

type Addition struct{}

func (Addition) Apply

func (Addition) Apply(a int, b int) int

type ChainHandler

type ChainHandler interface {
	Do(ctx context.Context) error
	Run(ctx context.Context) error
	SetNext(h ChainHandler) ChainHandler
}

type ChainNext

type ChainNext struct {
	// contains filtered or unexported fields
}

func (*ChainNext) Run

func (n *ChainNext) Run(ctx context.Context) error

func (*ChainNext) SetNext

func (n *ChainNext) SetNext(h ChainHandler) ChainHandler

type Earth

type Earth struct {
	Name string
}

func NewSingleton

func NewSingleton() *Earth

type Event

type Event struct {
	Data interface{}
}

type INotifier

type INotifier interface {
	Register(obs IObserver)
	Deregister(obs IObserver)
	Notify(eve Event)
}

type IObserver

type IObserver interface {
	OnNotify(eve Event)
}

type IPhone

type IPhone struct {
	Size    PhoneSize
	Color   PhoneColor
	SimCard PhoneSim
}

实现手机接口的IPhone

func (IPhone) Call

func (mine IPhone) Call() string

type IPhoneBuilder

type IPhoneBuilder struct {
	// contains filtered or unexported fields
}

实现手机构建者接口的构建者

func (IPhoneBuilder) Build

func (mine IPhoneBuilder) Build() PhoneInterface

func (IPhoneBuilder) Color

func (mine IPhoneBuilder) Color(color PhoneColor) PhoneBuilder

func (IPhoneBuilder) SimCard

func (mine IPhoneBuilder) SimCard(sim PhoneSim) PhoneBuilder

func (IPhoneBuilder) Size

func (mine IPhoneBuilder) Size(size PhoneSize) PhoneBuilder

type LinkObject

type LinkObject struct {
	// contains filtered or unexported fields
}

func (*LinkObject) ID

func (link *LinkObject) ID() int

type LinkPool

type LinkPool chan *LinkObject

func NewPool

func NewPool(total int) *LinkPool

func (*LinkPool) Get

func (pool *LinkPool) Get() *LinkObject

type Multiplication

type Multiplication struct{}

func (Multiplication) Apply

func (Multiplication) Apply(a int, b int) int

type NilChainHandler

type NilChainHandler struct {
	ChainNext
}

func (*NilChainHandler) Do

func (h *NilChainHandler) Do(ctx context.Context) error

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

func NewNotifier

func NewNotifier() Notifier

func (*Notifier) Deregister

func (n *Notifier) Deregister(obs IObserver)

func (*Notifier) Notify

func (n *Notifier) Notify(eve Event)

func (*Notifier) Register

func (n *Notifier) Register(obs IObserver)

type Observer

type Observer struct {
	Data interface{}
	// contains filtered or unexported fields
}

func NewObserver

func NewObserver(id int) *Observer

func (*Observer) OnNotify

func (o *Observer) OnNotify(eve Event)

type Operation

type Operation struct {
	Operator Operator
}

func (*Operation) Operate

func (o *Operation) Operate(a int, b int) int

type Operator

type Operator interface {
	Apply(a int, b int) int
}

type Pc

type Pc interface {
	RunPrint() string
}

pc接口

func NewPc

func NewPc(t PcType) Pc

type PcType

type PcType string

工厂方法实现

type PhoneBuilder

type PhoneBuilder interface {
	Size(size PhoneSize) PhoneBuilder
	Color(color PhoneColor) PhoneBuilder
	SimCard(sim PhoneSim) PhoneBuilder
	Build() PhoneInterface
}

手机构造接口

func NewIPhoneBuilder

func NewIPhoneBuilder() PhoneBuilder

type PhoneColor

type PhoneColor string

type PhoneInterface

type PhoneInterface interface {
	Call() string
}

手机接口

type PhoneSim

type PhoneSim string

type PhoneSize

type PhoneSize string

定义常量

Jump to

Keyboard shortcuts

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