All Articles

Using named return variables to capture panics in Go

Sometimes you can't help but call a function that might panic. Rather than letting it blow up your code, we learn how to use a deferred function and named return variables in order to capture the result as a standard Go error.

"I haven't needed X in 3 years" is a bad argument

In over a decade of driving, moving, and everything in between I have never needed a heavy duty truck like a Ford F-350, so clearly they aren’t useful and Ford should stop making them, right? Oh construction workers might complain, but they could just use dump trucks to haul their heavy loads. And farmers might have issues, but they have tractors which could suffice. So what is the big deal? Let’s stop making those trucks!

Building Caddy Server From Source

Caddy's licensing change makes it problematic for many bootstrapped projects. Learn to build Caddy from source which is still open source with no EULA.

Securing Cookies in Go

Learn how to properly secure cookies from tampering, theft, XSS, CSRF, and more in Go.

Using functional options instead of method chaining in Go

In Java, it is pretty common to see libraries that use method chaining (aka the builder pattern) to construct resources. For example, we might construct a user by doing something like: User user = new User.Builder() .name("Michael Scott") .email("michael@dundermifflin.com") .role("manager") .nickname("Best Boss") .build(); Builders are handy for a variety of reasons, but in the example above we are using a builder in order to define a subset of our User attributes before constructing the user object.

Subtle issues with ORMs and how to avoid them

One of the most common change requests I get with my Web Development course is to stop using GORM, and instead use the database/sql package that is part of Go’s standard library. When I receive feedback like this I often respond asking, “Why?” Why do they feel the database/sql package would be better suited for their education? Why do they feel ORMs will be problematic long term? I don’t ask these questions to be snarky or because I don’t care; I ask because I truly want to understand a problem before I look for solutions, and oftentimes people will tell you their problem is X, when in reality X is only a symptom of a deeper problem.

Avatar of Jon Calhoun
Articles and Tutorials by
Jon Calhoun

Jon Calhoun is a full stack web developer who also teaches about Go, web development, algorithms, and anything programming related. He also consults for other companies who have development needs. (If you need some development work done, get in touch!)

Jon is a co-founder of EasyPost, a shipping API that many fortune 500 companies use to power their shipping infrastructure, and prior to founding EasyPost he worked at google as a software engineer.

Jon's latest progress update: Writing Course Notes

Recent Articles All Articles Mini-Series Progress Updates Tags About Me Go Courses

©2018 Jonathan Calhoun. All rights reserved.

Want to build a web server in Go?

Subscribe to my mailing list and I'll send you over a sample from Web Development with Go where we build an http server from scratch. No more guessing how everything works - you will get hands on experience setting everything up.

    I won't send you spam. Unsubscribe at any time.