用Go语言写一个简单的Gitweb Server

Git的发行版中带了一个叫gitweb的工具,可以以web的方式来查看git仓库。但是gitweb本身是一个CGI脚本,需要一个支持CGI的Web服务器来运行它。这篇文章介绍如何用Go语言写一个简单的服务器,用来运行gitweb。 ...

March 7, 2018

看Python和Go语言对Unicode的支持

Unicode是一个支持世界上绝大多数语言的字符系统。支持Unicode的编程语言更容易实现全球化(internationalization)和进行本地化(localization)。那么支持Unicode需要编程语言具有什么样的特性呢,让我们来以Python 3和Go语言为例子做个探究。 ...

December 9, 2017

LZW压缩算法Go语言简易实现

Catfish3在Cpluscplus网站上写了一篇文章,如何用C++来实现Lempel-Ziv-Welch压缩算法。于是照猫画虎,用Go实现了一个简易的版本,只是确保了功能而且,没有考虑如何变得更好更优雅。 其实Go的runtime包含了一个更加成熟的LZW算法包"compress/lzw",采用了变长Code Bits。跟"compress/lzw"相比,下面的实现采用了16位定长的Code Bits,所以有可能压缩结果比源文件体积更大-_-‘。 ...

December 30, 2015

The Secret of Converting byte to string in Go

First let’s consider how to convert a byte to a string? Simple, the language specificationtells us, just do it like string(the_byte). But there is a secret here, see the following code: Guess what you get? The result is: Suprizing, huh! The result for 0x80 is c280! If you change the modifier in fmt from %x to %q, you can see more clearly: When converting a byte to a string using string(the_byte), the result is an encoded one....

December 24, 2015