使用二进制形式发布go package

我们在使用Go进行开发的时候, 经常会使用到第三方的库, 这时候我们一般都会通过go get到github.com、bitbucket或者自己私有库中去拉取第三库的源代码。 今天正好群里有网友问能不能将自己开发的库以二进制形式提供给用户,我就顺便整理了一下。

以二进制方式提供库的动机可能是为了保护自己公司的知识产权,也有可能是从安全的角度考虑,避免一些关键信息的泄漏等等,这不是本文讨论的范围。

阅读全文

[转]编写高性能的Go代码的最佳实践

原文: go-perfbook/performance

This document outlines best practices for writing high-performance Go code.

At the moment, it's a collection of links to videos, slides, and blog posts
("awesome-go-performance"), but I would like this to evolve into a longer book
format where the content is here instead of external. The links should be sorted into categories.

All the content will be licensed under CC-BY-SA.

阅读全文

年终盘点!2017年超有价值的Golang文章

马上就要进入2018年了,作为年终的盘点,本文列出了一些2017年的关于Go编程的一些文章,并加上简短的介绍。

文章排名不分先后, 文章也不一定完全按照日期来排列。我按照文章的大致内容分了类,便于查找。

文章主要从golangweekly、gocn每日新闻、medium、reddit、twitter、、知名博主的文章搜集而来。如果你发现好的2017年的Go文章没有列出来,欢迎在评论中粘帖出来,我会加入到文章正文中。

本文主要列出的是文章,2017年也涌现出来很多优秀的库和工具,但是不是本文要介绍的内容,所以没有列出来。

阅读全文

Go语言中实现基于 event-loop 网络处理

我们知道, Go语言为并发编程提供了简洁的编程方式, 你可以以"同步"的编程风格来并发执行代码, 比如使用go关键字新开一个goroutine。 对于网络编程,Go标准库和运行时内部采用 epoll/kqueue/IoCompletionPort来实现基于 event-loop的网络异步处理,但是通过netpoll的方式对外提供同步的访问。具体代码可以参考 runtime/netpollnetinternal/poll

Package poll supports non-blocking I/O on file descriptors with polling.
This supports I/O operations that block only a goroutine, not a thread.
This is used by the net and os packages.
It uses a poller built into the runtime, with support from the
runtime scheduler.

当然,我们平常不会设计到这些封装的细节,正常使用net包就很方便的开发网络程序了, 但是,如果我们想自己实现基于epollevent-loop网络程序呢?

阅读全文