智慧大石
https://pkg.go.dev/strconv@go1.19.3#NumErrortype NumError struct { Func string // the failing function (ParseBool, ParseInt, ParseUint, ParseFloat, ParseComplex) Num string // the input Err error // the reason the conversion failed (e.g. ErrRange, ErrSyntax, etc.)}错误是 ParseInt 类型。"ParseInt"是“失败函数”的名称,即返回错误的函数。实际的错误类型是*strconv.NumError。您可以像这样检查它和 func 名称:if e, ok := err.(*strconv.NumError); ok && e.Func == "ParseInt" { // do xyz}