---
# System prepended metadata

title: design pattem
tags: [Go]

---

# design pattem
https://blogtitle.github.io/some-useful-patterns/


## singleton 
https://blog.kennycoder.io/2021/08/22/Golang-Singleton-%E5%AF%A6%E7%8F%BE%E6%96%B9%E5%BC%8F%E6%8E%A2%E8%A8%8E/

https://zhuanlan.zhihu.com/p/579010653

https://kennychen-blog.herokuapp.com/2021/08/22/Golang-Singleton-%E5%AF%A6%E7%8F%BE%E6%96%B9%E5%BC%8F%E6%8E%A2%E8%A8%8E/

## Option
用來處理沒有default的
https://segmentfault.com/a/1190000019720760

https://levelup.gitconnected.com/options-pattern-in-golang-9a0384a9d8db

https://zhuanlan.zhihu.com/p/424164761
![](https://i.imgur.com/9aHaQEX.png)
![](https://i.imgur.com/lATESTP.png)

加上err驗證
![](https://i.imgur.com/LrLWJOM.png)


https://kennychen-blog.herokuapp.com/2021/09/06/Golang-%E5%B8%B8%E8%A6%8B%E7%9A%84-option-%E8%A8%AD%E8%A8%88%E6%8E%A2%E8%A8%8E/

## 状态模式
https://juejin.cn/post/6844904178549014536

## fan-in fan-out
https://ithelp.ithome.com.tw/articles/10268715
![](https://i.imgur.com/B84QJft.png)
![](https://i.imgur.com/CX1NpQH.png)

###### tags: `Go`