Skip to content
Snippets Groups Projects
Commit 7fcd4a70 authored by Robert Griesemer's avatar Robert Griesemer Committed by Gopher Robot
Browse files

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: default avatarRobert Griesemer <gri@google.com>
Reviewed-by: default avatarIan Lance Taylor <iant@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
parent 2e0a6f85
No related branches found
No related tags found
No related merge requests found
...@@ -84,7 +84,7 @@ func NewPkgDecoder(pkgPath, input string) PkgDecoder { ...@@ -84,7 +84,7 @@ func NewPkgDecoder(pkgPath, input string) PkgDecoder {
switch pr.version { switch pr.version {
default: default:
panic(fmt.Errorf("unsupported version: %v", pr.version)) panicf("unsupported version: %v", pr.version)
case 0: case 0:
// no flags // no flags
case 1: case 1:
...@@ -136,7 +136,7 @@ func (pr *PkgDecoder) AbsIdx(k RelocKind, idx Index) int { ...@@ -136,7 +136,7 @@ func (pr *PkgDecoder) AbsIdx(k RelocKind, idx Index) int {
absIdx += int(pr.elemEndsEnds[k-1]) absIdx += int(pr.elemEndsEnds[k-1])
} }
if absIdx >= int(pr.elemEndsEnds[k]) { if absIdx >= int(pr.elemEndsEnds[k]) {
errorf("%v:%v is out of bounds; %v", k, idx, pr.elemEndsEnds) panicf("%v:%v is out of bounds; %v", k, idx, pr.elemEndsEnds)
} }
return absIdx return absIdx
} }
...@@ -242,7 +242,7 @@ type Decoder struct { ...@@ -242,7 +242,7 @@ type Decoder struct {
func (r *Decoder) checkErr(err error) { func (r *Decoder) checkErr(err error) {
if err != nil { if err != nil {
errorf("unexpected decoding error: %w", err) panicf("unexpected decoding error: %w", err)
} }
} }
......
...@@ -194,7 +194,7 @@ func (w *Encoder) Flush() Index { ...@@ -194,7 +194,7 @@ func (w *Encoder) Flush() Index {
func (w *Encoder) checkErr(err error) { func (w *Encoder) checkErr(err error) {
if err != nil { if err != nil {
errorf("unexpected encoding error: %v", err) panicf("unexpected encoding error: %v", err)
} }
} }
...@@ -359,7 +359,7 @@ func (w *Encoder) Value(val constant.Value) { ...@@ -359,7 +359,7 @@ func (w *Encoder) Value(val constant.Value) {
func (w *Encoder) scalar(val constant.Value) { func (w *Encoder) scalar(val constant.Value) {
switch v := constant.Val(val).(type) { switch v := constant.Val(val).(type) {
default: default:
errorf("unhandled %v (%v)", val, val.Kind()) panicf("unhandled %v (%v)", val, val.Kind())
case bool: case bool:
w.Code(ValBool) w.Code(ValBool)
w.Bool(v) w.Bool(v)
......
...@@ -12,6 +12,6 @@ func assert(b bool) { ...@@ -12,6 +12,6 @@ func assert(b bool) {
} }
} }
func errorf(format string, args ...any) { func panicf(format string, args ...any) {
panic(fmt.Errorf(format, args...)) panic(fmt.Errorf(format, args...))
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment