大家好,我是gopher_looklook,现任某独角兽企业Go语言工程师,喜欢钻研Go源码,发掘各项技术在大型Go微服务项目中的最佳实践,期待与各位小伙伴多多交流,共同进步!为什么需要函数选项模式介绍 函数选项模式(functional option pattern) 之前,我们先来看这么一段代码。 type Server struct { host string port int } func NewServer(host string, port int) *Server { s := &Server{ host: host, ...