iPhone 使用 MAC 上的 Socks 代理
Step 1. Make sure the SOCKS tunnel on your work computer allows LAN connections so your iPhone/iPod Touch can connect to it.
$ ssh -N -g -D 1080 user@domain.com
Step 2. Create a text file and insert the following code:
function FindProxyForURL(url, host)
{
return "SOCKS 192.168.xx.xx:yyyy";
}
Replace the x’s with your IP and the y’s ...
Golang 的文件和目录
获取目录中的所有文件
io/ioutil
ioutil.ReadDir
// ReadDir reads the directory named by dirname and returns
// a list of directory entries sorted by filename.
func ReadDir(dirname string) ([]os.FileInfo, error) {
f, err := os.Open(dirname)
if err != nil {
return nil, err
}
list, err := f.Readdir(-1)
f.Close()
if err != nil {
return nil, err
}
...
Golang context 包
在 Go http 包的 Server 中,每一个请求在都有一个对应的goroutine去处理。请求处理函数通常会启动额外的goroutine用来访问后端服务,比如数据库和 RPC 服务。用来处理一个请求的goroutine通常需要访问一些与请求特定的数据,比如终端用户的身份认证信息、验证相关的 token、请求的截止时间。当一个请求被取消或超时时,所有用来处理该请求的goroutine都应该迅速退出,然后系统才能释放这些goroutine占用的资源,官方博客。
注意:go1.6及之前版本请使用golang.org/x/net/context。go1.7及之后已移到标准库context。
共计 238 篇文章,30 页。