Writing Testable Code in Go

I’ve had a hard time to wrap around the stub, mock in golang, but this blog post helped me immensely.

Link here to view the post

After reading it, my biggest issue was lack of my own interfaces in my program. Without my own interface, it was a big challenge to mock library defined interfaces; thus, making it quite hard to come up with tests.

After writing test, execute it like this:



Recently I got to know about RancherOS, which is an OS that provides pretty much only Docker host environment so that you can launch Docker containers.

My test environment is Mac OS Sierra with VMWare Fusion 8.5. What I did was as follows:

  1. Download ISO file for RancherOS
  2. Launch ISO via VMWare Fusion with 1GB ram and 10GB disk space (That’s normally what I use for linux distribution guest environment)
  3. Once I was on RancherOS terminal, I created cloud-config.yml file with ssh publick key in it. (Refer to the instruction)
  4. I made a note of IP address for the step #5
  5. After installing to the disk, I chose to reboot. From Mac terminal, I ssh’ed to the IP address of the RancherOS guest after RancherOS guest became available.

Pretty straightforward to install RancherOS on my mac.

RancherOS provides its own command line tool called ‘ros’ and this is the tool to configure the system, docker, etc.

Sync up Docker container time with Host’s

I’ve had some issues with my application’s user session being expired as soon as it got created. After further investigation, it was due to the fact that docker container’s time was far behind the current PDT(which is where I am and a default timezone for all my servers).

Easiest solution was to mount these two files from host to any containers:

After the two lines of docker volume, viola. Time synced between host and container.

Bye bye data-only container! Hello named volume!

Persistent data practice that I’ve been using with Docker has been the host volume although I knew that data-only container pattern existed.

So this time around, I was going to start utilizing data-only container pattern for some of db containers. However, I got to know that after docker version 1.9.0.

For example with data-only container pattern, we would have a docker-compose file like this:

However, a better approach would be:

New way of web application deployment: “Bakery” process

I have been quite interested in continuous deployment and working on ‘bakery’ process using OpenStack (which is another cloud environment comparable to AWS).

A traditional way of deployment is normally:

  • pull source code from source management on production env
  • create a tar file and then scp it & remote execute a script to untar
  • create a debian or rpm package, and then remote install it

They are ok ways, but main issue with them seems to be ability to keep multiple environment consistent and slow deployment processes.

Continue reading

Weekend Project – Backyard Makeover #1

I’ve been living in my place for little more than 3 years and have not done anything to my backyard except regular mowing and trimming some branches.

Now California weeds took over my grass and it got already out of my hand. Facing the backyard challenging, I’ve set a resolution for 2016 although it’s already past the new year: Backyard Makeover!

Without further due, this is the current state of my backyard.
Continue reading

merging two git repos with history

I needed to merge two repos with history so that the target repo has merging repo’s history. This answer at stackoverflow had solved my issue.

So that was to merge project-a into project-b.

One thing I need to note is that project-b and project-a have to be git-cloned already, so prerequisite for the above the order of execution was as follows:

Also, don’t forget to commit your changes after the merge.