Skip to content

Commit 50208aa

Browse files
committed
fix the regex
Signed-off-by: Robert Landers <landers.robert@gmail.com>
1 parent f76fd14 commit 50208aa

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

internal/extgen/moduleParser.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import (
88
"strings"
99
)
1010

11-
var phpModuleParser = regexp.MustCompile(`//\s*export_php:module\s+(init|shutdown)`)
11+
var (
12+
phpModuleParser = regexp.MustCompile(`//\s*export_php:module\s+(init|shutdown)`)
13+
funcNameRegex = regexp.MustCompile(`func\s+([a-zA-Z0-9_]+)`)
14+
)
1215

1316
// phpModule represents a PHP module with optional init and shutdown functions
1417
type phpModule struct {
@@ -86,7 +89,6 @@ func (mp *ModuleParser) parse(filename string) (module *phpModule, err error) {
8689
// extractGoFunction extracts the function name and code from a function declaration
8790
func (mp *ModuleParser) extractGoFunction(scanner *bufio.Scanner, firstLine string) (string, string, error) {
8891
// Extract function name from the first line
89-
funcNameRegex := regexp.MustCompile(`func\s+([a-zA-Z0-9_]+)`)
9092
matches := funcNameRegex.FindStringSubmatch(firstLine)
9193
if len(matches) < 2 {
9294
return "", "", fmt.Errorf("could not extract function name from line: %s", firstLine)

0 commit comments

Comments
 (0)