Home > other >  Golang if occur error: what is it
Golang if occur error: what is it

Time:04-27

Because the go error is dealing with a lot of, but specific what happened, but he said no
Query the database, for example, if the error happened that the structure of the returned structure is empty or something, isn't it can no longer go down

Even common json conversion have error
JsonStu, err:=json. Marshal (stu)
if err ! Nil={
FMT. Println (" generate json string error ")
}
But had never happened error, so I just wanted to know, if this happened, what happens,

CodePudding user response:

The error is a interface

Go code, can be directly see the error generation process, how can not know what is happening,

Such as errors. The New (" int is empty ")
  • Related