Fixing the Billion Dollar Mistake in Go by Borrowing from #rust
▻https://hackernoon.com/fixing-the-billion-dollar-mistake-in-go-by-borrowing-from-rust-66fab3ea7
panic: runtime error: invalid memory address or nil pointer dereferenceIf you ever used Go, you probably saw this error at least once. Somewhere a nil pointer or nil interface was passed to a function that doesn’t handle nil. In all cases this is a #programming error, either the function should handle nil or the caller shouldn’t have passed nil to the function. This Go experience report will try to make the case that nil is often not needed and being forced to have nil-able pointers and interfaces can cause panics in production. We’ll also briefly discuss how Rust solves this issue and how their solution could be applied to Go.Nil Can Be UsefulLet’s first start off by showing why allowing a value to be nil can be useful. The main use case for nil is indicating that a value is “missing”. A (...)