File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 5555 ErrInvalidRegex = errors .NewKind ("the given regular expression is invalid" )
5656)
5757
58+ // ShouldPanic determines whether the finalizer will panic if it finds a Regex that has not been closed.
59+ var ShouldPanic bool = true
60+
5861// RegexFlags are flags to define the behavior of the regular expression. Use OR (|) to combine flags. All flag values
5962// were taken directly from ICU.
6063type RegexFlags uint32
@@ -161,7 +164,7 @@ func CreateRegex(stringBufferInBytes uint32) Regex {
161164 // by GC, this finalizer ensures that regexes are being used as efficiently as possible by maximizing pool rotations.
162165 // Hopefully, this would be caught during development and not in production.
163166 runtime .SetFinalizer (pr , func (pr * privateRegex ) {
164- if pr .mod != nil {
167+ if pr .mod != nil && ShouldPanic {
165168 panic ("Finalizer found a Regex that was never closed" )
166169 }
167170 })
You can’t perform that action at this time.
0 commit comments