Go:Check Nil Interface the Right Way
I had a simple problem. I have a function which takes a parameter of type interface{}. I need to check it for nil. Any seasoned Go developer will know that a simple i==nil check will not work because interfaces in Go contains both type and value. So you can have cases when — Type is null-able(like map, pointer etc) and value is nil Type itself is nil (of course value will be nil) A nil will only work with option 2 above, as for option 1 a variable still have some type....