Tag Golang

2013

Opera Mini Server Mirror with Golang

再一次,由于不想在服务器上安装php,决定自己用Go语言写一个Opera Mini的代理服务器,也算是练手吧~项目地址在https://github.com/chon219/opm-server-golang 编译 & 运行 go build server.go ./server & 设置iptables作为socket代理 iptables -t nat -A PREROUTING -p tcp -m tcp --dport 9003 -j DNAT --to-destination 141.0.11.253:1080 iptables -t nat -A …

#Golang#opera

Golang时间格式化

最近用Go语言写程序用到了time包,需要将时间以2012-01-27 22:02:02的格式输出,但是Time对象(准确来说不是对象,而是struct)的Format方法并没有提供默认满足要求的layout string,需要自己来填写。 以前写Python时,对时间的格式化是采用"%Y-%m-%d %H:%M:%S"这样的layout string: datetime.now().strftime("%Y-%m-%d %H:%M:%S") 而Go语言的方式则略显奇葩,采用的是"2006-01-02 15:04:05"这样的layout string: time.Now().Format("2006-01-02 15:04:05") 从源码(http://golang.org/src/pkg/time/format.go [line 59])可以看出,2006代表年份,01代表月份...于是我一直很好奇,2006年1月2日这一天的15点04分05秒到底发生了什么?

#Golang