Can't I use an assistant?

Asked 1 years ago, Updated 1 years ago, 95 views

The creator of Go language wrote it down here Does everyone else think the same?

Why doesn't Go have an Assertion? Go does not have an assessment. It's certainly convenient to have, but in our experience, programmers are supposed to use it as a tool to properly deal with errors and not consider reporting. Proper error processing refers to continuing to operate without going down when the server encounters a situation that is not a serious error. Proper error reporting is to see the error right there so that the programmer doesn't have to analyze huge messages to find the part that messed up the system. It is particularly important that the error is clearly revealed when the programmer sees the error in unfamiliar code.

The same is true of the use of the asset() in the test program. Appropriate error handling is required to allow other tests to run after the test fails. Therefore, the person who debugs the failed one can fully understand what went wrong. It is also useful for testing that isPrime produces incorrect results. Programmers who cause the test to fail are not familiar with the code that fails. The time spent writing a nice error message will be repaid later when the test stops.

If many codes written for errors in testing seem redundant and unnecessary, a table-driven test is recommended. Go supports data structures very well.

We think this part is contentious and controversial. Many things and libraries in the Go language are different from recent ones. Simply we think it is well worthwhile to try a different approach.

c c++ error-handling go assert

2022-09-21 18:54

1 Answers

No, it's not. There is no problem if you use it for the purpose of assert().

If the common error handling method is "Let's deal with this and continue when an error occurs," assert() aims to "kill the program if an error occurs."


2022-09-21 18:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.