← Back to context Comment by yoghurtwere 1 day ago .unwrap()https://www.reddit.com/r/programming/comments/1p0srgs/commen... 6 comments yoghurtwere Reply rowanG077 20 hours ago Unwrap is an explicit action. Checking an error is usually just forgotten. No unwrap can enter your code without the dev being accutely aware of it. bayindirh 20 hours ago Your Go code won't compile if you don't check the error, though. maleldil 15 hours ago It does if you reuse the error variable, which is very common. Example: https://go.dev/play/p/ofL2fG-OIcCThis can't happen in Rust. rowanG077 19 hours ago Did you ever use go?``` package mainimport ( "errors" "fmt" )func getMessage() (string, error) { return "DO NOT INSPECT", errors.New("something went wrong") }func main() { msg, _ := getMessage() // Ignore the error. fmt.Println(msg) } ```Compiles normally and prints "DO NOT INSPECT" 2 replies →
rowanG077 20 hours ago Unwrap is an explicit action. Checking an error is usually just forgotten. No unwrap can enter your code without the dev being accutely aware of it. bayindirh 20 hours ago Your Go code won't compile if you don't check the error, though. maleldil 15 hours ago It does if you reuse the error variable, which is very common. Example: https://go.dev/play/p/ofL2fG-OIcCThis can't happen in Rust. rowanG077 19 hours ago Did you ever use go?``` package mainimport ( "errors" "fmt" )func getMessage() (string, error) { return "DO NOT INSPECT", errors.New("something went wrong") }func main() { msg, _ := getMessage() // Ignore the error. fmt.Println(msg) } ```Compiles normally and prints "DO NOT INSPECT" 2 replies →
bayindirh 20 hours ago Your Go code won't compile if you don't check the error, though. maleldil 15 hours ago It does if you reuse the error variable, which is very common. Example: https://go.dev/play/p/ofL2fG-OIcCThis can't happen in Rust. rowanG077 19 hours ago Did you ever use go?``` package mainimport ( "errors" "fmt" )func getMessage() (string, error) { return "DO NOT INSPECT", errors.New("something went wrong") }func main() { msg, _ := getMessage() // Ignore the error. fmt.Println(msg) } ```Compiles normally and prints "DO NOT INSPECT" 2 replies →
maleldil 15 hours ago It does if you reuse the error variable, which is very common. Example: https://go.dev/play/p/ofL2fG-OIcCThis can't happen in Rust.
rowanG077 19 hours ago Did you ever use go?``` package mainimport ( "errors" "fmt" )func getMessage() (string, error) { return "DO NOT INSPECT", errors.New("something went wrong") }func main() { msg, _ := getMessage() // Ignore the error. fmt.Println(msg) } ```Compiles normally and prints "DO NOT INSPECT" 2 replies →
Unwrap is an explicit action. Checking an error is usually just forgotten. No unwrap can enter your code without the dev being accutely aware of it.
Your Go code won't compile if you don't check the error, though.
It does if you reuse the error variable, which is very common. Example: https://go.dev/play/p/ofL2fG-OIcC
This can't happen in Rust.
Did you ever use go?
``` package main
import ( "errors" "fmt" )
func getMessage() (string, error) { return "DO NOT INSPECT", errors.New("something went wrong") }
func main() { msg, _ := getMessage() // Ignore the error. fmt.Println(msg) } ```
Compiles normally and prints "DO NOT INSPECT"
2 replies →