top | item 33724465

(no title)

kinjba11 | 3 years ago

Go does not have compile-time null safety or sum types :)

    foo := Foo{"hello"}
    fooPointer := &foo
    fooPointer = nil
    fmt.Println(fooPointer.Bar)
    > panic: runtime error: invalid memory address or nil pointer dereference
In a language like Kotlin a compile time error would prevent `fooPointer.Bar`, and in Rust `nil` does not exist. Go also does not have sum types, see for instance https://making.pusher.com/alternatives-to-sum-types-in-go/

discuss

order

No comments yet.