随笔分类 -  golang

摘要:小结:各种语言都支持传统的多线程模型实现并发python比较特殊因为有GIL无法真正并发、java/nodejs的reactor事件模型因为callback hell会导致业务逻辑分散和不易维护、scala通过akka事件库和actor模型实现了高并发和代码逻辑的连贯性、golang的创新在于使用m 阅读全文
posted @ 2021-06-27 21:24 junneyang 阅读(232) 评论(0) 推荐(0) 编辑
摘要:GRPC-负载均衡 阅读全文
posted @ 2018-01-11 11:26 junneyang 阅读(1144) 评论(0) 推荐(0) 编辑
摘要:golang-Microservice 阅读全文
posted @ 2017-01-09 18:05 junneyang 阅读(4107) 评论(0) 推荐(0) 编辑
摘要:参考资料: 阅读全文
posted @ 2016-12-24 09:29 junneyang 阅读(285) 评论(0) 推荐(0) 编辑
摘要:最佳实践 最佳实践 1 包管理 1 包管理 1.1 使用包管理对Golang项目进行管理,如:godep/vendor等工具 1.1 使用包管理对Golang项目进行管理,如:godep/vendor等工具 1.2 main/init函数使用,init函数参考python 1.2 main/init 阅读全文
posted @ 2016-12-23 18:56 junneyang 阅读(3949) 评论(0) 推荐(0) 编辑
摘要:直接上代码: 简介 Go语言的并发原语允许开发者以类似于 Unix Pipe 的方式构建数据流水线 (data pipelines),数据流水线能够高效地利用 I/O和多核 CPU 的优势。 本文要讲的就是一些使用流水线的一些例子,流水线的错误处理也是本文的重点。 阅读建议 数据流水线充分利用了多核 阅读全文
posted @ 2016-12-23 18:23 junneyang 阅读(2600) 评论(0) 推荐(1) 编辑
摘要:参考资料: http://studygolang.com/articles/7994--Defer函数调用参数的求值 golang的闭包和普通函数调用区别:http://studygolang.com/articles/356 结论: 闭包中参数是其地址 闭包中参数的确定是在声明时求值,而不是在调用 阅读全文
posted @ 2016-12-23 13:30 junneyang 阅读(368) 评论(0) 推荐(0) 编辑
摘要:结论: 闭包函数可以直接引用外层代码定义的变量, 但是,注意,闭包函数里面引用的是变量的地址, 当goroutine被调度时,改地址的值才会被传递给goroutine 函数。 介绍 go的闭包是一个很有用的东西。但是如果你不了解闭包是如何工作的,那么他也会给你带来一堆的bug。这里我会拿出Go In 阅读全文
posted @ 2016-12-23 13:21 junneyang 阅读(2116) 评论(0) 推荐(0) 编辑
摘要:代码示例: go程序包源码解读——golang.org/x/net/context: http://m.blog.csdn.net/article/details?id=49100433 Go语言并发模型:像Unix Pipe那样使用channel: https://segmentfault.com 阅读全文
posted @ 2016-12-22 21:14 junneyang 阅读(1725) 评论(0) 推荐(0) 编辑
摘要:服务端代码示例: 客户端代码示例: 参考资料: golang http请求优化: https://www.douban.com/note/285372115/ goreq: 极简单的流式golang http client: http://www.tuicool.com/articles/FNZbY 阅读全文
posted @ 2016-12-22 14:41 junneyang 阅读(51035) 评论(0) 推荐(0) 编辑
摘要:cannot define new methods on non-local type int 参考资料: http://wiki.jikexueyuan.com/project/the-way-to-go/10.6.html http://stackoverflow.com/questions/2 阅读全文
posted @ 2016-12-21 19:01 junneyang 阅读(1015) 评论(0) 推荐(0) 编辑
摘要:Gox 是一个简单的,不花俏的Go平台交叉编译工具,它的用处就和标准的 go build 一样。Gox 会并行地为多种平台编译。Gox 同时也提供了一套交叉编译工具链。 Gox 项目地址:https://github.com/mitchellh/gox 安装 为了安装 Gox,请使用 go get。 阅读全文
posted @ 2016-12-21 11:41 junneyang 阅读(2794) 评论(0) 推荐(0) 编辑
摘要:虽然golang是用C实现的,并且被称为下一代的C语言,但是golang跟C的差别还是很大的。它定义了一套很丰富的数据类型及数据结构,这些类型和结构或者是直接映射为C的数据类型,或者是用C struct来实现。了解golang的数据类型和数据结构的底层实现,将有助于我们更好的理解golang并写出质 阅读全文
posted @ 2016-12-20 18:11 junneyang 阅读(6098) 评论(0) 推荐(0) 编辑
摘要:https://www.douban.com/note/512625720/ http://blog.csdn.net/hanxin1987216/article/details/8156010 https://github.com/jemalloc https://github.com/heoni 阅读全文
posted @ 2016-12-20 14:44 junneyang 阅读(383) 评论(0) 推荐(0) 编辑
摘要:golang垃圾回收 & 性能调优 阅读全文
posted @ 2016-12-19 17:25 junneyang 阅读(941) 评论(0) 推荐(0) 编辑
摘要:Bookmarks 阅读全文
posted @ 2016-12-19 16:14 junneyang 阅读(388) 评论(0) 推荐(0) 编辑
摘要:Add Open vSwitch-based multitenant backend for use with OpenShift / Kubernetes: https://github.com/coreos/flannel/pull/384 flannel 通信原理图: https://raw. 阅读全文
posted @ 2016-12-19 10:34 junneyang 阅读(756) 评论(0) 推荐(0) 编辑
摘要:参考资料: 通过beego快速创建一个Restful风格API项目及API文档自动化: http://www.cnblogs.com/huligong1234/p/4707282.html Go 语言构建 RESTful Web 服务: https://www.oschina.net/transla 阅读全文
posted @ 2016-12-19 10:17 junneyang 阅读(3839) 评论(0) 推荐(0) 编辑
摘要:参考资料: Golang gRPC 示例: http://www.cnblogs.com/YaoDD/p/5504881.html grpc golang学习心得(1) 安装与测试: http://studygolang.com/articles/8274 golang中怎么处理socket长连接? 阅读全文
posted @ 2016-12-14 18:10 junneyang 阅读(447) 评论(0) 推荐(0) 编辑
摘要:参考资料: http://doc.oschina.net/grpc?t=60138 http://www.grpc.io/ https://thrift.apache.org/ https://git-wip-us.apache.org/repos/asf/thrift/?p=thrift.git; 阅读全文
posted @ 2016-12-05 15:41 junneyang 阅读(454) 评论(0) 推荐(0) 编辑