From 526be69307818bee024675482277ee6322c9c24b Mon Sep 17 00:00:00 2001 From: Egor Rudkov Date: Wed, 26 Feb 2020 23:23:33 +0300 Subject: [PATCH] Fix MustCompile comment error --- examples/regular-expressions/regular-expressions.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/regular-expressions/regular-expressions.go b/examples/regular-expressions/regular-expressions.go index 52ec06d..95d425a 100644 --- a/examples/regular-expressions/regular-expressions.go +++ b/examples/regular-expressions/regular-expressions.go @@ -64,10 +64,11 @@ func main() { // function name. fmt.Println(r.Match([]byte("peach"))) - // When creating constants with regular expressions - // you can use the `MustCompile` variation of - // `Compile`. A plain `Compile` won't work for - // constants because it has 2 return values. + // When creating global variables with regular + // expressions you can use the `MustCompile` variation + // of `Compile`. `MustCompile` panics instead of + // returning error, which makes it safer to use for + // global variables. r = regexp.MustCompile("p([a-z]+)ch") fmt.Println(r)