How to Check nil Interface in Golang?

type user interface{}
type staff struct{}
func compareNil() {
var generic user
generic = nil
// works as expected
fmt.Printf("value=%v type=%T (generic==nil)=%v\n", generic, generic, generic == nil)

--

--

--

Golang, Distributed Systems, File Systems, Python, C/C++, Linux

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Running PySpark on EKS Fargate: Part 1

Creating Enemy Explosions

Abstracting the Optimizely SDK — Part 2: Keeping it clean

CS373 Spring 2022: Week 14 Ziyi Zhao

How do we slow down a loop?

Themes, Epics, And The Art Of Writing User Stories

You Can Now Check Transaction Stats by Date

Design Patterns

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simplify Complexity

Simplify Complexity

Golang, Distributed Systems, File Systems, Python, C/C++, Linux

More from Medium

Druid complex Lookup using other dimensions, with native query or Golang

Sharding in Golang with benchmarks

[golang] How to use github for hosting self-updating binaries for your golang projects

Integrating README.md and Makefile with makedown