Understanding Nil
Offered By: Gopher Academy via YouTube
Course Description
Overview
Explore the intricacies of 'nil' in Go programming through this GopherCon 2016 talk by Francesc Campoy. Delve into the concept of nil as a zero value, its historical context, and its significance across various data types. Discover when nil is not actually nil, learn best practices for error handling, and understand the practical applications of nil in receivers, slices, and maps. Gain insights into leveraging nil channels in select statements, using nil interfaces for default signaling, and recognizing the overall utility of nil in Go programming. Through code examples and explanations, master the nuances of nil to write more efficient and idiomatic Go code.
Syllabus
Intro
welcome every single one of you
nil is (a) zero
interlude a bit of history
zero values what are they?
the type of nil
nil is a predeclared identifier representing the zero value for a pointer, channel, func, interface, map, or slice type.
zero values what do they mean?
type, value
when is nil not nil?
do not declare concrete error vars
do not return concrete error types
nil receivers are useful
use nil slices they're often fast enough
use nil maps as read-only empty maps
coding time
can we switch off a chan?
use nil chans to disable a select case
'nil values can satisfy interfaces
use nil interfaces to signal default
nil is useful
Taught by
Gopher Academy
Related Courses
A Holistic Go ExperienceGopher Academy via YouTube Safe, Fast, and Easy - Building a Plugin System with WebAssembly
Gopher Academy via YouTube A Journey Through Integration Testing with Go - What Could Go Wrong?
Gopher Academy via YouTube Kraken Wrangling for Dummies - Go Module Dependency Management at Scale
Gopher Academy via YouTube Go, the Data Engineer's Missing Tool?
Gopher Academy via YouTube