创建文件Manger.go
package chain
// 主管 经理  总经理  董事长
// 20   100   150    200
type Manger interface {
    HaveRight(money int) bool                     // 判断权限
    HandleFeeRequest(name string, mon...
				 
		
				
                 	
						
				
						
                	创建文件ImageFlyWeight.go
package FlyWeight
import "fmt"
type ImageFlyWeight struct {
    data string
}
// 初始化
func NewImageFlyWeight(filename string) *ImageFlyWeight {
    data := fmt.Sprintf("image ...
				 
		
				
                 	
						
				
						
                	创建文件Component.go
package Deacorator
type Component interface {
    Calc() int
}
type ConcreateComponent struct {
}
func (*ConcreateComponent) Calc() int {
    return 0
}
创建文件AddComponent.go
...
				 
		
				
                 	
						
				
						
                	创建文件Message.go
package bridge
// SNS短信
// Email
type AbstractMessage interface {
    SendMessage(text, to string) // 发送快,普通发送
}
type MessageImlementer interface {
    Send(text, to string) //...
				 
		
				
                 	
						
				
						
                	package main
import "fmt"
// 测试
type API interface {
    Test() string
}
type APICall struct {
    // 接口
    a AmoudleAPI
    b BmoudleAPI
}
func (api *APICall) Test() string {
    return fmt.S...
				 
		
				
                 	
						
				
						
                	package main
import "fmt"
type Subject interface {
    Do() string // 实际业务, 业务系统,检查是否欠费,检查密码是否正确
}
type RealSubject struct {
}
func (sb RealSubject) Do() string {
    return "智...
				 
		
				
                 	
						
				
						
                	创建文件:Component.go
package Composite
//有的时候是父节点,叶子
type Component interface {
    Parent() Component
    SetParent(Component)
    Name() string
    SetName(string)
    AddChild(Component)
   ...
				 
		
				
                 	
						
				
						
                	package main
import "fmt"
// 适配器目标接口
type Target interface {
    Request(int, int) string
}
type Adapter struct {
    Adaptee
}
func NewAdapter(adaptee Adaptee) Target {
    return &Adapte...
				 
		
				
                 	
						
				
						
                	创建文件:Builder.go
package Builder
type Builder interface {
    Part1()
    Part2()
    Part3()
}
type Director struct {
    builder Builder // 建造者的接口
}
// 创造一个接口
func NewDirector(builde...
				 
		
				
                 	
						
				
						
                	package main
import "fmt"
// 原型对象需要实现的接口
// copy 原有的对象
type Cloneable interface {
    Clone() Cloneable
}
// 原型的类
type PrototypeManager struct {
    prototypes map[string]Cloneable
...
				 
		
				
                 	
						
				
						
                	package main
import (
    "fmt"
    "sync"
)
type Single struct {
    Data int
}
var singleton *Single
var once sync.Once // 内核信号,时时刻刻只能运行一个
func GetInterface() *Single {
    once.Do(...
				 
		
				
                 	
						
				
						
                	创建DAOFactory.go
package AbstractFactory
// mysql
// sqlserver
// oracle
// 订单
// 订单报表
type OrderMainDAO interface { // 订单记录
    SaveOrderMain() // 保存
    //DeleteOrderMain()
    //SearchOrd...
				 
		
				
                 	
						
				
						
                	新建 OperatorFactory.go
package factory
// 实际运行类的接口
type Operator interface {
    SetLeft(int)
    SetRight(int)
    Result() int
}
// 工厂接口
type OperatorFactory interface {
    Create() Opera...
				 
		
				
                 	
						
				
						
                	package main
import "fmt"
// 中国人说, 你好
// 英国人说,hello
type API interface {
    Say(name string) string
}
func NewAPI(str string) API {
    if str == "en" {
        return &English{}
   ...
				 
		
				
                 	
						
				
						
                	在开发项目的工程中难免会遇到一些公用的常量定义,在刚开始的时候有点迷茫不知道怎么使用,后来还是在类的引用中恍然大悟,整理如下。
定义个Const类,放到utils文件夹,内容如下:
class Const {
  MIN_LUNAR_YEAY = 1900
  U...