[PR #211] [CLOSED] Use regexp compile #418

Closed
opened 2026-02-25 22:33:26 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/FiloSottile/mkcert/pull/211
Author: @CallanTaylor
Created: 11/5/2019
Status: Closed

Base: masterHead: use-regexp-compile


📝 Commits (3)

  • 17159ef Use regexp.Compile instead of regexp.MustCompile
  • 4e11eee correct assignment
  • 0f3cfa3 Given the regex is constant we can make it a global instead of changing the line to regexp.Compile

📊 Changes

2 files changed (+5 additions, -2 deletions)

View changed files

📝 cert.go (+2 -1)
📝 main.go (+3 -1)

📄 Description

The regexp.MustCompile function panics if the regex fails to compile and should only be used in globals or init functions. Instead use regexp.Compile and check err is nil.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/FiloSottile/mkcert/pull/211 **Author:** [@CallanTaylor](https://github.com/CallanTaylor) **Created:** 11/5/2019 **Status:** ❌ Closed **Base:** `master` ← **Head:** `use-regexp-compile` --- ### 📝 Commits (3) - [`17159ef`](https://github.com/FiloSottile/mkcert/commit/17159ef5757ad9832f41234603e74f3d8af88108) Use regexp.Compile instead of regexp.MustCompile - [`4e11eee`](https://github.com/FiloSottile/mkcert/commit/4e11eee09a0f8f7f1000e5bcfa0511d02d26ab38) correct assignment - [`0f3cfa3`](https://github.com/FiloSottile/mkcert/commit/0f3cfa3e436b4d87fb72d9cc4b0ce14ece218211) Given the regex is constant we can make it a global instead of changing the line to regexp.Compile ### 📊 Changes **2 files changed** (+5 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `cert.go` (+2 -1) 📝 `main.go` (+3 -1) </details> ### 📄 Description The [regexp.MustCompile function](https://golang.org/pkg/regexp/#MustCompile) panics if the regex fails to compile and should only be used in globals or init functions. Instead use [regexp.Compile](https://golang.org/pkg/regexp/#Compile) and check `err` is nil. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-25 22:33:26 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mkcert#418
No description provided.