Does the error mechanism in go use error or painc??

the try {} catche () {} structure in other languages is usually added under the entry function, and then trhow Exception is directly added when an exception occurs in the implementation of business logic

.

so in go, there are two ways, one is:

func A(a string) (res string, err error) {
    defer func() {
        if err := recover(); err != nil {
            fmt.Println(err)
        }
    }()
    res = B(a)
    return res, err
}

func B(b string) (res string) {
    if b == "a" {
        return "hello " + b
    } else {
        panic("params need a")
    }
}

my question is:

  1. what is the usage scenario of these two methods?
  2. what are the consequences of abusing panic?
Jun.08,2021

it is recommended to read two articles and you will understand.
https://blog.golang.org/defer.
https://www.jianshu.com/p/aee.
Golang error handling is necessary to have a good understanding

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b33fd7-40f1b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b33fd7-40f1b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?