Full Width [alt+shift+f] Shortcuts [alt+shift+k]
Sign Up [alt+shift+s] Log In [alt+shift+l]
1

How to Properly Use Defer in Golang

from Boot.dev Blog [alt+shift+b] in programming

What is the “defer” keyword in Go? 🔗 In the Go programming language, defer is a keyword that allows developers to delay the execution of a function until the current function returns. What throws some people off is that the deferred function’s arguments are evaluated immediately, but the function itself doesn’t fire until the wrapping function exits.
1st Jun 2021

Stay updated

Get a weekly newsletter with the top 5 articles worth reading every week.

More from Boot.dev Blog

The Boot.dev Beat. February 2026

A new year and another record broken! In January a combined 4,016,641 lessons and challenges were completed by you, dear pupils! And to top it off, we’re now releasing the much anticipated Power BI Course by none other than Alex the Analyst! I hope you enjoy it.

11th Feb 2026 • 1 votes
The Boot.dev Beat. January 2026

We’re off to an incredible start to 2026. December of 2025 broke a new record with 3,075,904 lessons completed and 82,578 training grounds challenges completed during the month! In January, I’m writing this on the 13th, and we’re already at 1,657,581 lessons and 47,795 challenges - so it’s looking like this is going to be a monster month. Best of luck to you all in the contest of the resolute.

13th Jan 2026 • 1 votes
The Boot.dev Beat. December 2025

We plan to wrap up 2025 with some important quality of life updates! League placement badges, lesson bookmarks, and major improvements to the Training Grounds are just a few of the highlights. Thanks for learning with us, we’re gearing up the platform for a ton of new courses in 2026.

7th Dec 2025 • 1 votes
Breaking Into Tech on Hard Mode: A Supply/Demand Analysis of Career Options

Markets are efficient, right? I understand that every ~10 years we find ourselves in some sort of stock market bubble, but I do believe that most markets are mostly efficient. Everyone out there is looking for a good deal, and despite the well-known irrationalities of human psycology, most of us seem to do a good job of looking out for number one.

23rd Nov 2025 • 1 votes
The Boot.dev Beat. October 2025

Searchable challenges in the Training Grounds, and realtime voice chats with Boots are now a thing. Also, my children and those of half my employees are sick with the flu… I hope you’ve all been able to avoid it!

1st Oct 2025 • 1 votes

More in programming

We solved SQLite's single-writer limitation

Multiple concurrent writers. Multiple processes. Same SQLite. No modifications.

an hour ago • 1 votes
SumatraPDF new features: April 4, 2026

New in the SumatraPDF pre-release builds: Bake PDF File New Bake PDF File command (CmdPdfBake) in the Ctrl + k command palette turns interactive form fields and annotations into static page content and saves the result as a new PDF, which then opens. Show PDF Outline New Show PDF Outline command (CmdShowPdfOutline) in the command palette shows the document’s outline (table of contents) as text in a window. Tab Groups menu Saving and restoring tab groups now has its own Tab Groups submenu (in the Favorites menu) with Save Tab Group and Restore Tab Group. Both are also in the tab right-click menu. There is also a window for managing saved groups (#4402). Screenshots include open menus Take Screenshot also captures open menus as separate windows you can pick. Menu bar improvements with tabs The custom menu bar shown when tabs are in the title bar works more like a normal menu bar, and toggling the menu bar is more reliable (#5442, #549). More: changes from April 4, 2026 and the full changelog.

12 hours ago • 1 votes
If your team is happy, are you doing a good job?

Brilliant jerks, ZIRP-era managers, and how psychological safety lost the plot. Part 3 of my conversation with Dr. Cat Hicks.

18 hours ago • 1 votes
WTF is context engineering? (with real examples)

Say you're deploying an AI assistant that processes online order returns. For it to work, it would need access to your store's purchase policy, item…

2 days ago • 1 votes
Hosting without hyperscalers
3 days ago • 1 votes
📚 BoredReading

You seem to be enjoying this.

Join free to unlock everything.

Create free account

Already have an account? Sign in