/dev/jcheng
  • About
  • Articles
  • Pages
  • Reviews
  • Tags
GitHub

Articles

February 14, 2020

Mocking in Go

Today I want to talk a little about the testify and gomock packages and doing mocks in Go.

Mocking is essential when writing code that depends on external services, e.g., microservices, message brokers, and datastores. For many people, this means web applications: My system has business rules and talks to multiple services. How do I test the business rules without setting up all the services locally?

Some people argue that mocks create a false sense of test coverage and introduce blind spots. I think that’s partially true but also too simplistic. In many cases, engineers gain sufficient value from testing “glue code” to make mocking worthwhile. This follows the principle of don’t let perfect be the enemy of good.

read more
February 8, 2020

Why I like Go

I have a few side projects, published and unpublished. By trade, I’ve come to programming as a Java programmer. I started coding directly against the Servlet API and have coded using Enterprise Java Beans, Play Framework, Spring Framework, and even some Scala. Lately, I’ve been coding mainly in Go with some Python.

Go is a really nice programming language. Some people like it for its simplicity. I want to offer a different take on why you should learn and use Go for your own projects.

read more
February 7, 2020

Delegation

One thing about job hopping is that you get to experience new perspectives on how people work. It forces you to reconsider what’s obvious. Take delegation for example. I used to think anyone with a bit of experience can do it effectively. It’s just about decomposing a system and assigning components to different people, right? It turns out effective delegation is much more nuanced.

Situational Leadership

Situation Leadership is a model that ascribes different delegation styles based on the competency (skill) and commitment (motivation) of each team member. Assuming motivation is not a factor, skill is the sole determinant on how much you should direct an engineer. A highly competent engineer requires very little direction. An inexperienced engineer requires specific and concrete directions.

read more
January 4, 2020

Viper Examples

Viper is a configuration library fo Go. It has been my go to library for configs. Some of the best features of Viper are:

  • Ability to unmarshal subsets of a configuration file into a Go struct
  • Ability to override contents of a configuration file using OS environment variables

Here’s a brief example that demonstrates both features:

Assume you have a configuration file at $HOME/server.toml

resolve_dns = true
http_keep_alive = 5

[example_com]
doc_root = "/var/www/example_com"
allow_files = "*.html"
login_required = true
login_lockout_count = 3

[example_org]
doc_root = "/var/www/example_org"
allow_files = "*.html, *.jpg"
login_required = false
login_lockout_count = 5

Then you can utilize the configuration file using this snippet:

read more
November 29, 2019

Go1 13 Errors

For me, Go 1.13 arrived with anticipation of better error handling. Presently, the second Google search result for Go 1.13 error hanlding is an article that refers to the “xerrors” package. One feature of the xerrors package is that it produced errors with a stack trace showing where the error came from. The addition to Go 1.13, however, did not include this particular feature, and left me spending frustrating hours trying to debug the loss of stack trace after switching from xerrors to the standard library.

read more
September 3, 2019

Why We Code Review

Code review can be an important part of a team’s culture, so it is worth thinking about. If you asked me about code review two years ago, I would’ve said its key to maintaining code quality and mentoring less experienced programmers. Now I know better. Code review is much about making the code better as it is about making the team happier. How the team runs code reviews should be based on the team’s values and culture.

read more
August 22, 2019

Interview Questions

Good technical interview questions are hard to find. In the last month, I’ve seen some really great ones and equally bad ones. I want to go through some of them and write down my highly biased 5-star rating on their effectiveness.

First, for some context on how I evaluate interview questions. Your interview questions should be:

  • Respectful of the candidates

  • Objective and evaluated consistently

  • Gathers relevant and insightful data

When it comes to data gathering, I’ve seen teams make two kinds of mistakes. The first mistake is coverage: The entire interview panel asks the same type of questions, with little coordination. The second mistake is that the interviewer interprets the results subjectively; They don’t have an objective and consistent way of evaluating answers and often rely on intuition to make a decision.

read more
August 19, 2019

Own Your Data

I previously wrote about owning my own data. An important part of data ownership is backing up your data. I use S3 as my long term data store. It is pretty easy to set this up using Terraform.

S3

Provisioning a S3 bucket is simply a single Terraform resource:

resource "aws_s3_bucket" "repo_archive_log" {
  acl = "log-delivery-write"
  bucket = "example-bucket"
  tags = {
    Name = "example"
    TTL = "persistent"
    ManagedBy = "Terraform"
  }
}
read more
August 11, 2019

Another year, another blog

A little more than a year ago, I moved my blog from Blogger to Medium. Medium, as a blogging platform, was always meant to be temporary. It is platform with a modern look. It is a free service. One does not need to worry about domain registration, uptime, security patches(!), or a host of little things that adds up. The price is, however, to give up control of your content.

Control is a high price. I will turn forty-one this year and memories seem strikingly precious. Control, for me, isn’t simply about monetization - I care little about that. Nor do I care much about appearance and layout. I just need occassional code snippets and images. Control means agency over how my writings are backed up and programmatically processing my contents.

read more
  • ««
  • «
  • 4
  • 5
  • 6
  • 7
  • 8
  • »
  • »»
© /dev/jcheng 2026
GitHub