惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
V
Vulnerabilities – Threatpost
A
Arctic Wolf
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
Hugging Face - Blog
Hugging Face - Blog
H
Hacker News: Front Page
D
Docker
人人都是产品经理
人人都是产品经理
Attack and Defense Labs
Attack and Defense Labs
Forbes - Security
Forbes - Security
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
aimingoo的专栏
aimingoo的专栏
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Simon Willison's Weblog
Simon Willison's Weblog
腾讯CDC
WordPress大学
WordPress大学
T
Tenable Blog
P
Proofpoint News Feed
月光博客
月光博客
T
Tor Project blog
The Cloudflare Blog
罗磊的独立博客
S
Secure Thoughts
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Hacker News
The Hacker News
P
Palo Alto Networks Blog
I
Intezer
小众软件
小众软件
N
News | PayPal Newsroom
V
Visual Studio Blog
L
LINUX DO - 最新话题
W
WeLiveSecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Troy Hunt's Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园_首页
D
DataBreaches.Net
P
Privacy International News Feed
博客园 - 三生石上(FineUI控件)
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Security Affairs
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
阮一峰的网络日志
阮一峰的网络日志

博客园 - ®Geovin Du Dream Park™

go: Functional Options Pattern go:Timing Functions Pattern python: Timing Functions Pattern go: Steady-State Pattern python: Steady-State Pattern go: Handshaking Pattern python: Handshaking Pattern go: Fail-Fast Pattern python: Fail-Fast Pattern I go: Deadline Pattern python: Deadline Pattern go: Circuit-Breaker Pattern python: Circuit-Breaker Pattern go: Bulkheads Pattern python: Bulkheads Pattern go: Push & Pull Pattern python: Push & Pull Pattern python: Publish/Subscribe Pattern II go: Publish/Subscribe Pattern python: Publish/Subscribe Pattern go: Futures & Promises Pattern python: Futures & Promises Pattern go: Worker Pool Pattern go:Pipeline Pattern python: Worker Pool Pattern python: Pipeline Pattern go: Fan-Out Pattern python: Fan-Out Pattern go: Fan-In Pattern python: Fan-In Pattern Fan-In go: Producer Consumer  Pattern python: Producer Consumer Pattern go: Parallelism Pattern python: Parallelism Pattern go: Reactor Pattern python: Reactor Pattern go: Generators Pattern python: speech to text offline python: Generators Pattern go: Coroutines Pattern python:Coroutines Pattern go: Broadcast Pattern python: Broadcast Pattern python: Bounded Parallelism Pattern go: Bounded Parallelism Pattern python: N-Barrier Pattern go: N-Barrier Pattern python: Semaphore Pattern go: Semaphore Pattern python: Read-Write Lock Pattern go: Read-Write Lock Pattern python: Monitor Pattern go: Monitor Pattern python: Mutex Pattern go: Lock/Mutex Pattern Python: Condition Variable Pattern go:Condition Variable Pattern python: Registry Pattern python: Interpreter Pattern go: Interpreter Pattern go: Registry Pattern go: Memento Pattern go: Command Pattern go: State Pattern go:Template Method Pattern go: Strategy Pattern go: Visitor Pattern go: Observer Pattern go: Mediator Pattern go: Iterator Pattern go: Chain of Responsibility Pattern go: Proxy Pattern go:Decorator Pattern go: Flyweight Pattern go: Composite Pattern go: Singleton Pattern go: Prototype Pattern go: Bridge Pattern go: Adapter Pattern go: Builder Pattern 密码进行加盐哈希 using CSharp,Python,Go,Java go: Abstract Factory Pattern go: Model,Interface,DAL ,Factory,BLL using mysql go: Simple Factory Pattern go: Factory Method Pattern go: goLang 在Windows环境搭建Go语言开发环境 CSharp: Parallel Extensions cpp: class python: 蝴蝶跟随鼠标 javascript: 中国历史人物热力分布图using echart javascript: 中国历史人物热力图 python: 初养龙虾微信纯文字自动回复using workBuddy python: object 入门 python: Factory Method Pattern python: Simple Factory Pattern python: Abstract Factory Pattern 区域化 代码 python: Null Object Pattern python: Builder Pattern python: Adapter Pattern
go: Facade Pattern
®Geovin Du D · 2026-04-20 · via 博客园 - ®Geovin Du Dream Park™

项目结构:

image

/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Facade Pattern 外观模式
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : goLang 2024.3.6 go 26.2
# os        : windows 10
# database  : mysql 9.0 sql server 2019, postgreSQL 17.0  Oracle 21c Neo4j
# Datetime  : 2026/4/20 20:24
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : ring.go
*/
package domain

// RingOrder 钻戒定制入参
type RingOrder struct {
	Carat    float64
	Clarity  string
	Material string
}
/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Facade Pattern 外观模式
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : goLang 2024.3.6 go 26.2
# os        : windows 10
# database  : mysql 9.0 sql server 2019, postgreSQL 17.0  Oracle 21c Neo4j
# Datetime  : 2026/4/20 20:24
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : ring.go
*/
package service

import (
	"fmt"
	"godesginpattern/facade/domain"
)

// IRing 戒托制作接口
type IRing interface {
	Make(domain.RingOrder)
}

