+13
-36
types.go
+13
-36
types.go
···
70
70
}
71
71
72
72
func MustExec(b Builder, p Database) sql.Result {
73
-
res, err := Exec(b, p)
74
-
if err != nil {
75
-
panic(err)
76
-
}
77
-
78
-
return res
73
+
return unwrap(Exec(b, p))
79
74
}
80
75
81
76
func MustExecContext(ctx context.Context, b Builder, p Database) sql.Result {
82
-
res, err := ExecContext(ctx, b, p)
83
-
if err != nil {
84
-
panic(err)
85
-
}
86
-
87
-
return res
77
+
return unwrap(ExecContext(ctx, b, p))
88
78
}
89
79
90
80
type Querier interface {
···
127
117
}
128
118
129
119
func MustQuery(b Builder, db Database) *sql.Rows {
130
-
rows, err := Query(b, db)
131
-
if err != nil {
132
-
panic(err)
133
-
}
134
-
135
-
return rows
120
+
return unwrap(Query(b, db))
136
121
}
137
122
138
123
func MustQueryContext(ctx context.Context, b Builder, db Database) *sql.Rows {
139
-
rows, err := QueryContext(ctx, b, db)
140
-
if err != nil {
141
-
panic(err)
142
-
}
143
-
144
-
return rows
124
+
return unwrap(QueryContext(ctx, b, db))
145
125
}
146
126
147
127
func MustQueryRow(b Builder, db Database) *sql.Row {
148
-
row, err := QueryRow(b, db)
149
-
if err != nil {
150
-
panic(err)
151
-
}
152
-
153
-
return row
128
+
return unwrap(QueryRow(b, db))
154
129
}
155
130
156
131
func MustQueryRowContext(ctx context.Context, b Builder, db Database) *sql.Row {
157
-
row, err := QueryRowContext(ctx, b, db)
158
-
if err != nil {
159
-
panic(err)
160
-
}
161
-
162
-
return row
132
+
return unwrap(QueryRowContext(ctx, b, db))
163
133
}
164
134
165
135
type Direction string
···
173
143
var zero T
174
144
return zero
175
145
}
146
+
147
+
func unwrap[P any](p P, e error) P {
148
+
if e != nil {
149
+
panic(e)
150
+
}
151
+
return p
152
+
}