Using No-Op Objects For Cleaner Code
Sooner or later every Go programmer will want to extract an object from another object such as Context or utilize an object that can be set to nil throughout the call stack. However, this can lead to ugly code that looks like: func someFunc(obj *MyObj) { if obj != nil { DoThis() } otherFunc(obj) } func otherFunc(obj *MyObj) { if obj != nil { DoThis() } ... } I this case, if our obj != nil, we want to
[Read More]