type ringImpl struct{}

func NewRing() IRing {
	return &ringImpl{}
}

func (r *ringImpl) Make(ord domain.RingOrder) {
	fmt.Printf("✅ 戒托制作:制作【%s】材质的戒托成功\n", ord.Material)
}



/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Facade Pattern 外观模式
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : goLang 2024.3.6 go 26.2
# os        : windows 10
# database  : mysql 9.0 sql server 2019, postgreSQL 17.0  Oracle 21c Neo4j
# Datetime  : 2026/4/20 20:24
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : inlay.go
*/
package service

import "fmt"

// IInlay 镶嵌接口
type IInlay interface {
	DoInlay()
}

type inlayImpl struct{}

func NewInlay() IInlay {
	return &inlayImpl{}
}

func (i *inlayImpl) DoInlay() {
	fmt.Println("✅ 珠宝镶嵌:将钻石镶嵌到戒托上成功")
}


/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Facade Pattern 外观模式
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : goLang 2024.3.6 go 26.2
# os        : windows 10
# database  : mysql 9.0 sql server 2019, postgreSQL 17.0  Oracle 21c Neo4j
# Datetime  : 2026/4/20 20:24
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : diamond.go
*/
package service

import (
	"fmt"
	"godesginpattern/facade/domain"
)

// IDiamond 钻石采购接口
type IDiamond interface {
	Buy(domain.RingOrder)
}

type diamondImpl struct{}

func NewDiamond() IDiamond {
	return &diamondImpl{}
}

func (d *diamondImpl) Buy(ord domain.RingOrder) {
	fmt.Printf("✅ 钻石采购:采购【%.2f克拉,净度%s】的钻石成功\n", ord.Carat, ord.Clarity)
}


/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Facade Pattern 外观模式
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : goLang 2024.3.6 go 26.2
# os        : windows 10
# database  : mysql 9.0 sql server 2019, postgreSQL 17.0  Oracle 21c Neo4j
# Datetime  : 2026/4/20 20:25
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : cert.go
*/
package service

import "fmt"

// ICert 证书办理接口
type ICert interface {
	Apply()
}

type certImpl struct{}

func NewCert() ICert {
	return &certImpl{}
}

func (c *certImpl) Apply() {
	fmt.Println("✅ 证书办理:成品钻戒鉴定证书办理成功")
}
/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Facade Pattern 外观模式
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : goLang 2024.3.6 go 26.2
# os        : windows 10
# database  : mysql 9.0 sql server 2019, postgreSQL 17.0  Oracle 21c Neo4j
# Datetime  : 2026/4/20 20:25
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : ring_facade.go
*/
package facade

import (
	"fmt"
	"godesginpattern/facade/domain"
	"godesginpattern/facade/service"
)

// IRingFacade 外观统一接口
type IRingFacade interface {
	Custom(ord domain.RingOrder)
}

type ringFacade struct {
	dia   service.IDiamond
	ring  service.IRing
	inlay service.IInlay
	cert  service.ICert
}

// NewRingFacade 依赖注入,完全解耦
func NewRingFacade(
	dia service.IDiamond,
	ring service.IRing,
	inlay service.IInlay,
	cert service.ICert,
) IRingFacade {
	return &ringFacade{
		dia:   dia,
		ring:  ring,
		inlay: inlay,
		cert:  cert,
	}
}

func (f *ringFacade) Custom(ord domain.RingOrder) {
	fmt.Println("======== 开始定制钻戒 ========")
	f.dia.Buy(ord)
	f.ring.Make(ord)
	f.inlay.DoInlay()
	f.cert.Apply()
	fmt.Println("======== 钻戒定制完成,可取货 ========\n")
}

调用:

/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Facade Pattern 外观模式
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : goLang 2024.3.6 go 26.2
# os        : windows 10
# database  : mysql 9.0 sql server 2019, postgreSQL 17.0  Oracle 21c Neo4j
# Datetime  : 2026/4/20 20:28
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : facadebll.go
facade/
├── domain
│   └── ring.go        // 领域模型
├── service
│   ├── diamond.go     // 钻石采购子系统
│   ├── ring.go        // 戒托制作子系统
│   ├── inlay.go       // 镶嵌子系统
│   └── cert.go        // 证书子系统
├── facade
│   └── ring_facade.go // 外观门面层
├── go.mod
└── main.go
*/
package bll

import (
	"godesginpattern/facade/domain"
	"godesginpattern/facade/facade"
	"godesginpattern/facade/service"
)

// 示例
func FacadeMain() {
	// 依赖注入初始化子系统
	diaSvc := service.NewDiamond()
	ringSvc := service.NewRing()
	inlaySvc := service.NewInlay()
	certSvc := service.NewCert()

	// 外观门面
	shop := facade.NewRingFacade(diaSvc, ringSvc, inlaySvc, certSvc)

	// 定制单1
	shop.Custom(domain.RingOrder{
		Carat:    1.0,
		Clarity:  "VVS",
		Material: "铂金",
	})

	// 定制单2
	shop.Custom(domain.RingOrder{
		Carat:    0.5,
		Clarity:  "VS",
		Material: "18K金",
	})
}

输出

image

哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)