/go-patterns-1

Go 语言编程模式最佳实践

Primary LanguageGoMIT LicenseMIT

go-patterns

Go 语言编程模式最佳实践,来源于耗子叔的博客分享总结,十分感谢。

也欢迎访问耗子叔的博客学习更多知识:https://coolshell.cn


一、切片,接口,性能

base.go

参考阅读:

Effective Go

Uber Go Style Guide

50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs

Go Advice

Go Code Review Comments

二、错误处理

error_handle.go

参考阅读:

Golang Error Handling lesson by Rob Pike

Errors are values

Error handling and Go

Working with Errors in Go 1.13

Golang: Six Error Handling techniques to help you write elegant code

三、Functional Options

functional_options.go

参考阅读:

Self-referential functions and the design of options

Implementing the Options Pattern in Golang

四、委托和控制反转

ioc.go

参考阅读:

IOC/DIP其实是一种管理**

Dependency Injection and IoC Container in Go

五、Map-Reduce

map_reduce.go

参考阅读:

官方文档:反射 reflect 包介绍

The Laws of Reflection

Simple apply/filter/reduce package — Rob Pike

六、Go Generation

generation.go

七、修饰器模式

decorator.go

参考阅读:

函数式编程

go-decorator-pattern

go-decorator-pattern

八、Pipeline

pipeline.go

参考阅读:

Go Concurrency Patterns: Pipelines and cancellation

九、Visitor 模式

visitor.go

参考阅读:

Visitor Design Pattern in Golang

Visitor in Golang