Skip to content

Commit 7fcd4a7

Browse files
griesemergopherbot
authored andcommitted
internal/pkgbits: s/errorf/panicf/ because that's what it is
Make it obvious that this function panics. Change-Id: I272142d2cf7132aa8915f8f4b5945834376db062 Reviewed-on: https://go-review.googlesource.com/c/go/+/606935 Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Robert Griesemer <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 2e0a6f8 commit 7fcd4a7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/internal/pkgbits/decoder.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func NewPkgDecoder(pkgPath, input string) PkgDecoder {
8484

8585
switch pr.version {
8686
default:
87-
panic(fmt.Errorf("unsupported version: %v", pr.version))
87+
panicf("unsupported version: %v", pr.version)
8888
case 0:
8989
// no flags
9090
case 1:
@@ -136,7 +136,7 @@ func (pr *PkgDecoder) AbsIdx(k RelocKind, idx Index) int {
136136
absIdx += int(pr.elemEndsEnds[k-1])
137137
}
138138
if absIdx >= int(pr.elemEndsEnds[k]) {
139-
errorf("%v:%v is out of bounds; %v", k, idx, pr.elemEndsEnds)
139+
panicf("%v:%v is out of bounds; %v", k, idx, pr.elemEndsEnds)
140140
}
141141
return absIdx
142142
}
@@ -242,7 +242,7 @@ type Decoder struct {
242242

243243
func (r *Decoder) checkErr(err error) {
244244
if err != nil {
245-
errorf("unexpected decoding error: %w", err)
245+
panicf("unexpected decoding error: %w", err)
246246
}
247247
}
248248

src/internal/pkgbits/encoder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (w *Encoder) Flush() Index {
194194

195195
func (w *Encoder) checkErr(err error) {
196196
if err != nil {
197-
errorf("unexpected encoding error: %v", err)
197+
panicf("unexpected encoding error: %v", err)
198198
}
199199
}
200200

@@ -359,7 +359,7 @@ func (w *Encoder) Value(val constant.Value) {
359359
func (w *Encoder) scalar(val constant.Value) {
360360
switch v := constant.Val(val).(type) {
361361
default:
362-
errorf("unhandled %v (%v)", val, val.Kind())
362+
panicf("unhandled %v (%v)", val, val.Kind())
363363
case bool:
364364
w.Code(ValBool)
365365
w.Bool(v)

src/internal/pkgbits/support.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ func assert(b bool) {
1212
}
1313
}
1414

15-
func errorf(format string, args ...any) {
15+
func panicf(format string, args ...any) {
1616
panic(fmt.Errorf(format, args...))
1717
}

0 commit comments

Comments
 (0)