GoのWebアプリケーションのエラー設計 の最後で紹介したように、エラーを変換する際に下位の情報をラップすることが xerrors.Errorf ではできません。 var ErrUserNotFound = NewApplicationError("Error", 101, "not found") func NewApplicationError(level string, code int, msg string) *ApplicationError { err := &ApplicationError{ level: level, code: code, msg: msg, } return err } func main() error { user, err := userSearch() if err != nil { // return ErrUserNotFound ではな