go-fucking-patterns

command module
v0.0.0-...-e059a18 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 2 Imported by: 0

README

Golang工程模式示例集合(Go Patterns Examples)

包括了go-patternsgolang-design-pattern中的全部模式

目前包括42种Go中常用的、面向工程化和最佳实践的模式/套路,自然也包含常见的23种设计模式,重点是这里全部是例子、通俗易懂,甚至每个模式下的例子,改一下名字,稍微再增加几行代码就可以直接用在项目和工程中了。

每一种设计模式都有其特定的应用场景和要解决的问题,了解模式的关键点就在于弄清这些目标场景和问题,千万不要纠结于:为什么这个模式叫这个名字,这个模式为啥要这样用? 要知道,最初,这些模式不是你总结的,也不是我的总结的,命名不由你我,如果是你我的写的,当然可以按照自己的喜欢的感觉给这些套路取名字,让其他人去费劲想

了解姿势 Ways

  • 所谓模式就是套路,如功夫,招有定式
  • 学习模式,就是学习一些经典套路,更弄清楚套路要解决的目标场景,这很重要,才能举一反三更好创新
  • 这里就是以实际代码示例出发,展示设计模式,通俗易懂
  • 除了常见的23种普适的设计模式,Go也有一些属于自己的模式

走起 Go

下载:

go https://github.com/crazybber/go-pattern-examples

跑一遍测试:

cd go-pattern-examples
go test ./...

行为型模式 Behavior Patterns

创建型模式 Creation Patterns

结构型模式 Structure Patterns

弹性模式 Resiliency Patterns

更多模式(同步/并发/并行) Go More Patterns(Concurrency/Parallelism/Sync)

参考资料(Design patters Articles)

Patterns Instructions Status
go-patterns 搜集整理到各种模式文章和代码 p
菜鸟设计模式 以Java为主的设计模式介绍 p
design_pattern 编程之家的设计模式 p
golang-design-pattern go语言的设计模式理论 p
go-resiliency go的一些弹性模式 m
Behavioral 设计模式中的行为模式(俄语版) m
go-patterns 一些设计模式 p
go_design_pattern 日语版设计模式 p
microsoft-patterns 微软设计模式系列文章(24) p/w

更多 More

需要重新温习下Go基础?看这里:

go-fucking-exercises

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
behavior
04_iterator/book_iterator
Package iterator is an example of the Iterator Pattern.
Package iterator is an example of the Iterator Pattern.
10_state
Package state is an example of the State Pattern.
Package state is an example of the State Pattern.
creation
gomore
08_semaphore/semaphore
Package semaphore implements the semaphore resiliency pattern for Go.
Package semaphore implements the semaphore resiliency pattern for Go.
13_batcher
Package batcher implements the batching resiliency pattern for Go.
Package batcher implements the batching resiliency pattern for Go.
resiliency
01_circuit_breaker/gobreaker
Package gobreaker implements the Circuit Breaker pattern.
Package gobreaker implements the Circuit Breaker pattern.
03_deadline
Package deadline implements deadline (also known as "timeout") resiliency pattern for Go.
Package deadline implements deadline (also known as "timeout") resiliency pattern for Go.
04_retrier
Package retrier implements the "retriable" resiliency pattern for Go.
Package retrier implements the "retriable" resiliency pattern for Go.
structure

Jump to

Keyboard shortcuts

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