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

推荐订阅源

P
Proofpoint News Feed
AI
AI
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
Scott Helme
Scott Helme
AWS News Blog
AWS News Blog
P
Privacy & Cybersecurity Law Blog
G
GRAHAM CLULEY
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
Cyberwarzone
Cyberwarzone
NISL@THU
NISL@THU
P
Privacy International News Feed
Schneier on Security
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
SecWiki News
SecWiki News
T
Tor Project blog
W
WeLiveSecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Troy Hunt's Blog
Cisco Talos Blog
Cisco Talos Blog
人人都是产品经理
人人都是产品经理
腾讯CDC
博客园 - 【当耐特】
Engineering at Meta
Engineering at Meta
The Hacker News
The Hacker News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
PCI Perspectives
PCI Perspectives
罗磊的独立博客
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
TaoSecurity Blog
TaoSecurity Blog
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Threat Research - Cisco Blogs
量子位
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
美团技术团队
D
Docker
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Tenable Blog

博客园 - ®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: Facade Pattern go: Flyweight Pattern go: Composite Pattern go: Singleton Pattern go: Prototype Pattern go: Bridge 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: Adapter Pattern
®Geovin Du D · 2026-04-18 · via 博客园 - ®Geovin Du Dream Park™

项目结构:

image

结构化优势
分层明确:实体、供应商、适配器、业务完全分离
职责单一:每个文件只做一件事
易扩展:新增供应商 C,只需增加:
adaptee/supplier_c.go
adapter/supplier_c_adapter.go
业务零改动:service/business.go 永远不需要修改
符合设计模式最佳实践

/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Adapter 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/18 20:55
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : jewelry.go
*/
package entity

// StandardJewelry 业务系统统一标准接口
type StandardJewelry interface {
	GetName() string
	GetWeight() float64
	GetMaterial() string
	GetCost() float64
}

// JewelryEntity 标准数据实体
type JewelryEntity struct {
	Name     string
	Weight   float64
	Material string
	Cost     float64
}

func (j *JewelryEntity) GetName() string { return j.Name }

func (j *JewelryEntity) GetWeight() float64 { return j.Weight }

func (j *JewelryEntity) GetMaterial() string { return j.Material }

func (j *JewelryEntity) GetCost() float64 { return j.Cost }
/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Adapter 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/18 20:56
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : supplier_a.go
*/
package adaptee

// SupplierA 传统中文Map格式
type SupplierA struct {
	Data map[string]interface{}
}


/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Adapter 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/18 20:56
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : supplier_b.go
*/
package adaptee

// SupplierB 国际英文结构体
type SupplierB struct {
	Name     string
	Carat    float64
	Material string
	Price    float64
}
/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Adapter 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/18 20:56
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : supplier_a_adapter.go
*/
package adapter

import (
	"godesginpattern/adapter/adaptee"
	"godesginpattern/adapter/entity"
)

// SupplierAAdapter 适配A → 标准接口
type SupplierAAdapter struct {
	supplier *adaptee.SupplierA
}

func NewSupplierAAdapter(s *adaptee.SupplierA) entity.StandardJewelry {
	return &SupplierAAdapter{supplier: s}
}

func (a *SupplierAAdapter) GetName() string {
	return a.supplier.Data["名称"].(string)
}

// 克重 → 统一转 float64(支持 int / float64)
func (a *SupplierAAdapter) GetWeight() float64 {
	switch val := a.supplier.Data["克重"].(type) {
	case int:
		return float64(val)
	case float64:
		return val
	default:
		return 0
	}
}

func (a *SupplierAAdapter) GetMaterial() string {
	return a.supplier.Data["材质"].(string)
}

// 供货价 → 统一转 float64(支持 int / float64)
// 这里修复了 panic 问题!
func (a *SupplierAAdapter) GetCost() float64 {
	switch val := a.supplier.Data["供货价"].(type) {
	case int:
		return float64(val)
	case float64:
		return val
	default:
		return 0
	}
}



/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Adapter 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/18 20:57
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : supplier_b_adapter.go
*/
package adapter

import (
	"godesginpattern/adapter/adaptee"
	"godesginpattern/adapter/entity"
)

// SupplierBAdapter 适配B → 标准接口
type SupplierBAdapter struct {
	supplier *adaptee.SupplierB
}

func NewSupplierBAdapter(s *adaptee.SupplierB) entity.StandardJewelry {
	return &SupplierBAdapter{supplier: s}
}

func (b *SupplierBAdapter) GetName() string     { return b.supplier.Name }
func (b *SupplierBAdapter) GetWeight() float64  { return b.supplier.Carat }
func (b *SupplierBAdapter) GetMaterial() string { return b.supplier.Material }
func (b *SupplierBAdapter) GetCost() float64    { return b.supplier.Price }
/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Adapter 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/18 20:57
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : business.go
*/
package service

import (
	"fmt"
	"godesginpattern/adapter/entity"
)

// BusinessProcess 统一业务流程
func BusinessProcess(j entity.StandardJewelry) {
	fmt.Println("=== 执行业务流程 ===")
	fmt.Printf("商品:%s\n", j.GetName())
	fmt.Printf("重量:%.2f\n", j.GetWeight())
	fmt.Printf("材质:%s\n", j.GetMaterial())
	fmt.Printf("成本:%.2f\n", j.GetCost())
	fmt.Println("入库、计价、下单完成 ✅\n")
}

调用:

/*
# 版权所有  2026 ©涂聚文有限公司™ ®
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:Adapter 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/18 21:02
# User      :  geovindu
# Product   : GoLand
# Project   : godesginpattern
# File      : adapterbll.go

adapter/
├── go.mod                  // Go 模块
├── entity/                 // 统一标准实体层
│   └── jewelry.go          // 标准接口 + 标准实体
├── adaptee/                // 被适配者(供应商原始接口)
│   ├── supplier_a.go       // 供应商A(中文Map)
│   └── supplier_b.go       // 供应商B(英文结构体)
├── adapter/                // 适配器层(核心转换)
│   ├── supplier_a_adapter.go
│   └── supplier_b_adapter.go
├── service/                // 业务逻辑层
│   └── business.go
└── main.go                 // 程序入口
*/
package bll

import (
	"godesginpattern/adapter/adaptee"
	"godesginpattern/adapter/adapter"
	"godesginpattern/adapter/service"
)

// 示例
func AdapterMain() {
	// 对接供应商A
	suppA := &adaptee.SupplierA{
		Data: map[string]interface{}{
			"名称":  "黄金项链",
			"克重":  5.2,
			"材质":  "足金",
			"供货价": 2800,
		},
	}
	adapterA := adapter.NewSupplierAAdapter(suppA)
	service.BusinessProcess(adapterA)

	// 对接供应商B
	suppB := &adaptee.SupplierB{
		Name:     "Diamond Ring",
		Carat:    0.5,
		Material: "Platinum",
		Price:    12000,
	}
	adapterB := adapter.NewSupplierBAdapter(suppB)
	service.BusinessProcess(adapterB)
} 

输出:

image

真正企业级结构化、严格分层、职责单一、完全可扩展
结构化 + 分层清晰 + 职责单一 + 易扩展


https://github.com/Comfy-Org/ComfyUI
https://www.comfy.org/zh-cn/


写好歌词提示词,可以生成歌
https://suno.com

teachablemachine.withgoogle.com
https://teachablemachine.withgoogle.com/train
https://www.geeksforgeeks.org/machine-learning/machine-learning-model-with-teachable-machine/

notebooklm.google.com
gemini.google.com

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