From 1dc4151f8b96817d6e30b7b00469ebddf15ae2a5 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 14 Feb 2022 15:49:36 -0800 Subject: [PATCH] logtail: add MustParsePublicID Signed-off-by: Josh Bleecher Snyder --- logtail/id.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/logtail/id.go b/logtail/id.go index 119b698f7..596634d19 100644 --- a/logtail/id.go +++ b/logtail/id.go @@ -113,6 +113,16 @@ func ParsePublicID(s string) (PublicID, error) { return p, nil } +// MustParsePublicID calls ParsePublicID and panics in case of an error. +// It is intended for use with constant strings, typically in tests. +func MustParsePublicID(s string) PublicID { + id, err := ParsePublicID(s) + if err != nil { + panic(err) + } + return id +} + func (id PublicID) MarshalText() ([]byte, error) { b := make([]byte, hex.EncodedLen(len(id))) if i := hex.Encode(b, id[:]); i != len(b) {