← Back to context

Comment by koakuma-chan

2 days ago

Does the Go compiler not force you to handle errors

It doesn't exactly, no. There are linters and a compiler-enforced check preventing unused variables. Overall it's pretty easy to accidentally drop errors or overwrite them before checking.

So no, it doesn't.

No language forces to handle errors. Even Rust.

  • > No language forces to handle errors. Even Rust.

    It does. If a function returns a Result or Option type, you can't just use its data; you have to either automatically propagate the error case upward, pattern match on both the success and error cases, or just use ".unwrap()" and explicitly choose to crash in the case of an error. There's no implicit crash like there is in a language that lets you dereference null pointers.