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)

--

--

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