Jon Calhoun Profile Banner
Jon Calhoun Profile
Jon Calhoun

@joncalhoun

Followers
9,875
Following
401
Media
458
Statuses
6,128

Panelist on @GoTimeFM • Teaching #golang • Want to learn Go with fun exercises? Try and

Pennsylvania, USA
Joined May 2008
Don't wanna be here? Send us removal request.
Explore trending content on Musk Viewer
@joncalhoun
Jon Calhoun
5 years
After 16 months of fostering my wife and I have officially adopted Danielle!  The journey here was challenging at times, but it was oh so worth it. Now I get to call her my sweet little daughter 🥰😍 Oh and I can finally share pictures of her!
Tweet media one
Tweet media two
Tweet media three
40
4
572
@joncalhoun
Jon Calhoun
4 years
Writing #golang code that needs closed (eg a DB connection)? Try returning the close function so it is harder for developers to forget.
Tweet media one
9
86
471
@joncalhoun
Jon Calhoun
5 years
🎉 I just released 🎉 Want to learn how algorithms and data structures work? Struggle with coding algorithms? Just want some fun coding problems while learning #golang ? Check the course out! And it is FREE! Yep, you heard me right. No💰 req for this one
7
111
297
@joncalhoun
Jon Calhoun
4 years
You don't need to manually add struct tags to your #golang types. Almost all editors support some fort of struct tag generation, which is really handy. Multiselect can also do the trick if you are familiar with it.
14
52
271
@joncalhoun
Jon Calhoun
3 years
If you use SQL and Go, how do you handle database migrations for your app? When do they run during a deploy, how are they rolled back, what tools, etc? I still don't think I've seen anything as smooth as Rails was in a Go app. Figured I'd explore options again.
38
31
257
@joncalhoun
Jon Calhoun
2 years
Does anyone have recommendations for beginner-friendly open source projects written in #golang that are accepting new contributors?
27
42
220
@joncalhoun
Jon Calhoun
3 years
It has been a long, but good weekend.
Tweet media one
24
1
219
@joncalhoun
Jon Calhoun
2 years
In 2022, I did this weird little experiment where I redesigned the net/http Handler in #golang . Rather than having a ServeHTTP(w, r) method, I instead broke it into two parts - a handler, and a responder that is returned from the handler. 🧵👇
Tweet media one
4
16
162
@joncalhoun
Jon Calhoun
2 years
My #golang courses are on sale until Oct 5. - Web Dev w/ Go () - Test w/ Go () My free courses are still free 🤪 - - If you know someone learning Go, please let them know. Thanks!
3
45
154
@joncalhoun
Jon Calhoun
3 years
Before #golang , I used to hate TDD. It just never worked for me. I doubt I practiced it perfectly, but it was hard to get into something that just didn't work for me. I still don't use it all the time - maybe 50% - but when I do Go somehow makes it so much more enjoyable.
7
11
140
@joncalhoun
Jon Calhoun
2 years
#golang Generics make supporting useful zero values a bit simpler by giving us a way to quickly and easily determine what value to use - a default, or a provided value. In the ex below, the Thing field can be set, or it can be left as the zero value and it will still work.
Tweet media one
6
19
134
@joncalhoun
Jon Calhoun
6 years
I finally released a mega-article on #golang code design, web apps, JSON APIs, and more (seriously, its like 40 pages 😱) that I've been writing for some time. Feedback & sharing are both appreciated!
5
50
132
@joncalhoun
Jon Calhoun
7 years
Use functional options to replace method chaining and the "builder pattern" in Go. #golang
Tweet media one
5
45
123
@joncalhoun
Jon Calhoun
4 years
Dependency injection sounds scary complicated, but in Go it is usually as simple as using an interface as a function argument (or struct field) instead of a specific type. Don't let your experience in other languages worry you! 😁
5
17
122
@joncalhoun
Jon Calhoun
4 years
New in #golang 1.14 - testing.T's Cleanup() method. Now any helper funcs can accept testing.T and handle both setup and cleanup. One example of this is when working with a test database, but really any functions designed to setup test resources could benefit from this.
Tweet media one
2
28
102
@joncalhoun
Jon Calhoun
4 years
@raagagrawal Is there a big dodgeball tournament coming up?
1
3
87
@joncalhoun
Jon Calhoun
7 years
Exercises 1, 2, & 3 are live! Create a quiz game, url shortener, and a choose your own adventure book in #golang
1
41
96
@joncalhoun
Jon Calhoun
3 years
I suppose now is as good a time as any to share the news. My wife and I will be adopting a baby boy who is due in early May. The backstory is kinda crazy, and I need to go back in time to when we adopted our first daughter for it all to make sense, but I'll share what I can. 🧵👇
13
0
97
@joncalhoun
Jon Calhoun
4 years
This article is spot on. Errors in #golang feel painful b/c devs want to ignore errors. Go forces devs to acknowledge that something may go wrong and to code for it. Annoying at first, but I guarantee my Go code has better error handling as a result.
7
31
91
@joncalhoun
Jon Calhoun
2 years
If you are confused about whether to use a pointer receiver or not in #golang , try asking, "Is there a good reason NOT to use a pointer receiver?" instead of "Should I use a pointer receiver?"
8
15
95
@joncalhoun
Jon Calhoun
4 years
I may need to update my testing course soon! Go 1.14 added Cleanup, and now Go 1.15 looks to be adding TempDir! With TempDir you can easily access a temporary directory for files used during testing. Best part? These are all cleaned up (deleted) for you automatically! #golang
Tweet media one
1
17
89
@joncalhoun
Jon Calhoun
4 years
Fun fact: #golang has a zip package that can be used to create compressed zip files. This can be handy when you need to programmatically select files to move to a USB stick, upload to a server, or create a download for a user. Working example at
Tweet media one
7
15
87
@joncalhoun
Jon Calhoun
4 years
If you are using interfaces in your #golang code, consider writing tests that accept any implementation of the interface. This helps sanity check all future implementations while also making sure you don't rely on poorly documented behavior.
Tweet media one
4
11
87
@joncalhoun
Jon Calhoun
4 years
I love this screenshot from the codebase. It just shows a bunch of #golang files all in a single package, yet the entire codebase still felt incredibly easy to understand and navigate.
Tweet media one
5
13
86
@joncalhoun
Jon Calhoun
1 year
My #golang courses are on sale until Jun 23. - Web Dev w/ Go () - Test w/ Go () If you know someone learning Go who would benefit from one of the courses, please let them know! Thanks! 😁
4
24
86
@joncalhoun
Jon Calhoun
5 years
Moving Towards Domain Driven Design in Go #golang This one took a while because it kept growing and evolving. I eventually had to accept that it needed broken into a few posts, and this one still ended up being huge.
2
23
84
@joncalhoun
Jon Calhoun
2 years
Quick tip: If you record videos, share your screen, give talks, etc, create a second set of settings for VS Code (or whatever editor) that increases font size, etc. Then comment out the settings you don't want at any given time.
Tweet media one
5
13
88
@joncalhoun
Jon Calhoun
4 years
Using a run function makes #golang main packages much easier to test. #vscode default snippets don't do this, so I suggest creating a new one. VSCode Snippet: More on run func: by @matryer
1
10
83
@joncalhoun
Jon Calhoun
4 years
It can help me to think about concurrency as an assembly line. Each worker (goroutine) does a task, then sends the result along the assembly line (channel). #golang
Tweet media one
5
17
84
@joncalhoun
Jon Calhoun
3 years
What resources do you recommend to people looking for #golang jobs?
17
12
82
@joncalhoun
Jon Calhoun
7 months
My #golang courses are on sale until April 5th. You should check them out! Web Development with Go - Test with Go -
5
18
84
@joncalhoun
Jon Calhoun
5 years
If you already have an account at you should see this now. Clicking the button will add it to your account. If you don't have an account yet, go to and sign up. I'll get the landing page + signup form for Algo w/ Go working tomorrow
Tweet media one
5
15
82
@joncalhoun
Jon Calhoun
2 years
has had over 100,000 signups since it was created. That's pretty freaking cool to see. Thanks everyone for checking it out! #golang
0
11
82
@joncalhoun
Jon Calhoun
5 years
I sat down this evening to re-record the sorting algorithm videos I released earlier, and wow. Already feeling 10x better about them. Pumped to get these released. And there are benchmarks now! #golang #Algorithms
3
19
77
@joncalhoun
Jon Calhoun
2 years
What are some topics you want to learn more about in Go?
41
4
75
@joncalhoun
Jon Calhoun
1 year
If you want to be a full stack developer, you have to accept that you can't master every technology you will be using. Nobody can master frontend and backend and docker and a dozen others, but you can learn each well enough to be productive across the whole stack.
5
6
73
@joncalhoun
Jon Calhoun
4 years
Gotcha day is a good day 🥰
@joncalhoun
Jon Calhoun
5 years
After 16 months of fostering my wife and I have officially adopted Danielle!  The journey here was challenging at times, but it was oh so worth it. Now I get to call her my sweet little daughter 🥰😍 Oh and I can finally share pictures of her!
Tweet media one
Tweet media two
Tweet media three
40
4
572
0
0
74
@joncalhoun
Jon Calhoun
4 years
The, "you don't need a CS degree" argument is crazy misleading. It is true that you don't need a degree, but you better be ready to bust your ass and hope the stars align along the way. A thread... /1
12
10
73
@joncalhoun
Jon Calhoun
4 years
The builder pattern makes it really hard to return errors during a build step. Consider using functional options instead, which work much better with incremental errors. #golang
Tweet media one
3
16
68
@joncalhoun
Jon Calhoun
4 years
Using JWTs in your #golang code? I would strongly suggest you add a test to verify the "none" signing method won't be accepted. This is a huge vulnerability that many people miss, and it is pretty quick to test.
Tweet media one
3
8
64
@joncalhoun
Jon Calhoun
4 years
My #golang courses Black Friday sale is live! 50% off any course or package. Web Dev w/ Go - Test w/ Go - I only offer this discount once a year & it is a big part of my income, so all purchases & shares are appreciated 😁
1
28
62
@joncalhoun
Jon Calhoun
5 years
Did you know that you can call methods directly from the type in #golang ? type Person struct { Name string } func (p Person) Greet() { fmt.Println("Hi, my name is", ) } func main() { p := Person{"Jon"} Person.Greet(p) }
6
15
64
@joncalhoun
Jon Calhoun
4 years
When inserting records into a Postgres DB using Go's database/sql package, remember that the Result type's LastInsertId method isn't supported by most drivers. Instead, you need to write a query that returns the newly created record's ID and scan for it. #golang #postgres #sql
Tweet media one
1
10
61
@joncalhoun
Jon Calhoun
5 years
What OS projects would you recommend to beginner Go devs who want to participate in #hacktoberfest ? #golang
6
11
58
@joncalhoun
Jon Calhoun
7 months
My "Build a Blog with #golang " exercise series just keeps growing, but it is fun so I'm not complaining! The next article walks through parsing metadata via frontmatter in preparation for showing a list of all blog posts. Check it out at
1
14
62
@joncalhoun
Jon Calhoun
2 years
I want to see if I can create a #gotime episode discussing how people are using #golang generics. To do this I need your help. Send me examples of generics in Go you have found useful. Could be something like options, a filter func, or whatever else.
14
6
63
@joncalhoun
Jon Calhoun
4 years
Does it mean I've made it if my paid courses are being torrented? 🤔
8
1
59
@joncalhoun
Jon Calhoun
4 years
When learning to code, it is important to realize that you can't just skip to the end. You can't write the code you will in five years without those five years of knowledge. There are ways to speed up the learning process, but you can't skip it entirely.
3
7
61
@joncalhoun
Jon Calhoun
1 year
The last #golang email I sent to my mailing list went to over 40k subscribers and had an open rate over 50%! So pumped that people find these emails worth reading! 😃 If you missed it, it was a crash course on Go's generics.
4
8
60
@joncalhoun
Jon Calhoun
3 years
I'm planning to offer a new years sale on my courses for anyone who wants to make a resolution to learn Go. Super late to announce this. Dec has been brutal. I even have course updates I did a week ago that I haven't released yet :(
5
9
59
@joncalhoun
Jon Calhoun
5 years
@rakyll Just do development on the production server! 🤣 (please don't do this)
5
0
61
@joncalhoun
Jon Calhoun
4 years
New to #golang ? There are many ways to declare variables. A good rule of thumb is to use the var keyword when you plan to assign a value later and := otherwise. This way your intent is clearly expressed. Just remember there may be exceptions.
Tweet media one
1
7
57
@joncalhoun
Jon Calhoun
5 years
It is possible to transition into a tech career without a CS degree, but I think far too many people underestimate the amount of work it takes. If it only took 3 months of coding 1 hour a day to land a job at Google their acceptance rate wouldn't be 0.2% 1/5
4
9
60
@joncalhoun
Jon Calhoun
5 years
Maybe Monday? It is way too nice out this weekend to spend it finishing this design. Sorry folks. 🚵‍♂️
Tweet media one
5
2
57
@joncalhoun
Jon Calhoun
6 years
I know I haven't released anything in a while but I am busy making my free algorithms course while also working on a new site and outlining some ideas for an advanced #golang web dev course. It just may take some time until you see the results of all the work.
3
2
55
@joncalhoun
Jon Calhoun
2 years
What are you using for #golang worker queues? Eg something like Sidekiq in Rails. Message queues (like rabbitmq)? Third party libs (like asynq)? Custom code to manage it all? Something else?
27
4
54
@joncalhoun
Jon Calhoun
4 years
When using #golang pkgs like database/sql or image we import the _ packages for side effects caused by their init functions (see image below). If writing a new lib, just have the user call Register themselves and provide them with a driver; it is much clearer what is happening.
Tweet media one
4
5
55
@joncalhoun
Jon Calhoun
5 years
More photos from today 😃 💚
Tweet media one
Tweet media two
Tweet media three
Tweet media four
0
0
54
@joncalhoun
Jon Calhoun
4 years
Use io.MultiWriter when you need to write to two sources at once. This can happen when you want to capture what is being written without changing the behavior of existing code. I find this especially useful when running commands via the exec package. #golang
Tweet media one
2
13
54
@joncalhoun
Jon Calhoun
6 years
Thank you for all of your support over the last week! It is still crazy to me that I have been able to help so many people 🤯  After taking some time to recover I'll be pushing more testing content and then starting on a new FREE course. I'm thinking algorithms in #golang
10
4
56
@joncalhoun
Jon Calhoun
6 years
I'm super late to announce this, but now has well over 10k students. In fact, it is very nearly 11k now 😱 Thanks everyone for checking out the #golang exercises and all the awesome feedback. I'm humbled to have helped so many ppl practice & learn Go!
2
8
55
@joncalhoun
Jon Calhoun
4 years
The := syntax in #golang is great, but it can lead to variable shadowing unknowingly. Eg if you declare an error variable in the main block, but use := with multiple variables in a block, the err variable will be shadowed.
Tweet media one
7
6
54
@joncalhoun
Jon Calhoun
7 months
Next up in my Build a Blog with #golang series - rendering markdown as HTML. Read it here: I'm looking forward to some of the content in the next few parts of the series, like adding support for custom markdown & reading files from GitHub.
0
5
55
@joncalhoun
Jon Calhoun
3 years
Happy new year everyone! 2021 was a tough one for me, but here is to hoping 2022 is better. Goals for the year: - Finish updating web dev w/ go - Release a new course in the works - Expand/update my free courses - More beginner-oriented content - More YouTube content
1
0
54
@joncalhoun
Jon Calhoun
4 years
Interface chaining is crazy powerful when combined with simple interfaces like io.Writer in #golang . Take this example from oto () which adds gzip support without needing to change any additional logic in the function.
Tweet media one
2
8
52
@joncalhoun
Jon Calhoun
4 years
Need to write a custom json decoding logic in #golang ? One way to do this is the UnmarshalJSON method, which implements the json.Unmarshaler interface () What is even neater - you can still leverage the json package to do the heavy lifting for you.
Tweet media one
1
7
51
@joncalhoun
Jon Calhoun
4 years
Did you know that #golang supports receive-only and send-only channels? These are useful when defining a func that only needs to perform one type of operation as it can prevent developers mistakes.
Tweet media one
1
12
53
@joncalhoun
Jon Calhoun
7 years
Exercise 7 which demonstrates how to build a CLI task manager in Go is now live - 💥💥💥 #golang screencast videos are about 1hr 30m in total and cover: - Building a CLI with spf13/cobra - Working with BoltDB - Using "go install"
0
16
52
@joncalhoun
Jon Calhoun
7 years
I built a thing → I'm trying to create tools to make debugging common errors in #golang easier. Errors in Go is my first attempt at a "database" of common errors and fixes. PRs and issues w/ suggested errors are encouraged!
2
26
52
@joncalhoun
Jon Calhoun
4 years
I've entered that stage of my development career where I am ready to become a mountain man isolated in the woods. Is there a term for this?
16
1
50
@joncalhoun
Jon Calhoun
7 years
Getting ready to start releasing videos for a new (and FREE!) course - . Super excited to share it soon! #golang #go
1
23
50
@joncalhoun
Jon Calhoun
4 years
Celebrating 8yrs of marriage with my wife today. 🥳 I won't be responding to emails today. That probably deserves a celebration emoji too.
1
0
49
@joncalhoun
Jon Calhoun
4 years
I spent 6 hours trying to get something working only to lay down for bed and immediately think of a solution. Some days you just need to step away for a bit.
3
0
49
@joncalhoun
Jon Calhoun
4 years
If you use #golang 's standard library for your http servers (pretty much all third party libs also do this), all incoming web requests will already be running in a goroutine before they touch your handlers.
5
7
49
@joncalhoun
Jon Calhoun
5 years
Historically I have limited my blog () to mostly #golang articles, but I do a lot more than write Go code. Would anyone be interested in me writing other aspects of my life? Eg I could write about working #remote in a small town.
7
2
48
@joncalhoun
Jon Calhoun
4 years
I've been using databases for quite some time, but I feel like @rakyll 's experience makes me look like a toddler who has been playing with blocks while she has been building spaceships 😂 Should be a good episode. I hope to learn a lot! 😁
@GoTimeFM
Go Time ⏰
4 years
Today at 3pm ET we will be recording an episode about #databases ! Tune in to hear @rakyll educate other panelists ( @matryer and @joncalhoun ) on the downsides to AUTOINCREMENTing, how to successfully perform live migrations, and more. #golang
Tweet media one
1
7
34
1
6
47
@joncalhoun
Jon Calhoun
3 years
I should release a new course named "What you need to know about generics while learning Go" and then leave the entire course blank. 🤣
3
3
47
@joncalhoun
Jon Calhoun
6 years
( #golang programming exercises) is nearing 20k signups, and I am oh so close to 2k followers on Twitter. I need to do something to celebrate. Maybe a free mini-course? Or in the near term, perhaps a sale on my premium courses? Ideas?
7
12
48
@joncalhoun
Jon Calhoun
4 years
Getting started in tech is 100x easier with a fun project. What was the first thing that sucked you into programming and made it fun? How about #golang - what was the first thing you worked on that made it hard to walk away from the computer?
22
4
48
@joncalhoun
Jon Calhoun
3 years
You can learn to paint in a few minutes, but becoming an artist takes a lifetime. Becoming a programmer is similar. You can learn to code hello world in an hour, but you can also spend the rest of your life learning and improving.
1
7
46
@joncalhoun
Jon Calhoun
4 years
Let's try to visualize a nil pointer error in #golang . When we declare a variable that is NOT a pointer, it is similar to printing out an empty form so that we can fill it out.
Tweet media one
Tweet media two
1
7
49
@joncalhoun
Jon Calhoun
5 years
For the next few weeks my #golang courses will be discounted. In addition to the discount, I am going to do everything I can to help out anyone who can't afford a course. Read more → (1/4)
5
21
43
@joncalhoun
Jon Calhoun
10 months
If you want to learn some #golang in 2024, my courses are on sale until the end of the day. - Web Dev with Go - - Test with Go -
0
13
47
@joncalhoun
Jon Calhoun
4 years
Need to sort a custom data type in #golang ? Just implement sort.Interface () with a new type for each sort criteria. This means you can have multiple sorts for the same type. Runnable example 👉
Tweet media one
1
9
46
@joncalhoun
Jon Calhoun
2 years
I'm looking for examples of #generics being used in #golang code. Ideally I'd like to see: 1. What you did before generics. 2. What you are doing with generics. In both cases a go playground example would be ideal. I want specific, runnable & easy to share examples.
1
2
45
@joncalhoun
Jon Calhoun
5 years
I really like the #golang error changes made in 1.13, but it does make switch statements over errors a little more verbose. I'm not sure if this is a bad thing, but I don't LOVE declaring all those variables before a switch. I wonder if this could be improved... 🤔
Tweet media one
2
6
46
@joncalhoun
Jon Calhoun
3 years
I bet you didn't realize it was this easy to create a static site generator with #golang ! Probably not ready for a public audience, but it is a nice way to hack together a single static HTML landing page.
Tweet media one
Tweet media two
Tweet media three
5
6
44
@joncalhoun
Jon Calhoun
4 years
Do you know any lesser-known people writing, teaching, or otherwise helping educate Gophers? Let me know who they are and share some examples of their work - I'd love to help out where I can! 😁 #golang
12
14
45
@joncalhoun
Jon Calhoun
6 years
I wonder if a mini-course demonstrating my dev environment and other tips/tricks I use to speed things up when doing #golang #dev would be helpful... 🤔
7
2
45
@joncalhoun
Jon Calhoun
4 years
@spf13 Feeling able to say "I don't understand" is like a superpower, and great teams are eager to teach something new rather than shame me for not knowing. I now can't imagine working with people who shamed me for not knowing something.
0
3
45
@joncalhoun
Jon Calhoun
4 years
It is annoying how often I *still* make this mistake. 😩
@GoTimeFM
Go Time ⏰
4 years
"You learn more by just kind of jumping in and doing stuff rather than trying to find the optimal path." 🗣️ @joncalhoun on his #golang mistakes
1
2
26
2
4
44
@joncalhoun
Jon Calhoun
4 years
I think she's pretty wonderful. 🥰
Tweet media one
1
0
45
@joncalhoun
Jon Calhoun
5 years
Today is my 7th anniversary with my amazing, wonder, beautiful, and supportive wife. Words can't describe how happy I am to have someone who stands by me and I honestly don't believe I would be doing what I do today if it weren't for her motivating me.
3
0
44
@joncalhoun
Jon Calhoun
3 years
Never build your own #sql queries. See the code attached for an example of this going poorly. Use existing, well tested libs to avoid this. Some #golang options: database/sql - in the standard lib
Tweet media one
3
6
43
@joncalhoun
Jon Calhoun
4 years
Need the ability to log in your #golang code, but don't want to pass in a logger all the time? Try limiting to just a single logging function and create a reusable type that gives it a sane default value, then embed that type.
Tweet media one
1
6
40
@joncalhoun
Jon Calhoun
4 years
In many cases, context values can be avoided altogether and the resulting code's dependencies will be much clearer. Two ways to do this are struct fields and closures. #golang #context This is important b/c context values should be context-specific. See
Tweet media one
4
8
41
@joncalhoun
Jon Calhoun
8 years
I'm giving away 5 copies of Web Development with Go (). Just retweet and follow to enter to win! #golang #webdev
12
180
40
@joncalhoun
Jon Calhoun
4 years
My wife drinks decaf coffee. I drink regular. This morning I have been dragging. She has been feeling super anxious. Turns out we swapped coffees on accident 🤦‍♂️
2
0
40
@joncalhoun
Jon Calhoun
4 years
I use the empty struct all the time to create sets using Go's map type. What are some other use cases for the empty struct? #golang More on the empty struct -
Tweet media one
5
7
41