On Reliable Persistence

2 July 2016

A short investigation on reliable persistence:

  • Crash consistency is hard but possible at a huge performance cost

  • Data safty must rely on distributed solution

  • Perhaps we should just give up manual fsync and rely on

    • OS background flush
    • corruption detection & correction at startup
    • replication

Note on OpenWRT

27 February 2016

Obtain OpenWRT

  • Find the device model at the Table of Hardware (Huawei HG556a C)
  • Open Device Techdata for Firmware OpenWrt Install URL
  • Open Device Page for Installation instructions

Computer - Cable - Router

Connect the computer to the router with a cable.

Install OpenWRT

Follow the instructions to install OpenWRT.


First login:


Change password to enable SSH:


For public key authentication, add the public key:

ssh-copy-id root@
ssh root@
mv ~/.ssh/authorized_keys /etc/dropbear


In /etc/config/wireless:

config wifi-device  radio0
	# option disabled 1

config wifi-iface
	option device     radio0
	option network    lan
	option mode       ap
	option encryption psk2
	option hidden     1
	option ssid       [SSID]
	option key        [WiFi password]
	option macaddr    [00:0A:4B:3C:6D:02]



Computer - WiFi - Router

Disconnect the cable to the router. Try SSH via WiFi.


In /etc/config/network:

It is better to change the lan address so that it will not be conflicted with the upstream address.

config interface 'lan'
	option ipaddr ''
# lan switch
config switch_vlan
	option device 	eth0
	option vlan 	1
	option ports 	"1 2 5t"

# wan switch
config switch_vlan
	option device 	eth0
	option vlan 	2
	option ports 	"0 5t"

For DHCP wan:

config interface wan
	option ifname eth0.2
	option proto  dhcp

For PPPOE wan:

config interface wan
	option ifname   eth0.2
	option proto    pppoe
	option username [PPPOE user name]
	option password [password]

Computer - WiFi - Router - Cable - Internet

Connect the internet cable to the router, reboot the router.

About Pretty Printing

1 February 2016


cat xxx.json | jq .


cat xxx.xml | xmllint --format -

Sending Email from Gmail using Go

31 January 2016
  1. Turn on “2-Step Verification” so that an “App password” can be generated

  2. go get gopkg.in/gomail.v2

  3. Send your Email like the example below:

package main

import (

func main() {
	m := gomail.NewMessage()
	m.SetHeader("From", "from_address@gmail.com")
	m.SetAddressHeader("To", "to_adress@xxx", "to_name")
	m.SetAddressHeader("Cc", "cc_adress@xxx", "cc_name")
	m.SetHeader("Subject", "Hello! TEST!")
	m.SetBody("text/html", "Hello! <b>TEST</b>!")

	d := gomail.NewPlainDialer("smtp.gmail.com", 587, "from_address@gmail.com", "the App password")

	if err := d.DialAndSend(m); err != nil {

SSH Resources in Go

31 January 2016
  • golang.org/x/crypto/ssh
  • github.com/YuriyNasretdinov/GoSSHa


RealTest: real test environment for Go

14 November 2015

h12.me/realtest provides real test environment for Go unit testing, based on Docker.


  • Queue
    • Kafka cluster (with zookeeper)
  • Database:
    • MySQL
    • MongoDB
  • Cache
    • Redis
  • Configuration service
    • ZooKeeper


Hǎiliàng Wáng


Aliyun OSS Go SDK

22 October 2015

Status Coverage
Status GoDoc

Aliyun OSS (Object Storage Service) Go SDK is a client SDK to access Aliyun OSS API, implemented in the Go programming language.


go get -u github.com/aliyun/aliyun-oss-go-sdk/oss
go test -v -cover github.com/aliyun/aliyun-oss-go-sdk/oss


  • Complete set of Aliyun OSS API
  • Thouroughly tested
    • 100% test coverage
    • intuitive table driven tests
    • full test suite completes within 2 seconds
  • Lint clean
    • golint
    • go fmt
    • goimports
    • go vet
    • race detector
  • Idiomatic & elegant
    • response is returned as a parsed object
    • error is returned as a Go error
    • named options for setting headers & parameters
  • Great extensibility
    • clean and orthogonal implementation
    • users can easily extend the SDK when a new API method is supported
  • No third party dependencies


Differences with Python SDK

  • HTTP header User-Agent, e.g. aliyun-sdk-go/0.1.1 (Linux/3.16.0-51-generic/x86_64;go1.5.1)
  • Go HTTP client does not support 100-Continue (will be supported after Go 1.6, see https://github.com/golang/go/issues/3665)
  • HTTP header keys are automatically converted into canonical format, e.g. x-oss-acl becomes X-Oss-Acl
  • Go GET request does not have redundant “Content-Length: 0” header
  • Parameters will be omitted if the argument is not set
  • Go always sends URL parameters and headers in canonical order


Hǎiliàng Wáng


licensed under the Apache License 2.0