let greeting_file = File::open("hello.txt")?l
vs file, err := os.Open("hello.txt")
if err != nil {
return fmt.errorf("faild to open hello; %w, err)
}
However, I would argue the distinction isn't just cosmetic. The compiler prevents me from not checking the error and blowing up the application with a nil pointer exception.The TFA even capes this pattern:
type Result[T any] struct {
Value T
Error error
}
and I wonder if we will start to see it more now that generics are in Go.