A Comprehensive Note about Proxy Settings

Git > cat ~/.gitconfig [http] proxy = socks5://[host]:[port] [https] proxy = socks5://[host]:[port] Curl (Homebrew) > cat ~/.curlrc socks5 = "[host]:[port]" Docker pull env HTTP_PROXY=http://xxx docker pull yyy GAE Set proxy export HTTP_PROXY http://[host]:[port] export HTTPS_PROXY http://[host]:[port] Delete cacerts.txt under GAE SDK installation to disable SSL verification ( make sure the proxy is safe before this step). Deploy. appcfg.py . --email=[address] --passin

July 8, 2015

Notes on the Design of Go

Refusing new features Avoid leaky abstraction as much as possible. If an abstraction is not solid enough, you’d rather not use them at all. Go is designed like this, the features are carefully selected. If a feature is not solid enough, it will not be allowed to enter Go. No implicit string concatenation Rob: That used to be in the language but was dropped when the semicolon insertion rules went in. You need the + to be able to span lines, and if you can’t span lines operatorless concatenation is close to pointless. ...

June 29, 2015

What Go cannot Do

This is a list about the corner cases that Go cannot do, and their work arounds. Run all deferred functions of other goroutines when a goroutine panics Uncaught panicking of one goroutine will exit the program without executing deferred functions of other goroutines. Workaround: this is the standard behavior, C++ with RAII also has the same problem. Persist your data in a way that crashing will not cause data integrity issue. ...

June 16, 2015

Schemata: database scheme extractor & code generator in Go

Database scheme extractor & code generator in Go. Supported database: MySQL SQLite

May 19, 2015

How to "go get" Behind a Proxy

Proxy for “go get” https_proxy=http://user:pass@proxy_host:port go get ... Proxy for Git In $HOME/.gitconfig: [https] proxy = proxy_url Proxy for Mercurial In $HOME/.hgrc: [http_proxy] host = host:port user = ... passwd = ...

May 6, 2015

Go 1.4.1 Build Failure and Solution

Today I tried to build Go 1.4.1 from source but it failed with this error: go/src/liblink/anames9.c:6:29: fatal error: ../cmd/9l/9.out.h: No such file or directory At first I thought the building routine might have be changed so I opened and read Installing Go from Source again, carefully, and found nothing special. Then I searched for the error source and it turned out that I should deleted anames*.c, manually. There is no document and no automatic cleaning script, and you would have to figure it out yourself if no one ever mentioned it (source). ...

January 29, 2015

A Shorter Domain Name

This year, I decided not to renewal the previous domain name (hailiang.ws) last year, but to register a shorter one. There are two reasons: Both the site URL and the email address will be cleaner. A more friendly Go import path will be possible for my repositories on Github. After comparing various choices on major domain providers, I chose h12.io as the new domain. It is the shortest but still meaningful domain that I can afford. H is the initial letter of my given name, 12 is simply the number of letters of my full name, and .me is a top level domain quite suitable for a personal website. ...

December 16, 2014

Gombi: Creating Your Own Parser is Easier than Regular Expressions

Gombi is a combinator-style scanner & parser library written in Go. It is practical, reasonably fast and extremely easy to use. Quick start go get -u h12.io/gombi Design Combinator parsers are straightforward to construct, modular and easily maintainable, compared to parser generators like Lex/Yacc. Internal DSL no additional code generation and compilation. Composable a subset of the syntax tree is also a parser. a language can be easily embedded into another one. Gombi is inspired by but not limited to parser combinators. Unlike a combinator parser, Gombi neither limits its API to functional only, nor limits its implementation to functional combinators. Go is not a pure functional language as Haskell, so cloning a combinator parser like Parsec to Go will only lead to an implementaion much worse than Parsec. Instead, Gombi is free to choose any Go language structures that are suitable for a modular and convenient API, and any algorithms that can be efficiently implemented in Go. ...

August 7, 2014

About 301 Moved Permanently

When building a website, there is one inevitable thing: 301 permanent redirection. The cases that have to involve 301 includes: Redirection from www subdomain to naked domain or vise versa. Redirection from slashed pretty URL to unslashed URL or vise versa. 301 is easy to implement with Go: func redirect301(w http.ResponseWriter, url string) { w.Header().Set("Location", url) w.WriteHeader(http.StatusMovedPermanently) } There is one more thing that needs attention: The root path of a domain always contains a slash (GET / in HTTP request), regardless the user enters the slash or not, so the root path needs no redirection. ...

July 25, 2014

Serving Static Pages on App Engine with Go

It is straightforward to serve static pages with Go or config file on App Engine, but how to serve static pages on App Engine with Go? I got the following error when I tried to customize the 404 page with Go: No such file or directory The solution turns out to be simple: do not do both. The file will not be accessible to Go if there is already a rule for it in config.yaml. Remove the rule from config.yaml and the file will be available to Go again (source: google-appengine-go). ...

July 6, 2014