From 526be69307818bee024675482277ee6322c9c24b Mon Sep 17 00:00:00 2001 From: Egor Rudkov Date: Wed, 26 Feb 2020 23:23:33 +0300 Subject: [PATCH 1/3] 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) From 6fcca63e42a58f311e93209ad7389d753e9d6256 Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Fri, 10 Apr 2020 17:58:40 -0700 Subject: [PATCH 2/3] Add one more word --- examples/regular-expressions/regular-expressions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/regular-expressions/regular-expressions.go b/examples/regular-expressions/regular-expressions.go index 95d425a..f05d269 100644 --- a/examples/regular-expressions/regular-expressions.go +++ b/examples/regular-expressions/regular-expressions.go @@ -67,7 +67,7 @@ func main() { // 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 + // returning an error, which makes it safer to use for // global variables. r = regexp.MustCompile("p([a-z]+)ch") fmt.Println(r) From b08d1e88d1ee98519d423ee34d62551c70247289 Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Fri, 10 Apr 2020 17:58:50 -0700 Subject: [PATCH 3/3] Regenerate --- examples/regular-expressions/regular-expressions.hash | 4 ++-- public/regular-expressions | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/regular-expressions/regular-expressions.hash b/examples/regular-expressions/regular-expressions.hash index a1d5644..bffd787 100644 --- a/examples/regular-expressions/regular-expressions.hash +++ b/examples/regular-expressions/regular-expressions.hash @@ -1,2 +1,2 @@ -3db643ab821ee2a5b70e05fbadbde1a7f7ba1591 -944r7pT2YIl +c0dd720036ac70269ce233bf47c5d6aefd43161f +LEKGY_d3Nu_P diff --git a/public/regular-expressions b/public/regular-expressions index 7a312eb..ec33157 100644 --- a/public/regular-expressions +++ b/public/regular-expressions @@ -43,7 +43,7 @@ in Go.

- +
package main
 
@@ -242,10 +242,11 @@ function name.

-

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 an error, which makes it safer to use for +global variables.