1

Go 初体验

 1 year ago
source link: https://fann.im/blog/2015/02/04/golang/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Go 初体验

Feb 4, 2015

用 Go 写了第一个线上服务,简单记录一些。

  1. 直接 net/http,没有用 Web 框架。之前用过 Beego,强大但过于黑盒,很多细节不理解,其实 Go 已经提供了 web 开发所需要的东西,这个服务只需对外 API,没有页面等,直接 net/http 反而更简单。
  2. 强制代码风格,大爱,包括定义但不使用直接报错,刚开始会有不适应,但是对整体代码质量很有帮助。
  3. database/sql 提供了统一的数据库操作接口,配上不同的 driver 即可。
  4. Golang 的 error handlling 是个特色,但作为 web service 有些繁琐,需要再学习看有没有更为简洁的处理方式。
  5. 无痛热更新比较麻烦,还没有找到类似 Nginx 的实现。
  6. 性能上简单的 ab 压测和 ngx_lua 差距不大,开发效率相对高一些,毕竟自带库更丰富。
  7. gin 可以监控代码变化并自动重新编译,代理方式,不错的开发辅助工具。

Was this page helpful?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK